:root {
  --ink: #0e2005;
  --ink-2: #48543f;
  --ink-3: #6f7a68;
  --canvas: #e6e8e5;
  --glass: rgba(250, 251, 248, .74);
  --glass-solid: rgba(253, 254, 252, .93);
  --bubble: rgba(250, 251, 248, .62);
  --line: rgba(14, 32, 5, .11);
  --line-strong: rgba(14, 32, 5, .22);
  --edge: rgba(255, 255, 255, .7);
  --shadow: 0 14px 40px rgba(29, 49, 20, .13);
  --pill-on: #000;
  --pill-on-ink: #fff;
  --moss: #295300;
  --leaf: #1c8a2c;
  --reported: #2f4c50;
  --estimate: #e0692b;
  --cursor: #e7a90c;
  --chip: #050705;
  --chip-ink: #fff;
  --chip-2: #a9b1a4;
  --chip-num: #2ee66b;
  --warn-bg: rgba(231, 169, 12, .14);
  --warn-line: rgba(160, 112, 0, .4);
  --silent: #c2410c;
  --font: "Urbanist", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --ink: #edf2e8;
  --ink-2: #b6c0ae;
  --ink-3: #8e9987;
  --canvas: #0a110d;
  --glass: rgba(19, 29, 23, .72);
  --glass-solid: rgba(21, 32, 25, .95);
  --bubble: rgba(24, 36, 29, .62);
  --line: rgba(237, 242, 232, .12);
  --line-strong: rgba(237, 242, 232, .26);
  --edge: rgba(237, 242, 232, .13);
  --shadow: 0 16px 44px rgba(0, 0, 0, .45);
  --pill-on: #edf2e8;
  --pill-on-ink: #0a110d;
  --moss: #8fd66f;
  --leaf: #5fdc7a;
  --reported: #92bcd6;
  --estimate: #f58a4b;
  --cursor: #f6c544;
  --chip: #040705;
  --chip-ink: #edf2e8;
  --chip-2: #9aa693;
  --chip-num: #4bf07f;
  --warn-bg: rgba(246, 197, 68, .1);
  --warn-line: rgba(246, 197, 68, .35);
  --silent: #ff9a5c;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--canvas); color: var(--ink); font: 500 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, p { margin: 0; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--leaf); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }

#map { position: fixed; inset: 0; background: var(--canvas); }
.maplibregl-ctrl-attrib { font: 500 11px var(--font) !important; }
.maplibregl-ctrl-attrib.maplibregl-compact { background: var(--glass) !important; }
.maplibregl-canvas { outline: none; }
.maplibregl-ctrl-top-right { top: 70px; right: 74px; }
.maplibregl-ctrl-attrib.maplibregl-attrib-empty { display: none; }
.maplibregl-ctrl-attrib { background: none !important; color: var(--ink-3); }
.maplibregl-ctrl-attrib a { color: var(--ink-2) !important; }
.maplibregl-popup-content { background: var(--glass-solid); color: var(--ink); border-radius: 14px; padding: 10px 14px; box-shadow: var(--shadow); font: 500 13px/1.4 var(--font); }
.maplibregl-popup-content b { display: block; font-weight: 700; }
.maplibregl-popup-tip { display: none; }

/* Top bar */
.topbar { position: fixed; z-index: 5; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 24px; padding: 20px 28px; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.logo { font-size: 27px; font-weight: 600; letter-spacing: -.02em; text-decoration: none; }
.logo span { color: var(--moss); }
.pills { display: flex; padding: 3px; margin-left: 28px; background: var(--glass-solid); border-radius: 999px; box-shadow: var(--shadow); overflow-x: auto; scrollbar-width: none; }
.pills a { padding: 8px 17px; border-radius: 999px; color: var(--ink-2); text-decoration: none; white-space: nowrap; font-size: 14.500px; }
.pills a:hover { color: var(--ink); }
.pills a[aria-current="page"] { background: var(--pill-on); color: var(--pill-on-ink); }
.tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.search { display: flex; align-items: center; gap: 8px; width: 230px; height: 44px; padding: 0 16px; background: var(--glass-solid); border-radius: 999px; box-shadow: var(--shadow); }
.search svg { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.search input { width: 100%; border: 0; outline: 0; background: none; }
.search input::placeholder { color: var(--ink-3); }
.search:focus-within { outline: 2px solid var(--leaf); outline-offset: 2px; }
.round { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: var(--glass-solid); box-shadow: var(--shadow); cursor: pointer; }
.round svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.round .sun { display: none; }
[data-theme="dark"] .round .sun { display: block; }
[data-theme="dark"] .round .moon { display: none; }

/* Map buttons */
.map-tools { position: fixed; z-index: 4; right: 28px; top: 96px; display: flex; flex-direction: column; gap: 6px; }
.square { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 12px; background: var(--glass); backdrop-filter: blur(14px); box-shadow: var(--shadow); cursor: pointer; font-size: 19px; line-height: 1; }
.square svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* Map views: the map is the page and everything floats on it */
main { position: relative; z-index: 2; pointer-events: none; }
.map-view { display: grid; grid-template-rows: minmax(390px, 1fr) auto; min-height: 100dvh; padding: 86px 28px 24px; gap: 14px; }
.stage { position: relative; }
.lede { position: absolute; left: 0; top: 4px; max-width: 335px; pointer-events: auto; }
.lede h1 { font-size: 23px; line-height: 1.2; font-weight: 600; letter-spacing: -.012em; text-wrap: pretty; text-shadow: 0 0 14px var(--canvas), 0 0 3px var(--canvas); }
.lede p { margin-top: 8px; font-size: 13.500px; line-height: 1.4; color: var(--ink-2); text-shadow: 0 0 8px var(--canvas), 0 0 2px var(--canvas); }
.link { padding: 0; border: 0; background: none; font-weight: 600; color: var(--ink); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }

/* The frosted circles */
.bubbles { position: absolute; inset: 0; pointer-events: none; }
.bubble { position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 148px; height: 148px; padding: 10px; border: 1px solid var(--edge); border-radius: 50%; background: var(--bubble); backdrop-filter: blur(16px) saturate(1.25); box-shadow: 0 10px 30px rgba(29, 49, 20, .1); text-align: center; pointer-events: auto; }
.bubble svg { flex: none; width: 30px; height: 30px; padding: 7px; border-radius: 50%; fill: none; stroke: currentColor; stroke-width: 2.200; stroke-linecap: round; stroke-linejoin: round; background: var(--glass-solid); }
.bubble.good svg { color: var(--leaf); }
.bubble.warm svg { color: var(--estimate); }
.bubble.sky svg { color: var(--reported); }
.bubble b { margin-top: 5px; font-size: 25px; line-height: 1.1; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.bubble b small { margin-left: 2px; font-size: 13px; font-weight: 600; letter-spacing: 0; }
.bubble span { margin-top: 4px; max-width: 120px; font-size: 10.500px; line-height: 1.25; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.bubble:nth-child(1) { left: 25%; top: 4%; }
.bubble:nth-child(2) { left: 29%; bottom: 0; }
.bubble:nth-child(3) { right: 26%; top: 2%; }
.bubble:nth-child(4) { right: 22%; bottom: 2%; }

/* Legend */
.legend { position: absolute; left: 0; bottom: 0; width: 225px; pointer-events: auto; }
.legend-ends { display: flex; justify-content: space-between; font-size: 12.500px; font-weight: 600; }
.legend-ends .high { color: #d13b2e; }
[data-theme="dark"] .legend-ends .high { color: #ff8a78; }
.legend-bar { height: 11px; margin: 3px 0 6px; border-radius: 6px; background: linear-gradient(90deg, #59c26a, #b5d24b 22%, #f2c230 45%, #f08c3a 72%, #e2533f); }
.legend-bar.reporting { background: linear-gradient(90deg, #e2533f, #f2c230 45%, #59c26a); }
.legend p { font-size: 12.500px; line-height: 1.3; color: var(--ink-2); text-shadow: 0 0 6px var(--canvas), 0 0 2px var(--canvas); }

/* Glass cards */
.dock { display: grid; grid-template-columns: minmax(0, 1.72fr) minmax(0, 1.08fr) minmax(0, 1fr); gap: 10px; pointer-events: auto; }
.dock.two { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.card { min-width: 0; padding: 18px 22px; border: 1px solid var(--edge); border-radius: 24px; background: var(--glass); backdrop-filter: blur(22px) saturate(1.2); box-shadow: var(--shadow); }
.card header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; }
.card h2 { font-size: 17px; line-height: 1.25; font-weight: 600; letter-spacing: -.005em; }
.chart { height: 178px; }
.chart.small { height: 112px; }
.chart.tall { height: 290px; }
.chart.short { height: 150px; }
.chart-wrap { position: relative; }
.fine { font-size: 12.500px; line-height: 1.35; color: var(--ink-2); }
.card .key + .fine, .card .chip + .fine { margin-top: 6px; }

/* Scrubber */
.scrub { display: flex; align-items: center; gap: 10px; padding: 3px 12px 3px 3px; border-radius: 999px; background: var(--line); }
.play { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%; background: var(--glass-solid); cursor: pointer; }
.play svg { width: 15px; height: 15px; fill: currentColor; }
#hour { width: 165px; height: 18px; margin: 0; accent-color: var(--cursor); background: none; cursor: pointer; }
#hour-label { min-width: 88px; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }

/* Keys */
.key { display: flex; flex-wrap: wrap; gap: 3px 16px; margin: 0; padding: 0; list-style: none; font-size: 12.500px; color: var(--ink-2); }
.key li { display: flex; align-items: center; gap: 6px; }
.key.column { flex-direction: column; margin-top: 12px; }
.swatch { width: 18px; height: 3px; border-radius: 2px; }
.swatch.gradient { background: linear-gradient(90deg, #59c26a, #f2c230, #e2533f); }
.swatch.reported { background: var(--reported); }
.swatch.band { height: 10px; background: rgba(224, 105, 43, .25); }
.swatch.truth { background: var(--ink); }
.swatch.estimate { background: var(--estimate); }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot.reported { background: var(--reported); }
.dot.filled { background: var(--leaf); }
.dot.estimate { background: var(--estimate); }

/* Cursor note on the chart */
.tip { position: absolute; z-index: 2; width: 190px; padding: 7px 11px; border-radius: 11px; background: var(--glass-solid); box-shadow: var(--shadow); font-size: 12.500px; line-height: 1.35; pointer-events: none; }
.tip div { display: flex; justify-content: space-between; gap: 8px; }
.tip time { color: var(--ink-3); font-weight: 500; }
.tip b { font-weight: 700; font-variant-numeric: tabular-nums; }
.tip i { flex: none; align-self: center; width: 9px; height: 9px; margin-right: 6px; border-radius: 3px; }
.tip .cat { display: flex; align-items: center; margin-right: auto; }

/* Dial */
.dial-body { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; }
.big { flex: none; }
.big b { display: block; font-size: 56px; line-height: 1; font-weight: 600; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.big span { font-size: 14px; color: var(--ink-2); }
.dial { flex: 0 1 188px; min-width: 0; height: 188px; }
.dial .ring { fill: none; stroke: var(--line-strong); }
.dial .wash { fill: var(--line); }
.dial text { fill: var(--ink); font-family: var(--font); text-anchor: middle; }
.dial .on { fill: var(--leaf); stroke: var(--glass-solid); stroke-width: 1; }
.dial .off { fill: none; stroke: var(--silent); stroke-width: 1.800; }
.dial .mark { fill: var(--moss); }
[data-theme="dark"] .dial .mark { fill: #1d4426; }
.dial .mark-text { fill: #fff; font-size: 9px; font-weight: 700; }
.note { display: flex; align-items: center; gap: 10px; margin-top: 4px; padding: 7px 14px; border-radius: 999px; background: linear-gradient(90deg, var(--glass-solid), rgba(89, 194, 106, .2)); font-size: 12.500px; line-height: 1.25; }
.note svg { flex: none; width: 20px; height: 20px; fill: none; stroke: var(--leaf); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.note b { display: block; font-weight: 700; font-size: 13.500px; }

/* Chip */
.chip { display: flex; align-items: center; gap: 14px; padding: 11px 18px; border-radius: 18px; background: var(--chip); color: var(--chip-ink); }
[data-theme="dark"] .chip { box-shadow: inset 0 0 0 1px rgba(237, 242, 232, .12); }
.chip .gauge { flex: none; width: 36px; height: 44px; }
.chip p { font-size: 14px; line-height: 1.25; }
.chip b { color: var(--chip-num); font-size: 25px; line-height: 1.15; font-weight: 600; letter-spacing: -.01em; }
.chip small { margin-left: 5px; color: var(--chip-2); font-size: 14px; }
.big-chip { margin: 14px 0; padding: 18px 20px; }
.big-chip b { font-size: 46px; }
.chip.gaps { margin-top: 4px; }

/* Sheets: reading views over the blurred map */
.sheet { position: relative; min-height: 100dvh; padding: 96px 28px 30px; background: linear-gradient(180deg, color-mix(in srgb, var(--canvas) 62%, transparent), color-mix(in srgb, var(--canvas) 86%, transparent)); backdrop-filter: blur(16px); pointer-events: auto; }
.sheet-head, .grid, .controls, .tiles, .credits { width: 100%; max-width: 1240px; margin-inline: auto; }
.sheet-head { margin-bottom: 22px; }
.sheet-head h1 { max-width: 21em; font-size: clamp(30px, 3.800vw, 46px); line-height: 1.08; font-weight: 600; letter-spacing: -.024em; text-wrap: balance; }
.sheet-head p { margin-top: 12px; max-width: 66ch; font-size: 16.500px; color: var(--ink-2); }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }
.card > p, .card .fine { margin-top: 8px; }
.stat-card { display: flex; flex-direction: column; }
.correction { background: var(--warn-bg); border-color: var(--warn-line); }
.correction p { max-width: 80ch; }
.credits { margin-top: 18px; font-size: 13px; color: var(--ink-2); }

/* Stacked bars */
.stack { display: grid; grid-template-columns: 124px minmax(0, 1fr); gap: 8px 12px; margin-top: 14px; align-items: center; font-size: 13.500px; }
.bar { display: flex; gap: 2px; height: 28px; }
.bar i { display: grid; place-items: center; min-width: 0; font-style: normal; font-size: 12.500px; font-weight: 700; color: #16200f; }
.bar i:first-child { border-radius: 7px 0 0 7px; }
.bar i:last-child { border-radius: 0 7px 7px 0; }
.stack-key { grid-column: 1 / -1; margin-top: 4px; }

/* Tables */
.table-wrap { margin-top: 10px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th { padding: 7px 12px 7px 0; border-bottom: 1px solid var(--line-strong); color: var(--ink-2); font-weight: 600; text-align: right; white-space: nowrap; }
td { padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; white-space: normal; min-width: 210px; }
tr:last-child td { border-bottom: 0; }
tr.ours td { font-weight: 700; }
.state { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.state svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.600; stroke-linecap: round; stroke-linejoin: round; }
.state.met { color: var(--leaf); }
.state.missed { color: var(--silent); }

/* Controls */
.controls { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field select, .field input { height: 44px; min-width: 190px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--glass-solid); color: var(--ink); font-weight: 500; font-size: 15px; }
.field.compact select { height: 34px; min-width: 200px; max-width: 100%; font-size: 13.500px; border-radius: 999px; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.tile { padding: 14px 22px; border: 1px solid var(--edge); border-radius: 22px; background: var(--glass); backdrop-filter: blur(22px); }
.tile b { display: block; font-size: 33px; line-height: 1.15; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile span { color: var(--ink-2); font-size: 13.500px; }

/* Dialog */
.sheet-dialog { width: min(600px, calc(100vw - 32px)); max-height: 86dvh; padding: 26px 30px; border: 1px solid var(--edge); border-radius: 26px; background: var(--glass-solid); color: var(--ink); box-shadow: var(--shadow); }
.sheet-dialog::backdrop { background: rgba(5, 12, 8, .4); backdrop-filter: blur(3px); }
.sheet-dialog h2 { margin: 16px 0 6px; font-size: 18px; font-weight: 600; }
.sheet-dialog h2:first-of-type { margin-top: 0; margin-right: 50px; }
.sheet-dialog p + p { margin-top: 8px; }
.close { position: absolute; top: 16px; right: 16px; width: 36px; height: 36px; font-size: 22px; box-shadow: none; background: var(--line); }

.notice { position: fixed; z-index: 9; left: 50%; bottom: 20px; transform: translateX(-50%); padding: 10px 18px; border-radius: 999px; background: var(--glass-solid); box-shadow: var(--shadow); }

/* Smaller laptops: tighter dock, smaller circles */
@media (max-width: 1320px) {
  .search { width: 170px; }
  .bubble { width: 128px; height: 128px; }
  .bubble b { font-size: 21px; }
  .bubble span { font-size: 9.500px; max-width: 106px; }
  .bubble svg { width: 26px; height: 26px; padding: 6px; }
  .pills a { padding: 8px 12px; font-size: 14px; }
  .logo { font-size: 24px; }
  .pills { margin-left: 4px; }
  .lede { max-width: 270px; }
  .lede h1 { font-size: 20px; }
  #hour { width: 110px; }
}

/* Tablets and phones: one column, map on top */
@media (max-width: 980px) {
  .topbar { position: relative; flex-wrap: wrap; gap: 10px; padding: 14px 16px; }
  .pills { order: 3; width: 100%; margin: 0; box-shadow: none; }
  .search { width: auto; flex: 1 1 130px; }
  .tools { flex: 1; justify-content: flex-end; }
  #map { position: absolute; height: 480px; bottom: auto; }
  .map-tools { position: absolute; top: 132px; right: 16px; }
  .map-view { display: block; min-height: 0; padding: 0 16px 20px; }
  .stage { min-height: 0; display: flex; flex-direction: column; gap: 12px; }
  .lede { position: static; max-width: none; padding: 14px 16px; border: 1px solid var(--edge); border-radius: 20px; background: var(--glass); backdrop-filter: blur(22px) saturate(1.2); box-shadow: var(--shadow); }
  .lede h1 { font-size: 19px; text-shadow: none; }
  .lede p { text-shadow: none; }
  .legend { position: static; order: 2; width: min(100%, 300px); margin-top: 270px; }
  .legend p { text-shadow: none; }
  .maplibregl-ctrl-top-right { top: auto; right: 0; bottom: 0; }
  .bubbles { order: 3; position: static; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; justify-items: center; }
  .bubble, .bubble:nth-child(n) { position: static; }
  .dock, .dock.two { grid-template-columns: minmax(0, 1fr); margin-top: 12px; }
  .scrub { width: 100%; }
  #hour { flex: 1; width: auto; min-width: 0; }
  .sheet { padding: 20px 16px 26px; }
  .grid, .tiles { grid-template-columns: minmax(0, 1fr); }
  .span-2, .span-3 { grid-column: auto; }
  .field { flex: 1 1 140px; }
  .field select, .field input { width: 100%; min-width: 0; }
  .field.compact { flex: 1 1 100%; }
}

/* Laptops: keep the whole dock on screen */
@media (min-width: 981px) and (max-height: 800px) {
  .map-view { grid-template-rows: minmax(300px, 1fr) auto; padding-top: 76px; padding-bottom: 14px; }
  .card { padding: 12px 18px; }
  .chart { height: 128px; }
  .chart.small { height: 74px; }
  .dial { flex-basis: 130px; height: 130px; }
  .big b { font-size: 44px; }
  .chip { padding: 7px 14px; }
  .chip .gauge { height: 34px; }
  .chip b { font-size: 21px; }
  .bubble { width: 112px; height: 112px; padding: 6px; }
  .bubble svg { display: none; }
  .bubble b { margin-top: 0; font-size: 20px; }
  .bubble span { max-width: 96px; }
}

/* Phones: each table row becomes a small labelled list, so no column is ever cut off */
@media (max-width: 640px) {
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  tbody tr { display: block; padding: 9px 0; border-bottom: 1px solid var(--line); }
  tbody tr:last-child { border-bottom: 0; }
  td, td:first-child { display: flex; justify-content: space-between; gap: 12px; min-width: 0; padding: 2px 0; border: 0; white-space: normal; }
  td:first-child { font-weight: 600; }
  td::before { content: attr(data-label); color: var(--ink-2); font-weight: 500; text-align: left; }
  td:first-child::before { content: none; }
  .tip { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
