:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: #eef2f6;
  color: #182231;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: linear-gradient(180deg, #f8fafc 0, #eef2f6 280px), #eef2f6; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 32px;
  background: #151c28;
  color: #fff;
  border-bottom: 1px solid #263346;
}

.eyebrow { margin: 0 0 6px; color: #93a4bb; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 24px; }
h2 { font-size: 17px; }

nav { display: flex; align-items: center; gap: 12px; }
nav a { color: #d8e3f0; font-weight: 700; text-decoration: none; }

main { max-width: 1220px; margin: 0 auto; padding: 28px; }
.login-main { display: flex; align-items: center; justify-content: center; width: 100%; max-width: none; min-height: calc(100vh - 96px); margin: 0; padding: 24px; }

.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat, .panel { background: #fff; border: 1px solid #dde5ee; border-radius: 8px; box-shadow: 0 12px 28px rgba(18, 28, 45, .06); }
.stat { padding: 18px; }
.stat span, .muted, .panel-title p { color: #657386; }
.stat span { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 700; }
.stat strong { font-size: 30px; }

.panel { margin-bottom: 18px; padding: 20px; overflow: hidden; }
.panel-title { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.panel-title p { margin: 0; }
.login-panel, .narrow { width: 100%; max-width: 420px; }
.login-panel { margin: 0; }

.stack { display: grid; gap: 14px; }
.inline-form, .actions, .command-actions, .command-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.inline-form { align-items: end; }
.actions { justify-content: flex-end; }

label { display: grid; gap: 7px; color: #334155; font-size: 13px; font-weight: 700; }
.checkbox { display: flex; align-items: center; min-height: 40px; }

input, textarea, select {
  width: min(560px, 100%);
  padding: 10px 11px;
  border: 1px solid #c8d3df;
  border-radius: 7px;
  background: #fff;
  color: #182231;
  font: inherit;
  font-weight: 500;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: #2f7ed8; box-shadow: 0 0 0 3px rgba(47, 126, 216, .15); }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 10px 13px;
  border: 0;
  border-radius: 7px;
  background: #246fc6;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
button:hover, .button:hover { background: #1d5fae; }
button:disabled { cursor: wait; opacity: .7; }
button.secondary { background: #e8eef5; color: #223146; }
button.secondary:hover { background: #dbe5ef; }
.button.secondary-link { background: #e8eef5; color: #223146; }
.button.secondary-link:hover { background: #dbe5ef; }
button.ghost { background: transparent; border: 1px solid #46566c; color: #eef5ff; }
button.ghost:hover { background: #263346; }
button.danger { background: #c7372f; }
button.danger:hover { background: #a92d27; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 10px; border-bottom: 1px solid #e5ebf1; text-align: left; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th { color: #66768b; font-size: 12px; font-weight: 800; text-transform: uppercase; }

.channel-link { display: block; margin-bottom: 4px; color: #155ca8; font-weight: 800; text-decoration: none; }
.channel-link:hover { text-decoration: underline; }
.muted { display: block; font-size: 12px; }

.badge { display: inline-block; padding: 5px 9px; border-radius: 999px; background: #edf2f7; color: #526174; font-size: 12px; font-weight: 800; }
.badge.ok { background: #dcf8e8; color: #12683a; }
.error { margin: 0; padding: 10px 12px; border: 1px solid #ffc6c1; border-radius: 7px; background: #fff1f0; color: #a92d27; }

.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.form-grid.compact { grid-template-columns: 160px 160px auto; align-items: end; }

.command-list { display: grid; gap: 12px; }
.command-card { padding: 16px; border: 1px solid #e0e7ef; border-radius: 8px; background: #fbfdff; }
.nested-panel { box-shadow: none; margin-bottom: 0; }
.checkbox-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 14px; }
.command-card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.command-card-head strong { margin-right: 8px; font-size: 16px; }
.command-edit { display: grid; gap: 12px; }
.command-edit textarea { width: 100%; }
.row-status { color: #31714a; font-size: 13px; font-weight: 700; }
.row-status.is-error { color: #a92d27; }
.empty-state { padding: 20px; border: 1px dashed #c8d3df; border-radius: 8px; color: #657386; text-align: center; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding-top: 16px; color: #657386; font-weight: 700; }
.page-disabled { display: inline-flex; align-items: center; min-height: 40px; padding: 10px 13px; border-radius: 7px; background: #f0f4f8; color: #9aa7b6; }

@media (max-width: 780px) {
  .topbar, .panel-title, .inline-form, .actions { align-items: stretch; flex-direction: column; }
  .pagination { align-items: stretch; flex-direction: column; }
  main { padding: 16px; }
  .login-main { min-height: calc(100vh - 142px); padding: 16px; }
  .stats-grid, .form-grid, .form-grid.compact, .checkbox-grid { grid-template-columns: 1fr; }
  .command-card-head { align-items: stretch; flex-direction: column; }
  table { display: block; overflow-x: auto; }
}
