.viz-root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --neutral: #c3c2b7;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-8: #e34948;
  --other: #b5b4ad;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --accent-wash: rgba(42, 120, 214, 0.08);
}
@media (prefers-color-scheme: dark) {
  .viz-root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --neutral: #55544f;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --other: #6b6a65;
    --accent-wash: rgba(57, 135, 229, 0.14);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
  line-height: 1.45;
}
a { color: var(--series-1); }

.topbar { padding: 20px 24px 4px; }
.topbar h1 { margin: 0; font-size: 22px; }
.tagline { margin: 2px 0 0; color: var(--text-secondary); }

.controls {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end;
  padding: 12px 24px;
}
.field { display: flex; flex-direction: column; gap: 4px; position: relative; }
.field label { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.field input[type=search], .field input[type=date] {
  font: inherit; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--axis); background: var(--surface-1); color: var(--text-primary);
}
.search { flex: 1 1 320px; max-width: 480px; }
.range input { width: 200px; }
.range output { font-weight: 400; color: var(--text-primary); }

.suggestions {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 1000;
  margin: 4px 0 0; padding: 4px; list-style: none;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.suggestions li { padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.suggestions li:hover, .suggestions li[aria-selected=true] { background: var(--accent-wash); }

.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px;
  padding: 0 24px;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.map-wrap { position: relative; align-self: start; }
#map {
  height: 560px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-1);
}
.map-legend {
  position: absolute; left: 12px; bottom: 12px; z-index: 500;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; color: var(--text-secondary);
  display: flex; flex-direction: column; gap: 4px;
}
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.swatch.sq { border-radius: 3px; }

.panel {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px;
}
.place { font-weight: 600; margin-bottom: 12px; }
.place small { display: block; font-weight: 400; color: var(--text-secondary); }
.hero-number { font-size: 56px; font-weight: 700; line-height: 1; }
.hero-number .unit { font-size: 24px; color: var(--text-secondary); margin-left: 2px; }
.hero-caption { color: var(--text-secondary); margin-top: 6px; }
.status {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 12px;
  font-weight: 600; font-size: 14px;
}
.status .dot { width: 12px; height: 12px; border-radius: 50%; display: inline-grid; place-items: center; }
.breakdown { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.breakdown .row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.breakdown .bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--grid); overflow: hidden; }
.breakdown .bar span { display: block; height: 100%; border-radius: 3px; }
.breakdown .val { font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.best { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--grid); font-size: 14px; color: var(--text-secondary); }
.best button { font: inherit; color: var(--series-1); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }
.loading { color: var(--text-secondary); font-size: 14px; margin-top: 12px; }
.error { color: var(--critical); font-size: 14px; margin-top: 12px; }

.card {
  margin: 16px 24px 0; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px;
}
.card-head h2 { margin: 0; font-size: 16px; }
.card-head .sub { margin: 2px 0 10px; color: var(--text-secondary); font-size: 13px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.timeline svg { display: block; width: 100%; height: auto; }
.timeline .axis text { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.timeline .grid line { stroke: var(--grid); stroke-width: 1; }
.timeline .baseline { stroke: var(--axis); stroke-width: 1; }
.timeline .weekend { fill: var(--grid); opacity: 0.45; }
.timeline .sel { fill: none; stroke: var(--text-primary); stroke-width: 1.5; rx: 6; }
.timeline .hit { fill: transparent; cursor: pointer; }
.timeline .hit:hover { fill: var(--accent-wash); }
.timeline .daylabel { fill: var(--text-muted); font-size: 10px; text-anchor: middle; font-variant-numeric: tabular-nums; }
.timeline .daylabel.selected { fill: var(--text-primary); font-weight: 700; }
.timeline .holmark { fill: var(--text-secondary); font-size: 9px; text-anchor: middle; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { text-align: left; font-size: 12px; color: var(--text-secondary); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--axis); }
td { padding: 7px 8px; border-bottom: 1px solid var(--grid); vertical-align: top; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.wbar { display: inline-block; height: 6px; border-radius: 3px; background: var(--series-1); vertical-align: middle; margin-right: 6px; }
.pill { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.muted { color: var(--text-muted); }

.foot { padding: 20px 24px 32px; color: var(--text-muted); font-size: 12px; }
.foot a { color: var(--text-secondary); }

.tooltip {
  position: fixed; z-index: 2000; pointer-events: none;
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.16);
  padding: 8px 10px; font-size: 13px; max-width: 300px;
}
.tooltip .tt-head { font-weight: 700; margin-bottom: 4px; }
.tooltip .tt-row { display: grid; grid-template-columns: auto 1fr auto; gap: 6px; align-items: center; }
.tooltip .tt-row .v { font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.tooltip .tt-note { color: var(--text-secondary); margin-top: 4px; font-size: 12px; }

.leaflet-container { font-family: inherit; }
@media (prefers-color-scheme: dark) {
  .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.85) saturate(0.5); }
}
.best .warn { color: var(--text-primary); margin-bottom: 8px; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.best .warn .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.region-dot { transition: none; }
