:root {
  --bg: #eef0f2; --panel: #ffffff; --ink: #17212b; --muted: #55626e; --line: #d8dde2;
  --sign: #0f6b4b; --sign-ink: #ffffff; --accent: #7b3294; --soft: #f3f5f7;
  --focus: #1a6fd1;
  --font: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11161b; --panel: #171d23; --ink: #e8edf1; --muted: #9aa7b2; --line: #2b353e;
    --sign: #14805a; --accent: #c58be0; --soft: #1e262d; --focus: #6aa9ff;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); overflow: hidden; }
button, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

#map { position: fixed; inset: 0; }

#panel {
  position: fixed; z-index: 2; top: 12px; left: 12px; bottom: 12px; width: 348px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .18);
}
.sign { background: var(--sign); color: var(--sign-ink); padding: 14px 18px 13px; margin: 6px 6px 0; border-radius: 4px; border: 2px solid rgba(255,255,255,.85); outline: 2px solid var(--sign); }
.sign h1 { margin: 0; font-size: 1.35rem; font-weight: 700; letter-spacing: .01em; line-height: 1.2; }
.sign p { margin: 2px 0 0; font-size: .85rem; opacity: .92; }

.tabs { display: flex; gap: 2px; padding: 12px 14px 0; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; padding: 8px 12px; cursor: pointer; font-weight: 500; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--sign); font-weight: 600; }

.body { overflow-y: auto; padding: 14px 18px 22px; flex: 1; }
.hint { color: var(--muted); margin: 0 0 14px; max-width: 60ch; }
.hint.small { font-size: .85rem; margin: 8px 0 0; }
.field { margin-bottom: 14px; }
.lbl { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
select { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--soft); }

.seg { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { flex: 1; background: var(--soft); border: 0; padding: 8px 6px; cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--sign); color: var(--sign-ink); font-weight: 600; }

.btn { width: 100%; padding: 9px 12px; border-radius: 6px; border: 1px solid var(--line); background: var(--soft); cursor: pointer; font-weight: 600; text-align: left; }
.btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.plain { width: auto; font-weight: 500; padding: 5px 10px; }

.legend { margin: 0 0 16px; }
.legend .row { display: flex; align-items: center; gap: 10px; font-size: .85rem; padding: 2px 0; font-variant-numeric: tabular-nums; }
.legend .sw { width: 28px; height: 8px; border-radius: 4px; flex: none; }
.legend .sw.box { height: 14px; border-radius: 2px; border: 1px solid rgba(0,0,0,.15); }
.legend .cap { margin: 8px 0 0; color: var(--muted); font-size: .8rem; }

#analysis { margin-top: 6px; }
#analysis:empty { display: none; }
.card { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 8px; }
.card h2 { margin: 0 0 2px; font-size: 1.05rem; line-height: 1.3; }
.card .sub { color: var(--muted); font-size: .85rem; margin: 0 0 10px; }
.big { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.card h3 { font-size: .85rem; margin: 14px 0 6px; font-weight: 600; }
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; font-size: .85rem; padding: 3px 0; font-variant-numeric: tabular-nums; }
.bars .bar { grid-column: 1 / -1; height: 5px; background: var(--soft); border-radius: 3px; }
.bars .bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

table.t { border-collapse: collapse; width: 100%; font-size: .85rem; font-variant-numeric: tabular-nums; }
table.t th { text-align: left; font-weight: 600; color: var(--muted); padding: 4px 6px 4px 0; border-bottom: 1px solid var(--line); }
table.t td { padding: 4px 6px 4px 0; border-bottom: 1px solid var(--line); }
table.t td:not(:first-child), table.t th:not(:first-child) { text-align: right; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 0 0 16px; }
.stats div span { display: block; font-size: .8rem; color: var(--muted); }
.stats div b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.pass { color: #1a7f4b; } .fail { color: #b3261e; }
.note { background: var(--soft); border-radius: 6px; padding: 10px 12px; font-size: .85rem; margin: 0 0 14px; }
#about ul { padding-left: 18px; margin: 0 0 14px; font-size: .88rem; }
#about h3 { font-size: .9rem; margin: 16px 0 6px; }

.maplibregl-popup-content { font: 14px/1.45 var(--font); padding: 12px 14px; border-radius: 8px; color: #17212b; min-width: 230px; }
.maplibregl-popup-content h4 { margin: 0 0 1px; font-size: 1rem; }
.maplibregl-popup-content .sub { color: #55626e; font-size: .8rem; margin: 0 0 8px; }
.maplibregl-popup-content table.t th { color: #55626e; border-color: #d8dde2; } .maplibregl-popup-content table.t td { border-color: #d8dde2; }
.maplibregl-popup-content .btn.plain { color: #17212b; background: #f3f5f7; border-color: #d8dde2; margin-top: 8px; }
.maplibregl-popup-close-button { font-size: 20px; padding: 2px 8px; }

@media (max-width: 760px) {
  #panel { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; height: 46vh; }
  .sign { padding: 9px 14px; } .sign h1 { font-size: 1.1rem; }
  .tabs { padding-top: 6px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* time-of-day bar + counts */
.periodbar { padding: 10px 14px 4px; border-bottom: 1px solid var(--line); }
.periodbar .lbl { margin-bottom: 4px; }
.seg.five button { padding: 7px 2px; font-size: .78rem; line-height: 1.15; }
#period-note { margin: 4px 0 2px; }
.check { display: flex; gap: 8px; align-items: baseline; margin: 12px 0 6px; font-size: .9rem; cursor: pointer; }
.check input { transform: translateY(1px); }
.tbar { display: flex; gap: 2px; margin: 6px 0 2px; align-items: flex-end; height: 34px; }
.tbar span { flex: 1; background: var(--soft); border: 1px solid var(--line); position: relative; min-height: 2px; }
.tbar span i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--sign); opacity: .75; }
.tlab { display: flex; gap: 2px; font-size: .68rem; color: var(--muted); text-align: center; }
.tlab span { flex: 1; }

/* counts tab */
.clist { display: flex; flex-direction: column; margin: 8px 0; border-top: 1px solid var(--line); }
.crow { display: grid; grid-template-columns: 46px 1fr auto auto; grid-template-areas: "d n n n" "d v1 v2 p"; gap: 1px 10px; align-items: baseline; text-align: left;
  padding: 8px 2px; background: none; border: 0; border-bottom: 1px solid var(--line); color: inherit; font: inherit; cursor: pointer; width: 100%; }
.crow:hover, .crow:focus-visible { background: var(--soft); }
.crow .cd { grid-area: d; font-weight: 700; font-size: 1rem; align-self: center; } .crow .cd small { font-weight: 400; color: var(--muted); font-size: .7rem; }
.crow .cn { grid-area: n; font-size: .82rem; line-height: 1.3; }
.crow .cv { font-size: .85rem; font-variant-numeric: tabular-nums; } .crow .v1 { grid-area: v1; } .crow .v2 { grid-area: v2; }
.crow .sub { color: var(--muted); font-size: .7rem; margin-right: 3px; }
.crow .pill { grid-area: p; justify-self: end; }
.pill { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: .75rem; font-weight: 600; color: #17212b; border: 1px solid rgba(0,0,0,.15); font-variant-numeric: tabular-nums; }
.pill.c0 { background: #3d7ea6; color: #fff; } .pill.c1 { background: #9cc0d1; } .pill.c2 { background: #c4cbd1; } .pill.c3 { background: #f2b84b; } .pill.c4 { background: #e0762f; color: #fff; } .pill.none { background: transparent; color: var(--muted); font-weight: 400; }
