:root {
  --ink: #1b1f24;
  --muted: #5c6670;
  --line: #d9dee3;
  --wash: #f4f5f7;
  --surface: #ffffff;
  --accent: #b5462a;
  --accent-ink: #8f3316;
  --ok: #2f7d4f;
  --warn: #b8860b;
  --bad: #b23a3a;
  --panel-w: 400px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--wash); }
body { display: grid; grid-template-rows: auto 1fr; height: 100vh; overflow: hidden; }

header.top {
  display: flex; align-items: center; gap: 18px; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
header.top h1 { font-size: 16px; margin: 0; font-weight: 650; letter-spacing: .01em; }
header.top .sub { font-size: 12px; color: var(--muted); }
header.top nav { margin-left: auto; display: flex; gap: 6px; }
header.top nav a {
  font-size: 13px; text-decoration: none; color: var(--ink); padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--wash);
}
header.top nav a.cur { background: var(--ink); color: #fff; border-color: var(--ink); }

main { display: grid; grid-template-columns: var(--panel-w) 1fr; min-height: 0; }
aside.panel {
  background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto;
  padding: 14px 16px 24px; font-size: 13.5px; line-height: 1.4;
}
#map { position: relative; min-height: 0; }
.maplibregl-canvas { outline: none; }

.search { position: relative; margin-bottom: 12px; }
.search input {
  width: 100%; padding: 9px 10px; font-size: 14px; border: 1px solid var(--line); border-radius: 6px;
}
.search ul {
  position: absolute; z-index: 5; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 0; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; max-height: 260px; overflow-y: auto;
  box-shadow: 0 6px 18px rgba(0,0,0,.08);
}
.search li { padding: 7px 10px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--wash); }
.search li:hover { background: var(--wash); }
.search ul:empty { display: none; }

.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 14px; }
h2 { font-size: 15px; margin: 14px 0 6px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 6px; }
.addr { font-size: 17px; font-weight: 650; margin: 2px 0; }
.meta { color: var(--muted); font-size: 12.5px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 6px 0; }
.kv div:nth-child(odd) { color: var(--muted); }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.col { border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: var(--wash); }
.col h4 { margin: 0 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.col .code { font-size: 18px; font-weight: 700; }
.col .name { font-size: 12px; color: var(--muted); min-height: 2.6em; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0 4px; }
.chip {
  font-size: 11.5px; padding: 3px 7px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  color: var(--muted);
}
.chip.yes { background: #e6f2ea; border-color: #b9dcc6; color: var(--ok); font-weight: 600; }
.chip.verify { border-style: dashed; }
.lotcheck { font-size: 12.5px; margin-top: 6px; }
.lotcheck b { font-weight: 650; }
.ok { color: var(--ok); } .bad { color: var(--bad); } .warn { color: var(--warn); }
.change {
  margin-top: 12px; padding: 10px 12px; border-radius: 8px; font-size: 13.5px; font-weight: 600;
  background: #eef1f4; border-left: 4px solid var(--muted);
}
.change.gap { background: #e6f2ea; border-left-color: var(--ok); }
.change.dz { background: #f8e9e9; border-left-color: var(--bad); }
.cond { margin-top: 8px; font-size: 12.5px; color: var(--warn); }
.foot { margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--muted); }
.foot a { color: var(--accent-ink); }

.controls { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.controls label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
select, button {
  font: inherit; font-size: 13px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface);
}
button.primary { background: var(--ink); color: #fff; border-color: var(--ink); cursor: pointer; }
button.link { border: none; background: none; color: var(--accent-ink); cursor: pointer; padding: 0; }

.legend { position: absolute; left: 10px; bottom: 26px; z-index: 3; background: rgba(255,255,255,.94);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; max-width: 260px; }
.legend .row { display: flex; align-items: center; gap: 6px; margin: 2px 0; }
.legend .sw { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); flex: none; }
.legend .t { font-weight: 650; margin-bottom: 4px; }

table.rank { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 6px; }
table.rank th, table.rank td { text-align: left; padding: 5px 4px; border-bottom: 1px solid var(--wash); }
table.rank th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
table.rank tr { cursor: pointer; }
table.rank tr:hover td { background: var(--wash); }
.tier { display: inline-block; width: 20px; text-align: center; border-radius: 4px; font-weight: 700; color: #fff; font-size: 11px; padding: 2px 0; }
.tier.A { background: #b5462a; } .tier.B { background: #d98e3d; } .tier.C { background: #c9b45a; color: #333; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.weights { margin: 6px 0; }
.weights label { display: grid; grid-template-columns: 110px 1fr 36px; align-items: center; gap: 8px; font-size: 12.5px; margin: 3px 0; }
.weights input[type=range] { width: 100%; }
.weights .v { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.note { font-size: 12px; color: var(--muted); }
.stat { display: inline-block; margin-right: 12px; font-size: 12.5px; }
.stat b { font-size: 16px; font-weight: 700; margin-right: 3px; }

.gapdot { color: var(--ok); font-size: 10px; }
.transit-note { border-left: 3px solid var(--warn); padding-left: 8px; margin: 8px 0 4px; }

@media (max-width: 900px) {
  :root { --panel-w: 100%; }
  body { height: 100dvh; }
  header.top { flex-wrap: wrap; gap: 6px 12px; padding: 8px 12px; }
  header.top h1 { font-size: 15px; }
  header.top nav { margin-left: 0; width: 100%; }
  header.top nav a { flex: 1; text-align: center; padding: 6px 4px; font-size: 12.5px; }
  main { grid-template-columns: 1fr; grid-template-rows: 48vh 1fr; }
  #map { order: 1; }
  aside.panel { order: 2; border-right: none; border-top: 1px solid var(--line); padding: 10px 12px 20px; }
  .legend { left: 6px; bottom: 6px; max-width: calc(100% - 60px); padding: 6px 8px; font-size: 11px; }
  .legend .row:not(:first-child) { display: none; }
  .legend.open .row { display: flex; }
  .legend .t { cursor: pointer; margin: 0; }
  .legend .t::after { content: " ▸"; color: var(--muted); }
  .legend.open .t::after { content: " ▾"; }
  .legend details.method { display: none; }
  .legend.open details.method { display: block; }
  .cols { grid-template-columns: 1fr; }
  .weights label { grid-template-columns: 96px 1fr 30px; }
}

/* home page (plain-English explainer) */
body.home { display: block; height: auto; min-height: 100vh; overflow: auto; }
body.home header.top { position: sticky; top: 0; z-index: 4; }
.home main { display: block; max-width: 860px; margin: 0 auto; padding: 24px 20px 60px; font-size: 15px; line-height: 1.55; }
.home h2 { font-size: 22px; margin: 34px 0 10px; font-weight: 700; letter-spacing: -.01em; }
.home h2:first-child { margin-top: 8px; }
.home h3 { font-size: 13px; margin: 18px 0 6px; }
.home p { margin: 8px 0; }
.home .lede { font-size: 18px; color: var(--ink); margin: 6px 0 18px; }
.home .cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 16px 0 8px; }
.home .card { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.home .card h3 { margin: 0; font-size: 17px; text-transform: none; letter-spacing: 0; color: var(--ink); font-weight: 700; }
.home .card p { margin: 0; color: var(--muted); font-size: 14px; flex: 1; }
.home .card a.btn { align-self: flex-start; margin-top: 8px; text-decoration: none; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 6px; font-size: 14px; font-weight: 600; }
.home ol, .home ul { padding-left: 22px; margin: 8px 0; }
.home li { margin: 4px 0; }
.home .facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.home .fact { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.home .fact b { display: block; font-size: 22px; font-weight: 700; }
.home .fact span { color: var(--muted); font-size: 13px; }
.home .example { background: var(--surface); border-left: 4px solid var(--accent); padding: 10px 14px; margin: 12px 0; border-radius: 0 8px 8px 0; }
.home table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 10px 0; }
.home th, .home td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.home th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }
.home .caveat { background: #fff8e6; border: 1px solid #f0dca0; border-radius: 8px; padding: 12px 16px; margin: 14px 0; }
.home a { color: var(--accent-ink); }
.home .foot { font-size: 13px; }
@media (max-width: 700px) { .home .cards { grid-template-columns: 1fr; } .home main { padding: 16px 14px 40px; font-size: 14.5px; } }

/* finder legend with methodology */
.legend--finder { max-width: 330px; max-height: calc(100% - 40px); overflow-y: auto; }
.legend .row { align-items: flex-start; }
.legend .row .sw { margin-top: 1px; }
details.method { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 6px; }
details.method summary { cursor: pointer; font-weight: 650; color: var(--accent-ink); }
details.method p { margin: 6px 0; font-size: 11.5px; line-height: 1.4; }
details.method p.src { color: var(--muted); }
table.mtab { width: 100%; border-collapse: collapse; font-size: 11px; margin: 4px 0; }
table.mtab th, table.mtab td { text-align: left; padding: 2px 4px; border-bottom: 1px solid var(--wash); vertical-align: top; }
table.mtab th { color: var(--muted); font-weight: 600; }
table.mtab td:last-child, table.mtab th:last-child { text-align: right; }
