:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --bar: #2a78d6;
  --critical: #d03b3b;
  /* injury severity: ordinal blue ramp, darker = worse on light */
  --sev-none: #86b6ef;
  --sev-possible: #5598e7;
  --sev-minor: #2a78d6;
  --sev-serious: #1c5cab;
  --sev-fatal: #0d366b;
  --sev-unknown: #b9b8b2;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --bar: #3987e5;
    /* on dark, lighter = worse */
    --sev-none: #184f95;
    --sev-possible: #256abf;
    --sev-minor: #3987e5;
    --sev-serious: #6da7ec;
    --sev-fatal: #b7d3f6;
    --sev-unknown: #52514e;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --ink: #f0efec; --ink-2: #c3c2b7; --grid: #2c2c2a; --axis: #383835;
  --border: rgba(255, 255, 255, 0.10); --accent: #3987e5; --bar: #3987e5;
  --sev-none: #184f95; --sev-possible: #256abf; --sev-minor: #3987e5; --sev-serious: #6da7ec; --sev-fatal: #b7d3f6;
  --sev-unknown: #52514e;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font-size: 14px; line-height: 1.45; }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0; }
.sub { margin: 2px 0 0; color: var(--ink-2); }

.top, .filters, .tiles, .mapwrap, .charts, .tablewrap, footer { max-width: 1400px; margin: 0 auto; padding: 0 16px; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 20px; padding-bottom: 12px; }

/* data-coverage disclaimer under the title; same 16px gutter as the other sections */
.notice {
  width: calc(100% - 32px); max-width: calc(1400px - 32px); margin: 0 auto 12px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: 8px; padding: 10px 14px; color: var(--ink-2);
}
.notice strong { color: var(--ink); }

.btn { font: inherit; border-radius: 8px; padding: 6px 12px; cursor: pointer; text-decoration: none; display: inline-block; }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--border); }
.btn.ghost:hover { border-color: var(--axis); }
.btn:disabled { opacity: .4; cursor: default; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-bottom: 12px; }
.filters input, .filters select {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 8px; min-height: 32px;
}
#q { flex: 1 1 260px; min-width: 200px; }
.ages { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); }
.ages input { width: 64px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--surface); cursor: pointer; user-select: none; }
.chip:has(input:checked) { border-color: var(--accent); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; padding-bottom: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.tile .v { font-size: 24px; font-weight: 600; }
.tile .l { color: var(--ink-2); font-size: 12.5px; }

.mapwrap { position: relative; }
#map { height: 58vh; min-height: 360px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.maptools { position: absolute; top: 10px; right: 26px; z-index: 500; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; border: 0; background: transparent; color: var(--ink-2); padding: 5px 10px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.legend { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px; color: var(--ink-2); }
.legend div { display: flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; border-radius: 50%; border: 2px solid var(--surface); }

.charts { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; padding-top: 12px; }
.chart { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.chart figcaption { font-weight: 600; margin-bottom: 4px; }
.chart svg { display: block; width: 100%; height: 160px; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .base { stroke: var(--axis); stroke-width: 1; }
.chart .bar { fill: var(--bar); }
.chart .hit { fill: transparent; }
.chart .hit:hover + .bar, .chart g:hover .bar { opacity: .8; }

.tablewrap { padding-top: 16px; padding-bottom: 8px; }
.tablehead { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.pager { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
th { font-weight: 600; color: var(--ink-2); white-space: nowrap; position: sticky; top: 0; background: var(--surface); }
th[data-sort] { cursor: pointer; }
th[aria-sort="ascending"]::after { content: " ↑"; }
th[aria-sort="descending"]::after { content: " ↓"; }
tbody tr.row { cursor: pointer; }
tbody tr.row:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
tr.detail td { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.sev { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.sev i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.flag { display: inline-block; font-size: 11.5px; border: 1px solid var(--border); border-radius: 999px; padding: 0 7px; margin: 0 4px 2px 0; color: var(--ink-2); white-space: nowrap; }
.muted { color: var(--muted); }
.det { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.det h3 { font-size: 13px; margin: 0 0 4px; }
.det ul { margin: 0; padding-left: 18px; }

footer { color: var(--ink-2); font-size: 12.5px; padding-top: 8px; padding-bottom: 32px; }

.tip { position: fixed; z-index: 2000; pointer-events: none; background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px; font-size: 12.5px; box-shadow: 0 4px 14px rgba(0,0,0,.12); }
.tip strong { font-size: 14px; }

.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--ink); }
.leaflet-popup-content { margin: 10px 12px; font-size: 13px; max-height: 300px; overflow-y: auto; }
.pop-item { padding: 4px 0; border-bottom: 1px solid var(--grid); }
.pop-item:last-child { border-bottom: 0; }
.leaflet-container { font: inherit; }
/* OSM tiles are busy and light-only: mute them so the crash marks carry the color */
.tiles-light { filter: grayscale(1) contrast(.9) brightness(1.05); }
.tiles-dark { filter: grayscale(1) invert(1) contrast(.85) brightness(.85); }

@media (max-width: 760px) {
  .charts { grid-template-columns: 1fr; }
  #map { height: 50vh; }
  .maptools { right: 26px; }
  .legend { display: none; }
  .top { flex-wrap: wrap; }
}
