/* Hark Urbanism
   Layout: a full-bleed map; thin chrome pinned to the edges (top bar, tool rail, view switcher),
   panels float over the map only when asked for.
   Identity: road-sign typography (Overpass descends from the FHWA highway alphabet) and
   guide-sign green as the single accent. */
:root {
  --bg: #e8ebe3;
  --surface: #fbfcf9;
  --surface-2: #f1f3ee;
  --surface-3: #e6e9e2;
  --ink: #151c18;
  --ink-2: #47514b;
  --muted: #7b847e;
  --line: rgba(21, 28, 24, 0.12);
  --line-strong: rgba(21, 28, 24, 0.22);
  --accent: #006b4f;
  --accent-2: #0b8a66;
  --accent-ink: #ffffff;
  --accent-soft: rgba(0, 107, 79, 0.1);
  --good: #0ca30c;
  --good-ink: #006300;
  --warn: #fab219;
  --serious: #ec835a;
  --bad: #d03b3b;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --div-neg: #d03b3b;
  --div-mid: #e1e0d9;
  --grid: #e1e0d9;
  --shadow: 0 1px 2px rgba(18, 28, 22, 0.08), 0 8px 28px rgba(18, 28, 22, 0.12);
  --font-ui: 'Overpass', 'Public Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-data: 'Overpass Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --r-sm: 4px;
  --r-md: 7px;
  --gap: 12px;
  --top-h: 52px;
  --rail-w: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141917;
    --surface: #1b211e;
    --surface-2: #222a26;
    --surface-3: #2a332e;
    --ink: #ecefea;
    --ink-2: #b6bfb9;
    --muted: #87918b;
    --line: rgba(236, 239, 234, 0.1);
    --line-strong: rgba(236, 239, 234, 0.2);
    --accent: #2fae80;
    --accent-2: #46c495;
    --accent-ink: #06150f;
    --accent-soft: rgba(47, 174, 128, 0.14);
    --good-ink: #0ca30c;
    --series-1: #3987e5;
    --series-2: #d95926;
    --div-mid: #383835;
    --grid: #2c2c2a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141917;
  --surface: #1b211e;
  --surface-2: #222a26;
  --surface-3: #2a332e;
  --ink: #ecefea;
  --ink-2: #b6bfb9;
  --muted: #87918b;
  --line: rgba(236, 239, 234, 0.1);
  --line-strong: rgba(236, 239, 234, 0.2);
  --accent: #2fae80;
  --accent-2: #46c495;
  --accent-ink: #06150f;
  --accent-soft: rgba(47, 174, 128, 0.14);
  --good-ink: #0ca30c;
  --series-1: #3987e5;
  --series-2: #d95926;
  --div-mid: #383835;
  --grid: #2c2c2a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.4 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { flex: none; display: block; }
.num { font-family: var(--font-data); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.app { position: relative; height: 100%; width: 100%; overflow: hidden; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
#map.pan { cursor: grab; }
#map.panning { cursor: grabbing; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
}

/* ---------- top bar ---------- */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; height: var(--top-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 max(12px, env(safe-area-inset-right, 0px)) 0 max(12px, env(safe-area-inset-left, 0px));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sign {
  display: grid; place-items: center; width: 34px; height: 30px;
  background: var(--accent); color: var(--accent-ink);
  border-radius: 5px; box-shadow: inset 0 0 0 2px var(--accent), inset 0 0 0 3.5px var(--accent-ink);
  font-weight: 800; font-size: 14px; letter-spacing: 0.02em; line-height: 1; padding-top: 2px;
}
.wordmark { font-weight: 800; font-size: 15px; letter-spacing: 0.01em; white-space: nowrap; }
.wordmark small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.cityname {
  border: 1px solid transparent; background: none; padding: 4px 8px; border-radius: var(--r-sm);
  font-weight: 700; font-size: 15px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cityname:hover { border-color: var(--line); }
.cityname-input { font-weight: 700; font-size: 15px; width: 180px; padding: 4px 8px; border: 1px solid var(--accent); border-radius: var(--r-sm); background: var(--surface); }
.tb-sep { width: 1px; height: 26px; background: var(--line); flex: none; }
.clock { display: flex; align-items: center; gap: 10px; }
.date { font-weight: 700; min-width: 74px; }
.date small { color: var(--muted); font-weight: 500; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px; gap: 2px; }
.seg button {
  border: 0; background: transparent; border-radius: 3px; padding: 4px 7px; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 4px; line-height: 1;
}
.seg button:hover { background: var(--surface-3); color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.kpis { display: flex; align-items: center; gap: 18px; margin-left: auto; min-width: 0; }
.kpi { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.kpi .k-label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.kpi .k-val { font-weight: 700; font-size: 15px; white-space: nowrap; }
.kpi .k-sub { font-size: 11px; color: var(--muted); white-space: nowrap; }
.kpi .k-sub.pos { color: var(--good-ink); }
.kpi .k-sub.neg { color: var(--bad); }
.tb-actions { display: flex; gap: 6px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px;
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--r-sm);
  font-weight: 600; font-size: 13px; color: var(--ink); line-height: 1.1; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn[aria-pressed="true"], .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.icon-btn { padding: 6px; }

/* ---------- tool rail ---------- */
.toolbar {
  position: absolute; top: calc(var(--top-h) + 12px); left: max(12px, env(safe-area-inset-left, 0px));
  width: var(--rail-w); display: flex; flex-direction: column; gap: 2px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow);
  z-index: 15;
}
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px 5px;
  border: 0; background: transparent; border-radius: var(--r-sm); color: var(--ink-2);
}
.tool span { font-size: 9.5px; font-weight: 600; letter-spacing: 0.02em; line-height: 1.1; text-align: center; }
.tool:hover { background: var(--surface-2); color: var(--ink); }
.tool[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.tool-sep { height: 1px; background: var(--line); margin: 4px 6px; }

/* ---------- flyout ---------- */
.flyout {
  position: absolute; top: calc(var(--top-h) + 12px); left: calc(max(12px, env(safe-area-inset-left, 0px)) + var(--rail-w) + 10px);
  width: 320px; max-height: calc(100% - var(--top-h) - 120px);
  display: flex; flex-direction: column; z-index: 14; overflow: hidden;
}
.flyout-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px; }
.flyout-head h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); font-weight: 700; }
.items { overflow-y: auto; padding: 0 6px 6px; display: flex; flex-direction: column; gap: 1px; }
.item {
  display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px;
  padding: 7px 8px; border: 0; background: transparent; border-radius: var(--r-sm); text-align: left; width: 100%;
}
.item:hover, .item:focus-visible { background: var(--surface-2); }
.item[aria-pressed="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.item .ic { width: 30px; height: 30px; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--surface-2); color: var(--ink-2); }
.item[aria-pressed="true"] .ic { background: var(--accent); color: var(--accent-ink); }
.item .nm { font-weight: 600; font-size: 13.5px; line-height: 1.2; }
.item .meta { font-size: 11.5px; color: var(--muted); }
.item .cost { font-family: var(--font-data); font-size: 12.5px; font-weight: 600; text-align: right; }
.item.locked { opacity: 0.5; }
.item.locked .cost { font-family: var(--font-ui); font-size: 11px; font-weight: 600; color: var(--muted); max-width: 90px; }
.item-detail { border-top: 1px solid var(--line); padding: 10px 14px 12px; font-size: 12.5px; color: var(--ink-2); background: var(--surface-2); }
.item-detail strong { color: var(--ink); font-size: 13px; }
.item-detail .facts { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.item-detail .facts b { color: var(--ink-2); font-weight: 600; }

/* ---------- inspector ---------- */
.inspector {
  position: absolute; top: calc(var(--top-h) + 12px); left: calc(max(12px, env(safe-area-inset-left, 0px)) + var(--rail-w) + 10px);
  width: 330px; max-height: calc(100% - var(--top-h) - 120px); overflow-y: auto; z-index: 14; padding: 14px;
}
.insp-head { display: flex; gap: 10px; align-items: flex-start; }
.insp-head .ic { width: 38px; height: 38px; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--surface-2); color: var(--ink-2); flex: none; }
.insp-head h3 { margin: 0; font-size: 16px; line-height: 1.2; text-wrap: balance; }
.insp-head .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.insp-head .x { margin-left: auto; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px 1px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; border: 1px solid var(--line-strong); color: var(--ink-2); background: var(--surface-2);
  white-space: nowrap;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.chip.good .dot { background: var(--good); }
.chip.warn .dot { background: var(--warn); }
.chip.serious .dot { background: var(--serious); }
.chip.bad .dot { background: var(--bad); }
.insp-status { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 6px; }
.facts-grid { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 10px 0 0; font-size: 13px; }
.facts-grid dt { color: var(--ink-2); white-space: nowrap; }
.facts-grid dd { margin: 0; text-align: right; min-width: 0; font-family: var(--font-data); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.insp-section { margin-top: 14px; }
.insp-section h4 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.insp-note { font-size: 12.5px; color: var(--ink-2); margin: 10px 0 0; }
.factor { display: grid; grid-template-columns: 112px 1fr 34px; align-items: center; gap: 8px; font-size: 12px; margin: 3px 0; }
.factor .track { height: 6px; background: var(--surface-3); border-radius: 3px; position: relative; overflow: hidden; }
.factor .fill { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 3px; }
.factor .fill.lo { background: var(--bad); }
.factor .fill.mid { background: var(--warn); }
.factor .v { text-align: right; font-family: var(--font-data); font-size: 11.5px; color: var(--ink-2); }
.insp-actions { display: flex; gap: 6px; margin-top: 14px; }

/* ---------- dashboard ---------- */
.dash {
  position: absolute; top: calc(var(--top-h) + 12px); right: max(12px, env(safe-area-inset-right, 0px)); bottom: 72px;
  width: 372px; display: flex; flex-direction: column; z-index: 16; overflow: hidden;
}
.dash-tabs { display: flex; align-items: center; gap: 2px; padding: 8px 8px 0; border-bottom: 1px solid var(--line); }
.dash-tabs .tab {
  border: 0; background: transparent; padding: 8px 10px 9px; font-weight: 700; font-size: 13px; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.dash-tabs .tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.dash-tabs .x { margin-left: auto; }
.dash-body { overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 16px; }
.dash-section h3 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile { border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 10px 8px; background: var(--surface); min-width: 0; }
.tile .t-label { font-size: 11.5px; color: var(--ink-2); font-weight: 600; }
.tile .t-val { font-size: 20px; font-weight: 700; line-height: 1.15; margin-top: 2px; }
.tile .t-sub { font-size: 11px; color: var(--muted); min-height: 15px; }
.tile .t-sub .up { color: var(--good-ink); }
.tile .t-sub .down { color: var(--bad); }
.spark { display: block; width: 100%; height: 28px; margin-top: 4px; overflow: visible; }
.spark-wrap { position: relative; }
.hero { display: flex; align-items: baseline; gap: 10px; }
.hero .h-val { font-size: 34px; font-weight: 800; line-height: 1; }
.hero .h-sub { color: var(--muted); font-size: 12.5px; }
.bars { display: flex; flex-direction: column; gap: 5px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr 70px; gap: 8px; align-items: center; font-size: 12.5px; }
.bar-row .b-label { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .b-track { height: 12px; position: relative; }
.bar-row .b-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; min-width: 1px; }
.bar-row .b-val { text-align: right; font-family: var(--font-data); font-variant-numeric: tabular-nums; font-size: 12px; }
.demand-row { display: grid; grid-template-columns: 84px 1fr 92px; gap: 8px; align-items: center; font-size: 12.5px; margin: 4px 0; }
.demand-row .d-track { position: relative; height: 12px; }
.demand-row .d-track::before { content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--line-strong); }
.demand-row .d-fill { position: absolute; top: 1px; bottom: 1px; }
.demand-row .d-fill.pos { left: 50%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.demand-row .d-fill.neg { right: 50%; background: var(--div-neg); border-radius: 4px 0 0 4px; }
.demand-row .d-txt { font-size: 11.5px; color: var(--ink-2); }
.advice { display: flex; flex-direction: column; gap: 6px; }
.adv {
  display: grid; grid-template-columns: 18px 1fr auto; gap: 8px; align-items: start;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-md); font-size: 12.5px; background: var(--surface);
}
.adv .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; }
.adv.bad .dot { background: var(--bad); }
.adv.serious .dot { background: var(--serious); }
.adv.warn .dot { background: var(--warn); }
.adv.good .dot { background: var(--good); }
.adv .sev { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; color: var(--muted); }
.adv .btn { padding: 3px 8px; font-size: 12px; }
.policies { display: flex; flex-direction: column; gap: 8px; }
.policy { display: grid; grid-template-columns: 18px 1fr; gap: 8px; align-items: start; font-size: 13px; cursor: pointer; }
.policy input { accent-color: var(--accent); width: 16px; height: 16px; margin-top: 1px; }
.policy.locked { cursor: default; opacity: 0.6; }
.slider-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; margin: 8px 0; font-size: 13px; }
.slider-row label { font-weight: 600; }
.slider-row output { font-family: var(--font-data); font-weight: 600; }
.slider-row input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); }
.slider-row .hint { grid-column: 1 / -1; font-size: 11.5px; color: var(--muted); }
.meter { margin: 8px 0; font-size: 12.5px; }
.meter .m-top { display: flex; justify-content: space-between; gap: 8px; }
.meter .m-track { height: 8px; border-radius: 4px; background: var(--surface-3); margin-top: 4px; position: relative; overflow: hidden; }
.meter .m-fill { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--good); }
.meter.warn .m-fill { background: var(--warn); }
.meter.bad .m-fill { background: var(--bad); }
.newslist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.newslist li { display: grid; grid-template-columns: 10px 1fr; gap: 8px; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line); cursor: default; }
.newslist li.has-loc { cursor: pointer; }
.newslist li .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; background: var(--muted); }
.newslist li.good .dot { background: var(--good); }
.newslist li.bad .dot { background: var(--bad); }
.newslist li time { display: block; font-size: 11px; color: var(--muted); }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th, .table td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: right; }
.table th:first-child, .table td:first-child { text-align: left; }
.table td { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.table td:first-child { font-family: var(--font-ui); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- bottom: views + legend ---------- */
.bottom {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: max(12px, env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 12;
  max-width: calc(100% - 24px);
}
.views {
  display: flex; gap: 2px; padding: 4px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--shadow); max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.views::-webkit-scrollbar { display: none; }
.view {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px 6px; border: 0; background: transparent;
  border-radius: var(--r-sm); font-weight: 650; font-size: 13px; color: var(--ink-2); white-space: nowrap;
}
.view:hover { background: var(--surface-2); color: var(--ink); }
.view[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.legend { padding: 10px 12px; min-width: 300px; max-width: 560px; font-size: 12px; }
.legend.wide { width: min(560px, calc(100vw - 24px)); }
.legend h4 { margin: 0; font-size: 12.5px; }
.legend .lg-sub { color: var(--muted); font-size: 11.5px; margin: 1px 0 8px; }
.legend .ramp { height: 10px; border-radius: 3px; }
.legend .ticks { display: flex; justify-content: space-between; font-family: var(--font-data); font-size: 11px; color: var(--ink-2); margin-top: 3px; }
.legend .swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 12px; }
.legend .sw { display: flex; align-items: center; gap: 7px; }
.legend .sw i { width: 14px; height: 10px; border-radius: 2px; flex: none; }
.legend .sw i.line { height: 4px; border-radius: 2px; }
.legend .sub-seg { margin-bottom: 8px; flex-wrap: wrap; }
.legend .sub-seg button { font-size: 12px; }
.legend .area-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.legend .area-chips button { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 12px; padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); cursor: pointer; }
.legend .area-chips button:hover { background: var(--surface-2); color: var(--ink); }
.legend .area-chips button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.legend .area-chips i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.legend .area-chips .n { font-family: var(--font-data); opacity: 0.7; }
.legend .area-chips button.none { opacity: 0.55; }
.legend .area-stat { font-size: 11.5px; color: var(--ink-2); margin-top: 2px; }

/* ---------- news ---------- */
.news {
  position: absolute; left: max(12px, env(safe-area-inset-left, 0px)); bottom: max(12px, env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column-reverse; gap: 6px; width: 300px; z-index: 11; pointer-events: none;
}
.toast {
  pointer-events: auto; display: grid; grid-template-columns: 10px 1fr; gap: 8px; align-items: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow);
  padding: 8px 10px; font-size: 12.5px; animation: toast-in 0.25s ease-out;
}
.toast .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 4px; background: var(--muted); }
.toast.good .dot { background: var(--good); }
.toast.bad .dot { background: var(--bad); }
.toast.fade { opacity: 0; transition: opacity 0.6s; }
.toast.has-loc { cursor: pointer; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- tooltip ---------- */
.tip {
  position: absolute; z-index: 30; pointer-events: none; max-width: 260px;
  background: var(--ink); color: var(--surface); border-radius: var(--r-sm); padding: 6px 9px; font-size: 12px; line-height: 1.35;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
.tip strong { font-weight: 700; }
.tip .t-val { font-family: var(--font-data); font-weight: 600; }
.tip .bad { color: #ff9b8f; }
.tip .good { color: #8fe39a; }
.tip .warn { color: #ffcf66; }
/* in dark themes the tooltip is light, so status colours go darker */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tip .bad { color: #b42f26; }
  :root:not([data-theme="light"]) .tip .good { color: #1d7a2c; }
  :root:not([data-theme="light"]) .tip .warn { color: #8f5c00; }
}
:root[data-theme="dark"] .tip .bad { color: #b42f26; }
:root[data-theme="dark"] .tip .good { color: #1d7a2c; }
:root[data-theme="dark"] .tip .warn { color: #8f5c00; }
.tip .muted { color: color-mix(in srgb, var(--surface) 65%, transparent); }

/* ---------- modal ---------- */
.modal {
  position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--bg) 55%, transparent); backdrop-filter: blur(3px);
}
.dialog {
  width: min(560px, 100%); max-height: calc(100% - 24px); overflow-y: auto; padding: 22px 22px 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
}
.dialog h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -0.01em; text-wrap: balance; }
.dialog .lede { color: var(--ink-2); margin: 0 0 16px; }
.dialog .field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.dialog .field > label, .dialog .field > span { font-size: 12px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.05em; }
.dialog input[type="text"], .dialog textarea, .dialog select {
  padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); width: 100%;
}
.dialog textarea { font-family: var(--font-data); font-size: 11px; min-height: 120px; resize: vertical; }
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choice {
  border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: 10px 12px; text-align: left; background: var(--surface);
  display: flex; flex-direction: column; gap: 2px;
}
.choice b { font-size: 13.5px; }
.choice span { font-size: 12px; color: var(--muted); }
.choice[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.dialog .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.menu-list { display: flex; flex-direction: column; gap: 4px; }
.menu-list .btn { justify-content: flex-start; padding: 9px 12px; font-size: 14px; }
.help-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.help-grid kbd { font-family: var(--font-data); font-size: 12px; padding: 1px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--surface-2); white-space: nowrap; }
.help-text p { margin: 0 0 10px; color: var(--ink-2); }
.help-text h3 { margin: 16px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .wordmark small { display: none; }
  .kpis { gap: 12px; }
}
@media (max-width: 980px) {
  .wordmark { display: none; }
  .tb-actions .btn .lbl { display: none; }
  .dash { width: min(372px, calc(100% - 24px)); }
}
@media (max-width: 720px) {
  :root { --top-h: 96px; }
  .topbar { flex-wrap: wrap; height: var(--top-h); align-content: space-evenly; column-gap: 10px; row-gap: 0; padding-top: 4px; padding-bottom: 4px; }
  .brand { order: 1; }
  .sign { width: 30px; height: 26px; font-size: 12px; }
  .clock { order: 2; gap: 6px; }
  .date { min-width: 0; font-size: 13px; }
  .seg button { padding: 4px 6px; }
  .tb-actions { order: 3; margin-left: auto; gap: 4px; }
  .tb-actions .btn { padding: 5px 7px; }
  .cityname { order: 4; max-width: 34vw; font-size: 14px; padding-left: 0; }
  .kpis { order: 5; margin-left: auto; gap: 12px; }
  .kpi .k-label { font-size: 9.5px; }
  .kpi .k-val { font-size: 13.5px; }
  .kpi .k-sub { display: none; }
  .kpi .k-sub#kNet { display: block; font-size: 10.5px; }
  .tb-sep { display: none; }
  .toolbar {
    top: auto; bottom: max(8px, env(safe-area-inset-bottom, 0px)); left: max(8px, env(safe-area-inset-left, 0px)); right: max(8px, env(safe-area-inset-right, 0px));
    width: auto; flex-direction: row; overflow-x: auto; padding: 4px; scrollbar-width: none;
  }
  .toolbar::-webkit-scrollbar { display: none; }
  .tool { min-width: 54px; }
  .tool-sep { width: 1px; height: auto; margin: 6px 2px; }
  .flyout, .inspector {
    top: auto; left: max(8px, env(safe-area-inset-left, 0px)); right: max(8px, env(safe-area-inset-right, 0px));
    bottom: calc(max(8px, env(safe-area-inset-bottom, 0px)) + 66px); width: auto; max-height: 46%;
  }
  .bottom { top: calc(var(--top-h) + 8px); bottom: auto; left: 8px; right: 8px; transform: none; align-items: stretch; max-width: none; }
  .views { align-self: center; }
  .legend { min-width: 0; max-width: none; }
  .dash { top: calc(var(--top-h) + 8px); left: 8px; right: 8px; bottom: calc(max(8px, env(safe-area-inset-bottom, 0px)) + 66px); width: auto; }
  .news { left: 8px; right: 8px; width: auto; bottom: calc(max(8px, env(safe-area-inset-bottom, 0px)) + 70px); }
  .choices { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
}

/* ---------- transit routes ---------- */
.route-list { display: flex; flex-direction: column; gap: 2px; margin: 8px 0 0; }
.route-row {
  display: grid; grid-template-columns: 14px minmax(0, 1fr) auto auto; align-items: center; gap: 8px;
  padding: 4px 6px; border: 0; background: transparent; border-radius: var(--r-sm); text-align: left; color: var(--ink); font-size: 12px; cursor: pointer;
}
.route-row:hover { background: var(--surface-2); }
.route-row .rr-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route-row .num { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.route-sw { width: 14px; height: 6px; border-radius: 3px; display: block; }
.legend .lg-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; color: var(--ink-2); font-size: 11.5px; flex-wrap: wrap; }
.warn-text { color: var(--serious) !important; }
.insp-head .ic.route-ic { color: #fff; }
.route-title { min-width: 0; flex: 1; }
.route-name {
  width: 100%; font: inherit; font-size: 16px; font-weight: 700; color: var(--ink); background: transparent;
  border: 1px solid transparent; border-radius: var(--r-sm); padding: 1px 4px; margin: -2px 0 0 -5px;
}
.route-name:hover { border-color: var(--line); }
.route-name:focus { border-color: var(--accent); outline: none; background: var(--surface-2); }
.route-ctl { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.route-ctl .seg button { padding: 4px 7px; font-size: 12px; }
.swatch-row { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.swatch { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line-strong); padding: 0; cursor: pointer; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
.stop-list { list-style: none; margin: 0; padding: 0; position: relative; }
.stop-list li { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto auto; align-items: center; gap: 8px; font-size: 12.5px; min-height: 26px; }
.stop-list .icon-btn { padding: 3px; }
.stop-dot { width: 11px; height: 11px; border-radius: 50%; border: 3px solid var(--ink); background: var(--surface); display: block; }
.stop-dot.ghost { border-style: dashed; border-width: 2px; border-color: var(--muted); }
.linklike { border: 0; background: none; padding: 0; color: var(--ink); font: inherit; text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linklike:hover { text-decoration: underline; }
