/* Kirkwood I-1 Rezoning Simulator — light-mode design, palette per dataviz reference */
:root {
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --good: #006300;
  --bad: #b3261e;
  --accent: #2a78d6;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px 64px; }

header.hero { padding: 28px 0 10px; }
header.hero h1 { font-size: 26px; margin: 0 0 6px; line-height: 1.2; }
header.hero p.tagline { margin: 0; color: var(--ink-2); max-width: 72ch; }
header.hero .provenance { color: var(--muted); font-size: 12.5px; margin-top: 6px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.layout { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 14px; margin-top: 14px; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

/* ---- map panel ---- */
#map { height: 470px; border-radius: 8px; }
@media (max-width: 900px) { #map { height: 360px; } }
.map-note { color: var(--muted); font-size: 12.5px; margin-top: 8px; }

.brushes { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.brush {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1.5px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--ink);
  padding: 5px 12px 5px 8px; font-size: 13px; cursor: pointer;
}
.brush .swatch { width: 13px; height: 13px; border-radius: 4px; display: inline-block; }
.brush.active { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink) inset; }
.brush:hover { background: #f1f0ec; }
.brush-hint { color: var(--muted); font-size: 12.5px; margin: 2px 0 8px; }

.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.preset {
  border: 1px solid var(--border); border-radius: 7px; background: #f1f0ec;
  padding: 5px 10px; font-size: 12.5px; cursor: pointer; color: var(--ink-2);
}
.preset:hover { background: #e9e8e2; color: var(--ink); }
.preset.reset-map { border-color: var(--baseline); background: var(--surface); font-weight: 600; }

.subarea-list { margin-top: 10px; display: grid; gap: 4px; }
.subarea-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 13px; padding: 5px 8px; border-radius: 6px; cursor: pointer;
}
.subarea-row:hover { background: #f1f0ec; }
.subarea-row .zone-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--ink-2); white-space: nowrap;
}
.subarea-row .zone-chip .swatch { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.subarea-row .zone-chip:hover { outline: 1.5px solid var(--ink); border-radius: 4px; }
.npv-tag { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--good); font-weight: 650; white-space: nowrap; }
.npv-tag.neg { color: #b3261e; }

/* factors table below the map */
.factor-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 10px; }
.factor-table th {
  text-align: right; font-weight: 600; color: var(--muted); font-size: 10.5px;
  padding: 2px 6px 5px; border-bottom: 1px solid var(--grid); white-space: nowrap;
}
.factor-table th:first-child, .factor-table th:nth-child(2) { text-align: left; }
.factor-table td { padding: 4px 6px; border-bottom: 1px solid #f0efec; vertical-align: middle; }
.factor-table td.ft-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.factor-table tr.ft-grp td {
  font-weight: 650; font-size: 10px; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--ink-2); padding: 9px 6px 3px; border-bottom: none;
}
.factor-table tr.ft-row { cursor: pointer; }
.factor-table tr.ft-row:hover { background: #f1f0ec; }
.factor-table tr.ft-locked { opacity: 0.55; cursor: pointer; }
.factor-table .ft-name { line-height: 1.2; }
.factor-table .ft-ac { display: block; color: var(--muted); font-size: 10px; }
.factor-table .ft-chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px;
  color: var(--ink-2); white-space: nowrap; padding: 1px 3px; border-radius: 4px;
}
.factor-table .ft-chip .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.factor-table .ft-chip:hover { outline: 1.5px solid var(--ink); }
.factor-table .ft-sub { color: var(--muted); font-size: 9.5px; margin-left: 1px; }
.factor-table .tip-pos { color: var(--good); font-weight: 650; }
.factor-table .tip-neg { color: var(--bad); font-weight: 650; }

/* ---- results panel ---- */
.hero-num { font-size: 40px; font-weight: 700; line-height: 1.05; letter-spacing: -0.5px; }
.hero-label { color: var(--ink-2); font-size: 13.5px; }
.hero-sub { color: var(--good); font-size: 14px; margin-top: 4px; font-weight: 600; }
.hero-caveat { color: var(--muted); font-size: 12.5px; margin-top: 6px; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.stat { border-top: 1px solid var(--grid); padding-top: 8px; }
.stat .v { font-weight: 650; font-size: 17px; }
.stat .k { color: var(--muted); font-size: 12px; }

.section-title { font-size: 15px; font-weight: 650; margin: 0 0 8px; }
.subtle { color: var(--muted); font-size: 12.5px; }

/* chart */
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.chart-toggle { font-size: 12.5px; color: var(--accent); background: none; border: none; cursor: pointer; padding: 2px 4px; }
#chart svg { display: block; width: 100%; height: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: 12.5px; color: var(--ink-2); }
.legend .item { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

table.fund-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
table.fund-table th, table.fund-table td { text-align: right; padding: 5px 6px; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
table.fund-table th:first-child, table.fund-table td:first-child { text-align: left; }
table.fund-table th { color: var(--muted); font-weight: 600; font-size: 12px; }
table.fund-table td.name { display: flex; align-items: center; gap: 7px; }
table.fund-table .swatch { width: 11px; height: 11px; border-radius: 3px; display: inline-block; flex: none; }

/* balance sheet */
.bs-row { margin: 12px 0; }
.bs-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 13.5px; }
.bs-top .name { font-weight: 600; }
.bs-top .cost-edit { display: inline-flex; align-items: center; gap: 3px; color: var(--ink-2); font-size: 12.5px; white-space: nowrap; }
.bs-top input[type="text"] {
  width: 84px; font: inherit; font-variant-numeric: tabular-nums; text-align: right;
  border: 1px solid var(--border); border-radius: 5px; padding: 2px 6px; background: var(--surface); color: var(--ink);
}
.bs-bar { height: 14px; background: #efeee9; border-radius: 4px; overflow: hidden; margin-top: 5px; position: relative; }
.bs-bar .fill { height: 100%; background: var(--good); border-radius: 4px 0 0 4px; }
.bs-bar .fill.partial { background: #7fae7f; }
.bs-verdict { font-size: 12.5px; margin-top: 3px; color: var(--ink-2); }
.bs-verdict.funded { color: var(--good); font-weight: 600; }
.bs-note { color: var(--muted); font-size: 12px; margin-top: 2px; }
.bs-summary { border-top: 1px solid var(--grid); margin-top: 12px; padding-top: 10px; font-size: 13.5px; }

/* assumptions drawer */
details.drawer { margin-top: 14px; }
details.drawer > summary {
  cursor: pointer; font-weight: 650; font-size: 15px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  list-style: none;
}
details.drawer > summary::-webkit-details-marker { display: none; }
details.drawer > summary::after { content: " ▸"; color: var(--muted); }
details.drawer[open] > summary::after { content: " ▾"; }
details.drawer .drawer-body {
  background: var(--surface); border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius) var(--radius); padding: 14px 16px;
}
.assumption-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; }
@media (max-width: 700px) { .assumption-grid { grid-template-columns: 1fr; } }
.assumption { font-size: 13px; }
.assumption .lab { display: flex; justify-content: space-between; gap: 8px; }
.assumption .lab .val { font-variant-numeric: tabular-nums; font-weight: 650; }
.assumption input[type="range"] { width: 100%; accent-color: var(--accent); }
.assumption .src { color: var(--muted); font-size: 11.5px; line-height: 1.35; }
.assumption-group-title { font-weight: 650; font-size: 13px; margin: 14px 0 6px; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.04em; }
.assumption.locked { background: #f4f3ef; border-radius: 6px; padding: 7px 9px; }
.assumption.locked .lab span { color: var(--ink-2); font-size: 12.5px; }
.reset-row { margin-top: 12px; }
.reset-btn { font-size: 12.5px; border: 1px solid var(--border); background: #f1f0ec; border-radius: 6px; padding: 5px 10px; cursor: pointer; }

/* caveats + footer */
.caveats { margin-top: 14px; }
.caveats ol { margin: 6px 0 0; padding-left: 20px; color: var(--ink-2); font-size: 13px; }
.caveats li { margin: 4px 0; }
footer { color: var(--muted); font-size: 12.5px; margin-top: 20px; }
footer a { color: var(--accent); }

/* leaflet tweaks */
.leaflet-container { font: inherit; background: #eceae4; }
.subarea-tip { font-size: 12.5px; line-height: 1.4; min-width: 220px; }
.subarea-tip b { font-size: 13.5px; }

.tip-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.tip-meta { color: var(--muted); font-size: 11.5px; }
.tip-divider { height: 1px; background: var(--grid); margin: 7px 0; }
.tip-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 2px 0; }
.tip-label { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.tip-value { text-align: right; font-weight: 600; }
.tip-sub { font-weight: 400; color: var(--muted); font-size: 11px; display: block; text-align: right; }
.tip-blurb { color: var(--ink-2); font-size: 11.5px; font-style: italic; line-height: 1.35; }
.tip-pos { color: var(--good); font-weight: 700; }
.tip-neg { color: var(--bad); font-weight: 700; }
.tip-chip { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.tip-dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; flex: none; }
.tip-badge {
  font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  white-space: nowrap; flex: none;
}
.tip-badge-accent { background: rgba(42, 120, 214, 0.14); color: #184f95; }
.tip-badge-muted { background: rgba(11, 11, 11, 0.07); color: var(--ink-2); }

/* floating map tooltip — top-level so the map edge never clips it */
#maptip {
  position: fixed; pointer-events: none; z-index: 3000; display: none;
  max-width: 300px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18); padding: 10px 12px;
}
.trail-label { background: transparent; border: none; box-shadow: none; font-weight: 700; font-size: 11px; }

/* chart tooltip */
#tip {
  position: fixed; pointer-events: none; z-index: 3000; display: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12); padding: 8px 10px; font-size: 12.5px; min-width: 170px;
}
#tip .yr { font-weight: 700; margin-bottom: 4px; }
#tip .row { display: flex; justify-content: space-between; gap: 12px; }
#tip .row .sw { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 5px; }
#tip .row.total { border-top: 1px solid var(--grid); margin-top: 4px; padding-top: 3px; font-weight: 650; }
