:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --bg-grad: radial-gradient(
      1100px 600px at 12% -10%,
      rgba(99, 102, 241, 0.18),
      transparent 70%
    ),
    radial-gradient(
      900px 500px at 100% 0%,
      rgba(14, 165, 233, 0.14),
      transparent 70%
    ),
    var(--bg);
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #0f172a;
  --ink-2: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --accent-strong: #4338ca;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --green: #047857;
  --green-soft: #d1fae5;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04),
    0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px -8px rgba(15, 23, 42, 0.18),
    0 4px 10px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 30px 60px -25px rgba(15, 23, 42, 0.35),
    0 12px 25px -10px rgba(15, 23, 42, 0.18);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--bg-grad);
  color: var(--ink);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

a:hover {
  text-decoration: underline;
}

code {
  background: #eef2f7;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 0.85em;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #4f46e5 0%, #0ea5e9 100%);
  color: white;
  font-weight: 800;
  letter-spacing: 0.05em;
  font-size: 0.95rem;
  box-shadow: var(--shadow-md);
}

.brand-eyebrow {
  margin: 0;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-weight: 700;
}

.brand-title {
  margin: 2px 0 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.brand-year-tag {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, #4f46e5 0%, #0ea5e9 100%);
  color: white;
  text-transform: uppercase;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

.tabs {
  display: flex;
  gap: 4px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.tab {
  border: 0;
  background: transparent;
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--muted);
  transition: background 0.15s, color 0.15s, transform 0.05s;
}

.tab:hover {
  color: var(--ink);
}

.tab.active {
  background: white;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* ---------- Layout ---------- */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.tab-panel {
  display: none;
  animation: fadeIn 0.25s ease both;
}

.tab-panel.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Hero / Search ---------- */
.hero {
  text-align: center;
  margin: 24px auto 28px;
  max-width: 760px;
}

.hero-title {
  margin: 0 0 14px;
  font-size: clamp(2rem, 4.4vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
  font-weight: 700;
}

.hero-accent {
  background: linear-gradient(135deg, #4f46e5, #0ea5e9);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-family: "Instrument Serif", "Inter", serif;
  font-style: italic;
  font-weight: 400;
  padding: 0 4px;
}

.hero-sub {
  margin: 0 auto;
  max-width: 540px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
}

.boundary-banner {
  margin: 18px auto 0;
  max-width: 640px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.08), rgba(14, 165, 233, 0.08));
  border: 1px solid rgba(79, 70, 229, 0.2);
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 0.86rem;
  text-align: left;
  line-height: 1.45;
}

.boundary-banner strong {
  color: var(--ink);
  font-weight: 700;
}

.boundary-banner-tag {
  background: white;
  color: var(--accent-strong);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid rgba(79, 70, 229, 0.25);
  white-space: nowrap;
  flex-shrink: 0;
}

.search-card {
  margin: 28px auto 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 18px;
  text-align: left;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr 140px auto;
  gap: 12px;
  align-items: end;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
  padding-left: 4px;
}

.field input {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel-soft);
  font-size: 1rem;
  transition: border 0.15s, box-shadow 0.15s, background 0.15s;
  outline: none;
}

.field input::placeholder {
  color: #94a3b8;
}

.field input:hover {
  border-color: var(--line-strong);
}

.field input:focus {
  border-color: var(--accent);
  background: white;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
}

.combo {
  position: relative;
}

.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  list-style: none;
  margin: 0;
  padding: 6px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  z-index: 10;
  display: none;
}

.suggestions.open {
  display: block;
}

.suggestions li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.95rem;
}

.suggestions li:hover,
.suggestions li.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.suggestions .suggest-tag {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.suggestions li.active .suggest-tag,
.suggestions li:hover .suggest-tag {
  color: var(--accent);
}

.btn-clear {
  height: 50px;
  padding: 0 18px;
  border-radius: var(--radius);
  background: var(--panel-soft);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-weight: 600;
  transition: background 0.15s, transform 0.05s;
}

.btn-clear:hover {
  background: white;
  border-color: var(--line-strong);
}

/* ---------- Answer card ---------- */
.answer {
  margin: 28px auto 0;
  max-width: 820px;
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: fadeIn 0.2s ease both;
}

.answer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  background: linear-gradient(135deg, var(--school-color, #4f46e5), #1e293b);
  color: white;
}

.answer-head .pill {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.answer-head h3 {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
}

.answer-head p {
  margin: 4px 0 0;
  opacity: 0.85;
  font-size: 0.92rem;
}

.answer-body {
  padding: 22px 24px;
}

.assignment-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.assignment-cell {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--panel-soft);
}

.assignment-cell .assign-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.assignment-cell .assign-school {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
}

.school-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--school-color, #4f46e5);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.answer-meta {
  margin-top: 16px;
  display: grid;
  gap: 8px;
  font-size: 0.92rem;
  color: var(--muted);
}

.answer-meta strong {
  color: var(--ink-2);
}

.answer-actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-primary,
.btn-ghost {
  border: 1px solid var(--line);
  background: white;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.15s, border 0.15s, transform 0.05s;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-strong);
}

.btn-ghost:hover {
  background: var(--panel-soft);
  border-color: var(--line-strong);
}

.btn-mini {
  padding: 6px 10px;
  font-size: 0.78rem;
  white-space: nowrap;
}

/* ---------- Redistricting alert (Lookup answer) ---------- */
.redistrict-banner {
  margin: 0 0 16px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #fff7ed 0%, #fef2f2 100%);
  border: 1px solid #fecaca;
  border-left: 5px solid #dc2626;
  border-radius: var(--radius);
  color: #7f1d1d;
  box-shadow: 0 1px 2px rgba(220, 38, 38, 0.06);
}

.redistrict-banner-soft {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1px solid #fde68a;
  border-left: 5px solid #d97706;
  color: #78350f;
  box-shadow: 0 1px 2px rgba(217, 119, 6, 0.06);
}

.redistrict-banner-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.redistrict-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: #dc2626;
  color: white;
  border-radius: 999px;
  white-space: nowrap;
}

.redistrict-tag::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
  animation: redistrict-pulse 1.6s ease-in-out infinite;
}

.redistrict-tag-soft {
  background: #d97706;
}

@keyframes redistrict-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7); }
  50% { box-shadow: 0 0 0 6px rgba(255, 255, 255, 0); }
}

.redistrict-banner-addr {
  font-size: 0.85rem;
  font-weight: 600;
  color: #7f1d1d;
  opacity: 0.85;
}

.redistrict-banner-soft .redistrict-banner-addr {
  color: #78350f;
}

.redistrict-lead {
  margin: 0 0 10px;
  font-size: 0.92rem;
  line-height: 1.45;
}

.redistrict-rows {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.redistrict-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(220, 38, 38, 0.15);
  border-radius: 8px;
  font-size: 0.9rem;
  flex-wrap: wrap;
}

.redistrict-row-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #7f1d1d;
  background: #fee2e2;
  padding: 2px 7px;
  border-radius: 999px;
}

.redistrict-from {
  color: #6b7280;
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  text-decoration-color: rgba(220, 38, 38, 0.4);
}

.redistrict-arrow {
  color: #dc2626;
  font-weight: 700;
  font-size: 1rem;
}

.redistrict-to {
  color: var(--ink-2);
  font-weight: 700;
  position: relative;
  padding-left: 14px;
}

.redistrict-to::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--school-color, #dc2626);
  transform: translateY(-50%);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
}

.redistrict-foot {
  margin: 0;
  font-size: 0.75rem;
  color: rgba(127, 29, 29, 0.7);
}

.redistrict-banner-soft .redistrict-foot {
  color: rgba(120, 53, 15, 0.7);
}

/* ---------- Lookup inline minimap ---------- */
.answer-minimap-wrap {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  overflow: hidden;
}

.answer-minimap-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: white;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
  flex-wrap: wrap;
}

.answer-minimap-head strong {
  color: var(--ink-2);
  font-weight: 700;
}

.answer-minimap-note {
  margin-top: 2px;
  font-size: 0.78rem;
}

.answer-minimap {
  height: 240px;
  width: 100%;
  background: #f1f5f9;
  position: relative;
  transition: filter 0.15s ease;
}

.answer-minimap:hover {
  filter: brightness(1.04) saturate(1.06);
}

.answer-minimap::after {
  content: "Click to expand";
  position: absolute;
  top: 8px;
  right: 10px;
  background: rgba(15, 23, 42, 0.78);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
  pointer-events: none;
  letter-spacing: 0.02em;
  z-index: 500;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.answer-minimap:hover::after {
  opacity: 1;
  transform: translateY(0);
}

.answer-minimap.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.answer-minimap-empty {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.answer-minimap-foot {
  margin: 0;
  padding: 8px 14px 10px;
  font-size: 0.78rem;
  background: var(--panel-soft);
  border-top: 1px solid var(--line);
}

/* Hide tile attribution inside the minimap (the wrap already credits
   the source via the rest of the UI; the popup-attribution badge feels
   noisy at this size). */
.answer-minimap .leaflet-control-attribution {
  display: none;
}

/* ---------- Full-map spotlight (highlighted address) ---------- */
.parcel-spotlight-shape {
  animation: parcel-spotlight-pulse 1.6s ease-in-out infinite;
  filter: drop-shadow(0 0 6px rgba(250, 204, 21, 0.85));
}

@keyframes parcel-spotlight-pulse {
  0%, 100% {
    stroke-opacity: 1;
    fill-opacity: 0.6;
  }
  50% {
    stroke-opacity: 0.6;
    fill-opacity: 0.85;
  }
}

.parcel-spotlight-pin {
  pointer-events: none;
}

.parcel-spotlight-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #facc15;
  border: 3px solid #92400e;
  box-shadow: 0 0 0 6px rgba(250, 204, 21, 0.45),
    0 0 0 12px rgba(250, 204, 21, 0.18);
  animation: parcel-spotlight-dot 1.6s ease-in-out infinite;
}

@keyframes parcel-spotlight-dot {
  0%, 100% {
    box-shadow: 0 0 0 6px rgba(250, 204, 21, 0.45),
      0 0 0 12px rgba(250, 204, 21, 0.18);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(250, 204, 21, 0.55),
      0 0 0 20px rgba(250, 204, 21, 0.05);
  }
}

.parcel-spotlight-label {
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: #0f172a;
  color: white;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.35);
}

.split-warning {
  margin-top: 16px;
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  background: var(--amber-soft);
  color: var(--amber);
  border-radius: var(--radius);
  font-size: 0.92rem;
  border: 1px solid #fde68a;
}

.split-options {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.split-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.split-option .school-dot {
  width: 10px;
  height: 10px;
}

.split-option strong {
  flex: 1;
}

.split-option .range-tag {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: white;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--ink-2);
}

/* ---------- Stats ---------- */
.quick-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 36px;
}

.stat {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.stat strong {
  display: block;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.stat span {
  color: var(--muted);
  font-size: 0.86rem;
}

.stat.amber strong {
  color: var(--amber);
}

.stat.blue strong {
  color: var(--accent);
}

/* ---------- Recent ---------- */
.recent {
  margin-top: 36px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-header h2,
.section-header h3 {
  margin: 0;
  letter-spacing: -0.01em;
}

.section-header h2 {
  font-size: 1.6rem;
}

.section-header h3 {
  font-size: 1rem;
}

.link {
  background: transparent;
  border: 0;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 4px 8px;
  border-radius: 8px;
}

.link:hover {
  background: var(--accent-soft);
}

.recent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.recent-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 8px 10px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border 0.15s;
}

.recent-chip:hover {
  background: var(--panel-soft);
  border-color: var(--line-strong);
}

.inline-search {
  width: 240px;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: white;
  font-size: 0.9rem;
}

.inline-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
}

/* ---------- Map ---------- */
.map-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  height: calc(100vh - 220px);
  min-height: 520px;
}

.map-legend {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  overflow-y: auto;
  box-shadow: var(--shadow-sm);
}

.map-legend h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.map-legend > p {
  margin: 0 0 14px;
  font-size: 0.85rem;
}

.year-toggle-wrap {
  display: grid;
  gap: 8px;
  padding: 12px;
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.year-toggle-wrap[hidden] {
  display: none;
}

.year-toggle-label {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.year-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}

.year-pill {
  border: 0;
  background: transparent;
  padding: 7px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.01em;
  transition: background 0.15s, color 0.15s;
}

.year-pill:hover {
  color: var(--ink);
}

.year-pill.active {
  background: linear-gradient(135deg, #4f46e5 0%, #0ea5e9 100%);
  color: white;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.15);
}

.changes-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}

.changes-toggle input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}

.year-toggle-meta {
  margin: 0;
  font-size: 0.74rem;
  line-height: 1.45;
}

.year-toggle-meta strong {
  color: var(--ink-2);
  font-weight: 700;
}

.legend-item {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, border 0.15s;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  font: inherit;
  color: inherit;
}

.legend-item:hover {
  background: var(--panel-soft);
  border-color: var(--line);
}

.legend-item.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.legend-item.active .legend-count {
  color: var(--accent-strong);
}

.legend-item .school-dot {
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

.legend-item .legend-name {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
}

.legend-item .legend-count {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.map-wrap {
  position: relative;
  height: 100%;
}

.map {
  height: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  background: #f1f5f9;
}

.map-reset {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1000;
  padding: 9px 14px;
  border: 0;
  border-radius: 999px;
  background: white;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 0.85rem;
  box-shadow: var(--shadow-md);
  transition: background 0.15s, transform 0.05s;
}

.map-reset:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.popup-zone-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 7px 12px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.popup-zone-btn:hover {
  background: var(--accent-strong);
}

.zone-notice {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  max-width: min(420px, calc(100% - 32px));
  padding: 10px 16px;
  background: rgba(15, 23, 42, 0.92);
  color: white;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  text-align: center;
}

.zone-notice.hidden {
  display: none;
}

.leaflet-tooltip.street-name-tooltip {
  background: rgba(15, 23, 42, 0.92);
  color: #f8fafc;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.25);
}

.leaflet-tooltip.street-name-tooltip::before {
  border-top-color: rgba(15, 23, 42, 0.92);
}

.leaflet-tooltip.parcel-change-tooltip {
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.45;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}

.leaflet-tooltip.parcel-change-tooltip::before {
  border-top-color: var(--line);
}

.leaflet-tooltip.parcel-change-tooltip strong {
  display: block;
  font-weight: 700;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}

.leaflet-tooltip.parcel-change-tooltip .change-arrow {
  display: inline-block;
  margin: 0 6px;
  color: var(--muted);
  font-weight: 700;
}

.school-marker {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 800;
  font-size: 0.78rem;
  border: 3px solid white;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.4);
}

.leaflet-popup-content-wrapper {
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}

.leaflet-popup-content {
  margin: 14px 16px;
  font-family: "Inter", sans-serif;
}

.popup-title {
  font-weight: 700;
  font-size: 1rem;
  margin: 0 0 4px;
}

.popup-meta {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.popup-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.85rem;
}

/* ---------- Per-parcel multi-source popup ---------- */
.parcel-multi-source-popup .leaflet-popup-content {
  margin: 12px 14px;
  min-width: 280px;
  max-width: 360px;
}

.parcel-popup .popup-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin: 0 0 2px;
}

.parcel-popup .popup-meta {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.parcel-popup .popup-change-banner {
  background: #fef3c7;
  color: #78350f;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.74rem;
  font-weight: 600;
  margin: 0 0 8px;
}

.parcel-popup .popup-sources {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.parcel-popup .popup-sources th,
.parcel-popup .popup-sources td {
  padding: 4px 6px;
  vertical-align: top;
  text-align: left;
  border-bottom: 1px solid #f1f5f9;
}

.parcel-popup .popup-sources th {
  font-weight: 600;
  color: var(--muted);
  width: 38%;
  white-space: nowrap;
}

.parcel-popup .popup-sources tr.src-redistricted td {
  color: #b45309;
  font-weight: 600;
}

.parcel-popup .popup-sources tr.src-zillow th,
.parcel-popup .popup-sources tr.src-redfin th {
  font-style: italic;
}

.parcel-popup .popup-section-title {
  margin: 10px 0 4px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.parcel-popup .popup-listings {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.parcel-popup .popup-listings th,
.parcel-popup .popup-listings td {
  padding: 3px 6px;
  text-align: left;
  border-bottom: 1px solid #f1f5f9;
}

.parcel-popup .popup-listings th {
  color: var(--muted);
  font-weight: 600;
}

.parcel-popup .popup-listings a {
  color: #2563eb;
  text-decoration: none;
}

.parcel-popup .popup-listings a:hover {
  text-decoration: underline;
}

/* ---------- Schools tab ---------- */
.school-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.school-card {
  display: block;
  width: 100%;
  text-align: left;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border 0.18s;
  cursor: pointer;
}

.school-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--line-strong);
}

.school-card .swatch {
  height: 64px;
  background: linear-gradient(135deg, var(--school-color), #1e293b);
  position: relative;
}

.school-card .swatch .badge {
  position: absolute;
  bottom: -14px;
  left: 16px;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: white;
  display: grid;
  place-items: center;
  color: var(--school-color);
  font-weight: 800;
  font-size: 0.85rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
}

.school-card .body {
  padding: 24px 18px 18px;
}

.school-card h3 {
  margin: 0 0 4px;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.school-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.school-card .body strong {
  display: block;
  margin-top: 12px;
  font-size: 0.88rem;
  color: var(--ink-2);
}

.school-card .boundary-tag {
  display: inline-block;
  margin-top: 10px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.school-card .boundary-tag.new-zone {
  background: rgba(79, 70, 229, 0.12);
  color: var(--accent-strong);
  border: 1px solid rgba(79, 70, 229, 0.25);
}

.school-card .boundary-tag.preschool-only {
  background: var(--amber-soft);
  color: var(--amber);
  border: 1px solid #fde68a;
}

.boundary-note {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  border: 1px solid rgba(79, 70, 229, 0.2);
  color: var(--ink-2);
  font-size: 0.9rem;
  line-height: 1.5;
}

.boundary-note.preschool-only {
  background: var(--amber-soft);
  border-color: #fde68a;
  color: #78350f;
}

.boundary-note strong {
  font-weight: 700;
}

.school-detail {
  margin-top: 24px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.school-detail-head {
  padding: 22px 24px;
  background: linear-gradient(135deg, var(--school-color), #1e293b);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.school-detail-head h3 {
  margin: 0;
  font-size: 1.4rem;
}

.school-detail-head .pill {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.school-detail-body {
  padding: 22px 24px;
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

.detail-meta strong {
  display: block;
  color: var(--ink-2);
  font-size: 0.95rem;
}

.detail-streets {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.detail-streets h4 {
  margin: 0 0 12px;
  font-size: 0.95rem;
}

.street-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px;
  font-size: 0.9rem;
  color: var(--ink-2);
}

.street-list span {
  padding: 4px 0;
}

.street-list .split-flag {
  margin-left: 6px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 8px;
}

/* ---------- Splits tab ---------- */
.splits-list {
  display: grid;
  gap: 14px;
}

.split-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.split-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.split-card-head h3 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.split-card-head .pill {
  background: var(--amber-soft);
  color: var(--amber);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 4px 10px;
}

.split-segments {
  display: grid;
  gap: 8px;
}

.split-segment {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.split-segment .school-dot {
  width: 10px;
  height: 10px;
}

.split-segment .seg-label {
  flex: 1;
  font-weight: 600;
  font-size: 0.92rem;
}

.split-segment .seg-range {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px 8px;
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 40px 24px;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 16px;
  }

  .tabs {
    overflow-x: auto;
    justify-content: flex-start;
  }

  main {
    padding: 24px 16px 60px;
  }

  .search-row {
    grid-template-columns: 1fr;
  }

  .field-num {
    grid-row: 2;
  }

  .btn-clear {
    width: 100%;
  }

  .quick-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .assignment-grid {
    grid-template-columns: 1fr;
  }

  .map-shell {
    grid-template-columns: 1fr;
    height: auto;
  }

  .map {
    height: 460px;
  }

  .map-legend {
    max-height: 320px;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .inline-search {
    width: 100%;
  }
}
