/* Design tokens — reference dataviz palette, light + dark. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --se1: #2a78d6;
  --se2: #eb6834;
  --se3: #1baf7a;
  --se4: #eda100;
  --delta-good: #006300;
  --delta-bad: #d03b3b;
  --warn: #fab219;
  --accent: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --se1: #3987e5;
    --se2: #d95926;
    --se3: #199e70;
    --se4: #c98500;
    --delta-good: #0ca30c;
    --delta-bad: #e66767;
    --accent: #3987e5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --se1: #3987e5;
  --se2: #d95926;
  --se3: #199e70;
  --se4: #c98500;
  --delta-good: #0ca30c;
  --delta-bad: #e66767;
  --accent: #3987e5;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.page { max-width: 1080px; margin: 0 auto; padding: 20px 20px 48px; }
a { color: var(--accent); }

/* Top bar */
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
h1 { font-size: 22px; font-weight: 650; margin: 0; }
.subtitle { margin: 2px 0 0; color: var(--ink-2); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.updated { color: var(--muted); font-size: 12px; }

h2 { font-size: 16px; font-weight: 650; margin: 0; }
.section-head { display: flex; align-items: baseline; gap: 10px; margin: 28px 0 10px; }
.section-meta { color: var(--muted); font-size: 12px; }

/* Buttons, segmented controls, chips */
.btn {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 12px; font: inherit; cursor: pointer;
}
.btn:hover { border-color: var(--axis); }
.btn-small { padding: 3px 10px; font-size: 12px; }

.filters { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 16px 0 8px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.seg-btn {
  border: 0; background: transparent; color: var(--ink-2);
  padding: 5px 12px; border-radius: 6px; font: inherit; cursor: pointer;
}
.seg-btn.is-active { background: var(--accent); color: #fff; }
.seg-btn:not(.is-active):hover { color: var(--ink); }

.zone-chips { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.zone-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 5px 10px; cursor: pointer; user-select: none;
  font: inherit; color: var(--muted);
}
.zone-btn.is-on { color: var(--ink); border-color: var(--axis); }
.zone-btn:not(.is-on) { text-decoration: line-through; }
.zone-btn:not(.is-on) .chip-key { opacity: 0.25; }
.zone-btn:hover { border-color: var(--axis); }
.chip-key { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.chip-key[data-zone-key="SE1"] { background: var(--se1); }
.chip-key[data-zone-key="SE2"] { background: var(--se2); }
.chip-key[data-zone-key="SE3"] { background: var(--se3); }
.chip-key[data-zone-key="SE4"] { background: var(--se4); }

/* Demo-data banner */
.banner {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--warn); border-radius: 10px;
  padding: 10px 14px; margin: 12px 0;
}
.banner-icon { color: var(--warn); font-size: 16px; }
.banner .btn { margin-left: auto; }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.tile-label { display: flex; align-items: center; gap: 7px; color: var(--ink-2); font-size: 13px; }
.tile-key { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.tile-value { font-size: 26px; font-weight: 600; margin-top: 2px; }
.tile-unit { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.tile-delta { font-size: 12px; margin-top: 2px; color: var(--muted); }
.tile-delta .up { color: var(--delta-good); }
.tile-delta .down { color: var(--delta-bad); }

/* Chart card */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 14px 8px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 0 2px 6px; color: var(--ink-2); font-size: 13px; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.legend-key { width: 14px; height: 2px; border-radius: 1px; display: inline-block; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; }
.chart-empty { color: var(--muted); text-align: center; padding: 60px 0; }

.tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  padding: 8px 10px; min-width: 150px; font-size: 12px;
}
.tooltip-time { color: var(--muted); margin-bottom: 4px; }
.tooltip-row { display: flex; align-items: center; gap: 7px; padding: 1px 0; }
.tooltip-key { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.tooltip-name { color: var(--ink-2); }
.tooltip-val { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Table view */
.table-view { border-top: 1px solid var(--grid); margin-top: 6px; }
.table-view summary { color: var(--ink-2); font-size: 13px; padding: 8px 2px; cursor: pointer; }
.table-wrap { max-height: 320px; overflow: auto; }
.table-wrap table { border-collapse: collapse; width: 100%; font-size: 13px; }
.table-wrap th, .table-wrap td { text-align: right; padding: 4px 10px; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
.table-wrap th:first-child, .table-wrap td:first-child { text-align: left; }
.table-wrap th { position: sticky; top: 0; background: var(--surface); color: var(--ink-2); font-weight: 600; }
.table-note { color: var(--muted); font-size: 12px; padding: 6px 2px; }

.foot { margin-top: 32px; color: var(--muted); font-size: 12px; }
