/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
  --bg:            #0b0f1a;
  --surface:       #111827;
  --surface-raise: #1a2236;
  --surface-high:  #1f2d44;
  --border:        #263248;
  --border-light:  #2f3e57;
  --text:          #e2e8f4;
  --text-muted:    #7a8fa8;
  --text-faint:    #3f526b;

  --accent:        #4f8ef7;
  --accent-glow:   rgba(79, 142, 247, 0.18);

  --pass:          #22c55e;
  --pass-bg:       rgba(34, 197, 94, 0.12);
  --marginal:      #f59e0b;
  --marginal-bg:   rgba(245, 158, 11, 0.12);
  --fail:          #ef4444;
  --fail-bg:       rgba(239, 68, 68, 0.12);

  --header-h:      60px;
  --sidebar-w:     288px;
  --radius:        10px;
  --radius-lg:     16px;
  --shadow:        0 4px 32px rgba(0, 0, 0, 0.55);
  --shadow-sm:     0 2px 12px rgba(0, 0, 0, 0.4);

  --glass-bg:      rgba(11, 15, 26, 0.82);
  --glass-blur:    blur(22px);
  --glass-border:  rgba(255, 255, 255, 0.06);
}

/* ── Light theme ───────────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:            #f0f4f9;
  --surface:       #ffffff;
  --surface-raise: #e8eef6;
  --surface-high:  #dce5f0;
  --border:        #c8d5e5;
  --border-light:  #b0c2d8;
  --text:          #1a2332;
  --text-muted:    #4a5f78;
  --text-faint:    #8fa3bb;

  --accent:        #2563eb;
  --accent-glow:   rgba(37, 99, 235, 0.12);

  --pass:          #16a34a;
  --pass-bg:       rgba(22, 163, 74, 0.10);
  --marginal:      #d97706;
  --marginal-bg:   rgba(217, 119, 6, 0.10);
  --fail:          #dc2626;
  --fail-bg:       rgba(220, 38, 38, 0.10);

  --shadow:        0 4px 32px rgba(0, 0, 0, 0.10);
  --shadow-sm:     0 2px 12px rgba(0, 0, 0, 0.07);

  --glass-bg:      rgba(240, 244, 249, 0.92);
  --glass-border:  rgba(0, 0, 0, 0.07);
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Accessibility utilities ──────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.skip-nav {
  position: fixed;
  top: -100%;
  left: 16px;
  z-index: 1000;
  padding: 10px 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  border-radius: var(--radius);
  text-decoration: none;
  transition: top 0.2s;
}
.skip-nav:focus { top: 8px; }

/* ── Focus ─────────────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ── Header ────────────────────────────────────────────────────────────── */
.app-header {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--header-h);
  z-index: 300;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 20px;
  gap: 12px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-icon { flex-shrink: 0; }

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
  white-space: nowrap;
  margin: 0;
  padding: 0;
  line-height: inherit;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.last-updated {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
}

.btn-toggle-sidebar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  background: var(--surface-raise);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
  font-family: inherit;
  white-space: nowrap;
}
.btn-toggle-sidebar:hover {
  background: var(--surface-high);
  color: var(--text);
  border-color: var(--border-light);
}
.btn-toggle-sidebar[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); }

.btn-theme {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--surface-raise);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
  flex-shrink: 0;
}
.btn-theme:hover {
  background: var(--surface-high);
  color: var(--text);
  border-color: var(--border-light);
}

/* ── Layout ────────────────────────────────────────────────────────────── */
.app-layout {
  position: fixed;
  inset: var(--header-h) 0 0 0;
  display: flex;
}

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
  position: absolute;
  left: 14px;
  top: 14px;
  bottom: 14px;
  width: var(--sidebar-w);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── Sidebar sections ──────────────────────────────────────────────────── */
.sidebar-section {
  padding: 20px 18px;
  border-bottom: 1px solid var(--glass-border);
}
.sidebar-section:last-child { border-bottom: none; }

.section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* ── Overview stats ────────────────────────────────────────────────────── */
.total-count-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 18px;
}

.total-num {
  font-size: 36px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -1px;
  line-height: 1;
}

.total-label {
  font-size: 12px;
  color: var(--text-muted);
}

/* Grade bars */
.grade-bars {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 18px;
}

.grade-bar-row {
  display: grid;
  grid-template-columns: 60px 1fr 32px;
  align-items: center;
  gap: 8px;
}

.grade-bar-label {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.pass-text     { color: var(--pass); }
.marginal-text { color: var(--marginal); }
.fail-text     { color: var(--fail); }

.grade-bar-track {
  height: 6px;
  background: var(--surface-raise);
  border-radius: 99px;
  overflow: hidden;
}

.grade-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  transition: width 0.1s;
}
.pass-fill     { background: var(--pass); }
.marginal-fill { background: var(--marginal); }
.fail-fill     { background: var(--fail); }

.grade-bar-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: right;
}

/* Avg score bar */
.avg-score-row {
  display: grid;
  grid-template-columns: 72px 1fr 40px;
  align-items: center;
  gap: 8px;
}

.avg-score-label {
  font-size: 12px;
  color: var(--text-muted);
}

.avg-track {
  height: 6px;
  background: var(--surface-raise);
  border-radius: 99px;
  overflow: hidden;
}

.avg-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--fail) 0%, var(--marginal) 50%, var(--pass) 100%);
  background-size: 200% 100%;
  transition: width 0.1s;
}

.avg-score-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-align: right;
}

/* ── Filters ───────────────────────────────────────────────────────────── */
.filter-group {
  border: none;
  padding: 0;
  margin-bottom: 18px;
}
.filter-group:last-child { margin-bottom: 0; }

.filter-legend {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Checkboxes */
.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.checkbox-label:hover .checkbox-box { border-color: var(--border-light); }

.checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox-box {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 2px solid var(--border-light);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}
.checkbox-box::after {
  content: '';
  display: none;
  width: 9px;
  height: 5px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translate(0.5px, -1px);
}

.checkbox-label input:checked ~ .pass-box     { background: var(--pass);     border-color: var(--pass); }
.checkbox-label input:checked ~ .marginal-box { background: var(--marginal); border-color: var(--marginal); }
.checkbox-label input:checked ~ .fail-box     { background: var(--fail);     border-color: var(--fail); }
.checkbox-label input:checked ~ .checkbox-box::after { display: block; }

.checkbox-label input:focus-visible ~ .checkbox-box {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.range-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.range-row {
  display: grid;
  grid-template-columns: 28px 1fr 28px;
  align-items: center;
  gap: 8px;
}

.range-row-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.range-row-val {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.range-input {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--surface-raise);
  border-radius: 99px;
  cursor: pointer;
  accent-color: var(--accent);
  outline: none;
}
.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent);
  cursor: pointer;
  transition: box-shadow 0.15s;
}
.range-input::-webkit-slider-thumb:hover { box-shadow: 0 0 0 4px var(--accent-glow); }
.range-input:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--accent-glow); }
.range-input::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  cursor: pointer;
}

/* Reset button */
.btn-reset {
  width: 100%;
  padding: 9px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
  font-family: inherit;
  text-align: center;
}
.btn-reset:hover {
  background: var(--surface-raise);
  color: var(--text);
  border-color: var(--border-light);
}

/* Results count */
.results-row {
  padding: 14px 18px 18px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid var(--glass-border);
}
.results-row #visible-count {
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  display: inline-block;
}

/* ── Map ───────────────────────────────────────────────────────────────── */
.map-wrapper {
  position: absolute;
  inset: 0;
  z-index: 0;
}

#map {
  width: 100%;
  height: 100%;
  background: var(--bg);
}

/* ── Map loader ─────────────────────────────────────────────────────────── */
.map-loader[hidden] { display: none; }
.map-loader {
  position: absolute;
  inset: 0;
  z-index: 900;  /* above all Leaflet panes */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(11, 15, 26, 0.7);
  backdrop-filter: blur(4px);
  color: var(--text-muted);
  font-size: 13px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
.loader-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Map error ──────────────────────────────────────────────────────────── */
.map-error {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  padding: 12px 20px;
  background: var(--fail-bg);
  border: 1px solid var(--fail);
  border-radius: var(--radius);
  color: var(--fail);
  font-size: 13px;
  max-width: 340px;
  text-align: center;
}

/* ── Search this area button ─────────────────────────────────────────────── */
/* ── Address search ──────────────────────────────────────────────────────── */
.addr-search {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 0;
  width: min(420px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 24px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
  padding: 0 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.addr-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6), 0 0 0 3px var(--accent-glow);
}
.addr-search-icon {
  flex-shrink: 0;
  color: var(--text-muted);
  margin-right: 8px;
}
.addr-input {
  flex: 1;
  height: 40px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  min-width: 0;
}
.addr-input::placeholder { color: var(--text-muted); }
.addr-clear {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--surface-raise);
  border: none;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  margin-left: 4px;
  transition: background 0.15s, color 0.15s;
}
.addr-clear[hidden] { display: none; }
.addr-clear:hover { background: var(--border-light); color: var(--text); }
.addr-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  list-style: none;
  max-height: 280px;
  overflow-y: auto;
  z-index: 901;
  padding: 4px 0;
}
.addr-suggestions[hidden] { display: none; }
.addr-suggestion {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 13px;
  line-height: 1.4;
}
.addr-suggestion:hover,
.addr-suggestion[aria-selected="true"] {
  background: var(--surface-raise);
}
.addr-suggestion-icon {
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--text-muted);
}
.addr-suggestion-text { flex: 1; min-width: 0; }
.addr-suggestion-main { color: var(--text); font-weight: 500; }
.addr-suggestion-sub { color: var(--text-muted); font-size: 12px; margin-top: 1px; }
.addr-no-results {
  padding: 12px 14px;
  color: var(--text-muted);
  font-size: 13px;
}

.search-area-btn {
  position: absolute;
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 800;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--surface-1);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
  transition: background 0.15s, box-shadow 0.15s;
}
.search-area-btn[hidden] { display: none; }
.search-area-btn:hover {
  background: var(--surface-2);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

/* ── Map legend ──────────────────────────────────────────────────────────── */
.map-legend {
  position: absolute;
  left: calc(var(--sidebar-w) + 26px);
  bottom: 44px;
  /* must exceed Leaflet popupPane (700) — #map has no z-index so panes share our stacking ctx */
  z-index: 1000;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 7px;
  pointer-events: none;
  /* CSS-only reveal — avoids GSAP/Leaflet stacking-context conflicts */
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}
.map-legend.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.legend-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
}

/* ── Custom marker icons ─────────────────────────────────────────────────── */
.marker-icon {
  background: none !important;
  border: none !important;
  cursor: pointer;
}
/* Scale the SVG child — Leaflet owns the div's transform for positioning */
.marker-icon svg {
  transition: transform 0.15s ease, filter 0.15s ease;
  display: block;
}
.marker-icon:hover svg,
.marker-icon:focus svg {
  transform: scale(1.45);
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.6));
}
.marker-icon:focus { outline: none; }
.marker-icon:focus svg { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 50%; }

/* ── Leaflet overrides ───────────────────────────────────────────────────── */
.leaflet-control-zoom {
  border: 1px solid var(--glass-border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-sm) !important;
  overflow: hidden;
}
.leaflet-control-zoom a {
  background: var(--glass-bg) !important;
  backdrop-filter: var(--glass-blur) !important;
  color: var(--text-muted) !important;
  border: none !important;
  border-bottom: 1px solid var(--glass-border) !important;
  width: 32px !important;
  height: 32px !important;
  line-height: 32px !important;
  font-size: 16px !important;
  font-weight: 400 !important;
  transition: background 0.15s, color 0.15s;
}
.leaflet-control-zoom a:last-child { border-bottom: none !important; }
.leaflet-control-zoom a:hover {
  background: var(--surface-high) !important;
  color: var(--text) !important;
}

.leaflet-control-attribution {
  background: var(--glass-bg) !important;
  backdrop-filter: var(--glass-blur) !important;
  color: var(--text-faint) !important;
  font-size: 10px !important;
  border-radius: var(--radius) 0 0 0 !important;
  border-top: 1px solid var(--glass-border) !important;
  border-left: 1px solid var(--glass-border) !important;
  padding: 4px 8px !important;
}
.leaflet-control-attribution a { color: var(--text-muted) !important; }

/* Tooltip */
.marker-tooltip-wrapper {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  box-shadow: var(--shadow-sm) !important;
  color: var(--text) !important;
  padding: 7px 10px !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 12px !important;
  white-space: nowrap;
}
.marker-tooltip-wrapper::before { display: none !important; }
.marker-tooltip-wrapper.leaflet-tooltip-top::before {
  display: block !important;
  border-top-color: var(--border) !important;
}

.marker-tooltip { display: flex; align-items: center; gap: 8px; }

.tt-score {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}
.tt-score.grade-pass     { background: var(--pass-bg);     color: var(--pass); }
.tt-score.grade-marginal { background: var(--marginal-bg); color: var(--marginal); }
.tt-score.grade-fail     { background: var(--fail-bg);     color: var(--fail); }

/* ── Modal backdrop ──────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 590;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal-backdrop[hidden] { display: none; }

/* ── Sheet handle (reused by sidebar and info panel) ─────────────────────── */
.sheet-handle {
  display: none;
  justify-content: center;
  padding: 10px 0 4px;
  flex-shrink: 0;
}

/* ── Info panel ──────────────────────────────────────────────────────────── */
.info-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 600;
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  will-change: transform, opacity;
}

.info-inner {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
  padding: 20px 20px 24px;
  position: relative;
}

.btn-close-info {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-raise);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.btn-close-info:hover { background: var(--surface-high); color: var(--text); }

.info-body {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.info-left { flex: 1; min-width: 0; }

.info-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: -0.2px;
  outline: none;
  line-height: 1.3;
}

.info-address {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.info-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.meta-key {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  font-weight: 500;
}

.meta-val {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.info-right { flex-shrink: 0; }

.info-score-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 70px;
  height: 70px;
  border-radius: var(--radius);
  gap: 2px;
}
.info-score-badge.grade-pass     { background: var(--pass-bg);     border: 1px solid var(--pass); }
.info-score-badge.grade-marginal { background: var(--marginal-bg); border: 1px solid var(--marginal); }
.info-score-badge.grade-fail     { background: var(--fail-bg);     border: 1px solid var(--fail); }

.info-score {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}
.info-score-badge.grade-pass     .info-score { color: var(--pass); }
.info-score-badge.grade-marginal .info-score { color: var(--marginal); }
.info-score-badge.grade-fail     .info-score { color: var(--fail); }

.info-grade {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.info-score-badge.grade-pass     .info-grade { color: var(--pass); }
.info-score-badge.grade-marginal .info-grade { color: var(--marginal); }
.info-score-badge.grade-fail     .info-grade { color: var(--fail); }

/* ── Reduced motion ──────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .loader-spinner { animation: none; border-top-color: var(--border); }
}

/* ── View toggle button ──────────────────────────────────────────────────── */
.btn-toggle-view {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  background: var(--surface-raise);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
  font-family: inherit;
  white-space: nowrap;
}
.btn-toggle-view:hover {
  background: var(--surface-high);
  color: var(--text);
  border-color: var(--border-light);
}
.btn-toggle-view[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-glow);
}


/* ── List panel ──────────────────────────────────────────────────────────── */
.map-wrapper.view-hidden { display: none; }

.list-panel {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}
.list-panel[hidden] { display: none; }

/* ── List header (sort + count bar) ─────────────────────────────────────── */
.list-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  padding-left: calc(var(--sidebar-w) + 28px);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border);
}

.list-sort-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.list-sort-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  margin-right: 2px;
}

.btn-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  background: var(--surface-raise);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
}
.btn-sort:hover { background: var(--surface-high); color: var(--text); border-color: var(--border-light); }
.btn-sort.is-active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}

.sort-dir {
  font-size: 11px;
  opacity: 0.8;
}

.list-result-count {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── List body (scrollable) ──────────────────────────────────────────────── */
.list-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px 20px;
  padding-left: calc(var(--sidebar-w) + 28px);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.list-body::-webkit-scrollbar { width: 5px; }
.list-body::-webkit-scrollbar-track { background: transparent; }
.list-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── List items ──────────────────────────────────────────────────────────── */
.list-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  margin-bottom: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
  outline: none;
}
.list-item:last-child { margin-bottom: 0; }
.list-item:hover {
  background: var(--surface-raise);
  border-color: var(--border-light);
  transform: translateX(2px);
}
.list-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.list-item-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.list-item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.1px;
}

.list-item-date {
  font-size: 11px;
  color: var(--text-faint);
}

/* ── List item score badge ───────────────────────────────────────────────── */
.list-item-badge {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 54px;
  border-radius: var(--radius);
  gap: 2px;
}
.list-item-badge.grade-pass     { background: var(--pass-bg);     border: 1px solid var(--pass); }
.list-item-badge.grade-marginal { background: var(--marginal-bg); border: 1px solid var(--marginal); }
.list-item-badge.grade-fail     { background: var(--fail-bg);     border: 1px solid var(--fail); }

.list-badge-score {
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}
.grade-pass     .list-badge-score { color: var(--pass); }
.grade-marginal .list-badge-score { color: var(--marginal); }
.grade-fail     .list-badge-score { color: var(--fail); }

.list-badge-grade {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.grade-pass     .list-badge-grade { color: var(--pass); }
.grade-marginal .list-badge-grade { color: var(--marginal); }
.grade-fail     .list-badge-grade { color: var(--fail); }

.list-empty {
  padding: 40px 0;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

/* ── Inspection history ─────────────────────────────────────────────────── */
.info-inspections {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.insp-history-heading {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin: 0 0 10px;
}

.insp-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--surface-raise);
}
.insp-card:last-child { margin-bottom: 0; }

.insp-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.insp-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.insp-meta {
  font-size: 11px;
  color: var(--text-muted);
  flex: 1;
}

.insp-score-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  margin-left: auto;
}
.chip-pass     { background: var(--pass-bg);     color: var(--pass);     border: 1px solid var(--pass); }
.chip-marginal { background: var(--marginal-bg); color: var(--marginal); border: 1px solid var(--marginal); }
.chip-fail     { background: var(--fail-bg);     color: var(--fail);     border: 1px solid var(--fail); }

.insp-inspector {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.violation-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.violation-item {
  background: var(--surface-high);
  border: 1px solid var(--border-light);
  border-radius: 7px;
  padding: 10px 12px;
}

.viol-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.viol-code {
  font-size: 10px;
  color: var(--text-faint);
  margin-bottom: 6px;
  font-family: monospace;
}

.viol-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 6px;
}

.viol-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 20px;
  background: var(--surface-raise);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.viol-tag--corrected {
  background: var(--pass-bg);
  color: var(--pass);
  border-color: var(--pass);
}

.viol-tag--repeat {
  background: var(--fail-bg);
  color: var(--fail);
  border-color: var(--fail);
}

.viol-notes {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  border-top: 1px solid var(--border);
  padding-top: 6px;
  margin-top: 2px;
}

.no-violations {
  font-size: 12px;
  color: var(--text-faint);
  margin: 6px 0 0;
  font-style: italic;
}

/* ── Marker clusters ─────────────────────────────────────────────────────── */
.marker-cluster-custom {
  background: none !important;
  border: none !important;
}

.cluster-icon {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--accent);
  border: 2.5px solid rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  font-family: 'Inter', system-ui, sans-serif;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s;
  cursor: pointer;
}
.cluster-icon:hover { transform: scale(1.12); }

/* ── Layer toggle button ─────────────────────────────────────────────────── */
.layer-btn {
  position: absolute;
  right: 14px;
  bottom: 140px;
  z-index: 1000;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.layer-btn:hover {
  background: var(--surface-high);
  color: var(--text);
  border-color: var(--border-light);
}
.layer-btn.is-satellite {
  color: var(--accent);
  border-color: var(--accent);
}
.layer-btn .icon-map { display: none; }
.layer-btn.is-satellite .icon-satellite { display: none; }
.layer-btn.is-satellite .icon-map { display: block; }

/* ── Locate me button ────────────────────────────────────────────────────── */
.locate-btn {
  position: absolute;
  right: 14px;
  bottom: 96px;
  z-index: 1000;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.locate-btn:hover {
  background: var(--surface-high);
  color: var(--text);
  border-color: var(--border-light);
}
.locate-btn.is-active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-glow);
}
@keyframes locatePulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}
.locate-btn.is-loading { animation: locatePulse 1s ease-in-out infinite; }

/* User location marker */
.user-location-pulse {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(79, 142, 247, 0.3);
  border: 2px solid var(--accent);
  animation: locatePulse 1.6s ease-in-out infinite;
}

/* ── Sidebar handle (mobile only) ────────────────────────────────────────── */
.sidebar-handle {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 18px 12px;
  cursor: pointer;
  flex-shrink: 0;
  border-bottom: 1px solid var(--glass-border);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-handle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.handle-bar {
  width: 36px;
  height: 4px;
  background: var(--border-light);
  border-radius: 99px;
}

.handle-stats {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}
.handle-stats strong {
  color: var(--text);
  font-weight: 600;
}
.handle-dot {
  margin: 0 5px;
  color: var(--text-faint);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  :root { --sidebar-w: calc(100vw - 28px); }

  .sidebar {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 78vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: none;
    transform: translateY(calc(100% - 64px));
    transition: transform 0.38s cubic-bezier(0.32, 0, 0.15, 1);
    will-change: transform;
    overflow: hidden;
  }

  .sidebar.is-expanded {
    transform: translateY(0);
    overflow-y: auto;
  }

  .sidebar-handle {
    display: flex;
  }

  .brand-sub { display: none; }

  .map-legend {
    left: 14px;
    bottom: calc(64px + 20px);
  }

  .list-header,
  .list-body {
    padding-left: 14px;
  }

  /* Push locate + layer buttons above the collapsed sidebar strip */
  .locate-btn {
    bottom: calc(64px + 96px);
  }
  .layer-btn {
    bottom: calc(64px + 140px);
  }

  /* Info panel → bottom sheet on mobile */
  .info-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 88vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    overflow-y: auto;
  }

  .info-inner {
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }

  .sheet-handle {
    display: flex;
    background: var(--surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border: 1px solid var(--border-light);
    border-bottom: none;
  }

  /* ── Touch target improvements ───────────────────────────────────────────── */

  /* Header toggle buttons: at least 44px tall */
  .btn-toggle-view,
  .btn-toggle-sidebar {
    min-height: 44px;
    padding-top: 0;
    padding-bottom: 0;
  }

  /* Checkbox labels: taller hit area */
  .checkbox-label {
    min-height: 44px;
    padding: 2px 0;
  }

  /* Range slider: larger thumb for fat fingers */
  .range-input {
    height: 36px;
  }
  .range-input::-webkit-slider-thumb {
    width: 26px;
    height: 26px;
  }
  .range-input::-moz-range-thumb {
    width: 26px;
    height: 26px;
  }

  /* Close info panel button: full 44px */
  .btn-close-info {
    width: 44px;
    height: 44px;
    top: 8px;
    right: 8px;
  }

  /* Address search clear button */
  .addr-clear {
    width: 36px;
    height: 36px;
  }

  /* Reset filters button */
  .btn-reset {
    padding: 13px 14px;
  }

  /* List sort buttons */
  .btn-sort {
    min-height: 44px;
    padding-top: 0;
    padding-bottom: 0;
  }

  /* List items: taller row */
  .list-item {
    padding: 16px;
  }
}
