/* Tokens: dataviz reference palette (light/dark selected, not flipped). */
.viz-root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --wash: rgba(11, 11, 11, 0.05);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --wash: rgba(255, 255, 255, 0.06);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
  }
}
:root[data-theme="dark"] .viz-root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --wash: rgba(255, 255, 255, 0.06);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}
main { max-width: 1200px; margin: 0 auto; padding: 24px 20px 40px; }

.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
h1 { font-size: 22px; font-weight: 600; margin: 0; }
h2 { font-size: 15px; font-weight: 600; margin: 0; }
.sub { margin: 4px 0 0; color: var(--text-secondary); }

button {
  font: inherit; color: var(--text-primary); background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 8px; padding: 5px 12px; cursor: pointer;
}
button:hover { background: var(--wash); }
button:focus-visible, .chart svg:focus-visible, summary:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }
button.ghost { color: var(--text-secondary); }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 28px; margin: 20px 0 16px; }
.filters .group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.filters-label { color: var(--text-secondary); margin-right: 4px; }
.filters button[aria-pressed="true"] { font-weight: 600; border-color: var(--text-secondary); }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
#price-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) { #price-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .tiles, #price-tiles { grid-template-columns: 1fr; } }
.tile {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.tile-label { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); }
.tile-label .name { color: var(--text-primary); font-weight: 600; }
.tile-label .detail { color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-value { font-size: 28px; font-weight: 600; letter-spacing: -0.01em; }
.tile-meta { color: var(--text-secondary); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.tile-meta .num { font-variant-numeric: tabular-nums; }
.status { display: inline-flex; align-items: center; gap: 5px; color: var(--text-secondary); }
.status .icon { font-size: 11px; line-height: 1; }
.status[data-state="live"] .icon { color: var(--good); }
.status[data-state="stale"] .icon { color: var(--warning); }
.status[data-state="down"] .icon { color: var(--critical); }

.key { display: inline-block; width: 14px; height: 2px; border-radius: 1px; flex: none; }

.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px 10px; margin-top: 12px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--text-secondary); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.chart { position: relative; height: 320px; margin-top: 8px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart.loading svg { opacity: 0.45; }
.chart .msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-muted); pointer-events: none; }
.chart .msg[hidden] { display: none; }
.axis text { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.end-label { fill: var(--text-primary); font-size: 12px; font-variant-numeric: tabular-nums; }
.end-label .lbl { fill: var(--text-secondary); }

.tooltip {
  position: absolute; pointer-events: none; z-index: 2; min-width: 170px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); padding: 8px 10px; font-size: 12px;
}
.tooltip[hidden] { display: none; }
.tooltip .t { color: var(--text-secondary); margin-bottom: 4px; }
.tooltip .row { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.tooltip .v { font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.tooltip .l { color: var(--text-secondary); }

details.card summary { cursor: pointer; font-weight: 600; padding: 2px 0 6px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 12px; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 4px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--text-secondary); font-weight: 600; }

.notes { margin-top: 16px; color: var(--text-secondary); font-size: 12px; max-width: 900px; }
.notes p { margin: 6px 0; }
