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

:root {
    --bg:           #080910;
    --surface:      #0f1020;
    --surface-2:    #171829;
    --surface-3:    #1f2038;
    --border:       #272848;
    --border-hi:    #3a3c62;
    --text:         #e2e3f2;
    --text-dim:     #6b6d96;
    --text-muted:   #34365a;
    --gold:         #f5c518;
    --gold-dim:     rgba(245,197,24,0.15);
    --jlp:          #1aff7e;
    --jlp-dim:      #00b359;
    --jlp-bg:       rgba(26,255,126,0.06);
    --jlp-border:   rgba(26,255,126,0.22);
    --pnp:          #ff7043;
    --pnp-dim:      #cc4e2a;
    --pnp-bg:       rgba(255,112,67,0.06);
    --pnp-border:   rgba(255,112,67,0.22);
    --radius:       14px;
    --radius-sm:    9px;
    --radius-xs:    6px;
    --t:            0.2s ease;
    --sidebar-w:    290px;
}

[data-theme="light"] {
    --bg:           #eef0f9;
    --surface:      #ffffff;
    --surface-2:    #f4f5fc;
    --surface-3:    #eaebf7;
    --border:       #d2d4ec;
    --border-hi:    #b0b2d8;
    --text:         #12132a;
    --text-dim:     #5c5e88;
    --text-muted:   #9092b8;
    --gold-dim:     rgba(180,140,0,0.12);
    --jlp:          #00a850;
    --jlp-dim:      #007a3c;
    --jlp-bg:       rgba(0,168,80,0.08);
    --jlp-border:   rgba(0,168,80,0.3);
    --pnp:          #e8521a;
    --pnp-dim:      #b83d10;
    --pnp-bg:       rgba(232,82,26,0.08);
    --pnp-border:   rgba(232,82,26,0.3);
}

html, body { height: 100%; overflow: hidden; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.app {
    display: flex;
    width: 100vw;
    height: 100vh;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.sidebar-header {
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

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

.brand-flag {
    width: 38px;
    height: 25px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
    display: block;
    object-fit: cover;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.brand-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: 0.3px;
}

.brand-subtitle {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

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

.icon-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    width: 28px;
    height: 28px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--t);
    flex-shrink: 0;
}

.icon-btn:hover {
    border-color: var(--gold);
    color: var(--gold);
    background: var(--gold-dim);
}

/* keep old id selector working as alias */
#clearMarkersBtn { /* inherits .icon-btn */ }

.sidebar-search {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    position: relative;
}

.search-dropdown {
    position: absolute;
    left: 12px; right: 12px;
    top: calc(100% - 2px);
    background: var(--surface);
    border: 1px solid var(--gold);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    list-style: none;
    z-index: 200;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}

.search-dropdown li {
    padding: 9px 12px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background var(--t);
}

.search-dropdown li:last-child { border-bottom: none; }

.search-dropdown li:hover,
.search-dropdown li.active {
    background: var(--surface-2);
    color: var(--gold);
}

.sidebar-search input {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 7px 11px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-family: inherit;
    outline: none;
    transition: var(--t);
}

.sidebar-search input::placeholder { color: var(--text-dim); }

.sidebar-search input:focus {
    border-color: var(--gold);
    background: var(--surface-3);
    box-shadow: 0 0 0 3px var(--gold-dim);
}

/* ── Party History Link ── */
.party-history-link {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 6px 8px;
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-dim);
    transition: var(--t);
    flex-shrink: 0;
}

.party-history-link:hover {
    border-color: var(--gold);
    color: var(--gold);
    background: var(--gold-dim);
}

.party-history-icon { font-size: 13px; }

.party-history-arrow {
    margin-left: auto;
    font-size: 15px;
    color: var(--text-muted);
    transition: var(--t);
}

.party-history-link:hover .party-history-arrow { color: var(--gold); }

#constituencyList {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    padding: 8px 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

#constituencyList li {
    padding: 8px 10px 8px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 400;
    color: var(--text-dim);
    transition: var(--t);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    border: 1px solid transparent;
    margin-bottom: 1px;
    letter-spacing: 0.1px;
}

#constituencyList li::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    border-radius: 2px;
    background: var(--gold);
    transition: height 0.2s ease;
}

#constituencyList li:hover {
    background: var(--surface-2);
    color: var(--text);
}

#constituencyList li:hover::before { height: 14px; }

#constituencyList li.active {
    background: var(--surface-3);
    color: var(--text);
    font-weight: 600;
    border-color: var(--border-hi);
}

#constituencyList li.active::before { height: 20px; }

.update-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 8px var(--gold);
    flex-shrink: 0;
    animation: glow-pulse 1.6s ease-in-out infinite;
}

@keyframes glow-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 6px var(--gold); }
    50%       { opacity: 0.5; box-shadow: 0 0 2px var(--gold); }
}

/* ── Main ── */
.main {
    flex: 1;
    overflow-y: auto;
    background: var(--bg);
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

/* ── Placeholder ── */
.main-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 10px;
    text-align: center;
    padding: 40px;
}

.placeholder-glyph {
    font-size: 52px;
    margin-bottom: 12px;
    filter: grayscale(0.4);
}

.main-placeholder h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.main-placeholder p {
    font-size: 14px;
    color: var(--text-dim);
    max-width: 280px;
    line-height: 1.6;
}

/* ── Main Content ── */
.main-content {
    padding: 36px 40px;
    max-width: 840px;
}

.result-header {
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

#constituencyName {
    font-size: 30px;
    font-weight: 900;
    color: var(--text);
    letter-spacing: -1px;
    line-height: 1.1;
    margin-bottom: 8px;
}

.boxes-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 11.5px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    letter-spacing: 0.3px;
}

.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ef4444;
    animation: glow-pulse 1.2s ease-in-out infinite;
    box-shadow: 0 0 5px #ef4444;
}

/* ── Section Heading ── */
.section-heading {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-heading::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ── Candidate Cards (live) ── */
.candidates-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 32px;
}

.candidate-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    position: relative;
    overflow: hidden;
    transition: border-color var(--t), transform var(--t);
}

.candidate-card:hover { transform: translateX(2px); }

.candidate-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--border-hi);
}

.candidate-card.jlp { background: var(--jlp-bg); border-color: var(--jlp-border); }
.candidate-card.jlp::before { background: var(--jlp); }
.candidate-card.jlp.winner { border-color: var(--jlp); box-shadow: 0 0 0 1px var(--jlp-border), 0 4px 20px rgba(26,255,126,0.1); }

.candidate-card.pnp { background: var(--pnp-bg); border-color: var(--pnp-border); }
.candidate-card.pnp::before { background: var(--pnp); }
.candidate-card.pnp.winner { border-color: var(--pnp); box-shadow: 0 0 0 1px var(--pnp-border), 0 4px 20px rgba(255,112,67,0.1); }

.winner-badge {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 1.8px;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 20px;
    display: inline-block;
    margin-bottom: 5px;
}

.jlp .winner-badge {
    background: rgba(26,255,126,0.12);
    color: var(--jlp);
    border: 1px solid var(--jlp-border);
}
.pnp .winner-badge {
    background: rgba(255,112,67,0.12);
    color: var(--pnp);
    border: 1px solid var(--pnp-border);
}

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

.candidate-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.2px;
}

.candidate-party-tag {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-top: 3px;
}

.jlp .candidate-party-tag { color: var(--jlp-dim); }
.pnp .candidate-party-tag { color: var(--pnp-dim); }
.candidate-card:not(.jlp):not(.pnp) .candidate-party-tag { color: var(--text-dim); }

.candidate-votes {
    text-align: right;
    min-width: 170px;
}

.votes-number {
    font-size: 26px;
    font-weight: 900;
    color: var(--text);
    line-height: 1;
    margin-bottom: 8px;
    font-variant-numeric: tabular-nums;
    letter-spacing: -1px;
}

.votes-bar-wrap {
    height: 4px;
    background: var(--surface-3);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 5px;
}

.votes-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.jlp .votes-bar { background: var(--jlp); }
.pnp .votes-bar { background: var(--pnp); }
.candidate-card:not(.jlp):not(.pnp) .votes-bar { background: var(--text-muted); }

.votes-pct {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

/* ── No data ── */
.no-data {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px;
    text-align: center;
    color: var(--text-dim);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 32px;
}

/* ── Historical Divider ── */
.historical-divider {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 8px 0 20px;
}

.historical-divider span {
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--text-muted);
    flex-shrink: 0;
    background: var(--bg);
    padding-right: 4px;
}

.historical-divider::before {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border));
}

.historical-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to left, transparent, var(--border));
}

/* ── Historical Accordion ── */
.historical-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    overflow: hidden;
    transition: border-color var(--t);
}

.historical-item.border-jlp { border-color: rgba(26,255,126,0.35); }
.historical-item.border-pnp { border-color: rgba(255,112,67,0.35); }
.historical-item.border-jlp:hover, .historical-item.border-jlp.open { border-color: rgba(26,255,126,0.7); }
.historical-item.border-pnp:hover, .historical-item.border-pnp.open { border-color: rgba(255,112,67,0.7); }
.historical-item:hover { border-color: var(--border-hi); }
.historical-item.open  { border-color: var(--border-hi); }

.hist-header {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    cursor: pointer;
    gap: 14px;
    user-select: none;
    transition: background var(--t);
}

.hist-header:hover {
    background: var(--surface-2);
}

.hist-year {
    font-size: 18px;
    font-weight: 900;
    color: var(--text);
    letter-spacing: -0.5px;
    min-width: 48px;
}

.hist-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
}

.hist-meta {
    flex: 1;
    display: flex;
    gap: 22px;
    align-items: center;
}

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

.meta-label {
    font-size: 8.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #7a7ca8;
}

.meta-value {
    font-size: 13px;
    font-weight: 800;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.3px;
}

/* ── Expand chevron button ── */
.hist-chevron {
    flex-shrink: 0;
    margin-left: auto;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border-hi);
    background: var(--surface-3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8a8cb8;
    font-size: 27px;
    transition: background var(--t), border-color var(--t), color var(--t), transform 0.25s ease;
}

.hist-header:hover .hist-chevron {
    background: var(--surface-2);
    border-color: var(--gold);
    color: var(--gold);
}

.historical-item.open .hist-chevron {
    transform: rotate(180deg);
    background: var(--gold-dim);
    border-color: var(--gold);
    color: var(--gold);
}

.hist-body {
    display: none;
    border-top: 1px solid var(--border);
    padding: 16px 18px;
}

.historical-item.open .hist-body { display: block; }

/* ── Historical Candidate Rows ── */
.hist-candidates {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.hist-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--border-hi);
    transition: var(--t);
}

.hist-row.jlp { border-left-color: var(--jlp); background: var(--jlp-bg); }
.hist-row.pnp { border-left-color: var(--pnp); background: var(--pnp-bg); }

.hist-row-name {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hist-row-party {
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    min-width: 36px;
}

.hist-row.jlp .hist-row-party { color: var(--jlp); }
.hist-row.pnp .hist-row-party { color: var(--pnp); }
.hist-row:not(.jlp):not(.pnp) .hist-row-party { color: var(--text-dim); }

.hist-row-right {
    min-width: 130px;
    text-align: right;
}

.hist-row-votes {
    font-size: 14px;
    font-weight: 800;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.3px;
}

.hist-row-bar-wrap {
    height: 3px;
    background: var(--surface-3);
    border-radius: 2px;
    margin: 4px 0;
}

.hist-row-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 0.6s ease;
}

.hist-row.jlp .hist-row-bar { background: var(--jlp); }
.hist-row.pnp .hist-row-bar { background: var(--pnp); }
.hist-row:not(.jlp):not(.pnp) .hist-row-bar { background: var(--text-muted); }

.hist-row-pct {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

/* ── ED Toggle ── */
.ed-toggle-btn {
    margin-top: 14px;
    padding: 7px 14px;
    font-size: 11.5px;
    font-weight: 700;
    font-family: inherit;
    letter-spacing: 0.5px;
    background: var(--surface-3);
    color: var(--text-dim);
    border: 1px solid var(--border-hi);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--t);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ed-toggle-btn:hover {
    background: var(--surface-2);
    color: var(--gold);
    border-color: var(--gold);
    box-shadow: 0 0 0 2px var(--gold-dim);
}

/* ── ED Breakdown Panel ── */
.ed-breakdown-panel {
    display: none;
    margin-top: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg);
}

.ed-section { border-bottom: 1px solid var(--border); }
.ed-section:last-child { border-bottom: none; }

.ed-section-title {
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 7px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}

.ed-rows { display: flex; flex-direction: column; }

.ed-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 14px;
    border-bottom: 1px solid rgba(39,40,72,0.5);
    font-size: 12px;
    transition: background var(--t);
}

.ed-row:last-child { border-bottom: none; }
.ed-row.jlp { background: rgba(26,255,126,0.02); }
.ed-row.pnp { background: rgba(255,112,67,0.02); }
.ed-row:hover { background: var(--surface-2); }

.ed-row-name {
    flex: 1;
    font-weight: 500;
    color: var(--text);
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ed-row-party {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    min-width: 34px;
}

.ed-row.jlp .ed-row-party { color: var(--jlp); }
.ed-row.pnp .ed-row-party { color: var(--pnp); }
.ed-row:not(.jlp):not(.pnp) .ed-row-party { color: var(--text-dim); }

.ed-row-bar-wrap {
    width: 70px;
    height: 3px;
    background: var(--surface-3);
    border-radius: 2px;
}

.ed-row-bar { height: 100%; border-radius: 2px; }

.ed-row.jlp .ed-row-bar { background: var(--jlp); }
.ed-row.pnp .ed-row-bar { background: var(--pnp); }
.ed-row:not(.jlp):not(.pnp) .ed-row-bar { background: var(--text-muted); }

.ed-row-votes {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    min-width: 48px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ── Did Not Exist card ── */
.historical-item.dne { opacity: 0.55; cursor: default; }
.dne-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    border-radius: 14px;
    background: var(--surface);
    border: 1px dashed var(--border);
    cursor: default;
}
.dne-year { font-size: 22px; font-weight: 800; color: #4a4c6a; min-width: 54px; }
.dne-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: #4a4c6a;
    text-transform: uppercase;
}

/* ── Incumbent tag ── */
.incumbent-tag {
    display: inline-block;
    font-size: 8px;
    font-weight: 900;
    letter-spacing: 0.5px;
    color: var(--gold);
    background: var(--gold-dim);
    border: 1px solid rgba(245,197,24,0.35);
    padding: 1px 5px;
    border-radius: 4px;
    margin-left: 5px;
    vertical-align: middle;
    line-height: 1.6;
}

/* ── Analytics Panel ── */
.analytics-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
}

.analytics-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 18px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    flex-wrap: wrap;
    background: var(--surface-2);
}

.analytics-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.seat-badge {
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 20px;
}

.seat-badge.jlp   { background: rgba(26,255,126,0.12); color: var(--jlp); border: 1px solid rgba(26,255,126,0.35); }
.seat-badge.pnp   { background: rgba(255,112,67,0.12); color: var(--pnp); border: 1px solid rgba(255,112,67,0.35); }
.seat-badge.gold  { background: rgba(245,197,24,0.12); color: var(--gold); border: 1px solid rgba(245,197,24,0.35); }
.seat-badge.danger { background: rgba(239,68,68,0.12); color: #ef6060; border: 1px solid rgba(239,68,68,0.35); }

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

.win-record {
    display: flex;
    align-items: center;
    gap: 5px;
}

.win-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.win-dot.jlp    { background: var(--jlp); }
.win-dot.pnp    { background: var(--pnp); }
.win-dot.none   { background: var(--border); }

.win-record-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-dim);
    margin-left: 5px;
    white-space: nowrap;
}

.key-stats-bar {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.key-stat {
    flex: 1;
    padding: 9px 14px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.key-stat:last-child { border-right: none; }

.key-stat-label {
    font-size: 7.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.key-stat-value {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trend-chart-section {
    padding: 14px 18px 10px;
}

.trend-chart-label {
    font-size: 8.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.trend-chart-wrap {
    height: 210px;
    position: relative;
}

/* ── Swing Badge ── */
.swing-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
}

.swing-badge.flip-jlp {
    background: rgba(26,255,126,0.15);
    color: var(--jlp);
    border: 1px solid rgba(26,255,126,0.4);
}

.swing-badge.flip-pnp {
    background: rgba(255,112,67,0.15);
    color: var(--pnp);
    border: 1px solid rgba(255,112,67,0.4);
}

.swing-badge.hold-jlp {
    background: rgba(26,255,126,0.07);
    color: var(--jlp-dim);
    border: 1px solid rgba(26,255,126,0.18);
}

.swing-badge.hold-pnp {
    background: rgba(255,112,67,0.07);
    color: var(--pnp-dim);
    border: 1px solid rgba(255,112,67,0.18);
}

.swing-badge.hold-steady {
    background: var(--surface-3);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* ── Mobile ── */
/* ── Mobile ── */
@media (max-width: 768px) {
    html, body { overflow: auto; }

    .app { flex-direction: column; height: auto; min-height: 100vh; }

    /* Sidebar becomes a collapsible top bar */
    .sidebar {
        width: 100%;
        height: auto;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border);
        overflow: visible;
    }
    .sidebar-header { padding: 14px 14px 12px; }
    .brand-title { font-size: 15px; }
    .brand-subtitle { font-size: 9px; }

    /* Constituency list: horizontal scrolling pill row on mobile */
    #constituencyList {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 8px 12px;
        gap: 6px;
        max-height: none;
    }
    #constituencyList li {
        white-space: nowrap;
        padding: 6px 12px;
        border-radius: 20px;
        border: 1px solid var(--border);
        font-size: 12px;
        flex-shrink: 0;
    }
    #constituencyList li.active {
        background: var(--surface-3);
        border-color: var(--gold);
        color: var(--gold);
    }

    .party-history-link { padding: 10px 14px; font-size: 13px; }
    .sidebar-search { padding: 8px 12px; }

    /* Main */
    .main { height: auto; overflow-y: visible; }
    .main-placeholder { height: 40vh; padding: 24px 16px; }
    .main-placeholder h2 { font-size: 20px; }
    .main-content { padding: 16px 14px 32px; }

    #constituencyName { font-size: 20px; }

    /* Analytics panel */
    .analytics-panel { padding: 14px; gap: 12px; }
    .key-stats-bar { flex-wrap: wrap; }
    .key-stat { flex: 0 0 calc(50% - 1px); border-right: none; border-bottom: 1px solid var(--border); padding: 8px 12px; }
    .key-stat:nth-child(odd) { border-right: 1px solid var(--border); }
    .key-stat-label { font-size: 8px; white-space: normal; }
    .key-stat-value { font-size: 13px; }
    .trend-chart-wrap { height: 180px; }

    /* Candidate cards */
    .candidates-grid { grid-template-columns: 1fr; }
    .candidate-card { padding: 12px 14px; gap: 12px; }
    .votes-number { font-size: 20px; }
    .candidate-votes { min-width: 110px; }

    /* Historical items */
    .hist-header { padding: 14px 14px; gap: 10px; flex-wrap: wrap; }
    .hist-year { font-size: 22px; min-width: 50px; }
    .hist-meta { gap: 10px; flex-wrap: wrap; }
    .hist-meta .meta-pill { padding: 4px 8px; }
    .meta-label { font-size: 9px; }
    .meta-value { font-size: 12px; }
    .swing-badge { font-size: 9px; padding: 3px 7px; }

    /* Historical rows */
    .hist-row { padding: 8px 12px; font-size: 13px; }

    /* ED breakdown */
    .ed-table th, .ed-table td { font-size: 11px; padding: 6px 8px; }
}

@media (max-width: 420px) {
    .key-stats-bar { grid-template-columns: 1fr 1fr; }
    .hist-header { gap: 8px; }
    .analytics-header { flex-direction: column; align-items: flex-start; gap: 8px; }
}
