:root {
  color-scheme: light;
  --navy-950: #071829;
  --navy-900: #0d2944;
  --navy-800: #17456c;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --paper: #ffffff;
  --canvas: #eaf0f6;
  --focus: #1976d2;
  --safe: #16784b;
  --favourable: #66b96b;
  --battleground: #efaa28;
  --difficult: #c84545;
  --shadow: 0 18px 44px rgba(7, 24, 41, 0.16);
  --soft-shadow: 0 8px 24px rgba(15, 42, 69, .08);
}

* { box-sizing: border-box; }

html, body { height: 100%; min-height: 100%; }

body {
  height: 100dvh;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--navy-950);
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}

button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, .constituency:focus-visible {
  outline: 3px solid rgba(15, 111, 255, 0.45);
  outline-offset: 2px;
}

.topbar {
  flex: 0 0 auto;
  min-height: 82px;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: white;
  background:
    radial-gradient(circle at 82% -40%, rgba(53, 168, 211, .28), transparent 38%),
    linear-gradient(125deg, #061625 0%, #0d2d4b 58%, #124d70 100%);
  border-bottom: 1px solid rgba(255,255,255,.13);
  box-shadow: 0 8px 28px rgba(4, 19, 32, .2);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 280px; }
.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 15px;
  background: linear-gradient(145deg, rgba(255,255,255,.2), rgba(255,255,255,.07));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 8px 20px rgba(0,0,0,.16);
  font-weight: 800;
  letter-spacing: .04em;
}
.brand-eyebrow { display: block; margin-bottom: 2px; color: #8fc7e2; font-size: .66rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.brand h1 { margin: 0; font-size: 1.2rem; line-height: 1.2; letter-spacing: -.02em; }
.brand p { margin: 3px 0 0; color: #cbdbea; font-size: .82rem; }

.state-summary { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.summary-pill {
  min-width: 88px;
  padding: 7px 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 12px;
  background: rgba(3, 15, 29, .32);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.summary-pill .dot { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255,255,255,.18); }
.summary-pill strong { font-size: 1rem; line-height: 1; }
.summary-pill small { display: block; margin-top: 2px; color: #cbdbea; font-size: .7rem; }

.workspace {
  min-height: 0;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 352px minmax(0, 1fr);
  overflow: hidden;
}

.filters {
  min-height: 0;
  padding: 22px 19px 28px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  background: linear-gradient(180deg, #f8fafc 0%, #f2f6fa 100%);
  border-right: 1px solid var(--slate-200);
}
.filters-heading { position: sticky; z-index: 35; top: -22px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: -2px -3px 18px; padding: 8px 3px 12px; background: rgba(248,250,252,.94); border-bottom: 1px solid rgba(203,213,225,.75); backdrop-filter: blur(10px); }
.eyebrow { display: block; margin-bottom: 3px; color: var(--slate-500); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; }
.filters h2 { margin: 0; font-size: 1.42rem; letter-spacing: -.035em; }
.text-button { padding: 4px 0; color: #1d5e94; background: transparent; border: 0; font-size: .83rem; font-weight: 700; }
.text-button:hover { text-decoration: underline; }

.field { position: relative; display: block; margin-bottom: 13px; }
.compact-field { margin-bottom: 0; }
.field > span { display: block; margin-bottom: 6px; color: var(--slate-700); font-size: .875rem; font-weight: 700; }
.field input, .field select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  color: var(--navy-950);
  background: white;
  border: 1px solid var(--slate-300);
  border-radius: 10px;
  font-size: .9rem;
  box-shadow: 0 1px 2px rgba(15,23,42,.025);
}
.field input:hover, .field select:hover { border-color: #94a3b8; }
.field input:focus, .field select:focus { border-color: var(--focus); }
.field select:disabled { color: #94a3b8; background: #f1f5f9; cursor: not-allowed; }
.field small { display: block; margin-top: 5px; color: var(--slate-500); font-size: .7rem; line-height: 1.35; }
.search-results {
  position: absolute;
  z-index: 50;
  top: 70px;
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  padding: 5px;
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: 9px;
  box-shadow: var(--shadow);
}
.search-result {
  width: 100%;
  padding: 9px 10px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--navy-950);
  background: transparent;
  border: 0;
  border-radius: 6px;
  text-align: left;
}
.search-result:hover { background: var(--slate-100); }
.search-result small { color: var(--slate-500); }
.filter-section {
  margin-top: 12px;
  padding: 15px;
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: 16px;
  box-shadow: var(--soft-shadow);
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.filter-section:hover { border-color: #bfd0dd; box-shadow: 0 11px 28px rgba(15,42,69,.1); }
.filter-accordion { padding: 0; }
.filter-accordion > summary { margin: 0; padding: 14px; list-style: none; cursor: pointer; user-select: none; }
.filter-accordion > summary::-webkit-details-marker { display: none; }
.filter-accordion > summary:focus-visible { outline: 3px solid rgba(25,118,210,.35); outline-offset: -3px; border-radius: 15px; }
.filter-accordion[open] > summary { margin-bottom: 13px; border-bottom: 1px solid var(--slate-100); }
.filter-section-body { padding: 0 14px 14px; }
.accordion-chevron { width: 28px; height: 28px; margin-left: auto; display: grid; place-items: center; flex: 0 0 auto; color: var(--navy-800); background: #edf4f8; border-radius: 9px; }
.accordion-chevron::before { content: "+"; font-size: 1.1rem; font-weight: 500; line-height: 1; }
.filter-accordion[open] .accordion-chevron::before { content: "−"; }
.primary-view { position: relative; overflow: hidden; background: linear-gradient(145deg, #eff7fd, #f8fbfe); border-color: #bdd8e9; }
.primary-view::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: linear-gradient(#1c83c5, #43b4c8); }
.mode-context { margin: 10px 1px 0; color: var(--slate-600); font-size: .73rem; line-height: 1.45; }
.population-filter { background: #f4f9fc; border-color: #d4e4ed; }
.dynamic-layers-filter { background: linear-gradient(145deg, #f1f8fb, #ffffff); border-color: #badbe6; }
.dynamic-layers-filter .field:last-child { margin-bottom: 0; }
.history-filter { background: #f8faf8; border-color: #d8e5da; }
.section-heading { display: flex; align-items: center; gap: 9px; margin-bottom: 13px; }
.section-heading .eyebrow { margin-bottom: 1px; font-size: .61rem; }
.section-heading h3 { margin: 0; font-size: .96rem; line-height: 1.15; letter-spacing: -.015em; }
.section-number {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  background: var(--navy-800);
  border-radius: 8px;
  font-size: .69rem;
  font-weight: 850;
}
.category-fieldset { margin: 0 0 13px; padding: 0; border: 0; }
.category-fieldset legend { margin-bottom: 6px; color: var(--slate-700); font-size: .78rem; font-weight: 700; }
.category-bulk-actions { margin-bottom: 8px; display: flex; justify-content: flex-end; gap: 4px; }
.category-bulk-actions button { padding: 4px 6px; color: #1d5e94; background: #eef6fb; border: 1px solid #cfe1ec; border-radius: 6px; font-size: .66rem; font-weight: 800; }
.category-bulk-actions button:hover { color: #103d62; background: #dfeef7; }
.category-options { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.category-option { position: relative; cursor: pointer; }
.category-option input { position: absolute; opacity: 0; pointer-events: none; }
.category-option > span {
  min-height: 37px;
  padding: 8px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--slate-600);
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: 7px;
  font-size: .82rem;
  font-weight: 750;
}
.category-option > span::before {
  content: "✓";
  width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  background: var(--category-color);
  border: 1px solid var(--category-color);
  border-radius: 5px;
  font-size: .66rem;
  font-weight: 900;
}
.category-option i { display: none; }
.category-option b { margin-left: auto; color: var(--slate-500); font-size: .68rem; }
.category-option input:checked + span { color: var(--navy-950); border-color: var(--category-color); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--category-color) 34%, transparent); }
.category-option input:not(:checked) + span { opacity: .62; background: #f8fafc; }
.category-option input:not(:checked) + span::before { content: ""; background: #fff; border-color: #94a3b8; }
.category-option input:focus-visible + span { outline: 3px solid rgba(15, 111, 255, .35); outline-offset: 2px; }
.category-option.safe { --category-color: var(--safe); }
.category-option.favourable { --category-color: var(--favourable); }
.category-option.battleground { --category-color: var(--battleground); }
.category-option.difficult { --category-color: var(--difficult); }
.method-note { margin: 11px 0 0; color: var(--slate-500); font-size: .68rem; line-height: 1.4; }
.advanced-filter { margin-top: 10px; overflow: hidden; background: #f8fafc; border: 1px solid var(--slate-200); border-radius: 11px; }
.advanced-filter > summary { padding: 11px 12px; color: var(--navy-800); font-size: .82rem; font-weight: 800; cursor: pointer; list-style-position: inside; }
.advanced-filter[open] > summary { background: #edf5fa; border-bottom: 1px solid #d7e4ec; }
.advanced-filter-body { padding: 12px; }
.advanced-filter-body .field:last-child { margin-bottom: 0; }
.display-toggle { margin-top: 12px; padding: 10px 11px; display: flex; align-items: center; gap: 9px; color: var(--slate-700); background: #f8fafc; border: 1px solid var(--slate-200); border-radius: 10px; font-size: .82rem; font-weight: 700; cursor: pointer; }
.display-toggle input { width: 17px; height: 17px; accent-color: var(--navy-800); }
.threshold-field { margin-bottom: 12px; }
.percentage-input { position: relative; }
.percentage-input input { padding-right: 38px; }
.percentage-input > span { position: absolute; top: 10px; right: 13px; color: var(--slate-500); font-size: .9rem; font-weight: 800; }
.population-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding-top: 11px;
  border-top: 1px solid #c9deeb;
}
.population-summary[hidden] { display: none; }
.population-summary > div { min-width: 0; padding: 7px 3px; background: rgba(255,255,255,.68); border-radius: 7px; text-align: center; }
.population-summary strong { display: block; font-size: 1rem; }
.population-summary span { display: block; margin-top: 2px; color: var(--slate-500); font-size: .62rem; }

.legend-block { margin: 16px 1px 0; padding: 14px; background: rgba(255,255,255,.8); border: 1px solid var(--slate-200); border-radius: 13px; box-shadow: var(--soft-shadow); }
.legend-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.legend-heading h3 { margin: 0; font-size: .88rem; }
.legend-heading span { color: var(--slate-500); font-size: .72rem; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.legend-item { display: flex; align-items: center; gap: 7px; color: var(--slate-700); font-size: .76rem; }
.legend-swatch { width: 12px; height: 12px; border: 1px solid rgba(15,23,42,.16); border-radius: 3px; }

.map-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 16px 18px 14px;
  background:
    radial-gradient(circle at 80% 10%, rgba(109, 190, 216, .13), transparent 30%),
    var(--canvas);
}
.map-toolbar {
  min-height: 44px;
  padding: 0 2px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.active-filter { color: var(--navy-800); font-size: .86rem; font-weight: 700; }
.toolbar-actions { display: flex; align-items: center; gap: 8px; }
.map-actions { display: flex; gap: 5px; }
.map-actions button {
  min-width: 38px;
  height: 36px;
  padding: 0 11px;
  color: var(--navy-900);
  background: white;
  border: 1px solid var(--slate-300);
  border-radius: 10px;
  font-size: .82rem;
  font-weight: 750;
  box-shadow: 0 3px 10px rgba(15,42,69,.07);
}
.map-actions button:hover { background: var(--slate-100); }
.export-menu-wrap { position: relative; }
.export-toggle {
  height: 38px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #fff;
  background: linear-gradient(145deg, var(--navy-800), #126b8d);
  border: 1px solid rgba(5, 49, 78, .45);
  border-radius: 10px;
  box-shadow: 0 5px 14px rgba(10, 52, 82, .18);
  font-size: .82rem;
  font-weight: 800;
}
.export-toggle:hover { background: linear-gradient(145deg, #123d61, #0d7599); }
.export-toggle > span { font-size: 1rem; line-height: 1; }
.export-menu {
  position: absolute;
  z-index: 90;
  top: calc(100% + 8px);
  right: 0;
  width: min(350px, calc(100vw - 28px));
  padding: 8px;
  color: var(--navy-950);
  background: rgba(255,255,255,.98);
  border: 1px solid var(--slate-200);
  border-radius: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.export-menu[hidden] { display: none; }
.export-menu-heading { padding: 9px 10px 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--slate-100); }
.export-menu-heading strong { font-size: .86rem; }
.export-menu-heading span { color: var(--slate-500); font-size: .7rem; }
.export-menu > button {
  width: 100%;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--navy-950);
  background: transparent;
  border: 0;
  border-radius: 9px;
  text-align: left;
}
.export-menu > button:hover, .export-menu > button:focus-visible { background: #edf5fb; }
.export-menu > button:disabled { opacity: .46; cursor: not-allowed; }
.export-menu i { width: 37px; height: 31px; display: grid; place-items: center; flex: 0 0 auto; color: #fff; background: var(--navy-800); border-radius: 7px; font-size: .61rem; font-style: normal; font-weight: 900; letter-spacing: .03em; }
.export-menu button[data-export="xlsx"] i { background: #16734d; }
.export-menu button[data-export="png"] i,
.export-menu button[data-export="svg"] i { background: #1e70a5; }
.export-menu button[data-export="report"] i { background: #b63838; }
.export-menu b, .export-menu small { display: block; }
.export-menu b { font-size: .78rem; }
.export-menu small { margin-top: 2px; color: var(--slate-500); font-size: .66rem; font-weight: 500; }
.export-menu > p { margin: 5px 8px 2px; padding-top: 8px; color: var(--slate-500); border-top: 1px solid var(--slate-100); font-size: .65rem; line-height: 1.4; }
.export-toast { position: fixed; z-index: 120; right: 20px; bottom: 20px; max-width: 330px; padding: 11px 14px; color: #fff; background: rgba(7,24,41,.96); border: 1px solid rgba(255,255,255,.13); border-radius: 10px; box-shadow: var(--shadow); font-size: .78rem; font-weight: 700; }

.map-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 620px;
  overflow: hidden;
  background:
    radial-gradient(circle at 27% 18%, rgba(255,255,255,.94), rgba(255,255,255,0) 34%),
    linear-gradient(145deg, #e4edf4, #d4e2eb);
  border: 1px solid #bdcedb;
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.72), 0 16px 36px rgba(15,42,69,.11);
  touch-action: none;
  cursor: grab;
  contain: layout paint style;
}
.map-stage.is-panning { cursor: grabbing; user-select: none; }
#assemblyMap { width: 100%; height: 100%; min-height: 620px; display: block; }
.map-loader { position: absolute; inset: 0; display: grid; place-items: center; color: var(--slate-600); font-weight: 700; }
.map-loader[hidden] { display: none; }
.map-group { transform-origin: 0 0; }
.constituency {
  stroke: rgba(255,255,255,.92);
  stroke-width: 1.15;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}
.constituency.is-selected {
  stroke: var(--navy-950);
  stroke-width: 2.5;
}
.hide-constituency-borders .constituency:not(.is-selected) { stroke: transparent; }
.constituency.is-muted { opacity: .075; }
.constituency.is-isolated-out, .constituency-hit.is-isolated-out, .map-label.is-isolated-out { opacity: 0; visibility: hidden; pointer-events: none; }
.constituency-hit { fill: transparent; stroke: transparent; stroke-width: 0; vector-effect: non-scaling-stroke; cursor: pointer; pointer-events: all; }
.constituency-hit.is-hovered { stroke: var(--navy-950); stroke-width: 2.5; }
.constituency-hit.is-muted { pointer-events: none; }
.constituency-hit:focus-visible { outline: none; }
.map-stage.is-panning .constituency-hit { pointer-events: none; }
.map-stage.is-panning .map-label { visibility: hidden; }
.map-label {
  fill: #071626;
  stroke: rgba(255,255,255,.92);
  stroke-width: 2.5px;
  paint-order: stroke;
  font-size: 8px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  letter-spacing: -.02em;
}
.map-label.is-name { font-size: 7px; font-weight: 750; letter-spacing: -.035em; }
.map-label.is-name .party-line { font-size: 6.5px; font-weight: 900; }
.map-label.is-muted { opacity: .05; }
.state-outline-halo,
.state-outline {
  fill: none;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.state-outline-halo { stroke: rgba(255,255,255,.96); stroke-width: 7; }
.state-outline { stroke: #0a243e; stroke-width: 3.2; }
.tooltip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 80;
  max-width: 260px;
  padding: 9px 11px;
  color: white;
  background: rgba(9,27,49,.96);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: .78rem;
  pointer-events: none;
  will-change: transform;
}
.tooltip strong { display: block; margin-bottom: 3px; font-size: .86rem; }
.tooltip > span { color: #b9cee0; }

.detail-panel {
  position: absolute;
  z-index: 40;
  top: 12px;
  right: 12px;
  bottom: 12px;
  width: min(350px, calc(100% - 24px));
  overflow-y: auto;
  padding: 16px;
  background: rgba(255,255,255,.97);
  border: 1px solid rgba(203,213,225,.9);
  border-radius: 12px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.detail-close {
  position: absolute;
  top: 11px;
  right: 12px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--slate-600);
  background: var(--slate-100);
  border: 0;
  border-radius: 50%;
  font-size: 1.25rem;
}
.detail-kicker { margin: 0 38px 5px 0; color: var(--slate-500); font-size: .75rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.detail-panel h2 { margin: 0 38px 3px 0; font-size: 1.2rem; line-height: 1.2; letter-spacing: -.025em; }
.detail-location { margin: 0 0 11px; color: var(--slate-600); font-size: .74rem; line-height: 1.35; }
.winner-card { padding: 11px 12px; color: white; background: var(--navy-900); border-radius: 10px; }
.detail-year-tabs { margin: 0 0 13px; padding: 4px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--slate-100); border-radius: 10px; }
.detail-year-tabs button { padding: 8px; color: var(--slate-600); background: transparent; border: 0; border-radius: 7px; font-size: .78rem; font-weight: 800; }
.detail-year-tabs button.is-active { color: #fff; background: var(--navy-800); box-shadow: 0 3px 8px rgba(23,69,108,.2); }
.winner-label { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; color: #dbeafe; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.winner-label i { width: 8px; height: 8px; border-radius: 50%; }
.winner-name { margin: 0; font-size: .98rem; line-height: 1.22; }
.winner-party { margin: 3px 0 8px; color: #d5e5f4; font-size: .74rem; }
.winner-numbers { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.winner-number { padding-top: 6px; border-top: 1px solid rgba(255,255,255,.18); }
.winner-number strong { display: block; font-size: .9rem; }
.winner-number span { color: #cbdbea; font-size: .7rem; }
.metrics { margin: 9px 0 12px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.metric { padding: 7px 5px; background: var(--slate-100); border-radius: 8px; text-align: center; }
.metric strong { display: block; font-size: .93rem; }
.metric span { display: block; margin-top: 3px; color: var(--slate-500); font-size: .67rem; }
.demographic-strip { margin: 0 0 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.demographic-strip > div { padding: 7px 8px; display: flex; align-items: center; justify-content: space-between; gap: 6px; background: #eef6fb; border: 1px solid #d2e5ef; border-radius: 8px; }
.demographic-strip span { color: var(--slate-600); font-size: .72rem; }
.demographic-strip strong { font-size: .9rem; }
.dynamic-detail-strip { margin: -5px 0 16px; padding: 12px 13px; background: #eef7fa; border: 1px solid #c9e2ea; border-radius: 9px; }
.dynamic-detail-strip p { margin: 0 0 8px; color: var(--slate-600); font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.dynamic-detail-strip > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 5px 0; border-top: 1px solid rgba(189,216,229,.7); }
.dynamic-detail-strip span { color: var(--slate-600); font-size: .75rem; }
.dynamic-detail-strip strong { font-size: .8rem; text-align: right; }
.historical-summary { margin: 0 0 10px; padding: 9px 10px; background: #f4f7f5; border: 1px solid #dbe6dc; border-radius: 9px; }
.historical-summary-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.historical-summary span { color: var(--slate-600); font-size: .72rem; }
.history-badge { padding: 5px 8px; color: #fff; background: var(--category-color, var(--navy-800)); border-radius: 6px; font-size: .72rem; font-weight: 850; }
.history-pattern { margin: 8px 0 0; color: var(--navy-900); font-size: .83rem; font-weight: 800; letter-spacing: .025em; }
.history-timeline { margin: 0 0 12px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.history-election { min-width: 0; padding: 7px 5px; background: #fff; border: 1px solid var(--slate-200); border-radius: 8px; text-align: center; }
.history-election { font: inherit; cursor: pointer; }
.history-election:hover { border-color: #8bb5cd; background: #f3f9fc; }
.history-election.is-active { border-color: var(--navy-800); box-shadow: inset 0 0 0 1px var(--navy-800); }
.history-election small { display: block; color: var(--slate-500); font-size: .62rem; line-height: 1.25; }
.history-election strong { display: block; margin: 4px 0 2px; color: var(--navy-900); font-size: .86rem; }
.history-election span { color: var(--slate-600); font-size: .67rem; }
.detail-section h3 { margin: 0 0 8px; font-size: .86rem; }
.candidate-table { width: 100%; border-collapse: collapse; font-size: .76rem; }
.candidate-table-wrap { max-height: 270px; overflow: auto; border: 1px solid var(--slate-200); border-radius: 9px; }
.candidate-table-wrap .candidate-table th { position: sticky; top: 0; z-index: 1; background: #f8fafc; }
.candidate-table th { padding: 7px 5px; color: var(--slate-500); border-bottom: 1px solid var(--slate-200); text-align: left; font-size: .66rem; text-transform: uppercase; letter-spacing: .05em; }
.candidate-table th:last-child, .candidate-table td:last-child { text-align: right; }
.candidate-table td { padding: 8px 5px; border-bottom: 1px solid var(--slate-100); vertical-align: top; }
.candidate-table td small { display: block; margin-top: 2px; color: var(--slate-500); }
.runner-card { margin: 7px 0 0; padding: 8px 10px; display: grid; grid-template-columns: 1fr auto; gap: 3px 8px; background: #f8fafc; border: 1px solid var(--slate-200); border-radius: 9px; }
.runner-card small { grid-column: 1 / -1; }
.runner-card span, .runner-card small { display: block; }
.runner-card span { font-size: .73rem; color: var(--slate-500); font-weight: 700; }
.runner-card strong { display: block; margin-top: 3px; font-size: .86rem; }
.runner-card > strong { align-self: center; color: var(--navy-800); }
.by-election-note { margin: 0 0 15px; padding: 10px 12px; color: #6b4b12; background: #fff8df; border: 1px solid #ead796; border-radius: 9px; font-size: .72rem; line-height: 1.45; }

.map-footnote { padding: 8px 3px 0; display: flex; justify-content: space-between; gap: 18px; color: var(--slate-500); font-size: .72rem; }

@media (max-width: 980px) {
  .topbar { align-items: flex-start; }
  .state-summary { max-width: 360px; }
  .workspace { grid-template-columns: 290px minmax(0, 1fr); }
  .filters { padding-inline: 14px; }
}

@media (max-width: 760px) {
  body { height: auto; min-height: 100%; display: block; overflow-y: auto; }
  .topbar { padding: 13px 15px; display: block; }
  .state-summary { margin-top: 12px; justify-content: flex-start; max-width: none; }
  .summary-pill { min-width: 76px; }
  .workspace { display: block; overflow: visible; }
  .filters { overflow: visible; border-right: 0; border-bottom: 1px solid var(--slate-200); }
  .filters-heading { margin-bottom: 14px; }
  .filters { display: block; }
  .filter-section { margin-top: 10px; }
  .legend { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .map-panel { overflow: visible; padding: 10px; }
  .map-toolbar { align-items: flex-start; }
  .toolbar-actions { align-items: flex-end; flex-direction: column-reverse; }
  .active-filter { padding-top: 7px; }
  .map-stage, #assemblyMap { min-height: 560px; }
  .detail-panel { top: auto; height: min(72%, 520px); }
  .map-footnote { display: block; }
  .map-footnote span { display: block; margin-bottom: 3px; }
}

@media (max-width: 480px) {
  .brand h1 { font-size: 1.02rem; }
  .filters { display: block; }
  .legend { grid-template-columns: 1fr 1fr; }
  .state-summary { display: grid; grid-template-columns: repeat(2, 1fr); }
  .map-actions button { padding-inline: 8px; }
  .map-actions button:nth-child(2) { min-width: 70px; }
  .export-toggle { height: 36px; }
  .map-stage, #assemblyMap { min-height: 500px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

.print-sheet { display: none; }

@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body.printing { height: auto; overflow: visible; background: #fff; }
  body.printing > :not(.print-sheet) { display: none !important; }
  body.printing .print-sheet { display: block; color: #102a45; font-family: Arial, sans-serif; }
  .print-sheet header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding-bottom: 8px; border-bottom: 2px solid #17456c; }
  .print-sheet header h1 { margin: 0; font-size: 20pt; }
  .print-sheet header p { margin: 3px 0 0; color: #475569; font-size: 8.5pt; }
  .print-sheet .print-meta { text-align: right; font-size: 8pt; }
  .print-sheet .print-summary { margin: 9px 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .print-sheet .print-summary div { padding: 7px 9px; background: #eef4f8; border: 1px solid #d8e2ea; border-radius: 5px; }
  .print-sheet .print-summary strong { display: block; font-size: 13pt; }
  .print-sheet .print-summary span { color: #64748b; font-size: 7pt; }
  .print-sheet .print-map { height: 132mm; margin: 6px 0 10px; }
  .print-sheet .print-map svg { width: 100%; height: 100%; }
  .print-sheet h2 { margin: 12px 0 6px; font-size: 13pt; }
  .print-sheet table { width: 100%; border-collapse: collapse; font-size: 7pt; }
  .print-sheet th { padding: 4px; color: #fff; background: #17456c; text-align: left; }
  .print-sheet td { padding: 3px 4px; border-bottom: 1px solid #d8e2ea; }
  .print-sheet tr { break-inside: avoid; }
  .print-sheet .profile-grid { margin: 12px 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .print-sheet .profile-grid div { padding: 10px; background: #eef4f8; border-radius: 5px; }
  .print-sheet .profile-grid strong, .print-sheet .profile-grid span { display: block; }
  .print-sheet .profile-grid span { margin-top: 3px; color: #64748b; font-size: 8pt; }
  .print-sheet .profile-history { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .print-sheet .profile-history div { padding: 10px; border: 1px solid #d8e2ea; border-radius: 5px; }
  .print-sheet .source-note { margin-top: 8px; color: #64748b; font-size: 7pt; }
}
