/* ============================================================
   SF Housing Dashboard — Brand Stylesheet
   Palette: C.3 "Violet in the Details"
   Typography: Barlow only (AG-equivalent, single-family hierarchy)
   ============================================================ */

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

:root {
  /* Brand palette — C.3 */
  --orange: #FF6100;
  --pink: #F4356C;
  --sky-blue: #489BDC;
  --soft-violet: #BF9CFF;
  --deep-violet: #5A2FB0;
  --navy: #0f1029;
  --cream: #FFFAF1;
  --dark-text: #1a1a2e;
  --violet-wash: #EDE5F9;

  --white: #FFFFFF;

  /* Typography — single-family (Barlow / AG-equivalent). Hierarchy comes
     from weight and size, not family contrast. */
  --font-heading: 'Barlow', 'Helvetica Neue', sans-serif;
  --font-body: 'Barlow', 'Helvetica Neue', sans-serif;
  --font-ui: 'Barlow', 'Helvetica Neue', sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--dark-text);
  /* Page-wide atmospheric gradient — extends from hero all the way
     through methodology so the page feels like a continuous designed
     surface instead of stacked rectangles. Three radial blobs at fixed
     positions so the warmth travels with the scroll. */
  background:
    radial-gradient(ellipse 90% 40% at 100% 0%, rgba(255, 141, 74, 0.30), transparent 65%),
    radial-gradient(ellipse 70% 35% at 0% 25%, rgba(191, 156, 255, 0.28), transparent 65%),
    radial-gradient(ellipse 80% 35% at 100% 55%, rgba(244, 53, 108, 0.16), transparent 60%),
    radial-gradient(ellipse 70% 35% at 0% 80%, rgba(122, 80, 220, 0.20), transparent 65%),
    linear-gradient(180deg, #FFF7EE 0%, var(--cream) 45%, #FFF3E8 100%);
  background-attachment: fixed;
  line-height: 1.55;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }

h1, h2, h3 {
  font-family: var(--font-heading);
  color: var(--dark-text);
  letter-spacing: -0.03em;
  line-height: 0.92;
}
h1 { font-weight: 900; }
h2 { font-weight: 900; }
h3 { font-weight: 700; }

/* === Error Banner === */
.error-banner[hidden] { display: none; }
.error-banner {
  background: rgba(244,53,108,0.06);
  border-bottom: 2px solid var(--pink);
  color: var(--dark-text);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  font-weight: 500;
}
.error-banner-icon { font-size: 1.25rem; color: var(--pink); }
.error-banner-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--dark-text);
  line-height: 1;
}

/* === Top branding bar (transparent, on the gradient) === */
.top-bar {
  background: rgba(255, 250, 241, 0.6);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  padding: 0.875rem 0;
  border-bottom: 1px solid rgba(26,26,46,0.06);
  position: relative;
  z-index: 50;
}
.top-bar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 3vw, 2.5rem);
  display: flex;
  align-items: baseline;
  gap: 0.875rem;
}
.logo-mark {
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 1.375rem;
  color: var(--orange);
  text-decoration: none;
  letter-spacing: -0.04em;
  line-height: 1;
}
.logo-context {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  color: rgba(26,26,46,0.65);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 600;
}

/* === Hero Section ===
   The body gradient does the atmosphere work; hero just sets the
   editorial pattern (kicker → big title → 20px lede). Decorative orb
   stays in the upper-right corner as a Trillo-style accent moment. */
.hero {
  background: transparent;
  padding: clamp(3.5rem, 8vw, 7rem) 0 clamp(2.5rem, 5vw, 4rem);
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: '';
  position: absolute;
  top: -10%;
  right: -8%;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 97, 0, 0.22), transparent 65%);
  pointer-events: none;
  z-index: 0;
}
.hero-inner { position: relative; z-index: 1; }
.hero-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding-left: clamp(1.25rem, 3vw, 2.5rem);
  padding-right: clamp(1.25rem, 3vw, 2.5rem);
}
.hero-kicker {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--deep-violet);
  margin-bottom: 0.875rem;
}
.hero-title {
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: clamp(2.75rem, 7.5vw, 5.5rem);
  line-height: 0.96;
  letter-spacing: -0.04em;
  color: var(--dark-text);
  margin: 0 0 1.5rem;
  max-width: 14ch;
}
.hero-title br { display: none; }
@media (min-width: 720px) {
  .hero-title br { display: inline; }
  .hero-title { max-width: none; }
}
.hero-lede {
  font-family: var(--font-body);
  font-size: clamp(1.0625rem, 1.4vw, 1.25rem);
  line-height: 1.5;
  font-weight: 400;
  color: var(--dark-text);
  max-width: 60ch;
  margin: 0;
}
.hero-lede strong {
  font-weight: 700;
}

/* === KPI band — editorial, no card chrome. Body gradient continues. */
.kpi-band {
  background: transparent;
  padding: clamp(2.5rem, 5vw, 4rem) 0 clamp(3.5rem, 7vw, 5.5rem);
}

/* === Interlude — Gates-Foundation-style punctuation between KPI band
   and tabs. Single editorial stat anchors a visual rhythm break.
   Asymmetric on desktop: massive number on the left, narrative line
   on the right; stacked on mobile. */
.interlude {
  background: transparent;
  padding: clamp(2rem, 5vw, 4.5rem) 0 clamp(3rem, 6vw, 5.5rem);
  position: relative;
}
.interlude-inner {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem 3rem;
  align-items: end;
  padding-left: clamp(1.25rem, 3vw, 2.5rem);
  padding-right: clamp(1.25rem, 3vw, 2.5rem);
}
@media (min-width: 768px) {
  /* `auto` on the first column lets it size to the stat's actual rendered
     width — not a `ch` value that resolves against the parent font size
     and clips to the first digit. */
  .interlude-inner { grid-template-columns: auto 1fr; }
}
.interlude-stat {
  font-family: var(--font-heading);
  font-size: clamp(4rem, 11vw, 9rem);
  font-weight: 900;
  line-height: 0.85;
  letter-spacing: -0.05em;
  margin: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  background: linear-gradient(135deg, #FF6100 0%, #F4356C 50%, #5A2FB0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--orange);
}
.interlude-line {
  font-family: var(--font-heading);
  font-size: clamp(1.125rem, 2vw, 1.5rem);
  line-height: 1.3;
  font-weight: 500;
  color: var(--dark-text);
  margin: 0;
  max-width: 36ch;
  letter-spacing: -0.015em;
}
.interlude-line strong { font-weight: 800; }
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(2rem, 4vw, 3rem);
  padding-left: clamp(1.25rem, 3vw, 2.5rem);
  padding-right: clamp(1.25rem, 3vw, 2.5rem);
}
@media (min-width: 768px) {
  .kpi-grid { grid-template-columns: 1fr 1fr 1fr; }
}
.kpi {
  display: flex;
  flex-direction: column;
  gap: 0;
  /* Subtle separator on desktop — uses a left border on cols 2 & 3 */
}
@media (min-width: 768px) {
  .kpi + .kpi {
    border-left: 1px solid rgba(26,26,46,0.08);
    padding-left: clamp(1.5rem, 2.5vw, 2.25rem);
  }
}
.kpi-kicker {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--deep-violet);
  margin-bottom: 0.75rem;
}
.kpi-number {
  font-family: var(--font-heading);
  font-size: clamp(3.25rem, 6.5vw, 5rem);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.045em;
  margin: 0 0 1rem;
  font-variant-numeric: tabular-nums;
  /* All three KPI numbers carry the Aperture gradient treatment
     (orange → pink → deep violet) for visual coherence. */
  background: linear-gradient(135deg, #FF6100 0%, #F4356C 50%, #5A2FB0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--orange); /* fallback for browsers without bg-clip text */
}
.kpi-detail {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: #4a4555;
  margin: 0;
  max-width: 32ch;
}
.kpi-detail strong { color: var(--dark-text); font-weight: 700; }
.kpi-delta {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 0.875rem 0 0;
}
.kpi-delta.behind { color: var(--pink); }
.kpi-delta.on-pace { color: var(--deep-violet); }
.kpi-footnote {
  font-family: var(--font-body);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: #6a6275;
  margin: 0.75rem 0 0;
}

/* Progress bar */
.progress-bar-wrap {
  height: 10px;
  background: #E8E4DF;
  border-radius: 5px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: 5px;
  transition: width 0.8s ease;
  width: 0;
}
.progress-bar.behind { background: var(--pink); }
.progress-bar.on-pace { background: var(--sky-blue); }

/* (Old .hero-delta pill style removed — replaced by .kpi-delta in the
   KPI band block above.) */

.hero-context {
  margin-top: 1.25rem;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: #555;
  max-width: 800px;
  line-height: 1.7;
}

/* === Tabs Navigation ===
   Sticky, with a backdrop-blur so it lifts off the gradient atmosphere
   instead of sitting flat. */
.tabs-nav {
  background: rgba(255, 250, 241, 0.85);
  backdrop-filter: saturate(150%) blur(10px);
  -webkit-backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid rgba(26,26,46,0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}
.tabs-scroll {
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  gap: 0.5rem;
  padding: 0.875rem 0;
}
.tabs-scroll::-webkit-scrollbar { display: none; }

/* Tabs read as CTA pills — heavier weight, real padding, clear active
   state with gradient fill. No emojis. */
.tab {
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 700;
  padding: 0.75rem 1.25rem;
  border: 1.5px solid rgba(26, 26, 46, 0.15);
  background: rgba(255, 255, 255, 0.5);
  color: var(--dark-text);
  cursor: pointer;
  white-space: nowrap;
  border-radius: 100px;
  transition: all 0.18s ease;
  letter-spacing: -0.005em;
}
.tab:hover {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(255, 97, 0, 0.5);
  transform: translateY(-1px);
}
.tab.active {
  background: linear-gradient(135deg, #FF6100 0%, #F4356C 100%);
  color: var(--white);
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(255, 97, 0, 0.35);
}
.tab.active:hover {
  background: linear-gradient(135deg, #FF6100 0%, #F4356C 100%);
  transform: translateY(-1px);
}

/* === Tab Panels — transparent so the body gradient runs through.
   The chart-container and story-callout cards lift off the warm
   atmosphere; the tab surface itself doesn't compete. */
.tab-panels {
  background: transparent;
  padding: clamp(2.5rem, 5vw, 4rem) 0 clamp(3.5rem, 6vw, 5rem);
  min-height: 400px;
  position: relative;
}
.tab-panel { display: none; }
.tab-panel[hidden] { display: none; }
.tab-panel.active { display: block; }

/* Panel header — Gates-Foundation-style asymmetric: BIG title on the left,
   editorial lede on the right at desktop. The lede IS the section's
   intro / story / takeaway in one cohesive sentence — no separate boxed
   callout competing for attention. */
.panel-header {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem 3rem;
  margin-bottom: clamp(2rem, 4vw, 3rem);
  align-items: baseline;
}
@media (min-width: 880px) {
  /* Column 1 sized "auto" so the track always fits the big h2 (the old
     14ch track was measured in BODY-font ch — one third of the h2's actual
     glyph size — so long titles overflowed into the lede). The h2 wraps
     via its own max-width, measured in ITS font's ch. */
  .panel-header { grid-template-columns: auto 1fr; }
  .panel-header h2 { max-width: 12ch; }
}
.panel-header h2 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: clamp(2rem, 4.2vw, 3rem);
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 0.96;
  color: var(--dark-text);
}
.panel-header p,
.panel-lede {
  margin: 0;
  max-width: 60ch;
  color: var(--dark-text);
  font-family: var(--font-body);
  font-size: clamp(1rem, 1.3vw, 1.0625rem);
  line-height: 1.6;
}
.panel-lede strong { font-weight: 700; }

.filter-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-family: var(--font-ui);
}
.filter-row label { font-weight: 500; }
.district-select {
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  padding: 0.375rem 0.75rem;
  border: 1px solid #CCC;
  border-radius: 6px;
  background: var(--white);
  color: var(--dark-text);
}

/* === Chart toolbar (bars / lines toggle) === */
.chart-toolbar {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.chart-toolbar-label {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--deep-violet);
}
.seg-control {
  display: inline-flex;
  border: 1px solid rgba(26, 26, 46, 0.15);
  border-radius: 100px;
  padding: 3px;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(6px);
}
.seg-control-option {
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.4rem 0.95rem;
  border: none;
  background: transparent;
  color: var(--dark-text);
  cursor: pointer;
  border-radius: 100px;
  transition: background 0.18s, color 0.18s;
  letter-spacing: -0.005em;
}
.seg-control-option:hover { background: rgba(26, 26, 46, 0.04); }
.seg-control-option.is-active {
  background: linear-gradient(135deg, #FF6100 0%, #F4356C 100%);
  color: var(--white);
}
.seg-control-option.is-active:hover { background: linear-gradient(135deg, #FF6100 0%, #F4356C 100%); }

/* === Charts === */
.chart-container {
  position: relative;
  width: 100%;
  height: clamp(420px, 52vh, 580px);
  margin-bottom: 2.5rem;
  padding: 1.75rem 1.5rem 1.25rem;
  background: var(--white);
  border-radius: 14px;
  box-shadow: 0 4px 32px rgba(15, 16, 41, 0.05), 0 1px 2px rgba(15, 16, 41, 0.04);
}
.chart-container canvas { width: 100% !important; height: 100% !important; }

/* Tiny editorial note BELOW the chart — lives where a caption would in
   a magazine. Median lag stat sits inline, not in a box. */
.chart-note {
  margin: -1rem 0 2rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  line-height: 1.5;
  color: #6a6275;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: baseline;
}
.chart-note-stat {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1rem;
  color: var(--dark-text);
  letter-spacing: -0.015em;
}
.chart-note-stat::before {
  content: 'Median approval \2192 keys-in-hand: ';
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--deep-violet);
  margin-right: 0.4rem;
}
.chart-note-aside { color: #6a6275; }

/* === Tables === */
.table-responsive { overflow-x: auto; margin-bottom: 2rem; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table th {
  text-align: left;
  padding: 0.75rem;
  background: var(--navy);
  color: var(--white);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.8125rem;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.data-table th small {
  display: block;
  font-weight: 400;
  font-size: 0.6875rem;
  opacity: 0.7;
  letter-spacing: 0;
  margin-top: 2px;
}
.data-table td {
  padding: 0.75rem;
  border-bottom: 1px solid rgba(26,26,46,0.08);
}
.data-table tbody tr:nth-child(even) { background: rgba(255,250,241,0.6); }
/* Default hover: tables that ARE interactive (district scorecard, slowest
   projects). Excluded by ID below for tables that aren't clickable, so the
   hover cue doesn't lie. */
.data-table tbody tr:hover { background: var(--violet-wash); }
#income-table tbody tr:hover { background: transparent; }

.row-stalled td { border-left: 4px solid var(--pink); }
.status-on-pace { color: var(--deep-violet); font-weight: 600; }
.status-behind { color: var(--pink); font-weight: 600; }

.loading-cell { text-align: center; color: #888; padding: 2rem !important; }

/* Highlight D8 in table */
.district-highlight {
  border: 2px solid var(--deep-violet);
  border-radius: 6px;
}

/* === Map === */
.map-layout {
  display: flex;
  gap: 1rem;
  position: relative;
}
.map-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--white);
  border: 1px solid rgba(26,26,46,0.08);
  border-radius: 8px;
  padding: 1rem;
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  max-height: 600px;
  overflow-y: auto;
  position: relative;
}
.map-sidebar h3 {
  font-size: 0.9375rem;
  margin-bottom: 0.75rem;
}
.map-sidebar fieldset {
  border: none;
  margin-bottom: 1rem;
}
.map-sidebar legend {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
  color: var(--deep-violet);
}
.map-sidebar label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 0.375rem;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 0.8125rem;
}

/* Map legend dots — match the actual Leaflet marker fill colors in app.js */
.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 1px rgba(26, 26, 46, 0.15);
}
.dot-completed { background: #5A2FB0; }    /* deep violet — matches statusColor('completed') and chart's Completed bars */
.dot-construction { background: #FF6100; } /* orange — actively building */
.dot-progress { background: #BF9CFF; }     /* soft violet — pre-construction stages */
.dot-stalled { background: #F4356C; }      /* pink — stalled override */

.legend-note {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(26, 26, 46, 0.08);
  font-size: 0.75rem;
  color: #5a5563;
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  gap: 0.375rem;
}
.legend-note .dot { margin-top: 0.2rem; }
.sidebar-toggle-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  display: none;
}
.sidebar-toggle {
  display: none;
  padding: 0.5rem 1rem;
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  font-weight: 600;
  border: 1px solid #CCC;
  border-radius: 6px;
  background: var(--white);
  cursor: pointer;
  margin-bottom: 0.75rem;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.dot-green { background: var(--sky-blue); }
.dot-blue { background: var(--orange); }
.dot-amber { background: var(--soft-violet); }
.dot-coral { background: var(--pink); }

.map-main { flex: 1; min-width: 0; }
.map-container {
  width: 100%;
  height: 550px;
  border-radius: 8px;
  border: 1px solid rgba(26,26,46,0.08);
  background: #F0F0F0;
}
.map-footer {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: #888;
  margin-top: 0.5rem;
}
.map-loading {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  color: var(--deep-violet);
  font-weight: 600;
}
.loading-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--orange);
  display: inline-block;
  animation: loading-pulse 1.2s ease-in-out infinite;
}
.loading-dot:nth-child(2) { animation-delay: 0.15s; }
.loading-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes loading-pulse {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
  40%           { opacity: 1;    transform: scale(1.15); }
}

/* === District Scorecard — bar-list layout (replaced the table) ===
   Sorted by pipeline-size desc, each row leads with a horizontal bar so the
   relative scale is immediately legible (cf. 501 Voices' Top-N speakers list). */
.district-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid rgba(26,26,46,0.08);
}
.district-row {
  padding: 1.25rem 0;
  border-bottom: 1px solid rgba(26,26,46,0.08);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  transition: background 0.15s;
  outline: none;
}
.district-row:hover { background: rgba(255, 97, 0, 0.035); }
.district-row:focus-visible { background: rgba(255, 97, 0, 0.06); }
.district-row.is-d8 .dr-name { color: var(--deep-violet); }

.dr-head {
  display: flex;
  align-items: baseline;
  gap: 0.875rem;
  flex-wrap: wrap;
}
.dr-name {
  font-family: var(--font-heading);
  font-size: 1.1875rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.02em;
  color: var(--dark-text);
}
.dr-neighborhoods {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: #6a6275;
  margin: 0;
}

.dr-bar-row {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.dr-bar {
  flex: 1;
  height: 10px;
  background: rgba(26,26,46,0.06);
  border-radius: 5px;
  overflow: hidden;
}
.dr-bar-fill {
  display: block;
  height: 100%;
  background: var(--orange);
  border-radius: 5px;
  transition: width 0.4s ease-out;
}
.dr-bar-readout {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  min-width: 130px;
  justify-content: flex-end;
}
.dr-bar-num {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--dark-text);
  font-variant-numeric: tabular-nums;
}
.dr-bar-label {
  font-family: var(--font-ui);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #6a6275;
  font-weight: 600;
}

.dr-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2.25rem;
  margin: 0.375rem 0 0;
}
.dr-stat {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}
.dr-stat dt {
  font-family: var(--font-ui);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--deep-violet);
  font-weight: 600;
  margin: 0;
}
.dr-stat dd {
  font-family: var(--font-heading);
  font-weight: 700;
  margin: 0;
  font-size: 0.9375rem;
  color: var(--dark-text);
  font-variant-numeric: tabular-nums;
}
.vs-city {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-left: 0.375rem;
}
.vs-city.slower { color: var(--pink); }
.vs-city.faster { color: var(--deep-violet); }

/* (Old .tab-story callout removed — story content now lives inline as
   the panel-lede, so we have one cohesive intro per section instead of
   header + box + chart-stat all competing.) */

/* Bottleneck controls — district picker spacing without a panel-header wrap */
.bottleneck-controls {
  margin-bottom: clamp(1.5rem, 3vw, 2.25rem);
}

/* === Timeline Visual === */
.timeline-section {
  margin: 2rem 0;
  padding: 1.5rem;
  background: var(--white);
  border: 1px solid rgba(26,26,46,0.08);
  border-radius: 12px;
}
.timeline-section h3 {
  margin-bottom: 0.25rem;
  font-size: clamp(18px, 2.2vw, 22px);
}
.timeline-subtitle {
  font-size: 0.875rem;
  color: #666;
  margin-bottom: 1.5rem;
}
.timeline-track {
  margin-bottom: 1.25rem;
}
.timeline-track-label {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.8125rem;
  margin-bottom: 0.375rem;
  color: var(--dark-text);
}
.timeline-n {
  font-weight: 400;
  font-size: 0.75rem;
  color: #999;
  margin-left: 0.5rem;
}
.timeline-bars {
  display: flex;
  height: 36px;
  border-radius: 6px;
  overflow: hidden;
  background: #E8E4DF;
}
.timeline-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--white);
  transition: width 0.6s ease;
  min-width: 0;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}
.timeline-bar .bar-label {
  padding: 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Timeline stages — brand spectrum: bureaucracy (dark) → completion (action) */
.timeline-bar-planning     { background: var(--navy); }
.timeline-bar-entitlement  { background: var(--deep-violet); }
.timeline-bar-permit       { background: var(--soft-violet); color: var(--navy); }
.timeline-bar-issue        { background: var(--orange); color: var(--navy); }
.timeline-bar-preconstruct { background: var(--pink); }
.timeline-bar-construction { background: var(--sky-blue); color: var(--navy); }

.timeline-track-total {
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--dark-text);
  margin-top: 0.25rem;
  text-align: right;
}
.timeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: #555;
}
.timeline-legend-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.timeline-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
.timeline-callout {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(244,53,108,0.06);
  border-left: 3px solid var(--pink);
  border-radius: 0 6px 6px 0;
  font-size: 0.8125rem;
  color: #555;
  line-height: 1.6;
}

/* === Table Controls === */
.table-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
  align-items: center;
}
.table-control-group {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-family: var(--font-ui);
  font-size: 0.8125rem;
}
.table-control-group label {
  font-weight: 500;
  color: #555;
  white-space: nowrap;
}
.table-control-select {
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  padding: 0.3rem 0.625rem;
  border: 1px solid #CCC;
  border-radius: 6px;
  background: var(--white);
  color: var(--dark-text);
}
.show-more-btn {
  display: block;
  margin: 0.75rem auto 0;
  padding: 0.5rem 1.5rem;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--white);
  background: var(--sky-blue);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.show-more-btn:hover {
  background: #3A87C4;
}

/* === Methodology === */
.methodology {
  padding: 2rem 0;
  border-top: 1px solid rgba(26,26,46,0.08);
}
.methodology details { margin-bottom: 1rem; }
.methodology summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.methodology summary::-webkit-details-marker { display: none; }
.methodology summary::before {
  content: '\25B8';
  font-size: 1rem;
  transition: transform 0.2s;
  color: var(--deep-violet);
}
.methodology details[open] summary::before { transform: rotate(90deg); }
.inline-heading {
  display: inline;
  font-size: 1.25rem;
  margin: 0;
}
.methodology-content {
  padding: 1rem 0 0 1.5rem;
  font-size: 0.9375rem;
  line-height: 1.7;
}
.methodology-content h3 {
  font-size: 1rem;
  margin: 1.5rem 0 0.5rem;
  color: var(--deep-violet);
}
.methodology-content ul {
  margin-left: 1rem;
  margin-bottom: 1rem;
}
.methodology-content li { margin-bottom: 0.25rem; }

/* === Footer === */
.site-footer {
  background: var(--navy);
  color: rgba(255,255,255,0.6);
  padding: 1.5rem 0;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  text-align: center;
  line-height: 1.8;
}
.site-footer a { color: var(--white); }

/* === Loading Overlay === */
.loading-overlay[hidden] { display: none; }
.loading-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,250,241,0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #E8E4DF;
  border-top-color: var(--deep-violet);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay p {
  margin-top: 1rem;
  font-family: var(--font-ui);
  color: #555;
  font-size: 0.875rem;
}

/* === Tooltips === */
.tooltip-trigger {
  border-bottom: 1px dashed #999;
  cursor: help;
  position: relative;
}
.tooltip-trigger .tooltip-text {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: var(--white);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  line-height: 1.4;
  width: max-content;
  max-width: 260px;
  z-index: 200;
  transition: opacity 0.2s;
  pointer-events: none;
}
.tooltip-trigger:hover .tooltip-text,
.tooltip-trigger:focus .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* Unavailable section fallback */
.section-unavailable {
  text-align: center;
  padding: 3rem 1rem;
  color: #888;
  font-size: 0.9375rem;
}

/* Leaflet popup override */
.leaflet-popup-content {
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  line-height: 1.5;
}
.leaflet-popup-content strong { color: var(--dark-text); }
.popup-stalled { color: var(--pink); font-weight: 600; }
.popup-asof {
  display: inline-block;
  margin-top: 0.5rem;
  font-style: italic;
  font-size: 0.75rem;
  color: #777;
}

/* Table footnote — explains methodology under data tables */
/* Table subtitle — context line above tables */
.table-subtitle {
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.5;
  color: #4a4555;
  margin-top: 0.5rem;
  margin-bottom: 1.5rem;
  max-width: 60ch;
}

/* Income table h3 — give it room and confidence */
.table-responsive h3 {
  font-family: var(--font-heading);
  font-size: clamp(1.5rem, 2.6vw, 1.875rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  margin: 2rem 0 0.25rem;
  color: var(--dark-text);
}

/* Income-table % cell — bar visualization with on-pace marker */
.pct-cell { min-width: 220px; padding: 0.875rem 1rem; }
.pct-cell-inner {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}
.pct-bar {
  position: relative;
  flex: 1;
  height: 12px;
  background: rgba(26, 26, 46, 0.06);
  border-radius: 6px;
  overflow: visible;
  min-width: 100px;
}
.pct-bar-fill {
  display: block;
  height: 100%;
  border-radius: 6px;
  transition: width 0.4s ease-out;
}
.pct-bar-marker {
  /* Vertical pip showing where 'on pace' would be at this point in the
     cycle. Reads as: 'we're filling toward this benchmark.' */
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: rgba(26, 26, 46, 0.35);
  border-radius: 1px;
  transform: translateX(-1px);
  pointer-events: none;
}
.pct-readout {
  font-family: var(--font-heading);
  font-size: 0.9375rem;
  font-weight: 800;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  min-width: 80px;
  text-align: right;
}
.pct-readout.status-on-pace { color: var(--deep-violet); }
.pct-readout.status-behind { color: var(--pink); }

.totals-row td {
  border-top: 2px solid var(--dark-text);
  padding-top: 1rem;
  font-family: var(--font-heading);
}

/* Bigger, more readable footnote text under tables */
.table-footnote + .table-footnote { margin-top: 1rem; }
.table-footnote {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.55;
  color: #4a4555;
  margin-top: 1.25rem;
  max-width: 70ch;
}
.table-footnote strong { color: var(--deep-violet); }

/* === Responsive: Tablet === */
@media (min-width: 768px) {
  .district-grid { grid-template-columns: 1fr 1fr; }
}

/* === Responsive: Desktop === */
@media (min-width: 1024px) {
  .district-grid { grid-template-columns: 1fr 1fr 1fr; }
}

/* === Responsive: Mobile === */
@media (max-width: 767px) {
  .tab { padding: 0.75rem 0.875rem; font-size: 0.75rem; }
  .tab-icon { display: none; }
  .map-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    z-index: 500;
    border-radius: 0;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 4px 0 16px rgba(0,0,0,0.15);
  }
  .map-sidebar.open { transform: translateX(0); }
  .sidebar-toggle-close { display: block; }
  .sidebar-toggle { display: block; }
  .map-container { height: 400px; }
  .data-table { font-size: 0.8125rem; }
  .data-table th, .data-table td { padding: 0.5rem; }
  .panel-header { flex-direction: column; align-items: flex-start; }
  /* Hide less essential columns on mobile */
  .hide-mobile { display: none; }
}

/* ── Review attribution: which desk has the file ──────────────────────── */
.review-deep { margin: 2.5rem 0 1rem; }
.review-deep h3 { margin-top: 2.25rem; }
.review-lede {
  max-width: 68ch;
  margin: 0.5rem 0 1.1rem;
  color: var(--dark-text);
  line-height: 1.55;
}
.chart-footnote {
  max-width: 72ch;
  margin: 0.6rem 0 0.4rem;
  font-size: 0.8125rem;
  color: #6a6275;
  line-height: 1.5;
}

/* Horizontal bar list (funnel + longest-stop). Identity lives in the ink
   label; the fill carries magnitude only. */
.hbar-list { margin: 0.75rem 0 0.25rem; }
.hbar-row {
  display: grid;
  grid-template-columns: minmax(150px, 220px) 1fr 110px;
  align-items: center;
  gap: 0.75rem;
  padding: 0.3rem 0;
}
.hbar-label { font-size: 0.875rem; color: var(--dark-text); line-height: 1.25; }
.hbar-sub { display: block; font-size: 0.75rem; color: #6a6275; }
.hbar-track { background: rgba(26,26,46,0.06); border-radius: 4px; height: 18px; }
.hbar-fill {
  height: 100%;
  min-width: 3px;
  background: var(--deep-violet);
  border-radius: 4px;
}
.hbar-fill-highlight { background: var(--orange); }
.hbar-value { font-size: 0.8125rem; color: var(--dark-text); white-space: nowrap; }
.station-details { margin: 0.9rem 0 0.4rem; }
.station-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--deep-violet);
  margin-bottom: 0.5rem;
}
.station-code { font-size: 0.72rem; color: #6a6275; letter-spacing: 0.03em; }

/* Planning SLA stage rows */
.sla-stages { margin: 0.75rem 0 1.25rem; }
.sla-stage-row {
  display: grid;
  grid-template-columns: minmax(150px, 230px) minmax(160px, 240px) 1fr 130px;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(26,26,46,0.07);
}
.sla-stage-name { font-size: 0.875rem; color: var(--dark-text); }
.sla-stage-days { font-size: 0.8125rem; color: #6a6275; }
.sla-stage-meter { background: rgba(26,26,46,0.06); border-radius: 4px; height: 12px; }
.sla-stage-meter-fill {
  height: 100%;
  min-width: 3px;
  background: var(--deep-violet);
  border-radius: 4px;
}
.sla-stage-over { font-size: 0.8125rem; color: var(--dark-text); white-space: nowrap; }
.sla-trend-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--dark-text);
  margin: 0.75rem 0 0.4rem;
}

/* Year bar strips (SLA trend + issuance trend) */
.year-bars {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  height: 120px;
  margin: 0.25rem 0 0.5rem;
  padding-bottom: 1.4rem;
  position: relative;
}
.year-bars-tall { height: 150px; }
.year-bar-col {
  flex: 1;
  max-width: 84px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  position: relative;
}
.year-bar {
  width: 100%;
  background: var(--deep-violet);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
}
.year-bar-good { background: var(--orange); }
.year-bar-thin .year-bar { opacity: 0.35; }
.year-bar-pct { font-size: 0.75rem; color: var(--dark-text); margin-bottom: 2px; }
.year-bar-thin .year-bar-pct { color: #9a94a3; }
.year-bar-label {
  position: absolute;
  bottom: -1.4rem;
  font-size: 0.75rem;
  color: #6a6275;
}

@media (max-width: 640px) {
  .hbar-row { grid-template-columns: minmax(110px, 140px) 1fr 84px; gap: 0.5rem; }
  .sla-stage-row { grid-template-columns: 1fr 1fr; row-gap: 0.25rem; }
  .sla-stage-meter { grid-column: 1 / 2; }
  .sla-stage-over { grid-column: 2 / 3; }
  .year-bars { gap: 0.35rem; }
  .year-bar-pct { font-size: 0.68rem; }
  .year-bar-label { font-size: 0.68rem; }
}

/* Map tab lede */
.map-lede { margin: 0 0 1rem; max-width: 72ch; }
