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

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Helvetica, sans-serif;
  font-size: 15px;
  color: #1a1a2e;
  background: #f2f3f6;
  line-height: 1.5;
}

a { color: #2171b5; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ──────────────────────────────────────────────────────────────── */
header {
  background: #1a1a2e;
  color: #fff;
  padding: 28px 0;
}
.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
}
header h1 {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}
header .subtitle {
  color: #8fa4c0;
  margin-top: 5px;
  font-size: 0.88rem;
}

/* ── Main layout ─────────────────────────────────────────────────────────── */
main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
/* ── Breadcrumb strip ──────────────────────────────────────────────────── */
#breadcrumb-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  font-size: 13px;
  color: #555;
  padding: 2px 0 8px;
}
.bc-crumb { line-height: 1.4; }
.bc-current { color: #222; font-weight: 600; }
.bc-sep { color: #bbb; user-select: none; padding: 0 2px; font-size: 15px; }
.bc-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 13px;
  color: #1a73e8;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.bc-link:hover { color: #1558b0; }
/* ── Summary cards ───────────────────────────────────────────────────────── */
.summary-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
.card {
  background: #fff;
  border-radius: 8px;
  padding: 20px 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
  text-align: center;
}
.card-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
  color: #1a1a2e;
}
.card-value.female  { color: #c9304f; }
.card-value.male    { color: #1a5fa0; }
.card-value.unknown { color: #777; }
.card-label {
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #777;
  margin-top: 5px;
}
.card-sub {
  font-size: 0.78rem;
  color: #aaa;
  margin-top: 3px;
}

/* ── Panels ──────────────────────────────────────────────────────────────── */
.panel {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
  padding: 22px 24px;
}
.panel h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
}
.subtitle-small {
  font-size: 0.78rem;
  font-weight: 400;
  color: #888;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.panel-header h2 { margin-bottom: 0; }

/* ── Toggle buttons ──────────────────────────────────────────────────────── */
.toggle-group {
  display: flex;
  border: 1px solid #dde0e8;
  border-radius: 6px;
  overflow: hidden;
}
.toggle {
  padding: 6px 14px;
  border: none;
  background: #fff;
  cursor: pointer;
  font-size: 0.82rem;
  color: #555;
  transition: background .12s, color .12s;
}
.toggle + .toggle { border-left: 1px solid #dde0e8; }
.toggle:hover  { background: #f0f2f7; }
.toggle.active { background: #1a1a2e; color: #fff; }

/* ── Map ─────────────────────────────────────────────────────────────────── */
.map-layout {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}
#map {
  flex: 1 1 auto;
  min-width: 0;
  height: 560px;
  border-radius: 6px;
  border: 1px solid #e0e3ea;
}
#map-legend {
  flex: 0 0 210px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 0.81rem;
  color: #444;
}
.legend-title {
  font-weight: 600;
  font-size: 0.84rem;
  color: #1a1a2e;
}
.legend-hue-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.legend-row-label { color: #666; }
.legend-bar {
  height: 16px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,.06);
}
/* Blue(male) → purple → pink(female), fully saturated */
.confident-bar {
  background: linear-gradient(to right, #2171b5, #8b67a4, #d6496f);
}
/* Same hue range blended 55% toward grey (#adb5bd) */
.uncertain-bar {
  background: linear-gradient(to right, #6d94b8, #a0899e, #c98b9c);
}
.legend-axis-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: #999;
}
.legend-note {
  font-size: 0.78rem;
  line-height: 1.45;
  color: #555;
}

/* Hover info box */
.map-info-box {
  background: #f7f8fa;
  border: 1px solid #e0e3ea;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 0.79rem;
  min-height: 80px;
  color: #444;
}
.map-info-placeholder { color: #bbb; font-style: italic; }
.map-info-box strong  { display: block; font-size: 0.85rem; color: #1a1a2e; margin-bottom: 5px; }
.mi-table { width: 100%; border-collapse: collapse; }
.mi-table td { padding: 1px 3px; }
.mi-table td:first-child { color: #888; }
.mi-section { font-style: italic; font-size: 0.76rem; color: #777; padding-top: 4px; }
.mi-warn { color: #9a6300; font-size: 0.76rem; margin-top: 5px; background: #fff8e1; border-radius: 3px; padding: 2px 5px; }

/* ── Charts ──────────────────────────────────────────────────────────────── */
.chart-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.chart-box h3 {
  font-size: 0.82rem;
  font-weight: 500;
  color: #666;
  margin-bottom: 8px;
}
.chart-scroll {
  position: relative;
  width: 100%;
}

/* ── Council table ───────────────────────────────────────────────────────── */
.table-note {
  font-size: 0.79rem;
  color: #888;
  margin-bottom: 10px;
}
.unknown-note { color: #9a6300; font-weight: 600; }
#table-search {
  border: 1px solid #dde0e8;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.84rem;
  width: 210px;
  outline: none;
  transition: border-color .15s;
}
#table-search:focus { border-color: #2171b5; }

.table-wrapper {
  overflow-x: auto;
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 6px;
}
#council-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.81rem;
  white-space: nowrap;
}
#council-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f2f3f6;
  padding: 8px 10px;
  text-align: right;
  border-bottom: 2px solid #dde0e8;
  user-select: none;
  cursor: default;
}
#council-table thead th:first-child { text-align: left; }
#council-table thead th.sortable { cursor: pointer; }
#council-table thead th.sortable:hover { background: #e4e7ef; color: #1a1a2e; }
#council-table thead th.sorted-asc::after  { content: ' ▲'; font-size: 0.68em; opacity: .7; }
#council-table thead th.sorted-desc::after { content: ' ▼'; font-size: 0.68em; opacity: .7; }

#council-table tbody tr:nth-child(even) { background: #fafbfd; }
#council-table tbody tr:hover { background: #eef2fb; }
#council-table td {
  padding: 5px 10px;
  text-align: right;
  border-bottom: 1px solid #f0f0f3;
}
#council-table td:first-child { text-align: left; color: #1a1a2e; }

.pct-cell { font-weight: 600; }
.pct-high-female { color: #c9304f; }
.pct-high-male   { color: #1a5fa0; }
.pct-neutral     { color: #444; }
.unknown-cell    { color: #9a6300; }
.unknown-badge {
  font-size: 0.68rem;
  background: #fff3cd;
  color: #9a6300;
  border: 1px solid #ffd96644;
  border-radius: 3px;
  padding: 1px 4px;
  margin-left: 3px;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
footer {
  background: #1a1a2e;
  color: #8fa4c0;
  padding: 24px 0;
  font-size: 0.79rem;
  line-height: 1.8;
}
.footer-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
}
footer a { color: #7ab3d8; }
footer a:hover { color: #fff; }

/* ── Confidence badge in table ───────────────────────────────────────────── */
.conf-cell { white-space: nowrap; }
.conf-badge {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
}
.conf-high { background: #2e7d32; }
.conf-med  { background: #f9a825; }
.conf-low  { background: #c62828; }
.conf-none { background: #bbb; }

/* Map info box confidence line */
.mi-conf {
  margin-top: 6px;
  font-size: 0.75rem;
  color: #777;
}
.mi-conf-pct {
  font-weight: 600;
  color: #444;
}

/* ── Methodology tile ────────────────────────────────────────────────────── */
.methodology-tile {
  background: #fff8e1;
  border: 2px solid #f9a825;
  border-radius: 8px;
  padding: 22px 26px;
  display: flex;
  gap: 18px;
  align-items: flex-start;
  box-shadow: 0 1px 4px rgba(0,0,0,.09);
  position: relative;
}
.meth-dismiss {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.1rem;
  color: #a07820;
  cursor: pointer;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 4px;
}
.meth-dismiss:hover { background: rgba(0,0,0,.07); }
.meth-icon {
  font-size: 2.2rem;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 2px;
}
.meth-body h2 {
  font-size: 1.15rem;
  font-weight: 800;
  color: #7a4f00;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.meth-body p {
  font-size: 0.88rem;
  color: #5a3d00;
  line-height: 1.65;
  margin-bottom: 8px;
}
.meth-body p:last-child { margin-bottom: 0; }
.meth-body strong { color: #4a3000; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 40px rgba(0,0,0,.22);
  width: 100%;
  max-width: 820px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 80px);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid #eee;
  position: sticky;
  top: 0;
  background: #fff;
  border-radius: 10px 10px 0 0;
  z-index: 1;
}
.modal-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1a1a2e;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: #888;
  padding: 0 4px;
}
.modal-close:hover { color: #1a1a2e; }
.modal-body {
  padding: 18px 22px 24px;
  overflow-y: auto;
}

/* Ward grid */
.ward-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  margin-top: 4px;
}
.ward-btn {
  background: #f2f3f6;
  border: 1px solid #dde0e8;
  border-radius: 7px;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  font-size: 0.84rem;
  color: #1a1a2e;
}
.ward-btn:hover { background: #e4e7ef; border-color: #2171b5; }
.ward-btn strong { display: block; font-size: 0.9rem; margin-bottom: 4px; }
.ward-btn .ward-meta { font-size: 0.75rem; color: #888; }

/* Results table */
.modal-back {
  background: none;
  border: none;
  color: #2171b5;
  font-size: 0.84rem;
  cursor: pointer;
  padding: 0;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.modal-back:hover { text-decoration: underline; }
.ward-results-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 12px;
}
.ward-results-meta {
  font-size: 0.78rem;
  color: #888;
  margin-bottom: 14px;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.results-table thead th {
  background: #f2f3f6;
  padding: 7px 10px;
  text-align: left;
  border-bottom: 2px solid #dde0e8;
  white-space: nowrap;
  font-weight: 600;
  color: #555;
}
.results-table th.num, .results-table td.num { text-align: right; }
.results-table tbody tr:nth-child(even) { background: #fafbfd; }
.results-table tbody tr:hover { background: #eef2fb; }
.results-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #f0f0f3;
  vertical-align: middle;
}
.results-table tr.elected-row td { font-weight: 700; }
.elected-tick { color: #1a7a3c; font-size: 1rem; }
.not-elected-cross { color: #aaa; font-size: 0.95rem; }
.gender-f { color: #c9304f; }
.gender-m { color: #1a5fa0; }
.gender-u { color: #999; font-style: italic; }
.method-badge {
  display: inline-block;
  font-size: 0.68rem;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 500;
  white-space: nowrap;
}
.method-existing  { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.method-gender_guesser { background: #e3f2fd; color: #1565c0; border: 1px solid #bbdefb; }
.method-ons       { background: #fff3e0; color: #e65100; border: 1px solid #ffe0b2; }
.method-claude    { background: #f3e5f5; color: #6a1b9a; border: 1px solid #e1bee7; }
.method-unknown   { background: #f5f5f5; color: #757575; border: 1px solid #e0e0e0; }

/* Clickable table rows */
#council-table tbody tr { cursor: pointer; }

/* ── Export button ───────────────────────────────────────────────────────── */
.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s;
}
.btn-export:hover { background: #2e2e50; }

/* ── Panel header row (heading + export button side-by-side) ─────────────── */
.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.panel-header-row h2 { margin-bottom: 0; flex: 1; }
.btn-section-export {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: #f0f2f8;
  color: #333;
  border: 1px solid #cdd2e0;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s;
}
.btn-section-export:hover { background: #dde0ef; }

/* ── Export choice modal ─────────────────────────────────────────────────── */
#export-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
#export-modal[hidden] { display: none; }
.export-modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 32px;
  width: 500px;
  max-width: calc(100vw - 32px);
  position: relative;
  box-shadow: 0 8px 40px rgba(0,0,0,.22);
}
.export-modal-box h3 { margin: 0 0 6px; font-size: 1.2rem; }
.export-modal-desc { color: #555; margin: 0 0 20px; font-size: 0.9rem; }
.export-choice-row {
  display: flex;
  gap: 14px;
}
.export-choice-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 16px;
  background: #f7f8fc;
  border: 2px solid #dde0e8;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  text-align: center;
}
.export-choice-btn:hover { border-color: #3949ab; background: #eef0f8; }
.ecb-icon { font-size: 1.8rem; line-height: 1; }
.ecb-label { font-weight: 600; font-size: 0.95rem; color: #222; }
.ecb-desc { font-size: 0.78rem; color: #666; line-height: 1.4; }

/* ── Incumbency heading in drilldown panels ──────────────────────────────── */
.drilldown-inc-heading {
  font-size: 0.88rem;
  font-weight: 600;
  color: #555;
  margin: 18px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.btn-clear-selection {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  background: #e8eaf6;
  color: #3949ab;
  border: 1px solid #9fa8da;
  border-radius: 12px;
  font-size: 0.75rem;
  cursor: pointer;
  margin-left: 10px;
  vertical-align: middle;
  transition: background .12s;
}
.btn-clear-selection:hover { background: #c5cae9; }

/* Inline message in chart scroll area */
.chart-msg { padding: 20px; color: #888; font-size: 0.85rem; font-style: italic; }

/* ── Party detail panel ──────────────────────────────────────────────────── */
#party-detail {
  margin-top: 18px;
  border-top: 1px solid #eaecf0;
  padding-top: 18px;
}
.party-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.party-detail-name {
  font-size: 1rem;
  font-weight: 700;
  color: #1a1a2e;
}
.btn-clear-party {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  background: #e8eaf6;
  color: #3949ab;
  border: 1px solid #9fa8da;
  border-radius: 12px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background .12s;
}
.btn-clear-party:hover { background: #c5cae9; }

.party-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.party-stat-tile {
  background: #f7f8fb;
  border: 1px solid #e8eaf0;
  border-radius: 7px;
  padding: 12px 14px;
  text-align: center;
}
.pst-value {
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.1;
  color: #1a1a2e;
}
.pst-value.female { color: #c9304f; }
.pst-value.male   { color: #1a5fa0; }
.pst-label {
  font-size: 0.71rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #777;
  margin-top: 4px;
  line-height: 1.4;
}
.pst-sub {
  font-size: 0.69rem;
  color: #aaa;
  text-transform: none;
  letter-spacing: 0;
}
.party-sentence {
  font-size: 0.87rem;
  color: #333;
  margin: 8px 0;
  line-height: 1.55;
  padding: 8px 12px;
  background: #f7f8fb;
  border-left: 3px solid #c5cae9;
  border-radius: 0 5px 5px 0;
}
.party-no-cands {
  font-size: 0.83rem;
  color: #888;
  font-style: italic;
  margin-top: 12px;
}
.party-cands-header {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1a1a2e;
  margin: 14px 0 8px;
}
.party-cands-scroll {
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 6px;
}

/* ── Council stats panel (shown below map when a council is selected) ─── */
#council-stats {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #e0e0e0;
}
.council-stats-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.council-stats-name {
  font-weight: 700;
  font-size: 1.05rem;
}
.council-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}
@media (max-width: 600px) {
  .council-stats-grid { grid-template-columns: repeat(2, 1fr); }
}
.council-stat-tile {
  background: #f7f8fb;
  border-radius: 8px;
  padding: 10px 12px;
}
.council-stat-tile .pst-value { font-size: 1.35rem; font-weight: 700; }
.council-stat-tile .pst-label { font-size: 0.82rem; color: #555; margin-top: 2px; }
.council-stat-tile .pst-sub   { font-size: 0.75rem; color: #888; }

/* Table header: search + export button side by side */
.table-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Ward detail: back button + export button in one bar */
.ward-detail-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.ward-detail-bar .modal-back { margin-bottom: 0; }

/* Export button inside modal (ward list) */
.modal-export-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

/* ── Responsive additions ─────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .methodology-tile { flex-direction: column; gap: 10px; }
  .modal { max-height: none; }
}
.leaflet-tooltip {
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .map-layout    { flex-direction: column; }
  #map           { height: 400px; flex: none; width: 100%; }
  #map-legend    { flex: none; width: 100%; flex-direction: row; flex-wrap: wrap; gap: 10px; }
  .chart-pair    { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  main           { padding: 14px 12px 40px; }
  .panel         { padding: 16px 14px; }
  header h1      { font-size: 1.3rem; }
}

/* ── Chart hints ──────────────────────────────────────────────────────────── */
.chart-hint {
  font-size: 0.75rem;
  color: #aaa;
  text-align: center;
  margin: 5px 0 0;
  font-style: italic;
}

/* Clickable candidate rows */
.results-table tbody tr.cand-row { cursor: pointer; }
.results-table tbody tr.cand-row:hover { background: #e8f0fb; }

/* Chart canvas cursor */
.chart-scroll canvas { cursor: pointer; }

/* ── Candidate detail modal ─────────────────────────────────────────────── */
.cand-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.cand-modal-overlay[hidden] { display: none; }

.cand-modal-card {
  background: #fff;
  border-radius: 12px;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px 24px 22px;
  position: relative;
  box-shadow: 0 10px 40px rgba(0,0,0,.22);
}

.cand-modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: #888;
  padding: 0 4px;
}
.cand-modal-close:hover { color: #1a1a2e; }

/* Header row: photo + info */
.cand-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
  padding-right: 28px; /* avoid close button overlap */
}
.cand-header.no-photo { display: block; }
.cand-photo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid #eee;
}
.cand-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 4px;
}
.cand-party-badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  background: #eef2fb;
  color: #2a4a9a;
  border-radius: 4px;
  padding: 2px 8px;
  margin-bottom: 5px;
}
.cand-council-line {
  font-size: 0.82rem;
  color: #666;
}
.cand-ward {
  color: #2171b5;
}

/* Stats row */
.cand-stats-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.cand-stat {
  background: #f2f3f6;
  border-radius: 7px;
  padding: 10px 14px;
  min-width: 80px;
  text-align: center;
}
.cs-val {
  font-size: 1rem;
  font-weight: 700;
  color: #1a1a2e;
}
.cs-lbl {
  font-size: 0.7rem;
  color: #888;
  margin-top: 2px;
}
.cs-elected .cs-val   { color: #1a7a3c; }
.cs-not-elected .cs-val { color: #999; }

/* Social / external links */
.cand-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.cand-link {
  display: inline-block;
  font-size: 0.77rem;
  padding: 4px 10px;
  border-radius: 5px;
  text-decoration: none;
  border: 1px solid #dde0e8;
  color: #2171b5;
  background: #f7f9fc;
  transition: background .12s;
}
.cand-link:hover { background: #e4ecf9; border-color: #2171b5; }
.dc-link { background: #fff3cd; border-color: #f9a825; color: #7a4f00; }
.dc-link:hover { background: #ffe99a; }
.results-link { font-size: 0.72rem; color: #555; }

/* Statement */
.cand-stmt {
  margin-bottom: 16px;
  background: #f7f8fb;
  border-left: 3px solid #dde0e8;
  padding: 10px 14px;
  border-radius: 0 6px 6px 0;
}
.cand-stmt h4 {
  font-size: 0.78rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}
.cand-stmt p {
  font-size: 0.83rem;
  color: #444;
  line-height: 1.6;
  max-height: 180px;
  overflow-y: auto;
}

/* Gender block */
.cand-gender-block {
  border-top: 1px solid #eee;
  padding-top: 14px;
  margin-top: 4px;
}
.cand-gender-block h4 {
  font-size: 0.78rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 8px;
}
.cand-gender-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.method-sm {
  font-size: 0.72rem;
  color: #666;
  background: #f2f3f6;
  border-radius: 3px;
  padding: 1px 6px;
}
.cand-disclaimer {
  font-size: 0.74rem;
  color: #999;
  line-height: 1.45;
}
.cand-disclaimer a { color: #2171b5; }

/* ── Incumbency / outcome badges ─────────────────────────────────────────── */
.inc-badge {
  display: inline-block;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 1px 6px;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 5px;
  white-space: nowrap;
}
.inc-badge--held {
  background: #d4edda;
  color: #155724;
  border: 1px solid #b1d8bb;
}
.inc-badge--lost {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #f5d97a;
}
.inc-badge--new {
  background: #d1ecf1;
  color: #0c5460;
  border: 1px solid #9cd6e2;
}

/* ── Election type badges ─────────────────────────────────────────────────── */
.election-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 3px;
  white-space: nowrap;
}
.election-badge--full {
  background: #d4edda;
  color: #155724;
  border: 1px solid #b1d8bb;
}
.election-badge--partial {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
}

/* ── Seat Changes panel ───────────────────────────────────────────────────── */
#seat-changes-section { padding-bottom: 4px; }
.seat-changes-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}
.seat-changes-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}
.seat-changes-context {
  font-size: 0.9rem;
  font-weight: 400;
  color: #666;
}
.seat-changes-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}
@media (max-width: 700px) {
  .seat-changes-tiles { grid-template-columns: repeat(2, 1fr); }
}
.sc-held  { border-left: 4px solid #2a9a55; }
.sc-lost  { border-left: 4px solid #e09a00; }
.sc-new   { border-left: 4px solid #0c8a9a; }

/* ── Ward incumbent mini-summary bar ─────────────────────────────────────── */
.ward-inc-summary {
  background: #f3f4f8;
  border: 1px solid #e0e0e8;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 0.83rem;
  color: #444;
  margin-bottom: 14px;
}
.ward-inc-summary strong { color: #222; }

/* ── Methodology link in tile ────────────────────────────────────────────── */
.meth-full-link {
  font-size: 0.84rem;
  color: #a07820;
  font-weight: 600;
  text-decoration: underline;
}
.meth-full-link:hover { color: #7a4f00; }

/* ── Methodology full-page modal ─────────────────────────────────────────── */
.meth-modal-inner {
  max-width: 780px;
}
.meth-modal-body {
  padding: 4px 4px 12px;
}
.meth-section {
  margin-bottom: 28px;
}
.meth-section h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid #e8eaf0;
}
.meth-section h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: #333;
  margin: 14px 0 6px;
}
.meth-section p, .meth-section li {
  font-size: 0.86rem;
  color: #444;
  line-height: 1.7;
}
.meth-section ol, .meth-section ul {
  padding-left: 20px;
  margin: 8px 0 8px;
}
.meth-section li { margin-bottom: 6px; }
.meth-section a { color: #2171b5; }
