/* House Hunt map — Phase 0 shell. Sidebar + full-bleed map, light/dark aware. */
:root {
  --bg: #ffffff;
  --panel: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --sidebar-w: 320px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a; --panel: #1e293b; --border: #334155;
    --text: #e2e8f0; --muted: #94a3b8; --accent: #60a5fa;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

#app { display: flex; height: 100vh; width: 100vw; overflow: hidden; position: relative; }

/* Dashboard (per-county crosstab) — takes the map's place when active. A flex
   sibling of #map so it works in both the desktop (row) and narrow (column)
   layouts; #map is display:none'd while the dashboard shows. */
.dashboard { flex: 1 1 auto; min-width: 0; min-height: 0; overflow: auto; background: var(--bg); }
.dash-inner { padding: 22px 26px 40px; max-width: 1100px; }
.dash-title { margin: 0 0 4px; font-size: 18px; font-weight: 700; }
.dash-sub { margin: 0 0 18px; color: var(--muted); font-size: 12.5px; max-width: 70ch; }
.dash-empty { color: var(--muted); }
.dash-scroll { overflow-x: auto; }
.dash-table { border-collapse: separate; border-spacing: 3px; font-size: 13px; }
.dash-table th {
  font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
  font-weight: 600; text-align: center; padding: 4px 6px; white-space: nowrap;
}
.dash-table th.dash-county { text-align: left; }
.dash-county { text-align: left; font-weight: 600; padding: 6px 10px 6px 4px; white-space: nowrap; }
.dash-num { text-align: right; color: var(--muted); padding: 6px 10px; font-variant-numeric: tabular-nums; }
.dash-cell {
  width: 52px; text-align: center; padding: 8px 6px; border-radius: 6px;
  font-weight: 600; font-variant-numeric: tabular-nums; cursor: default;
}
.dash-na {
  width: 52px; text-align: center; padding: 8px 6px; border-radius: 6px;
  color: var(--muted); background: var(--panel); font-size: 12px;
}

#sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sidebar-head { padding: 18px 18px 10px; border-bottom: 1px solid var(--border); }
.sidebar-head h1 { margin: 0; font-size: 18px; font-weight: 700; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

.panel { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.panel h2 {
  margin: 0 0 10px; font-size: 11px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); font-weight: 600;
}

/* Region segmented control */
.segmented { display: flex; gap: 6px; }
.segmented button {
  flex: 1; padding: 8px 6px; font: inherit; font-size: 13px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); transition: all .12s;
}
.segmented button[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}

/* Place filter (region → county) */
.place-filter { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.place-label { font-size: 12px; color: var(--muted); flex: 0 0 auto; }
.place-filter select {
  flex: 1; min-width: 0; padding: 6px 8px; font: inherit; font-size: 13px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text);
}

/* Layer radio list */
.layer-list { display: flex; flex-direction: column; gap: 4px; }
.layer-list label {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px;
  border-radius: 8px; cursor: pointer;
}
.layer-list label:hover { background: var(--bg); }
.layer-list input { accent-color: var(--accent); }
.layer-list .disabled { color: var(--muted); cursor: not-allowed; }

.layer-list input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }
.hint { margin: 8px 2px 0; color: var(--muted); font-size: 11px; min-height: 14px; }

/* Combine mode toggle */
.combine-mode { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.combine-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.segmented-sm { flex: 1; }
.segmented-sm button { padding: 5px 6px; font-size: 12px; }

/* Legend */
.legend { display: flex; flex-direction: column; gap: 6px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.legend-swatch { width: 16px; height: 16px; border-radius: 4px; flex: 0 0 16px; border: 1px solid rgba(0,0,0,.15); }
.legend-empty { color: var(--muted); font-size: 12px; }
.legend-note { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); color: var(--muted); font-size: 11px; }

.sidebar-foot { margin-top: auto; padding: 12px 18px; color: var(--muted); font-size: 11px; }

#map { flex: 1 1 auto; height: 100%; }

/* Popup */
.maplibregl-popup-content {
  font: inherit; border-radius: 10px; padding: 12px 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,.18);
}
.popup-title { font-weight: 700; margin: 0 0 4px; }
.popup-level { font-weight: 600; }
.popup-detail { color: var(--muted); font-size: 12px; margin-top: 4px; }
.popup-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 2px 0; }
.popup-row span { color: var(--muted); }

@media (max-width: 720px) {
  #app { flex-direction: column; }
  #sidebar { width: 100%; flex: 0 0 auto; max-height: 42vh; border-right: none; border-bottom: 1px solid var(--border); }
}
