:root {
  --ink: #1b1b1b;
  --muted: #6b6b6b;
  --line: #e3e3e3;
  --bg: #fafafa;
  --accent: #bd0026;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.4;
}
header { padding: 20px 24px 8px; }
h1 { font-size: 20px; margin: 0; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.note { margin: 6px 0 0; font-size: 12.5px; color: #8a5a00; background: #fff7e6;
  border: 1px solid #ffe2a8; padding: 5px 9px; border-radius: 6px; display: inline-block; }


.controls { display: flex; align-items: center; gap: 18px; padding: 6px 24px 12px; flex-wrap: wrap; }
.controls label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
select { font-size: 13px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.toggle button { font-size: 12.5px; padding: 4px 10px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; }
.toggle button:first-child { border-radius: 6px 0 0 6px; }
.toggle button:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
.toggle button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.spacer { flex: 1; }
.legend { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
.legend i { width: 16px; height: 12px; display: inline-block; border: 1px solid rgba(0,0,0,.1); }

main { display: grid; grid-template-columns: 1.05fr 1fr; grid-template-areas: "map chart" "table table";
  gap: 14px; padding: 4px 24px 24px; }
.mapwrap { grid-area: map; position: relative; }
#map { height: 440px; border: 1px solid var(--line); border-radius: 8px; }
.map-ctrl { position: absolute; top: 10px; left: 10px; z-index: 2; display: flex;
  box-shadow: 0 1px 4px rgba(0,0,0,.2); border-radius: 6px; }
.map-ctrl button { font-size: 12px; padding: 5px 10px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; }
.map-ctrl button:first-child { border-radius: 6px 0 0 6px; }
.map-ctrl button:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
.map-ctrl button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.map-legend { position: absolute; bottom: 10px; left: 10px; z-index: 2; max-width: calc(100% - 20px);
  background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 9px; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
#barchart { grid-area: chart; height: 440px; }
.table-area { grid-area: table; }
#tablewrap { max-height: 440px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
@media (max-width: 900px) { main { grid-template-columns: 1fr; grid-template-areas: "map" "chart" "table"; }
  #barchart { height: 320px; } }

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
thead th { position: sticky; top: 0; background: #fff; border-bottom: 2px solid var(--line);
  padding: 7px 8px; text-align: right; cursor: pointer; white-space: nowrap; font-weight: 600; }
thead th:first-child { text-align: left; }
thead th.sorted { color: var(--accent); }
tbody td { padding: 5px 8px; text-align: right; border-bottom: 1px solid #f1f1f1; font-variant-numeric: tabular-nums; }
tbody td:first-child { text-align: left; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #fff6f6; }
tbody tr.sel { background: #ffe9e9; }
td.metric-on { font-weight: 650; color: var(--accent); }
th.metric-on { color: var(--accent); }

.maplibregl-popup-content { font-size: 12px; padding: 9px 11px; border-radius: 7px; }
.popup h4 { margin: 0 0 5px; font-size: 13px; }
.popup table { font-size: 11.5px; }
.popup td { padding: 1px 4px; }
.popup .k { color: var(--muted); text-align: left; }

/* per-admin exposure bar chart — VERTICAL bars (light = total, dark = in-need subset) */
.bc { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px 6px; overflow: hidden; }
.bc-head { font-size: 12px; margin: 0 2px 4px; color: var(--ink); flex: 0 0 auto; }
/* bars share a baseline because the name row is a FIXED height under each column */
#bars { flex: 1 1 auto; display: flex; align-items: flex-end; gap: 5px; overflow-x: auto; overflow-y: hidden; padding: 0 2px; }
.vbar { display: flex; flex-direction: column; align-items: center; height: 100%; min-width: 22px; cursor: pointer; }
.vbar-top { flex: 0 0 14px; }  /* headroom so the tallest bar's total label isn't clipped */
.vbar-plot { flex: 1 1 auto; min-height: 0; width: 18px; display: flex; align-items: flex-end; }
.vbar-col { width: 18px; background: #fdc6a8; border-radius: 2px 2px 0 0; min-height: 1px; position: relative; }
.vbar.sel .vbar-col { outline: 1px solid #cb181d; }
.vbar-sec { position: absolute; left: 0; bottom: 0; width: 100%; background: #cb181d; border-radius: 2px 2px 0 0; }
/* total floats just above the top of the light bar; sector at the top of the dark bar */
.vbar-totlabel { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 1px;
  font-size: 8.5px; color: #999; line-height: 1; white-space: nowrap; pointer-events: none; }
.vbar.sel .vbar-totlabel { color: var(--accent); font-weight: 650; }
.vbar-seclabel { position: absolute; left: 50%; transform: translate(-50%, -100%); font-size: 8px;
  color: #cb181d; font-weight: 600; line-height: 1; white-space: nowrap; pointer-events: none; }
.vbar-name { flex: 0 0 auto; height: 58px; writing-mode: vertical-rl; font-size: 9px; color: #888;
  overflow: hidden; white-space: nowrap; margin-top: 4px; }
.vbar.sel .vbar-name { color: var(--accent); font-weight: 650; }

/* swatch chips that tie the table headers to the bar-chart colours */
.sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
td.pin-exp { color: #cb181d; font-weight: 600; }

footer { padding: 4px 24px 28px; font-size: 11.5px; color: var(--muted); }
footer a { color: var(--muted); }
