/* Monochrome operations board: black masthead with pill navigation, soft grey ground,
   white rounded cards in four columns. Charts are charcoal and light grey; teal marks the
   selected period, red/green dots show change against the year before. */
:root {
  --bg: #e8ebef;
  --panel: #ffffff;
  --panel-2: #f6f6f7;
  --fg: #161616;
  --muted: #5b5f66;
  --faint: #8d9198;
  --line: #e4e5e8;
  --grid: #efeff1;

  --ink: #3c3d40;     /* main bars */
  --past: #d3d4d7;    /* other periods */
  --hi: #1aa39d;
  --navy: #13233b;      /* masthead + selected controls */
  --navy-2: #1d3352;    /* hover / secondary on navy */
  --navy-ink: #0d1a2d;  /* darkest navy: table head, tooltips */
  --on-navy: #dbe3ee;   /* main text on navy */
  --on-navy-2: #a9b6c8; /* secondary text on navy */      /* selected period */
  --red: #e23b48;
  --green: #3c9a4e;
  --coral: #e8735a;

  --t-fire: #e23b48;
  --t-blast: #f09440;
  --t-chem: #1aa39d;
  --t-acc: #3f6fb5;
  --t-other: #9b9ea4;
  --bar: #8fd3ce;      /* chart bars: light teal */
  --bar-hi: #0a8f88;   /* chart emphasis: selected / highest */
  --track: #eef0f2;    /* empty part of rings and bars */
  --t-day: #86cf7e;    /* time of day */
  --t-eve: #f2c94c;
  --t-night: #4b5563;
  --t-inj: #f09440;

  /* masthead */
  --top-bg: linear-gradient(160deg, #f4f8fc 0%, #e4ecf6 100%);
  --top-glow:
    radial-gradient(42% 120% at 92% -10%, rgba(26, 163, 157, .38) 0%, transparent 70%),
    radial-gradient(35% 90% at 0% 110%, rgba(26, 163, 157, .12) 0%, transparent 70%),
    radial-gradient(38% 110% at 68% 120%, rgba(56, 120, 220, .22) 0%, transparent 70%),
    radial-gradient(30% 80% at 100% 100%, rgba(120, 100, 230, .14) 0%, transparent 70%);
  --top-dots: rgba(19, 35, 59, .13);
  --top-glass: rgba(255, 255, 255, .72);
  --hi-ring: rgba(26, 163, 157, .22);
  --amber: #e8962a;
  --top-fg: #2a3a52;
  --top-fg-2: #5b6b82;
  --top-strong: #13233b;
  --top-mark: #1aa39d;
  --top-underline: #a9b6c8;
  --top-btn: #ffffff;
  --top-btn-edge: #cfd9e6;
  --top-btn-hover: #f1f4f8;
  --top-shadow: 0 1px 0 #d3dde9, 0 10px 28px -18px rgba(19, 35, 59, .35);

  /* surfaces + text that change with the theme */
  --text-2: #3a3d42;     /* sub-headings, labels */
  --cause: #33363b;
  --chip: #ffffff;       /* header pickers */
  --chip-hover: #eef2f7;
  --chip-fg: #111111;
  --chip-k: #55595f;
  --step: #333333;
  --step-off: #b3b3b3;
  --nav-bg: #ffffff;
  --nav-edge: #cfd9e6;
  --nav-hover: #eef2f7;
  --sel: var(--navy);    /* selected controls */
  --sel-on: #ffffff;     /* chosen dropdown */
  --soft: #ececee;       /* small toggles */
  --soft-fg: #333333;
  --input: #efeff1;
  --input-focus: #ffffff;
  --row-alt: #fafafb;
  --row-hover: #eef7f6;
  --row-focus: #dff3f1;
  --warn-text: #c27a0e;
  --err-bg: #fdecee;
  --ghost: #ffffff;
  --ghost-fg: #13233b;
  --ghost-hover: #eef2f7;
  --card-edge: transparent;
  --card-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 10px 30px -18px rgba(0, 0, 0, .25);
  --tip-edge: transparent;
  --parcel-edge: #4a4d52;
  --sep: #555555;

  --font: "Sarabun", "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
  --font-head: "Sarabun", "Noto Sans Thai Looped", "Leelawadee UI", Tahoma, sans-serif;
  --font-num: "Sarabun", "Noto Sans Thai Looped", "Leelawadee UI", Tahoma, sans-serif;
  --radius: 22px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 17px/1.6 var(--font); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button { font: inherit; }
.wrap { max-width: 1560px; margin-inline: auto; padding-inline: max(16px, 2.2vw); }

/* ---------- masthead ---------- */
.top { position: relative; isolation: isolate; background: var(--top-bg); color: var(--top-strong); border-radius: 0 0 26px 26px; box-shadow: var(--top-shadow); }
/* modern masthead backdrop: soft colour glows + a dot grid that fades out behind the title */
.top::before, .top::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: -1; }
.top::before { background: var(--top-glow); }
.top::after { background-image: radial-gradient(var(--top-dots) 1.1px, transparent 1.6px); background-size: 20px 20px;
  -webkit-mask-image: linear-gradient(105deg, transparent 30%, #000 75%); mask-image: linear-gradient(105deg, transparent 30%, #000 75%); }
.top-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px 24px; align-items: center; padding-block: 20px 8px; }
.brand { display: flex; gap: 12px; align-items: center; min-width: 0; }
.brand-mark { color: var(--top-mark); flex: none; }
.brand-name { font-family: var(--font-head); font-size: 17.5px; font-weight: 700; line-height: 1.35; }
.brand-sub { font-size: 11.5px; letter-spacing: .07em; color: var(--top-fg-2); }
.nav { display: flex; gap: 4px; background: var(--nav-bg); border-radius: 999px; padding: 4px; border: 2px solid var(--nav-edge); justify-self: center; }
.nav-a { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--chip-fg); font-family: var(--font-head); font-weight: 600;
  font-size: 16px; padding: 7px 22px; border-radius: 999px; white-space: nowrap; transition: background .15s, color .15s; }
.nav-a:hover { background: var(--nav-hover); }
.nav-a.on { background: var(--sel); color: #fff; }
.nav-a:focus-visible { outline: 2px solid var(--hi); outline-offset: 2px; }
.status { justify-self: end; text-align: right; display: grid; gap: 4px; justify-items: end; }
.status-line { display: flex; align-items: center; gap: 8px; font-size: 14.5px; color: var(--top-fg); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #6b7c93; flex: none; }
.dot.live { background: #34d17a; box-shadow: 0 0 0 3px rgba(52, 209, 122, .25); }
.dot.backup { background: #f5b041; }
.dot.err { background: var(--red); }
.refresh { display: inline-flex; align-items: center; gap: 6px; background: var(--top-btn); color: var(--top-strong); border: 1px solid var(--top-btn-edge);
  border-radius: 999px; padding: 2px 12px 2px 9px; font-size: 14px; cursor: pointer; }
.refresh[hidden] { display: none; }
.refresh:hover { background: var(--top-btn-hover); }
.refresh svg { width: 16px; height: 16px; flex: none; }
.refresh.spin { opacity: .6; cursor: progress; }
.refresh.spin svg { animation: refresh-spin .9s linear infinite; }
@keyframes refresh-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .refresh.spin svg { animation: none; } }
.refresh.logout:hover { color: var(--red); }
.status-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; justify-content: flex-end; }

.title-row { display: flex; flex-wrap: wrap; gap: 20px 32px; align-items: flex-end; justify-content: space-between; padding-block: 34px 30px; }
.title-l { min-width: 0; max-width: 760px; display: grid; gap: 4px; justify-items: start; }
.top h1 { font-family: var(--font-head); font-weight: 700; font-size: clamp(1.6rem, 1.15rem + 1.5vw, 2.4rem); line-height: 1.25; margin: 4px 0 0; color: var(--top-strong); letter-spacing: -.01em; }
.top h1 b { color: var(--top-strong); font-weight: 800; }
.period { display: inline-flex; align-items: center; gap: 8px; font-size: 14.5px; font-weight: 600; color: var(--top-fg); background: var(--top-glass);
  border: 1px solid var(--top-btn-edge); border-radius: 999px; padding: 4px 14px 4px 11px; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.period::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--hi); box-shadow: 0 0 0 3px var(--hi-ring); flex: none; }
.take { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 0; }
.take:empty { display: none; }
.take-note { margin: 0; font-size: 16px; color: var(--top-fg-2); }
.stat { --c: var(--hi); min-width: 128px; padding: 9px 18px 10px 14px; border-radius: 14px; background: var(--top-glass); border: 1px solid var(--top-btn-edge);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); box-shadow: inset 3px 0 0 var(--c); }
.stat.s-inj { --c: var(--amber); }
.stat.s-dead { --c: var(--red); }
.stat-k { font-size: 13.5px; color: var(--top-fg-2); line-height: 1.3; }
.stat-v { font-size: 14.5px; color: var(--top-fg); line-height: 1.2; }
.stat-v b { font-family: var(--font-head); font-size: 28px; font-weight: 800; color: var(--top-strong); margin-right: 5px; letter-spacing: -.01em; }
.ghost { margin-top: 8px; background: var(--ghost); color: var(--ghost-fg); border: 0; border-radius: 999px; padding: 3px 18px; font-size: 15px; cursor: pointer; }
.ghost:hover { background: var(--ghost-hover); }

.title-r { display: grid; gap: 10px; justify-items: end; max-width: 100%; }
.pickers { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; max-width: 100%; }
.pick { background: var(--chip); color: var(--chip-fg); box-shadow: 0 0 0 1px var(--nav-edge); border-radius: 12px; display: flex; align-items: center; min-height: 58px; }
.pick-k { display: block; font-size: 12.5px; color: var(--chip-k); line-height: 1.2; }
.pick-v { display: block; font-family: var(--font-head); font-size: 17px; font-weight: 700; line-height: 1.3; }
.stepper { padding: 0 4px; }
.pick-in { text-align: center; min-width: 7.5rem; padding: 4px 6px; }
.step { background: none; border: 0; font-size: 26px; line-height: 1; width: 32px; height: 46px; cursor: pointer; color: var(--step); border-radius: 8px; }
.step:hover:not(:disabled) { background: var(--chip-hover); }
.step:disabled { color: var(--step-off); cursor: default; }
.quarters { padding: 5px; gap: 2px; }
.qbtn { background: none; border: 0; border-radius: 9px; cursor: pointer; padding: 3px 12px; text-align: center; color: var(--chip-fg); }
.qbtn .pick-k { font-size: 12px; }
.qbtn .pick-v { font-size: 16px; }
.qbtn:hover { background: var(--chip-hover); }
.qbtn[aria-pressed="true"] { background: var(--sel); color: #fff; }
.qbtn[aria-pressed="true"] .pick-k { color: var(--on-navy-2); }
.sel { flex-direction: column; align-items: stretch; justify-content: center; padding: 5px 14px; width: min(100%, 17rem); }
.sel select { font: inherit; font-family: var(--font-head); font-size: 16px; font-weight: 700; border: 0; background: transparent; color: var(--chip-fg); padding: 0; cursor: pointer; width: 100%; text-overflow: ellipsis; }
.sel.on { background: var(--sel-on); box-shadow: inset 0 0 0 2px var(--hi); }
.step:focus-visible, .qbtn:focus-visible, .sel select:focus-visible, .ghost:focus-visible, .refresh:focus-visible { outline: 2px solid var(--hi); outline-offset: 2px; }

/* ---------- body ---------- */
.main { display: grid; gap: 26px; padding-block: 30px 44px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr)); gap: 24px; align-items: stretch; scroll-margin-top: 20px; }
.card { background: var(--panel); border-radius: var(--radius); padding: 26px 28px; box-shadow: var(--card-shadow); border: 1px solid var(--card-edge);
  display: grid; gap: 10px; align-content: start; min-width: 0; scroll-margin-top: 20px; }
.card h2 { font-family: var(--font-head); font-size: 1.25rem; font-weight: 700; margin: 0 0 4px; }
.card h3 { font-size: 1.05rem; font-weight: 500; color: var(--text-2); margin: 4px 0 2px; }
.hint { font-size: 13.5px; color: var(--faint); font-weight: 400; margin-left: 6px; }
.card hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0 6px; width: 100%; }
.card-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }
.note { margin: 0; font-size: 15px; color: var(--muted); }
.empty { color: var(--muted); font-size: 15px; padding: 18px 0; text-align: center; }

/* metric block */
.metric { display: grid; gap: 2px; }
.m-head { display: flex; align-items: center; gap: 12px; }
.m-title { font-size: 1.05rem; font-weight: 500; color: var(--text-2); }
.arrow { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex: none; }
.arrow.up { background: var(--red); }
.arrow.down { background: var(--green); }
.arrow.flat { background: var(--past); }
.arrow svg { width: 15px; height: 15px; }
.m-val { margin-top: 6px; font-size: 16px; color: var(--muted); }
.m-val b { font-family: var(--font-num); font-size: 2rem; font-weight: 700; color: var(--fg); margin-right: 4px; }
.m-pm { font-size: 14px; color: var(--faint); }
.m-pm .up { color: var(--red); font-weight: 600; }
.m-pm .down { color: var(--green); font-weight: 600; }
.chart, .m-chart { position: relative; }
.m-chart, .chart { margin-top: 8px; }
svg text { font-family: var(--font); }

/* horizontal bars: label at left, thin rounded bar, value right after it */
.hbars { display: grid; gap: 4px; }
.hb { display: grid; grid-template-columns: minmax(5.5rem, 36%) 1fr; gap: 10px; align-items: center; font-size: 15px; color: var(--text-2); }
.hb .l { text-align: right; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.hb .t { display: flex; align-items: center; gap: 8px; min-height: 30px; min-width: 0; }
.hb .f { height: 14px; flex: none; background: var(--bar); border-radius: 0 4px 4px 0; transition: width .45s cubic-bezier(.2, .7, .2, 1); }
.hb .v { white-space: nowrap; color: var(--fg); font-size: 14.5px; font-weight: 600; }
.hb .v small { font-weight: 400; color: var(--muted); margin-left: 5px; font-size: 13px; }
.hb.click { cursor: pointer; background: none; border: 0; padding: 2px 4px; margin-inline: -4px; border-radius: 8px; font: inherit; color: inherit; text-align: left; width: calc(100% + 8px); }
.hb.click:hover { background: var(--panel-2); }
.hb.click:focus-visible { outline: 2px solid var(--hi); }
.hb.sel .f { background: var(--bar-hi); }
.hb.sel .l { color: var(--fg); font-weight: 600; }
.hb.dim { opacity: .45; }
.scroll { max-height: 470px; overflow: auto; padding-right: 6px; }

/* rings */
.rings { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 14px 8px; justify-items: center; }
.ring { display: grid; justify-items: center; gap: 4px; text-align: center; }
.ring-t { font-size: 15px; color: var(--text-2); line-height: 1.3; min-height: 2.6em; display: flex; align-items: flex-end; }
.ring svg { width: 92px; height: 92px; }
.ring-s { font-size: 13px; color: var(--faint); }

/* donut */
.donut { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px 18px; }
.donut-svg { width: 150px; height: 150px; flex: none; }
.donut-leg { display: grid; gap: 8px; }
.dl { display: flex; gap: 8px; align-items: flex-start; }
.dl .sw { border-radius: 3px; margin-top: 6px; }
.dl-l { font-size: 15px; font-weight: 600; line-height: 1.35; }
.dl-v { font-size: 13.5px; color: var(--faint); }

/* map */
.wide { padding: 26px 28px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 15px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 11px; height: 11px; border-radius: 50%; display: inline-block; flex: none; }
#map { height: 520px; border-radius: 14px; z-index: 0; margin-top: 6px; }
#map-section .leaflet-popup-content-wrapper { border-radius: 12px; }
#map-section .leaflet-popup-content { font-family: var(--font); font-size: 15px; line-height: 1.6; margin: 12px 14px; }
.pop-h { font-family: var(--font-head); font-weight: 700; font-size: 16px; margin-bottom: 2px; }
.pop-m { color: var(--muted); }
.seg { display: inline-flex; background: var(--soft); border-radius: 999px; padding: 3px; }
.seg-btn { border: 0; background: none; border-radius: 999px; padding: 3px 16px; font-size: 14.5px; color: var(--soft-fg); cursor: pointer; }
.seg-btn[aria-pressed="true"] { background: var(--sel); color: #fff; }
.seg-btn:focus-visible { outline: 2px solid var(--hi); outline-offset: 2px; }
.map-ctrls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.chk { display: inline-flex; align-items: center; gap: 7px; font-size: 14.5px; color: var(--soft-fg); cursor: pointer; background: var(--soft); border-radius: 999px; padding: 4px 14px 4px 10px; }
.chk input { width: 16px; height: 16px; margin: 0; accent-color: var(--sel); }
.chk:focus-within { outline: 2px solid var(--hi); outline-offset: 2px; }
.parcel-note { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-size: 14px; }
.parcel-note:empty { display: none; }
.parcel-note .pk { display: inline-flex; align-items: center; gap: 6px; }
.parcel-note .ps { width: 14px; height: 10px; border-radius: 2px; border: 1.5px solid var(--parcel-edge); flex: none; }

/* table */
.search-wrap { display: flex; align-items: center; gap: 8px; width: min(100%, 320px); padding: 7px 14px; border-radius: 999px; background: var(--input); color: var(--faint); }
.search-wrap:focus-within { background: var(--input-focus); box-shadow: inset 0 0 0 2px var(--hi); color: var(--hi); }
.search { font: inherit; font-size: 16px; border: 0; outline: 0; background: transparent; color: var(--fg); width: 100%; min-width: 0; padding: 0; }
.tablewrap { max-height: 580px; overflow: auto; border-radius: 12px; border: 1px solid var(--line); margin-top: 4px; }
.table { width: 100%; border-collapse: collapse; font-size: 16px; line-height: 1.6; }
.table th { position: sticky; top: 0; background: var(--sel); color: #fff; text-align: left; font-weight: 600; padding: 11px 12px; white-space: nowrap; z-index: 1; }
.table th button { color: inherit; background: none; border: 0; padding: 0; cursor: pointer; font-weight: 600; }
.table th[aria-sort="ascending"] button::after { content: " ▲"; font-size: 11px; color: var(--hi); }
.table th[aria-sort="descending"] button::after { content: " ▼"; font-size: 11px; color: var(--hi); }
.table th button:focus-visible { outline: 2px solid var(--hi); outline-offset: 2px; }
.table td { padding: 12px; border-bottom: 1px solid var(--grid); vertical-align: top; }
.table tbody tr:nth-child(even) td { background: var(--row-alt); }
.table tbody tr:hover td { background: var(--row-hover); }
.table .n { text-align: right; }
.table tr.row { cursor: pointer; }
.table tr.row:focus-visible { outline: 2px solid var(--hi); outline-offset: -2px; }
.table tr.focus td, .table tr.focus:hover td { background: var(--row-focus); }
.table tr.focus td:first-child { box-shadow: inset 4px 0 0 var(--hi); }
.table td.case { white-space: nowrap; }
.table .pin { color: var(--hi); vertical-align: -2px; margin-right: 4px; }
.table tr.nopt { cursor: default; }
.map-wrap { position: relative; }
.map-focus { position: absolute; z-index: 500; left: 12px; right: 12px; bottom: 12px; display: flex; align-items: center; gap: 12px; justify-content: space-between;
  background: var(--navy-ink); color: #fff; border-radius: 12px; padding: 8px 8px 8px 14px; font-size: 15px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }
.map-focus > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mf-btns { display: flex; gap: 6px; flex: none; }
.map-focus #map-focus-back { background: var(--navy-2); color: #fff; }
.map-focus button { flex: none; border: 0; border-radius: 999px; background: #fff; color: #111; padding: 4px 14px; font-size: 14.5px; font-weight: 600; cursor: pointer; }
.map-focus button:focus-visible { outline: 2px solid var(--hi); outline-offset: 2px; }
.focus-ring { animation: ring 1.6s ease-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes ring { 0% { stroke-opacity: 1; transform: scale(.6); } 100% { stroke-opacity: 0; transform: scale(1.6); } }
@media (prefers-reduced-motion: reduce) { .focus-ring { animation: none; } }
.toast { position: fixed; z-index: 3000; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--navy-ink); color: #fff; border-radius: 12px;
  padding: 10px 16px; font-size: 15px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); max-width: calc(100% - 32px); }
.table td.cause { min-width: 18rem; max-width: 34rem; color: var(--cause); }
.table td.dead-pos { color: var(--red); font-weight: 700; }
.table td.inj-pos { color: var(--warn-text); font-weight: 700; }
.pill { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.pill .sw { background: var(--pc); }

/* tooltip */
.tip { position: fixed; pointer-events: none; background: var(--navy-ink); color: #fff; border: 1px solid var(--tip-edge); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  padding: 8px 12px; font-size: 14.5px; z-index: 2000; white-space: nowrap; }
.tip .h { color: var(--on-navy-2); margin-bottom: 2px; }
.tip .r { display: flex; align-items: center; gap: 7px; }
.tip .r b { margin-left: auto; padding-left: 14px; font-weight: 700; }

.foot { display: flex; flex-wrap: wrap; gap: 4px 20px; justify-content: space-between; font-size: 14.5px; color: var(--muted); padding-top: 4px; }
.foot a { color: var(--fg); }

@media (max-width: 1100px) {
  .top-row { grid-template-columns: 1fr auto; }
  .nav { grid-column: 1 / -1; grid-row: 2; justify-self: start; }
  .title-r { justify-items: start; }
  .pickers { justify-content: flex-start; }
}
@media (max-width: 680px) {
  body { font-size: 16px; }
  .top-row { grid-template-columns: 1fr; }
  .status { justify-self: start; justify-items: start; text-align: left; }
  .nav { width: 100%; justify-content: space-between; }
  .nav-a { padding: 6px 12px; font-size: 15px; }
  .card { padding: 20px 18px; }
  .hide-sm { display: none; }
  .table { font-size: 15px; }
  .pickers { width: 100%; }
  .quarters { display: grid; grid-template-columns: repeat(5, 1fr); width: 100%; }
  .qbtn { padding: 3px 2px; }
  .qbtn .pick-k { font-size: 10.5px; }
  .stepper, .sel { width: 100%; }
  .pick-in { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { .hb .f { transition: none; } }


/* ---------- theme toggle ---------- */
.theme-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--top-btn); color: var(--top-strong); border: 1px solid var(--top-btn-edge);
  border-radius: 999px; padding: 2px 12px 2px 9px; font-size: 14px; cursor: pointer; }
.theme-btn:hover { background: var(--top-btn-hover); }
.theme-btn:focus-visible { outline: 2px solid var(--hi); outline-offset: 2px; }
.theme-btn svg { width: 16px; height: 16px; }
.theme-btn .i-sun { display: none; }
:root[data-theme="dark"] .theme-btn .i-sun { display: block; }
:root[data-theme="dark"] .theme-btn .i-moon { display: none; }

/* ---------- dark theme ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b111a;
  --panel: #141c28;
  --panel-2: #1b2534;
  --fg: #e8edf4;
  --muted: #a7b2c2;
  --faint: #8592a4;
  --line: #253144;
  --grid: #1d2838;

  --ink: #c9d3e0;
  --past: #34425a;
  --hi: #2bbfb7;
  --navy: #101c30;
  --navy-2: #22395c;
  --navy-ink: #0a1220;
  --on-navy: #dbe3ee;
  --on-navy-2: #a3b1c4;
  --red: #ff6470;
  --green: #4cc26a;
  --coral: #f08a72;

  --t-fire: #ff6470;
  --t-blast: #f7a24f;
  --t-chem: #2bbfb7;
  --t-acc: #6b9ae0;
  --t-other: #8a97a9;
  --bar: #3f9e98;
  --bar-hi: #5fe0d6;
  --track: #223044;
  --t-day: #9ad891;
  --t-eve: #f5d35a;
  --t-night: #8b95a5;
  --t-inj: #f7a24f;

  --text-2: #c4cdd9;
  --cause: #c9d2de;
  --chip: #1b2738;
  --chip-hover: #26354b;
  --chip-fg: #e8edf4;
  --chip-k: #97a5b8;
  --step: #d0d8e3;
  --step-off: #4f5d72;
  --nav-bg: #1b2738;
  --nav-edge: #2e3d55;
  --nav-hover: #26354b;
  --sel: #2b5d94;
  --sel-on: #0e1724;
  --soft: #1b2534;
  --soft-fg: #d0d8e3;
  --input: #1b2534;
  --input-focus: #0e1724;
  --row-alt: #172030;
  --row-hover: #18303a;
  --row-focus: #173c40;
  --warn-text: #f0a63a;
  --err-bg: #3a1a20;
  --ghost: #26354b;
  --ghost-fg: #e8edf4;
  --ghost-hover: #304260;
  --card-edge: #1f2a3b;
  --card-shadow: 0 10px 30px -18px rgba(0, 0, 0, .7);
  --tip-edge: #2e3d55;
  --parcel-edge: #b6c1cf;
  --sep: #4f5d72;
  --top-bg: linear-gradient(160deg, #13233b 0%, #0b1526 100%);
  --top-glow:
    radial-gradient(42% 120% at 92% -10%, rgba(43, 191, 183, .38) 0%, transparent 70%),
    radial-gradient(35% 90% at 0% 110%, rgba(43, 191, 183, .12) 0%, transparent 70%),
    radial-gradient(38% 110% at 68% 120%, rgba(60, 120, 230, .32) 0%, transparent 70%),
    radial-gradient(30% 80% at 100% 100%, rgba(140, 110, 255, .20) 0%, transparent 70%);
  --top-dots: rgba(255, 255, 255, .10);
  --top-glass: rgba(255, 255, 255, .07);
  --hi-ring: rgba(43, 191, 183, .25);
  --amber: #f5b041;
  --top-fg: #dbe3ee;
  --top-fg-2: #a3b1c4;
  --top-strong: #ffffff;
  --top-mark: #8fd8d2;
  --top-underline: #5c708c;
  --top-btn: rgba(255, 255, 255, .1);
  --top-btn-edge: rgba(255, 255, 255, .22);
  --top-btn-hover: rgba(255, 255, 255, .18);
  --top-shadow: 0 1px 0 #1f2a3b;
}
:root[data-theme="dark"] .sel select option { background: var(--panel); color: var(--fg); }
:root[data-theme="dark"] .leaflet-bar a { background: var(--panel-2); color: var(--fg); border-bottom-color: var(--line); }
:root[data-theme="dark"] .leaflet-bar a:hover { background: var(--chip-hover); }
:root[data-theme="dark"] .leaflet-bar { border-color: var(--line); }
:root[data-theme="dark"] .leaflet-popup-content-wrapper, :root[data-theme="dark"] .leaflet-popup-tip { background: var(--panel-2); color: var(--fg); }
:root[data-theme="dark"] .leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
:root[data-theme="dark"] .leaflet-control-attribution { background: rgba(20, 28, 40, .8); color: var(--faint); }
:root[data-theme="dark"] .leaflet-control-attribution a { color: var(--muted); }
:root[data-theme="dark"] .leaflet-container { background: #10161f; }
:root[data-theme="dark"] .map-focus button:not(#map-focus-back) { background: var(--fg); color: var(--navy-ink); }

/* stat chips: keep all three on one row on phones */
@media (max-width: 680px) {
  .take { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: 100%; }
  .take:empty { display: none; }
  .stat { min-width: 0; padding: 8px 10px 9px 12px; }
  .stat-v b { font-size: 24px; margin-right: 3px; }
  .stat-v { font-size: 13.5px; }
}
