/* Teradek Cloud BI prototype — tokens follow the dataviz reference palette (validated light + dark). */
:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --surface-2: #f3f2ef; --hover: rgba(11,11,11,.045);
  --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781; --grid: #e1e0d9; --axis: #c3c2b7;
  --border: rgba(11,11,11,.10); --border-2: rgba(11,11,11,.16);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --other: #b5b3ac; --cmp: #a8a69f; --fade: #dcdad3;
  --accent: #2a78d6; --accent-ink: #1c5cab; --accent-wash: rgba(42,120,214,.10);
  --pos: #2a78d6; --neg: #e34948; --neutral-mid: #f0efec;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --good-ink: #006300; --bad-ink: #b42b2b;
  --seq0: #e6effa; --seq1: #cde2fb; --seq2: #9ec5f4; --seq3: #6da7ec; --seq4: #3987e5; --seq5: #256abf; --seq6: #184f95; --seq7: #0d366b;
  --hatch: rgba(11,11,11,.18);
  --shadow: 0 8px 28px rgba(11,11,11,.12), 0 1px 3px rgba(11,11,11,.08);
  --r: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #222220; --hover: rgba(255,255,255,.05);
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781; --grid: #2c2c2a; --axis: #383835;
    --border: rgba(255,255,255,.10); --border-2: rgba(255,255,255,.16);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767;
    --other: #5c5b56; --cmp: #75736d; --fade: #393936;
    --accent: #3987e5; --accent-ink: #86b6ef; --accent-wash: rgba(57,135,229,.16);
    --pos: #3987e5; --neg: #e66767; --neutral-mid: #383835;
    --good-ink: #0ca30c; --bad-ink: #e66767;
    --seq0: #172235; --seq1: #0d366b; --seq2: #104281; --seq3: #184f95; --seq4: #256abf; --seq5: #3987e5; --seq6: #6da7ec; --seq7: #b7d3f6;
    --hatch: rgba(255,255,255,.22);
    --shadow: 0 10px 30px rgba(0,0,0,.55), 0 1px 3px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #222220; --hover: rgba(255,255,255,.05);
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781; --grid: #2c2c2a; --axis: #383835;
  --border: rgba(255,255,255,.10); --border-2: rgba(255,255,255,.16);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767;
  --other: #5c5b56; --cmp: #75736d; --fade: #393936;
  --accent: #3987e5; --accent-ink: #86b6ef; --accent-wash: rgba(57,135,229,.16);
  --pos: #3987e5; --neg: #e66767; --neutral-mid: #383835;
  --good-ink: #0ca30c; --bad-ink: #e66767;
  --seq0: #172235; --seq1: #0d366b; --seq2: #104281; --seq3: #184f95; --seq4: #256abf; --seq5: #3987e5; --seq6: #6da7ec; --seq7: #b7d3f6;
  --hatch: rgba(255,255,255,.22);
  --shadow: 0 10px 30px rgba(0,0,0,.55), 0 1px 3px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--page); color: var(--ink); font-size: 13px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.num, td.n, .tab-num { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
#app { display: grid; grid-template-columns: 208px 1fr; grid-template-rows: 52px 1fr; height: 100vh; }
.hdr { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: relative; z-index: 20; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; color: var(--ink); font-size: 14px; letter-spacing: -.01em; width: 176px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 24px; height: 24px; border-radius: 7px; background: var(--ink); color: var(--surface); display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.search-btn { flex: 0 1 460px; display: flex; align-items: center; justify-content: space-between; gap: 10px; height: 32px; padding: 0 8px 0 12px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px; color: var(--muted); }
.search-btn:hover { border-color: var(--border-2); }
kbd { font: 11px system-ui; border: 1px solid var(--border-2); border-radius: 4px; padding: 1px 5px; color: var(--muted); background: var(--surface); }
.hdr-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn { height: 30px; min-width: 30px; border: 1px solid transparent; background: transparent; border-radius: 8px; color: var(--ink-2); display: inline-grid; place-items: center; padding: 0 6px; }
.icon-btn:hover { background: var(--hover); }
.icon-btn.on { background: var(--accent-wash); color: var(--accent-ink); }
.nav-toggle { display: none; }
.avatar { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-2); font-size: 11px; font-weight: 600; color: var(--ink-2); }
.fresh { display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--ink-2); font-size: 12px; }
.fresh:hover { background: var(--hover); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

.nav { background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; padding: 10px 8px 20px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 7px; color: var(--ink-2); font-size: 13px; margin: 1px 0; }
.nav a:hover { background: var(--hover); text-decoration: none; color: var(--ink); }
.nav a.active { background: var(--accent-wash); color: var(--accent-ink); font-weight: 600; }
.nav .ni { width: 18px; text-align: center; opacity: .8; font-size: 13px; }
.nav .sep { height: 1px; background: var(--border); margin: 10px 6px; }
.nav .lock { margin-left: auto; font-size: 10px; opacity: .6; }
.nav .grp { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 10px 4px; }

.main { overflow-y: auto; padding: 0 24px 60px; }
.crumbbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 0 10px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--ink-2); }
.crumbs .cur { color: var(--ink); font-weight: 650; font-size: 18px; letter-spacing: -.015em; }
.crumbs .sep { opacity: .5; }
.page-actions { display: flex; gap: 6px; }
.btn { height: 30px; padding: 0 11px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; white-space: nowrap; }
.btn:hover { border-color: var(--border-2); color: var(--ink); }
.btn.primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn.sm { height: 24px; padding: 0 8px; font-size: 12px; border-radius: 6px; }
.btn.on { background: var(--accent-wash); color: var(--accent-ink); border-color: transparent; }

/* ---------- filter bar ---------- */
.filterbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.fctl { height: 30px; display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; border-radius: 7px; border: 1px solid transparent; background: var(--surface-2); color: var(--ink); font-size: 12.5px; }
.fctl:hover { border-color: var(--border-2); }
.fctl .lbl { color: var(--muted); }
.fctl .car { font-size: 9px; color: var(--muted); }
.fctl.set { background: var(--accent-wash); color: var(--accent-ink); }
.fctl.set .lbl { color: var(--accent-ink); opacity: .8; }
.fsep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); padding: 0 6px; cursor: pointer; user-select: none; }
.switch { width: 28px; height: 16px; border-radius: 9px; background: var(--axis); position: relative; transition: background .15s; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: left .15s; }
.toggle.on .switch { background: var(--accent); }
.toggle.on .switch::after { left: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0 0; min-height: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 4px 0 9px; border-radius: 12px; background: var(--accent-wash); color: var(--accent-ink); font-size: 12px; }
.chip.not { background: rgba(227,73,72,.12); color: var(--bad-ink); }
.chip.muted { background: var(--surface-2); color: var(--muted); padding-right: 9px; }
.chip button { border: 0; background: transparent; width: 18px; height: 18px; border-radius: 50%; color: inherit; display: grid; place-items: center; font-size: 13px; padding: 0; }
.chip button:hover { background: var(--hover); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 12px 0 4px; }
.tabs a { padding: 8px 12px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 13px; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }

/* ---------- grid & panels ---------- */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); display: flex; flex-direction: column; min-width: 0; position: relative; }
.panel-h { display: flex; align-items: flex-start; gap: 8px; padding: 12px 14px 4px; }
.panel-t { min-width: 0; flex: 1; }
.panel-title { font-weight: 620; font-size: 13.5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.panel-sub { color: var(--muted); font-size: 12px; margin-top: 1px; }
.info { border: 0; background: transparent; color: var(--muted); width: 16px; height: 16px; border-radius: 50%; font-size: 11px; padding: 0; display: inline-grid; place-items: center; border: 1px solid var(--border-2); line-height: 1; }
.info:hover { color: var(--ink); border-color: var(--ink-2); }
.panel-ctl { display: flex; align-items: center; gap: 2px; flex: none; }
.pc { height: 24px; min-width: 24px; padding: 0 7px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.pc:hover { background: var(--hover); color: var(--ink); }
.pc.on { color: var(--accent-ink); background: var(--accent-wash); }
.seg-ctl { display: inline-flex; border: 1px solid var(--border); border-radius: 7px; padding: 1px; margin-right: 4px; }
.seg-ctl button { border: 0; background: transparent; border-radius: 5px; height: 22px; padding: 0 8px; color: var(--muted); font-size: 11.5px; }
.seg-ctl button.on { background: var(--surface-2); color: var(--ink); box-shadow: 0 0 0 1px var(--border); }
.panel-b { padding: 6px 14px 14px; flex: 1; min-height: 0; position: relative; }
.panel.loading .panel-b > * { opacity: .35; }
.panel.loading::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 50% 100%; animation: bar 1s linear infinite; border-radius: var(--r) var(--r) 0 0; }
@keyframes bar { from { background-position: -50% 0; } to { background-position: 150% 0; } }
.badge { display: inline-flex; align-items: center; gap: 4px; height: 18px; padding: 0 6px; border-radius: 5px; font-size: 10.5px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
.badge.live { background: rgba(12,163,12,.12); color: var(--good-ink); }
.badge.sample { background: rgba(250,178,25,.18); color: #8a5a00; }
:root[data-theme="dark"] .badge.sample { color: #fab219; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .badge.sample { color: #fab219; } }
.badge.est { background: var(--accent-wash); color: var(--accent-ink); }
.badge.planned { background: var(--surface-2); color: var(--muted); }
.badge.proxy { background: rgba(98,80,214,.13); color: var(--s7); }
.note { color: var(--muted); font-size: 11.5px; }
.panel-foot { padding: 0 14px 12px; color: var(--muted); font-size: 11.5px; }

/* stat tiles */
.kpis { display: grid; gap: 14px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px 10px; cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 2px; min-width: 0; position: relative; }
.tile:hover { border-color: var(--border-2); background: linear-gradient(var(--hover), var(--hover)), var(--surface); }
.tile .lbl { color: var(--ink-2); font-size: 12px; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .val { font-size: 24px; font-weight: 640; letter-spacing: -.02em; line-height: 1.2; margin-top: 2px; }
.tile .sub { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .row { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.tile svg.spark { flex: none; }
.delta { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.delta.good { color: var(--good-ink); }
.delta.bad { color: var(--bad-ink); }
.delta.flat { color: var(--muted); }
.delta .abs { font-weight: 400; color: var(--muted); }
.hero .val { font-size: 52px; font-weight: 650; letter-spacing: -.035em; line-height: 1.05; }
.hero { padding: 16px 18px; }
.meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 6px; box-shadow: inset 0 0 0 1px var(--border); }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* charts */
svg.chart { display: block; width: 100%; overflow: visible; }
svg text { fill: var(--muted); font-size: 11px; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
svg .lbl-ink { fill: var(--ink-2); }
svg .lbl-strong { fill: var(--ink); font-weight: 600; }
svg .grid line { stroke: var(--grid); stroke-width: 1; }
svg .base { stroke: var(--axis); stroke-width: 1; }
svg [data-drill], svg [data-tip] { cursor: pointer; }
svg .mark { transition: opacity .12s; }
svg .faded { opacity: .22; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-2); margin: 2px 0 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; cursor: default; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.ln { height: 2px; width: 14px; border-radius: 1px; }
.legend i.dash { height: 0; width: 14px; border-top: 2px dashed var(--cmp); border-radius: 0; }

/* ranked bars (HTML) */
.rb { display: flex; flex-direction: column; gap: 3px; }
.rb-row { display: grid; grid-template-columns: minmax(80px, 38%) 1fr auto; align-items: center; gap: 10px; padding: 3px 4px; border-radius: 6px; cursor: pointer; }
.rb-row:hover { background: var(--hover); }
.rb-row .l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.rb-row .t { height: 14px; position: relative; }
.rb-row .t i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; background: var(--s1); min-width: 2px; }
.rb-row .t i.negbar { border-radius: 4px 0 0 4px; }
.rb-row .v { font-variant-numeric: tabular-nums; color: var(--ink); text-align: right; white-space: nowrap; font-size: 12.5px; }
.rb-row .v small { color: var(--muted); margin-left: 6px; }
.rb-row.faded { opacity: .35; }
.rb-more { margin-top: 6px; font-size: 12px; }
.thin-seg { display: flex; height: 6px; gap: 2px; border-radius: 3px; overflow: hidden; }
.thin-seg i { display: block; height: 100%; }

/* segmented bar (tall) */
.segbar { display: flex; gap: 2px; height: 56px; border-radius: 6px; overflow: hidden; margin: 6px 0 8px; }
.segbar div { display: flex; flex-direction: column; justify-content: flex-end; padding: 6px 8px; color: #fff; font-size: 12px; font-weight: 600; min-width: 2px; cursor: pointer; overflow: hidden; white-space: nowrap; }
.segbar div.dk { color: #0b0b0b; }
.segbar div:hover { filter: brightness(1.08); }

/* tables */
.tbl-wrap { overflow: auto; max-height: 520px; border-radius: 6px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th { position: sticky; top: 0; background: var(--surface); text-align: left; font-weight: 600; color: var(--ink-2); padding: 7px 8px; border-bottom: 1px solid var(--border-2); white-space: nowrap; cursor: pointer; user-select: none; z-index: 1; }
.tbl th.n, .tbl td.n { text-align: right; }
.tbl th:hover { color: var(--ink); }
.tbl td { padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover td { background: var(--hover); }
.tbl .sortind { font-size: 9px; color: var(--muted); margin-left: 3px; }
.tbl td.hl { font-weight: 600; color: var(--ink); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 8px; color: var(--muted); font-size: 12px; }
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }
.status .si { font-size: 11px; font-weight: 700; width: 14px; height: 14px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; line-height: 1; }
.flag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 10px; font-size: 11.5px; background: var(--surface-2); color: var(--ink-2); margin-right: 4px; }
.flag.crit { background: rgba(208,59,59,.12); color: var(--bad-ink); }
.flag.warn { background: rgba(250,178,25,.18); color: #8a5a00; }
:root[data-theme="dark"] .flag.warn { color: #fab219; }

/* states */
.state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; color: var(--muted); min-height: 160px; padding: 16px; }
.state .ico { font-size: 22px; opacity: .8; }
.state b { color: var(--ink-2); font-weight: 600; }
.skel { background: linear-gradient(90deg, var(--surface-2) 0%, var(--hover) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: sk 1.2s ease infinite; border-radius: 6px; }
@keyframes sk { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* tooltip, popover, overlay, drawer */
.tooltip { position: fixed; z-index: 100; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--border-2); border-radius: 8px; box-shadow: var(--shadow); padding: 8px 10px; font-size: 12px; min-width: 120px; max-width: 320px; opacity: 0; transition: opacity .08s; }
.tooltip.show { opacity: 1; }
.tooltip .tt-h { color: var(--muted); font-size: 11.5px; margin-bottom: 4px; }
.tooltip .tt-r { display: flex; align-items: center; gap: 8px; justify-content: space-between; padding: 1px 0; }
.tooltip .tt-r b { font-variant-numeric: tabular-nums; font-weight: 600; }
.tooltip .tt-r span { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tooltip .tt-f { border-top: 1px solid var(--border); margin-top: 5px; padding-top: 4px; color: var(--muted); font-size: 11px; }
.sw { width: 9px; height: 9px; border-radius: 2px; display: inline-block; flex: none; }
.popover { position: fixed; z-index: 90; background: var(--surface); border: 1px solid var(--border-2); border-radius: 10px; box-shadow: var(--shadow); min-width: 220px; max-width: 360px; display: none; padding: 4px; }
.popover.show { display: block; }
.pop-h { padding: 8px 10px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.pop-h b { display: block; font-size: 12.5px; }
.pop-h span { color: var(--muted); font-size: 12px; }
.mi { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 7px 10px; border-radius: 6px; text-align: left; font-size: 12.5px; color: var(--ink); }
.mi:hover, .mi.kb { background: var(--hover); }
.mi .k { width: 16px; text-align: center; color: var(--muted); }
.mi .r { margin-left: auto; color: var(--muted); font-size: 11.5px; }
.mi.check::after { content: "✓"; margin-left: auto; font-weight: 700; color: var(--accent-ink); }
.mi[disabled] { opacity: .4; cursor: default; }
.mdiv { height: 1px; background: var(--border); margin: 4px 0; }
.mgrp { padding: 6px 10px 2px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.32); z-index: 80; display: none; align-items: flex-start; justify-content: center; padding-top: 10vh; }
.overlay.show { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border-2); border-radius: 12px; box-shadow: var(--shadow); width: min(640px, calc(100vw - 32px)); max-height: 78vh; display: flex; flex-direction: column; overflow: hidden; }
.modal.wide { width: min(1080px, calc(100vw - 32px)); }
.modal-h { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.modal-h h3 { margin: 0; font-size: 15px; font-weight: 620; flex: 1; }
.modal-b { padding: 14px 16px; overflow: auto; }
.search-in { width: 100%; border: 0; background: transparent; font-size: 15px; padding: 14px 16px; border-bottom: 1px solid var(--border); outline: none; }
.sres { overflow: auto; padding: 4px; }
.sres .mi small { color: var(--muted); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); background: var(--surface); border-left: 1px solid var(--border-2); box-shadow: var(--shadow); z-index: 85; transform: translateX(105%); transition: transform .18s ease; overflow: auto; }
.drawer.show { transform: none; }
.drawer .dh { padding: 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.drawer .dh h3 { margin: 0; font-size: 15px; flex: 1; }
.drawer .db { padding: 16px; }
.drawer dt { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; margin-top: 14px; }
.drawer dd { margin: 4px 0 0; }
code, pre { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; }
pre { background: var(--surface-2); padding: 10px 12px; border-radius: 8px; overflow: auto; white-space: pre-wrap; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); background: var(--ink); color: var(--surface); padding: 9px 14px; border-radius: 9px; font-size: 12.5px; opacity: 0; pointer-events: none; transition: all .18s; z-index: 120; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* entity header */
.ent { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 16px 18px; display: grid; grid-template-columns: 1fr auto; gap: 12px; margin-top: 4px; }
.ent h2 { margin: 0; font-size: 20px; letter-spacing: -.015em; }
.ent .meta { color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; font-size: 12.5px; }
.ent .meta span { display: inline-flex; gap: 5px; align-items: center; }
.ent .meta .k { color: var(--muted); }
.copy { border: 0; background: transparent; color: var(--muted); padding: 0 2px; font-size: 11px; }
.copy:hover { color: var(--ink); }
.health { text-align: right; }
.health .score { font-size: 30px; font-weight: 650; letter-spacing: -.02em; }
.bench { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.bullet { position: relative; height: 18px; margin: 8px 0 4px; }
.bullet .trk { position: absolute; left: 0; right: 0; top: 7px; height: 4px; background: var(--surface-2); border-radius: 2px; box-shadow: inset 0 0 0 1px var(--border); }
.bullet .band { position: absolute; top: 4px; height: 10px; background: var(--fade); border-radius: 3px; }
.bullet .med { position: absolute; top: 1px; width: 2px; height: 16px; background: var(--muted); }
.bullet .me { position: absolute; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); transform: translateX(-6px); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.settings-grid div { display: flex; justify-content: space-between; border-bottom: 1px solid var(--border); padding: 6px 0; }
.settings-grid div span:first-child { color: var(--muted); }
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-day { color: var(--muted); font-size: 11.5px; padding: 8px 0 2px; }
.tl-it { display: flex; gap: 10px; align-items: flex-start; padding: 5px 0; }
.tl-ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: 11px; flex: none; }
.tl-it .tx { flex: 1; }
.tl-it .tx small { display: block; color: var(--muted); }
.meterlist { display: flex; flex-direction: column; gap: 10px; }
.ml-row .top { display: flex; justify-content: space-between; font-size: 12.5px; }
.ml-row .top span:first-child { color: var(--ink-2); }
.ml-row .meter { height: 8px; }

/* explore */
.explore { display: grid; grid-template-columns: 240px 1fr; gap: 14px; margin-top: 14px; }
.fields { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 10px; max-height: calc(100vh - 220px); overflow: auto; }
.fields input { width: 100%; height: 30px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); padding: 0 10px; margin-bottom: 8px; }
.fgrp { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 10px 4px 4px; }
.fld { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; cursor: pointer; font-size: 12.5px; color: var(--ink-2); }
.fld:hover { background: var(--hover); color: var(--ink); }
.fld .fi { width: 16px; text-align: center; color: var(--muted); font-family: ui-monospace, monospace; font-size: 11px; }
.fld.sel { color: var(--accent-ink); background: var(--accent-wash); }
.qrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 0; }
.qrow .ql { width: 72px; color: var(--muted); font-size: 12px; }
.pill { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 4px 0 10px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; }
.pill button { border: 0; background: transparent; color: var(--muted); padding: 0 4px; }

/* responsive */
@media (max-width: 1439px) {
  #app { grid-template-columns: 56px 1fr; }
  .nav a .tx, .nav .grp, .nav .lock { display: none; }
  .nav a { justify-content: center; padding: 8px 0; }
  .brand { width: auto; }
  .nav:hover { width: 208px; position: relative; z-index: 15; box-shadow: var(--shadow); }
  .nav:hover a .tx, .nav:hover .grp, .nav:hover .lock { display: inline; }
  .nav:hover a { justify-content: flex-start; padding: 6px 10px; }
}
@media (max-width: 1023px) {
  .grid > .panel, .grid > .kpis { grid-column: span 12 !important; }
  .bench { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .explore { grid-template-columns: 1fr; }
}
@media (max-width: 767px) {
  #app { grid-template-columns: 1fr; }
  .nav { position: fixed; top: 52px; left: 0; bottom: 0; width: 240px; z-index: 30; transform: translateX(-100%); transition: transform .18s; }
  .nav.open { transform: none; box-shadow: var(--shadow); }
  .nav a .tx, .nav .grp { display: inline !important; }
  .nav a { justify-content: flex-start !important; padding: 6px 10px !important; }
  .nav-toggle { display: inline-grid; }
  .brand { width: auto; } .brand span:last-child { display: none; }
  .search-btn span { display: none; } .search-btn { flex: 0 0 auto; } .search-btn::before { content: "⌕"; color: var(--muted); }
  .main { padding: 0 16px 60px; }
  .fresh span:last-child { display: none; }
  .filterbar .opt { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .hero .val { font-size: 40px; }
  .page-actions .btn .tx { display: none; }
  .ent { grid-template-columns: 1fr; } .health { text-align: left; }
  .bench { grid-template-columns: 1fr; }
}
@media (forced-colors: active) { .switch, .meter > i { forced-color-adjust: none; } }

.tile.static { cursor: default; }
.tile.static:hover { border-color: var(--border); background: var(--surface); }

/* ---- login (Teradek ID, superadmin only) */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--page); }
.login[hidden], #app[hidden] { display: none; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 28px 24px 24px; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.login-brand { font-size: 16px; margin-bottom: 6px; }
.login-sub { margin: 0 0 18px; color: var(--muted); font-size: 12.5px; }
.login-l { font-size: 12px; color: var(--ink-2); margin: 10px 0 4px; }
.login-in { height: 34px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border-2); background: var(--surface); color: var(--ink); font: inherit; font-size: 13.5px; }
.login-in:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.login-btn { margin-top: 18px; height: 34px; justify-content: center; font-size: 13px; }
.login-btn:disabled { opacity: .6; cursor: progress; }
.login-err { display: flex; flex-direction: column; gap: 2px; padding: 9px 11px; border-radius: 8px; font-size: 12.5px; color: var(--ink); background: var(--surface-2); border-left: 3px solid var(--critical); margin-bottom: 4px; }
.login-err[hidden] { display: none; }
.login-err.authorization { border-left-color: var(--serious); }
.login-err.upstream { border-left-color: var(--warning); }
.toggle.dis { opacity: .5; cursor: not-allowed; }
