.viz-root {
  color-scheme: light;
  --page: #f4f3ef;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e0da;
  --grid: #e8e6e0;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7a7974;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --other: rgba(82, 81, 78, 0.22);
  --other-hi: #0b0b0b;
  --band: rgba(82, 81, 78, 0.14);
  --good: #006300;
  --bad: #b42323;
  --live: #0ca30c;
  --warn: #c98500;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    color-scheme: dark;
    --page: #121211;
    --surface-1: #1a1a19;
    --surface-2: #232321;
    --border: #2e2e2b;
    --grid: #2a2a27;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8e86;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --other: rgba(195, 194, 183, 0.2);
    --other-hi: #f0efec;
    --band: rgba(195, 194, 183, 0.12);
    --good: #4cc04c;
    --bad: #f07a7a;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.viz-root { background: var(--page); color: var(--text-primary); min-height: 100vh; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

.top { padding: 40px 0 24px; }
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
h1 { font-size: clamp(26px, 4vw, 38px); line-height: 1.15; margin: 6px 0 10px; letter-spacing: -.01em; }
.lede { color: var(--text-secondary); max-width: 760px; margin: 0 0 16px; font-size: 16px; }
.status { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--surface-1); border: 1px solid var(--border); font-size: 13px; color: var(--text-secondary); }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.status.live .dot { background: var(--live); box-shadow: 0 0 0 0 rgba(12,163,12,.5); animation: pulse 2s infinite; }
.status.wait .dot { background: var(--warn); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(12,163,12,.45); } 70% { box-shadow: 0 0 0 8px rgba(12,163,12,0); } 100% { box-shadow: 0 0 0 0 rgba(12,163,12,0); } }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.kpi .lab { font-size: 12.5px; color: var(--text-secondary); }
.kpi .val { font-size: 28px; font-weight: 650; letter-spacing: -.01em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .note { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 820px) { .kpis { grid-template-columns: repeat(2, 1fr); } }

.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 18px 18px 14px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 6px; }
h2 { font-size: 17px; margin: 0 0 2px; }
h3 { font-size: 14px; margin: 0 0 6px; }
.sub { margin: 0; color: var(--text-secondary); font-size: 13px; max-width: 720px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--text-secondary); align-items: center; }
.legend .k { display: inline-flex; align-items: center; gap: 6px; }
.legend .ln { width: 16px; height: 0; border-top: 2px solid; display: inline-block; border-radius: 2px; }
.legend .bx { width: 14px; height: 10px; background: var(--band); display: inline-block; border-radius: 2px; }

.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .lbl { fill: var(--text-secondary); font-size: 11.5px; font-weight: 600; }
.chart .grid line { stroke: var(--grid); }
.chart .zero { stroke: var(--text-muted); stroke-dasharray: 2 3; }
.empty { padding: 48px 12px; text-align: center; color: var(--text-muted); }

.tip { position: fixed; pointer-events: none; z-index: 20; background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; box-shadow: 0 6px 24px rgba(0,0,0,.12); opacity: 0; transition: opacity .08s; max-width: 300px; }
.tip.on { opacity: 1; }
.tip .t { color: var(--text-muted); margin-bottom: 4px; }
.tip .r { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tip .r .n { color: var(--text-secondary); display: inline-flex; align-items: center; gap: 6px; }
.tip .r b { font-variant-numeric: tabular-nums; }
.tip .key { width: 12px; border-top: 2px solid; display: inline-block; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 10px; align-items: center; }
.chip { border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary); border-radius: 999px; padding: 4px 11px; font: inherit; font-size: 12.5px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--text-primary); color: var(--surface-1); border-color: var(--text-primary); }
.search { margin-left: auto; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); border-radius: 8px; padding: 5px 10px; font: inherit; font-size: 13px; min-width: 180px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th { text-align: right; font-weight: 600; color: var(--text-secondary); padding: 8px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--surface-1); }
th.l, td.l { text-align: left; }
th[aria-sort="descending"]::after { content: " ↓"; }
th[aria-sort="ascending"]::after { content: " ↑"; }
td { text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tr.bench td { font-weight: 650; }
.nm { font-weight: 550; color: var(--text-primary); }
.fam { color: var(--text-muted); }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.tag { display: inline-block; font-size: 10.5px; padding: 0 6px; border-radius: 4px; border: 1px solid var(--border); color: var(--text-muted); margin-left: 6px; vertical-align: 1px; }
.barcell { display: inline-block; width: 64px; height: 8px; position: relative; vertical-align: middle; margin-left: 8px; }
.barcell::before { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; border-left: 1px solid var(--border); }
.barcell i { position: absolute; top: 0; height: 8px; background: var(--text-secondary); opacity: .55; border-radius: 2px; }

.rules .cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 10px; }
.rules ul { margin: 0; padding-left: 18px; color: var(--text-secondary); font-size: 13.5px; }
.rules li { margin-bottom: 6px; }
@media (max-width: 820px) { .rules .cols { grid-template-columns: 1fr; } }
.foot { color: var(--text-muted); font-size: 12px; padding: 8px 0 40px; }

dialog { border: 1px solid var(--border); border-radius: 16px; background: var(--surface-1); color: var(--text-primary); width: min(860px, 94vw); max-height: 90vh; padding: 20px 22px; }
dialog::backdrop { background: rgba(0,0,0,.45); }
.close-row { position: sticky; top: 0; float: right; margin: -6px -8px 0 0; }
.close-row button { border: 0; background: var(--surface-2); color: var(--text-primary); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 14px; }
.dgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0; }
.dgrid .kpi .val { font-size: 20px; }
@media (max-width: 640px) { .dgrid { grid-template-columns: repeat(2, 1fr); } }
.mini { font-size: 12.5px; }
.mini td, .mini th { padding: 5px 6px; }

.daybar { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.daybar .chip { padding: 5px 12px; font-size: 13px; }
.daybar .chip .live { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--live); margin-left: 6px; vertical-align: 2px; }
body.v-sum .only-day, body.v-day .only-sum { display: none; }
.viz-root { --div-pos: #2a78d6; --div-neg: #e34948; --div-mid: #f0efec; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .viz-root { --div-pos: #3987e5; --div-neg: #e66767; --div-mid: #383835; } }
table.heat td.cell { text-align: center; min-width: 62px; font-size: 12px; border-left: 2px solid var(--surface-1); color: var(--text-primary); }
table.heat td.na { color: var(--text-muted); }
.scale { display: inline-flex; align-items: center; gap: 6px; }
.scale i { display: inline-block; width: 90px; height: 10px; border-radius: 3px; background: linear-gradient(90deg, var(--div-neg), var(--div-mid), var(--div-pos)); }
