/* nova-gate dashboard
 *
 * Type scale: every font size in this file is one of these seven tokens. Nothing else
 * sets a font size, so headings, tables and numbers stay in proportion on every page.
 */
:root {
  --t-xs: 12px;   --lh-xs: 16px;   /* labels, axis ticks, badges */
  --t-sm: 13px;   --lh-sm: 20px;   /* tables, secondary text */
  --t-md: 14px;   --lh-md: 20px;   /* body, inputs, buttons */
  --t-lg: 16px;   --lh-lg: 24px;   /* card and drawer titles */
  --t-xl: 20px;   --lh-xl: 28px;   /* page title */
  --t-2xl: 28px;  --lh-2xl: 36px;  /* stat values */
  --t-hero: 48px; --lh-hero: 52px; /* the one headline number on Overview */

  --font: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --r-sm: 6px; --r-md: 8px; --r-lg: 12px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;

  color-scheme: light;
  --page: #f9f9f7;
  --surface: #ffffff;
  --surface-2: #f4f4f1;
  --sunken: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #6f6e69;
  --muted: #898781;
  --line: rgba(11, 11, 11, 0.08);
  --line-2: rgba(11, 11, 11, 0.14);
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-wash: rgba(42, 120, 214, 0.10);
  --track: #e6e5df;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 16px rgba(11, 11, 11, 0.04);
  --shadow-lg: 0 12px 48px rgba(11, 11, 11, 0.16);

  --team-1: #2a78d6; --team-2: #eb6834; --team-3: #1baf7a; --team-other: #b9b8b0;
  --tier-1: #86b6ef; --tier-2: #3987e5; --tier-3: #1c5cab; --tier-4: #0d366b;

  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --good-ink: #006300; --critical-ink: #b42828; --warning-ink: #8a5a00;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #222220; --sunken: #141413;
    --ink: #f0efec; --ink-2: #c3c2b7; --ink-3: #a3a29a; --muted: #898781;
    --line: rgba(255, 255, 255, 0.08); --line-2: rgba(255, 255, 255, 0.14);
    --grid: #2c2c2a; --axis: #383835; --track: #2c2c2a;
    --accent: #3987e5; --accent-ink: #86b6ef; --accent-wash: rgba(57, 135, 229, 0.16);
    --shadow: none; --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.6);
    --team-1: #3987e5; --team-2: #d95926; --team-3: #199e70; --team-other: #5a5955;
    --tier-1: #86b6ef; --tier-2: #3987e5; --tier-3: #256abf; --tier-4: #184f95;
    --good-ink: #0ca30c; --critical-ink: #e66767; --warning-ink: #fab219;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #222220; --sunken: #141413;
  --ink: #f0efec; --ink-2: #c3c2b7; --ink-3: #a3a29a; --muted: #898781;
  --line: rgba(255, 255, 255, 0.08); --line-2: rgba(255, 255, 255, 0.14);
  --grid: #2c2c2a; --axis: #383835; --track: #2c2c2a;
  --accent: #3987e5; --accent-ink: #86b6ef; --accent-wash: rgba(57, 135, 229, 0.16);
  --shadow: none; --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.6);
  --team-1: #3987e5; --team-2: #d95926; --team-3: #199e70; --team-other: #5a5955;
  --tier-1: #86b6ef; --tier-2: #3987e5; --tier-3: #256abf; --tier-4: #184f95;
  --good-ink: #0ca30c; --critical-ink: #e66767; --warning-ink: #fab219;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page); color: var(--ink);
  font: 400 var(--t-md)/var(--lh-md) var(--font);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
button.link { border: 0; background: none; padding: 0; font: inherit; color: var(--accent-ink); cursor: pointer; }
button.link:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: var(--t-xs); line-height: var(--lh-xs); }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------------- shell ---------------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  padding: var(--s4) var(--s3); border-right: 1px solid var(--line); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s2) var(--s5); }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; flex: none; position: relative;
  background: var(--ink);
}
.brand-mark::before, .brand-mark::after {
  content: ""; position: absolute; top: 6px; bottom: 5px; width: 3px; border-radius: 2px; background: var(--surface);
}
.brand-mark::before { left: 6px; }
.brand-mark::after { right: 6px; }
.brand-name { font-size: var(--t-lg); line-height: var(--lh-lg); font-weight: 600; letter-spacing: -0.01em; }
.brand-name span { color: var(--muted); font-weight: 400; }
.nav-group { margin-bottom: var(--s4); }
.nav-label {
  padding: 0 var(--s2) var(--s1); font-size: var(--t-xs); line-height: var(--lh-xs);
  font-weight: 500; color: var(--muted);
}
.nav a {
  display: flex; align-items: center; gap: var(--s3); height: 34px; padding: 0 var(--s2);
  border-radius: var(--r-sm); color: var(--ink-2); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--surface-2); color: var(--ink); }
.nav svg { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.side-foot { margin-top: auto; display: grid; gap: var(--s2); padding: var(--s3) var(--s2) 0; border-top: 1px solid var(--line); }
.status-line { display: flex; align-items: center; gap: var(--s2); font-size: var(--t-xs); line-height: var(--lh-xs); color: var(--ink-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.good { background: var(--good); }
.dot.bad { background: var(--critical); }
.foot-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }

.main { min-width: 0; padding: var(--s6) var(--s6) var(--s7); max-width: 1320px; }
.topbar { display: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s5); flex-wrap: wrap; }
.page-title { font-size: var(--t-xl); line-height: var(--lh-xl); font-weight: 600; letter-spacing: -0.01em; }
.page-sub { margin-top: 2px; font-size: var(--t-sm); line-height: var(--lh-sm); color: var(--muted); }

/* ---------------- controls ---------------- */
.seg {
  display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--r-md);
  background: var(--sunken); border: 1px solid var(--line);
}
.seg button {
  border: 0; background: transparent; height: 28px; padding: 0 var(--s3); border-radius: 6px;
  font-size: var(--t-sm); line-height: var(--lh-sm); font-weight: 500; color: var(--ink-2); cursor: pointer;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(11, 11, 11, 0.08); }
.seg.sm button { height: 24px; padding: 0 var(--s2); font-size: var(--t-xs); line-height: var(--lh-xs); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: 34px; padding: 0 var(--s4); border-radius: var(--r-md); border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn.primary:hover { opacity: 0.88; }
.btn.danger { color: var(--critical-ink); }
.btn.danger.solid { background: var(--critical); border-color: var(--critical); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.sm { height: 28px; padding: 0 var(--s3); font-size: var(--t-sm); }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; }

.input, .select {
  height: 34px; padding: 0 var(--s3); border-radius: var(--r-md); border: 1px solid var(--line-2);
  background: var(--surface); min-width: 0;
}
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.input.search { width: 240px; padding-left: 32px; background-image: none; }
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 10px; top: 9px; width: 16px; height: 16px; stroke: var(--muted); fill: none; stroke-width: 1.8; }
.field { display: grid; gap: 6px; align-content: start; }
.field > span { font-size: var(--t-sm); line-height: var(--lh-sm); font-weight: 500; color: var(--ink-2); }
.field small { font-size: var(--t-xs); line-height: var(--lh-xs); color: var(--muted); }
.field .input, .field .select { width: 100%; }
.prefix { position: relative; }
.prefix::before { content: "$"; position: absolute; left: 12px; top: 7px; color: var(--muted); }
.prefix .input { padding-left: 24px; }
.check { display: flex; align-items: center; gap: var(--s2); font-size: var(--t-sm); line-height: var(--lh-sm); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--ink); margin: 0; }
.toolbar { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s4); }
.toolbar .spacer { flex: 1; }

/* ---------------- cards & grid ---------------- */
.grid { display: grid; gap: var(--s4); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.overview { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); align-items: start; }
/* Stat tiles follow the width of their column, not the window: 4 across, 2×2 when narrow. */
.stack { container-type: inline-size; }
@container (max-width: 760px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container (max-width: 280px) { .grid.cols-4 { grid-template-columns: minmax(0, 1fr); } }
.stack { display: grid; gap: var(--s4); align-content: start; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow); min-width: 0;
}
.card-pad { padding: var(--s5); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s5) 0; }
.card-head.wrap { flex-wrap: wrap; }
.row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.card-title { font-size: var(--t-lg); line-height: var(--lh-lg); font-weight: 600; }
.card-sub { font-size: var(--t-sm); line-height: var(--lh-sm); color: var(--muted); }
.card-body { padding: var(--s4) var(--s5) var(--s5); }

.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s5); align-items: end; }
.hero-label { font-size: var(--t-sm); line-height: var(--lh-sm); color: var(--ink-2); font-weight: 500; }
.hero-value { font-size: var(--t-hero); line-height: var(--lh-hero); font-weight: 600; letter-spacing: -0.03em; margin-top: var(--s2); }
.hero-of { font-size: var(--t-md); line-height: var(--lh-md); color: var(--muted); margin-top: var(--s2); }
.hero-meter { margin-top: var(--s5); }
.hero-side { text-align: right; font-size: var(--t-sm); line-height: var(--lh-sm); color: var(--muted); }
.hero-side strong { display: block; color: var(--ink); font-size: var(--t-lg); line-height: var(--lh-lg); font-weight: 600; }

.stat { padding: var(--s4) var(--s5); }
.stat-label { font-size: var(--t-sm); line-height: var(--lh-sm); color: var(--ink-2); font-weight: 500; }
.stat-value { font-size: var(--t-2xl); line-height: var(--lh-2xl); font-weight: 600; letter-spacing: -0.02em; margin-top: var(--s1); }
.stat-note { font-size: var(--t-xs); line-height: var(--lh-xs); color: var(--muted); margin-top: 2px; }

/* ---------------- meters ---------------- */
.meter { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.meter.lg { height: 8px; border-radius: 4px; }
.meter > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.4s ease; }
.meter.warn > i { background: var(--warning); }
.meter.over > i { background: var(--critical); }
.meter-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px var(--s3); align-items: center; }
.meter-row .meter { grid-column: 1 / -1; }
.meter-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter-val { font-size: var(--t-sm); line-height: var(--lh-sm); color: var(--ink-2); }
.list { display: grid; gap: var(--s4); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 var(--s2);
  border-radius: 11px; background: var(--sunken); color: var(--ink-2);
  font-size: var(--t-xs); line-height: var(--lh-xs); font-weight: 500; white-space: nowrap;
}
.chip .sw { width: 8px; height: 8px; border-radius: 2px; }
.chip.good { color: var(--good-ink); }
.chip.bad { color: var(--critical-ink); }
.chip.warn { color: var(--warning-ink); }
.chip svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------- attention list ---------------- */
.alerts { display: grid; }
.alert { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: var(--s3); padding: var(--s3) 0; border-top: 1px solid var(--line); }
.alert:first-child { border-top: 0; padding-top: 0; }
.alert svg { width: 18px; height: 18px; margin-top: 1px; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.alert .i-critical { stroke: var(--critical); }
.alert .i-warning { stroke: var(--warning); }
.alert .i-serious { stroke: var(--serious); }
.alert .i-good { stroke: var(--good); }
.swatch { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }
.alert-who { font-weight: 500; }
.alert-text { font-size: var(--t-sm); line-height: var(--lh-sm); color: var(--ink-2); }
.alert button.link { border: 0; background: none; padding: 0; color: var(--ink); font-weight: 500; cursor: pointer; text-align: left; }
.alert button.link:hover { text-decoration: underline; }
.empty { padding: var(--s6) var(--s4); text-align: center; color: var(--muted); font-size: var(--t-sm); line-height: var(--lh-sm); }
.empty strong { display: block; color: var(--ink); font-size: var(--t-md); line-height: var(--lh-md); font-weight: 500; margin-bottom: var(--s1); }

/* ---------------- tables ---------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); line-height: var(--lh-sm); }
th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: var(--t-xs); line-height: var(--lh-xs);
  padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface);
}
td { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th.r, td.r { text-align: right; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td, tbody tr.selected td { background: var(--surface-2); }
tbody tr.selected td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
tbody tr.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
td .who { font-weight: 500; color: var(--ink); font-size: var(--t-md); line-height: var(--lh-md); }
td .sub { color: var(--muted); font-size: var(--t-xs); line-height: var(--lh-xs); white-space: nowrap; }
td .who { white-space: nowrap; }
td .cell-meter { display: grid; gap: 6px; min-width: 120px; }
tr.detail td { background: var(--sunken); padding: var(--s3) var(--s4) var(--s4); }
.kv { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--s1) var(--s4); font-size: var(--t-sm); line-height: var(--lh-sm); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.err-text { color: var(--critical-ink); }
.warn-text { color: var(--warning-ink); }

/* person and team detail pages */
.back { display: inline-flex; align-items: center; gap: var(--s1); margin-bottom: var(--s3); font-size: var(--t-sm); line-height: var(--lh-sm); color: var(--ink-2); }
.back svg, .person-sub svg, .btn svg.i-sm { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.back:hover { color: var(--ink); text-decoration: none; }
.person-sub { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s4); }
.person-sub > span { display: inline-flex; align-items: center; gap: 6px; }
.team-tag { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
a.plain { color: inherit; }
a.plain:hover { color: var(--accent-ink); }
.note .link { font-size: inherit; }
.table-foot { display: flex; justify-content: center; padding: var(--s3); border-top: 1px solid var(--line); }
.arrow { color: var(--muted); padding: 0 2px; }

/* ---------------- charts ---------------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .tick { fill: var(--muted); font-size: var(--t-xs); font-family: var(--font); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .mark { transition: opacity 0.15s; }
.chart .col:hover .mark, .chart .col:focus .mark { opacity: 0.82; }
.chart .col:focus { outline: none; }
.chart .col:focus-visible .hit { stroke: var(--accent); stroke-width: 2; }
.chart .hit { fill: transparent; }
.chart .value-label { fill: var(--ink-2); font-size: var(--t-xs); font-family: var(--font); font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: var(--s4); flex-wrap: wrap; font-size: var(--t-xs); line-height: var(--lh-xs); color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.loading .chart, .loading .table-wrap, .loading .refetch { opacity: 0.5; transition: opacity 0.2s; }

.hbar { display: grid; grid-template-columns: 150px minmax(0, 1fr) 72px; gap: var(--s3); align-items: center; padding: 5px 0; }
.hbar-name { font-size: var(--t-sm); line-height: var(--lh-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 16px; position: relative; }
.hbar-track i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; background: var(--accent); min-width: 2px; }
.hbar-val { text-align: right; font-size: var(--t-sm); line-height: var(--lh-sm); color: var(--ink-2); }

.stackbar { display: flex; gap: 2px; height: 24px; }
.stackbar i { display: block; height: 100%; min-width: 3px; }
.stackbar i:first-child { border-radius: 4px 0 0 4px; }
.stackbar i:last-child { border-radius: 0 4px 4px 0; }
.stackbar i:only-child { border-radius: 4px; }
.router-row { display: grid; gap: var(--s2); }
.router-row + .router-row { margin-top: var(--s5); }
.router-head { display: flex; justify-content: space-between; font-size: var(--t-sm); line-height: var(--lh-sm); }

.tip {
  position: fixed; z-index: 50; pointer-events: none; min-width: 160px; padding: var(--s2) var(--s3);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  font-size: var(--t-xs); line-height: var(--lh-xs);
}
.tip-title { color: var(--muted); margin-bottom: 6px; }
.tip-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: var(--s2); align-items: center; padding: 2px 0; }
.tip-row i { width: 12px; height: 2px; border-radius: 1px; }
.tip-row b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.tip-row span { color: var(--ink-2); }
.tip-total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }

/* ---------------- teams ---------------- */
.teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--s4); }
.team-card .card-body { display: grid; gap: var(--s4); }
.team-name { display: flex; align-items: center; gap: var(--s2); }
.team-name i { width: 10px; height: 10px; border-radius: 3px; }
.team-figure { font-size: var(--t-2xl); line-height: var(--lh-2xl); font-weight: 600; letter-spacing: -0.02em; }
.team-figure span { font-size: var(--t-md); line-height: var(--lh-md); color: var(--muted); font-weight: 400; letter-spacing: 0; }
.team-facts { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.fact-label { font-size: var(--t-xs); line-height: var(--lh-xs); color: var(--muted); }
.fact-value { font-weight: 500; }

/* ---------------- drawer & dialog ---------------- */
.scrim { position: fixed; inset: 0; background: rgba(11, 11, 11, 0.32); z-index: 40; animation: fade 0.15s ease; }
.side-scrim { display: none; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); z-index: 41;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: slide 0.2s ease;
}
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); padding: var(--s5); border-bottom: 1px solid var(--line); }
.drawer-title { font-size: var(--t-lg); line-height: var(--lh-lg); font-weight: 600; }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--s5); display: grid; gap: var(--s5); align-content: start; }
.drawer-foot { display: flex; gap: var(--s2); padding: var(--s4) var(--s5); border-top: 1px solid var(--line); }
.drawer-foot .spacer { flex: 1; }
.section-label { font-size: var(--t-xs); line-height: var(--lh-xs); font-weight: 500; color: var(--muted); margin-bottom: var(--s3); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); }
.section-actions { display: flex; gap: var(--s3); font-size: var(--t-xs); line-height: var(--lh-xs); }
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.mini-stat { padding: var(--s3); border-radius: var(--r-md); background: var(--sunken); }
.mini-stat b { display: block; font-size: var(--t-lg); line-height: var(--lh-lg); font-weight: 600; }
.mini-stat span { font-size: var(--t-xs); line-height: var(--lh-xs); color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
.form-grid .full { grid-column: 1 / -1; }
.models-box { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2) var(--s4); padding: var(--s3); border: 1px solid var(--line); border-radius: var(--r-md); }
.danger-zone { display: grid; gap: var(--s2); padding: var(--s4); border: 1px solid var(--line); border-radius: var(--r-md); }
.danger-zone p { font-size: var(--t-sm); line-height: var(--lh-sm); color: var(--ink-2); }
.danger-zone .row { display: flex; gap: var(--s2); flex-wrap: wrap; }

.dialog {
  position: fixed; z-index: 42; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  animation: pop 0.18s ease;
}
.dialog-body { padding: var(--s5); display: grid; gap: var(--s4); }
.dialog-title { font-size: var(--t-lg); line-height: var(--lh-lg); font-weight: 600; }
.dialog-text { font-size: var(--t-md); line-height: var(--lh-md); color: var(--ink-2); }
.dialog-foot { display: flex; justify-content: flex-end; gap: var(--s2); padding: 0 var(--s5) var(--s5); }
.secret {
  display: flex; align-items: center; gap: var(--s2); padding: var(--s3); border-radius: var(--r-md);
  background: var(--sunken); border: 1px solid var(--line); font-family: var(--mono); font-size: var(--t-sm); line-height: var(--lh-sm);
}
.secret code { flex: 1; overflow-wrap: anywhere; }
.note { padding: var(--s3); border-radius: var(--r-md); background: var(--sunken); font-size: var(--t-sm); line-height: var(--lh-sm); color: var(--ink-2); display: flex; gap: var(--s2); }
.note svg { width: 16px; height: 16px; flex: none; margin-top: 2px; stroke: var(--warning); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.form-error { color: var(--critical-ink); font-size: var(--t-sm); line-height: var(--lh-sm); }

.toast {
  position: fixed; z-index: 60; bottom: var(--s5); left: 50%; transform: translateX(-50%);
  padding: var(--s2) var(--s4); border-radius: var(--r-md); background: var(--ink); color: var(--surface);
  font-size: var(--t-sm); line-height: var(--lh-sm); box-shadow: var(--shadow-lg); animation: pop 0.18s ease;
}
.toast.bad { background: var(--critical); color: #fff; }

/* ---------------- login ---------------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: var(--s4); }
.login-card { width: min(380px, 100%); padding: var(--s6); }
.login-card .brand { padding: 0 0 var(--s5); }
.login-card form { display: grid; gap: var(--s4); }
.login-title { font-size: var(--t-xl); line-height: var(--lh-xl); font-weight: 600; }
.login-sub { font-size: var(--t-sm); line-height: var(--lh-sm); color: var(--muted); margin-top: var(--s1); }

/* ---------------- skeleton ---------------- */
.skel { border-radius: var(--r-sm); background: linear-gradient(90deg, var(--sunken), var(--surface-2), var(--sunken)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }

@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -48%) scale(0.98); } }
.toast { animation-name: fade; }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.page > * { animation: rise 0.35s ease both; }
.page > *:nth-child(2) { animation-delay: 0.04s; }
.page > *:nth-child(3) { animation-delay: 0.08s; }
.page > *:nth-child(4) { animation-delay: 0.12s; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------------- responsive ---------------- */
@media (max-width: 1100px) {
  .grid.overview { grid-template-columns: minmax(0, 1fr); }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: fixed; z-index: 45; left: 0; width: 260px; transform: translateX(-100%); visibility: hidden;
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
  }
  .side.open { transform: none; visibility: visible; box-shadow: var(--shadow-lg); transition: transform 0.2s ease; }
  .side-scrim.open { display: block; }
  .topbar {
    display: flex; align-items: center; gap: var(--s3); position: sticky; top: 0; z-index: 30;
    height: 52px; padding: 0 var(--s4); background: var(--surface); border-bottom: 1px solid var(--line);
  }
  .topbar .brand { padding: 0; }
  .main { padding: var(--s5) var(--s4) var(--s7); }
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero-side { text-align: left; }
  .input.search { width: 100%; }
  .search-wrap { flex: 1 1 100%; }
  .form-grid, .models-box { grid-template-columns: minmax(0, 1fr); }
  .hbar { grid-template-columns: 110px minmax(0, 1fr) 64px; }
}
@media (max-width: 520px) {
  .card-pad { padding: var(--s4); }
  .stat { padding: var(--s3) var(--s4); }
  .mini-stats { grid-template-columns: minmax(0, 1fr); }
  .page-head { align-items: flex-start; }
}
.field > .seg { justify-self: start; }
