/* ============================================
   pc-components.css - PollCheck design system components
   Consolidated from the three flagship pages:
   gb-polls.css, css/p2n.css, demographic-swingometer/mrp-scenario.css.
   Requires css/pc-tokens.css. Playbook: /design-system.html

   Conventions:
   - Prefix: pc-
   - State classes: .is-active, .is-open, .is-pos / .is-neg / .is-nc
   - Colour slot: set --party-color on the element (inline or via JS)
   - Dark mode: token-driven via body.dark-mode; component-level
     dark overrides only where a data-URI or shadow needs swapping

   Contents:
   1  Wrapper, links, focus pack        9  Stat tiles, hero strip, seat chips
   2  Masthead, section scaffold       10  Bars: rows, stacks, seatbar, diverge
   3  Anchor nav, CTA row              11  Cards: poll card, panel, method cards
   4  Buttons, segmented controls      12  Pills, badges, tags
   5  Tabs                             13  Legends, swatches, sparkgrid
   6  Form controls, filter popover    14  Disclosure: FAQ, small, collapse card
   7  Party sliders                    15  Chart scaffolding, tooltip, events
   8  Tables                           16  Modal, toast, note boxes
   ============================================ */

/* ============ 1. Wrapper, links, focus pack ============ */
.pc-wrap {
    position: relative;
    max-width: 960px;
    margin: 0 auto;
    padding: 48px 32px 64px;
    font-family: var(--pc-sans);
    color: var(--pc-text-body);
    box-sizing: border-box;
}
.pc-wrap * { box-sizing: border-box; }
.pc-wrap--wide { max-width: 1080px; }
.pc-num { font-variant-numeric: tabular-nums; }

.pc-wrap a {
    color: var(--pc-text);
    text-decoration: underline;
    text-decoration-color: var(--pc-nc);
    text-underline-offset: 2px;
    transition: text-decoration-color 0.15s;
}
.pc-wrap a:hover {
    text-decoration-color: var(--pc-text);
}

/* Focus pack - one recipe sitewide */
.pc-wrap button:focus-visible,
.pc-wrap a:focus-visible,
.pc-wrap select:focus-visible,
.pc-wrap input:focus-visible,
.pc-wrap summary:focus-visible {
    outline: 2px solid var(--pc-text);
    outline-offset: 2px;
}
.pc-wrap input[type="range"]:focus-visible {
    outline: 2px solid var(--pc-text);
    outline-offset: 4px;
}
@media (pointer: coarse) {
    .pc-btn, .pc-select, .pc-tab, .pc-mode-btn { min-height: 44px; }
}

/* ============ 2. Masthead, section scaffold ============ */
.pc-kicker {
    font-family: var(--pc-sans);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--pc-text);
    margin: 0 0 8px 0;
}
.pc-masthead-rule {
    border: none;
    border-top: 3px solid var(--pc-text);
    margin: 0 0 16px 0;
}
.pc-masthead-headline {
    font-family: var(--pc-serif);
    font-size: 32px;
    font-weight: 700;
    color: var(--pc-text);
    line-height: 1.15;
    margin: 0 0 6px 0;
}
.pc-masthead-subtitle {
    font-family: var(--pc-sans);
    font-size: 14px;
    font-weight: 400;
    color: var(--pc-text-secondary);
    line-height: 1.5;
    margin: 0;
}
.pc-standfirst {
    font-family: var(--pc-serif);
    font-style: italic;
    font-size: 17px;
    line-height: 1.45;
    color: var(--pc-text-secondary);
    margin: 0;
    max-width: 620px;
}

/* Masthead grid variant: kicker + headline left, meta column right */
.pc-masthead {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "kicker meta" "headline meta";
    column-gap: 24px;
    border-bottom: 1px solid var(--pc-border);
    padding-bottom: 18px;
}
.pc-masthead .pc-kicker {
    grid-area: kicker;
    border-top: 3px solid var(--pc-text);
    padding-top: 10px;
    margin-bottom: 12px;
}
.pc-masthead .pc-masthead-headline { grid-area: headline; margin-bottom: 12px; }
.pc-masthead-meta {
    grid-area: meta;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 10px;
}
.pc-data-through {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--pc-text-meta);
}

/* Section scaffold */
.pc-section { margin-bottom: 52px; }
.pc-rule {
    border: none;
    border-top: 1px solid var(--pc-border);
    margin: 40px 0;
}
.pc-section-label {
    font-family: var(--pc-sans);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--pc-text-meta);
    margin: 0 0 16px 0;
}
.pc-section-title {
    font-family: var(--pc-serif);
    font-size: 23px;
    font-weight: 700;
    color: var(--pc-text);
    line-height: 1.2;
    margin: 0 0 6px 0;
}
.pc-section-label:has(+ .pc-section-title) { margin-bottom: 8px; }
.pc-help {
    font-family: var(--pc-sans);
    font-size: 12px;
    color: var(--pc-text-muted);
    line-height: 1.5;
    margin: 6px 0 16px;
    max-width: 640px;
}
.pc-footnote {
    font-size: 11px;
    color: var(--pc-text-meta);
    margin-top: 10px;
}
.pc-sources {
    font-size: 11px;
    color: var(--pc-text-muted);
    line-height: 1.6;
    margin-top: 32px;
}

/* Serif prose: intro block and bold-value callout sentence */
.pc-intro {
    font-family: var(--pc-serif);
    font-size: 17px;
    line-height: 1.6;
    color: var(--pc-text-body);
    max-width: 700px;
    margin: 0 0 16px;
}
.pc-callout {
    font-family: var(--pc-serif);
    font-size: 16px;
    line-height: 1.5;
    color: var(--pc-text-body);
    margin: 0;
    max-width: 700px;
}
.pc-callout strong { font-weight: 700; color: var(--pc-text); }

/* ============ 3. Anchor nav, CTA row ============ */
.pc-anchors {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0;
    margin: 18px 0 0;
}
.pc-anchor {
    font-size: 13px;
    font-weight: 600;
    color: var(--pc-text-secondary);
    text-decoration: none;
}
.pc-wrap .pc-anchor { text-decoration: none; }
.pc-anchor:hover { color: var(--pc-text); }
.pc-anchors .pc-anchor + .pc-anchor { margin-left: 12px; }
.pc-anchor + .pc-anchor::before {
    content: "";
    display: inline-block;
    width: 1px;
    height: 12px;
    background: var(--pc-border);
    margin-right: 12px;
    vertical-align: middle;
}

.pc-cta-row {
    display: flex;
    align-items: center;
    gap: 0;
    margin: 14px 0 0 0;
}
.pc-cta-link {
    font-family: var(--pc-sans);
    font-size: 13px;
    font-weight: 600;
    color: var(--pc-text-secondary);
    text-decoration: underline;
    text-underline-offset: 2px;
    padding: 4px 0;
}
.pc-cta-link:hover { color: var(--pc-text); }
.pc-cta-sep {
    width: 1px;
    height: 12px;
    background: var(--pc-border);
    margin: 0 12px;
}

/* ============ 4. Buttons, segmented controls ============ */
.pc-btn {
    font-family: var(--pc-sans);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--pc-border);
    background: var(--pc-surface);
    color: var(--pc-text-body);
    padding: 7px 13px;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.1s;
    line-height: 1;
    white-space: nowrap;
}
.pc-btn:hover { border-color: var(--pc-text-muted); }
/* Ink invert - default active state (view toggles, pills) */
.pc-btn.is-active {
    background: var(--pc-text);
    color: var(--pc-on-ink);
    border-color: var(--pc-text);
}
/* Primary action (CSV export, modal links) */
.pc-btn-primary {
    background: var(--pc-text);
    border: 1px solid var(--pc-text);
    border-radius: 0;
    color: var(--pc-on-ink);
    font-family: var(--pc-sans);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0 14px;
    height: 30px;
    cursor: pointer;
    transition: background 120ms;
}

/* Time-range group - the one accent-highlighted control */
.pc-seg {
    display: inline-flex;
    gap: 6px;
    flex-wrap: wrap;
}
.pc-seg .pc-btn {
    font-size: 14px;
    font-weight: 600;
    padding: 9px 17px;
    border-radius: 3px;
}
.pc-seg .pc-btn.is-active {
    background: var(--pc-accent);
    color: #FFFFFF;
    border-color: var(--pc-accent);
}

/* Joined segmented toggle (bordered, no gaps; active inverts to ink) */
.pc-mode-toggle {
    display: flex;
    width: fit-content;
    border: 1px solid var(--pc-border);
    overflow: hidden;
}
.pc-mode-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--pc-sans);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.1;
    min-height: 34px;
    padding: 7px 13px;
    white-space: nowrap;
    color: var(--pc-text-meta);
    background: none;
    border: none;
    cursor: pointer;
    transition: background 120ms, color 120ms;
}
.pc-mode-btn + .pc-mode-btn { border-left: 1px solid var(--pc-border); }
.pc-mode-btn:hover { color: var(--pc-text); background: var(--pc-hover-bg); }
.pc-mode-btn.is-active { background: var(--pc-text); color: var(--pc-on-ink); }

/* Compact joined presets (date presets etc.) */
.pc-presets {
    display: inline-flex;
    border: 1px solid var(--pc-border);
}
.pc-presets button {
    font-family: var(--pc-sans);
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    border: 0;
    background: transparent;
    padding: 5px 8px;
    cursor: pointer;
    color: var(--pc-text-secondary);
    border-right: 1px solid var(--pc-border);
}
.pc-presets button:last-child { border-right: 0; }
.pc-presets button.is-active {
    background: var(--pc-text);
    color: var(--pc-on-ink);
}

/* Theme toggle (top-right icon button; icons swap on body.dark-mode) */
.pc-theme-toggle {
    position: absolute;
    top: 24px;
    right: 24px;
    z-index: 10;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 30px;
    background: var(--pc-surface);
    color: var(--pc-text-secondary);
    border: 1px solid var(--pc-border);
    border-radius: 0;
    cursor: pointer;
    padding: 0;
    transition: color 120ms, border-color 120ms, background 120ms;
}
.pc-theme-toggle:hover { color: var(--pc-text); border-color: var(--pc-text); }
.pc-theme-icon { display: none; }
body:not(.dark-mode) .pc-theme-icon-moon { display: block; }
body.dark-mode .pc-theme-icon-sun { display: block; }

/* Control layout rows */
.pc-controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.pc-controls-group {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* ============ 5. Tabs ============ */
/* Page-level underline tabs */
.pc-tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--pc-border);
    margin: 0 0 20px;
}
.pc-tab {
    background: transparent;
    border: 0;
    border-bottom: 3px solid transparent;
    padding: 14px 20px 12px;
    font-family: var(--pc-sans);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--pc-text-secondary);
    cursor: pointer;
    transition: color 120ms, border-color 120ms;
    margin-bottom: -1px;
}
.pc-tab:hover { color: var(--pc-text); }
.pc-tab.is-active,
.pc-tab[aria-selected="true"] {
    color: var(--pc-text);
    border-bottom-color: var(--pc-text);
}
.pc-tab-panel[hidden] { display: none; }
@media (max-width: 768px) {
    .pc-tab-bar { overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
    .pc-tab { padding: 12px 14px 10px; font-size: 11px; }
}

/* Mini in-card tabs */
.pc-minitabs {
    display: flex;
    gap: 0;
    margin-bottom: 10px;
    border-bottom: 2px solid var(--pc-border);
}
.pc-minitab {
    padding: 5px 10px;
    font-family: var(--pc-sans);
    font-size: 11px;
    font-weight: 600;
    color: var(--pc-text-meta);
    cursor: pointer;
    border: 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    background: none;
    transition: color 0.15s;
}
.pc-minitab:hover { color: var(--pc-text-body); }
.pc-minitab.is-active { color: var(--pc-text); border-bottom-color: var(--pc-text); }

/* ============ 6. Form controls, filter popover ============ */
.pc-select {
    font-family: var(--pc-sans);
    font-size: 13px;
    font-weight: 400;
    color: var(--pc-text-body);
    border: 1px solid var(--pc-border);
    background: var(--pc-surface);
    padding: 6px 28px 6px 10px;
    border-radius: 2px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 10px 6px;
    line-height: 1.3;
}
body.dark-mode .pc-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23cbd5e1'/%3E%3C/svg%3E");
}

.pc-input {
    padding: 6px 10px;
    background: var(--pc-surface);
    border: 1px solid var(--pc-border);
    border-radius: 0;
    color: var(--pc-text);
    font-family: var(--pc-sans);
    font-size: 12px;
    height: 30px;
}
.pc-input::placeholder { color: var(--pc-text-meta); font-style: italic; }
.pc-input:focus { outline: none; border-color: var(--pc-text); }

.pc-date {
    font-family: var(--pc-sans);
    font-size: 13px;
    border: 1px solid var(--pc-border);
    background: var(--pc-surface);
    color: var(--pc-text);
    padding: 5px 8px;
}

/* Multi-select filter popover */
.pc-filter {
    position: relative;
}
.pc-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.pc-filter-btn::after {
    content: "";
    width: 10px;
    height: 6px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: 10px 6px;
}
.pc-filter-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 40;
    min-width: 200px;
    max-height: 320px;
    overflow-y: auto;
    background: var(--pc-surface);
    border: 1px solid var(--pc-border);
    border-radius: 2px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    padding: 6px 0;
    font-family: var(--pc-sans);
}
body.dark-mode .pc-filter-menu { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5); }
.pc-filter-menu-head {
    display: flex;
    justify-content: space-between;
    padding: 4px 12px 8px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--pc-border-light);
}
.pc-filter-menu-head a {
    font-size: 11px;
    color: var(--pc-text-secondary);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.pc-filter-opt {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--pc-text-body);
    cursor: pointer;
}
.pc-filter-opt:hover { background: var(--pc-hover-bg); }
.pc-filter-opt input { cursor: pointer; margin: 0; flex: none; }

/* Filter-result banner */
.pc-filter-banner {
    font-family: var(--pc-sans);
    font-size: 12px;
    color: var(--pc-text-secondary);
    margin-bottom: 12px;
}
.pc-filter-banner a { color: var(--pc-text-secondary); margin-left: 8px; }

/* Pagination */
.pc-page-btn {
    background: var(--pc-surface);
    border: 1px solid var(--pc-border);
    border-radius: 0;
    padding: 6px 12px;
    font-family: var(--pc-sans);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--pc-text-body);
    cursor: pointer;
    transition: color 120ms, border-color 120ms;
}
.pc-page-btn:hover:not(:disabled) { color: var(--pc-text); border-color: var(--pc-text); }
.pc-page-btn:disabled { color: var(--pc-text-meta); cursor: not-allowed; opacity: 0.55; }

/* ============ 7. Party sliders ============ */
/* Set --party-color on .pc-slider-row (or inline on the input) and
   update --perc from JS so the fill tracks the value. */
.pc-slider-row {
    --party-color: var(--pc-text-meta);
    display: flex;
    flex-direction: column;
    padding: 10px 0;
    border-bottom: 1px solid var(--pc-border-grid);
}
.pc-slider-row:last-child { border-bottom: 0; }
.pc-slider-meta {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 6px;
}
.pc-slider-swatch {
    flex: 0 0 auto;
    width: 10px;
    height: 10px;
    background: var(--party-color);
    transform: translateY(1px);
}
.pc-slider-name {
    flex: 1 1 auto;
    font-family: var(--pc-serif);
    font-weight: 700;
    font-size: 15px;
    color: var(--pc-text);
}
.pc-slider-ref {
    flex: 0 0 auto;
    font-family: var(--pc-sans);
    font-size: 10px;
    font-weight: 600;
    color: var(--pc-text-meta);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.pc-slider-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
}
.pc-slider-value-block {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 64px;
    justify-content: flex-end;
}
.pc-slider-value {
    font-family: var(--pc-sans);
    font-size: 16px;
    font-weight: 800;
    color: var(--pc-text);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.pc-slider {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    margin: 0;
    background: linear-gradient(
        to right,
        var(--party-color, var(--pc-text)) 0%,
        var(--party-color, var(--pc-text)) var(--perc, 0%),
        var(--pc-slider-track) var(--perc, 0%),
        var(--pc-slider-track) 100%
    );
    border: 0;
    border-radius: 0;
    outline: none;
    cursor: pointer;
}
.pc-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--party-color, var(--pc-text));
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
    cursor: pointer;
}
.pc-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--party-color, var(--pc-text));
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
    cursor: pointer;
}
.pc-slider::-moz-range-track { background: transparent; border: 0; }
@media (max-width: 768px) {
    .pc-slider { height: 16px; }
    .pc-slider::-webkit-slider-thumb { width: 28px; height: 28px; }
    .pc-slider::-moz-range-thumb { width: 28px; height: 28px; }
}

/* ============ 8. Tables ============ */
.pc-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.pc-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--pc-sans);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.pc-table thead th {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--pc-text-meta);
    text-align: left;
    padding: 6px 8px;
    border-bottom: 2px solid var(--pc-text);
    white-space: nowrap;
}
.pc-table thead th:not(:first-child) { text-align: right; }
.pc-table tbody td {
    padding: 8px 8px;
    border-bottom: 1px solid var(--pc-border-light);
    color: var(--pc-text-body);
}
.pc-table tbody td:not(:first-child) { text-align: right; }
.pc-table tbody tr:hover { background: var(--pc-hover-bg); }

/* Party-coloured column accent: set --party-color on the th */
.pc-table thead th.pc-party-col {
    border-top: 3px solid var(--party-color);
    color: var(--party-color);
}

/* Sortable headers */
.pc-th-sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
    white-space: nowrap;
}
.pc-th-sortable:hover { background: var(--pc-hover-bg); }
.pc-sort-icon {
    font-size: 8px;
    color: var(--pc-text-meta);
    margin-left: 2px;
}

/* Stacked per-cell delta */
.pc-table .pc-cell-delta {
    display: block;
    font-size: 10px;
    line-height: 1.2;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
}
.pc-cell-delta.is-pos { color: var(--pc-positive); }
.pc-cell-delta.is-neg { color: var(--pc-negative); }
.pc-cell-delta.is-nc { color: var(--pc-text-meta); }

/* Clickable / active rows (rank tables): tint fill + ink left bar */
.pc-table tbody tr.is-clickable { cursor: pointer; }
.pc-table tbody tr.is-active {
    background: var(--pc-tint);
    box-shadow: inset 3px 0 0 var(--pc-text);
}

/* Table furniture */
.pc-table-count {
    font-family: var(--pc-sans);
    font-size: 12px;
    color: var(--pc-text-meta);
    margin: 4px 0 8px 0;
}

/* Heat matrix (cell backgrounds set inline; leader cell outlined) */
.pc-heat { border-collapse: collapse; width: 100%; min-width: 660px; }
.pc-heat thead th {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--pc-text-meta);
    border-bottom: 2px solid var(--pc-text);
    padding: 8px 10px;
    text-align: right;
    white-space: nowrap;
}
.pc-heat thead th:first-child { text-align: left; }
.pc-heat tbody tr { border-bottom: 1px solid var(--pc-border-light); }
.pc-heat-rowlabel {
    font-size: 13px;
    font-weight: 600;
    color: var(--pc-text);
    padding: 11px 10px;
    white-space: nowrap;
}
.pc-heat-cell {
    font-size: 13px;
    text-align: right;
    padding: 11px 10px;
    font-variant-numeric: tabular-nums;
    color: var(--pc-text);
}
.pc-heat-cell.is-lead { font-weight: 700; box-shadow: inset 0 0 0 2px var(--pc-text); }

/* ============ 9. Stat tiles, hero strip, seat chips ============ */
/* Bordered KPI grid with optional sparkline */
.pc-stat-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    border: 1px solid var(--pc-border);
}
.pc-stat-cell {
    padding: 14px 16px 12px;
    border-right: 1px solid var(--pc-border-light);
}
.pc-stat-cell:last-child { border-right: 0; }
.pc-stat-name {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: var(--pc-sans);
    font-size: 12px;
    font-weight: 600;
    color: var(--pc-text-secondary);
}
.pc-stat-num {
    font-family: var(--pc-sans);
    font-size: 28px;
    font-weight: 700;
    color: var(--pc-text);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    margin-top: 4px;
}
.pc-stat-num sup {
    font-size: 13px;
    font-weight: 400;
    color: var(--pc-text-meta);
}
.pc-stat-lbl {
    font-family: var(--pc-sans);
    font-size: 10px;
    color: var(--pc-text-meta);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 2px;
}
.pc-stat-spark {
    width: 100%;
    height: 38px;
    display: block;
    margin-top: 8px;
}
.pc-stat-spark path {
    fill: none;
    stroke-width: 1.25;
    vector-effect: non-scaling-stroke;
    stroke-linejoin: round;
    stroke-linecap: round;
}
.pc-stat-chg {
    font-family: var(--pc-sans);
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    margin-top: 6px;
}
.pc-stat-chg-label {
    font-weight: 600;
    color: var(--pc-text-meta);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 4px;
}
@media (max-width: 768px) {
    .pc-stat-grid { grid-template-columns: repeat(2, 1fr); }
    .pc-stat-cell:nth-child(2n) { border-right: 0; }
}

/* Hero numbers strip: party-colour left border stat blocks */
.pc-hero-strip {
    display: flex;
    gap: 0;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.pc-hero-party {
    flex: 1;
    min-width: 80px;
    padding: 10px 12px;
    border-left: 4px solid var(--party-color, var(--pc-nc));
    margin-bottom: 8px;
}
.pc-hero-name {
    font-family: var(--pc-sans);
    font-size: 11px;
    color: var(--pc-text-secondary);
    margin: 0 0 2px 0;
    line-height: 1;
}
.pc-hero-pct {
    font-family: var(--pc-sans);
    font-size: 28px;
    font-weight: 700;
    color: var(--pc-text);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.pc-hero-changes {
    display: flex;
    gap: 8px;
    margin-top: 3px;
}
.pc-hero-chg {
    font-family: var(--pc-sans);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    white-space: nowrap;
}
.pc-hero-chg-label {
    font-size: 9px;
    font-weight: 600;
    color: var(--pc-text-meta);
    margin-right: 2px;
    text-transform: uppercase;
}
.pc-hero-chg.is-pos { color: var(--pc-positive); }
.pc-hero-chg.is-neg { color: var(--pc-negative); }
.pc-hero-chg.is-nc { color: var(--pc-nc); }
@media (max-width: 768px) {
    .pc-hero-strip { display: grid; grid-template-columns: repeat(4, 1fr); }
    .pc-hero-party { min-width: unset; }
    .pc-hero-pct { font-size: 24px; }
}
@media (max-width: 480px) {
    .pc-hero-strip { grid-template-columns: 1fr 1fr; }
    .pc-hero-party { padding: 8px 12px; margin-bottom: 0; }
    .pc-hero-pct { font-size: 22px; }
}

/* Seat chips: 3px party-colour left rule + name + count + delta */
.pc-seat-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-family: var(--pc-sans);
    font-variant-numeric: tabular-nums;
}
.pc-seat-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    line-height: 1.2;
    padding: 4px 9px 4px 8px;
    background: var(--pc-surface);
    border: 1px solid var(--pc-border-light);
    border-left: 3px solid var(--party-color, var(--pc-border));
}
.pc-seat-chip-name {
    font-size: 10px;
    font-weight: 700;
    color: var(--pc-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.pc-seat-chip-seats {
    font-size: 13px;
    font-weight: 800;
    color: var(--pc-text);
}
.pc-seat-chip-delta { font-size: 10px; font-weight: 600; }
.pc-seat-chip-delta.is-pos { color: var(--pc-positive); }
.pc-seat-chip-delta.is-neg { color: var(--pc-negative); }
.pc-seat-chip-delta.is-nc { color: var(--pc-text-meta); }

/* ============ 10. Bars ============ */
/* Horizontal party bar row: name / track+fill / value / change */
.pc-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-family: var(--pc-sans);
    font-variant-numeric: tabular-nums;
}
.pc-bar-name {
    width: 70px;
    flex-shrink: 0;
    color: var(--pc-text-secondary);
    font-size: 12px;
}
.pc-bar-track {
    flex: 1 1 auto;
    height: 18px;
    background: var(--pc-tint);
    position: relative;
    overflow: hidden;
}
.pc-bar-fill {
    display: block;
    height: 100%;
    background: var(--party-color, var(--pc-text-meta));
    opacity: 0.82;
}
.pc-bar-val {
    width: 38px;
    text-align: right;
    font-size: 13px;
    font-weight: 700;
    color: var(--pc-text);
    flex: 0 0 38px;
}
.pc-bar-chg {
    width: 42px;
    text-align: right;
    font-size: 12px;
    font-weight: 600;
    flex: 0 0 42px;
}
.pc-bar-chg.is-pos { color: var(--pc-positive); }
.pc-bar-chg.is-neg { color: var(--pc-negative); }
.pc-bar-chg.is-nc { color: var(--pc-text-muted); }

/* Stacked 100% bar with in-segment labels */
.pc-stack {
    display: flex;
    width: 100%;
    height: 22px;
    background: var(--pc-tint);
    border: 1px solid var(--pc-border);
    overflow: hidden;
}
.pc-stack-seg {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
    background: var(--party-color, var(--pc-nc));
    color: #fff;
    transition: flex-grow 260ms cubic-bezier(.4, 0, .2, 1);
    container-type: inline-size;
}
.pc-stack-seg-label {
    font-family: var(--pc-sans);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #fff;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
    white-space: nowrap;
    overflow: hidden;
    padding: 0 4px;
    max-width: 100%;
}
@container (max-width: 20px) {
    .pc-stack-seg-label { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .pc-stack-seg { transition: none; }
}

/* Labelled stack row: label / bar / lead readout */
.pc-stack-row {
    display: grid;
    grid-template-columns: 116px 1fr 132px;
    align-items: center;
    gap: 14px;
    font-family: var(--pc-sans);
    font-variant-numeric: tabular-nums;
}
.pc-stack-rowlabel {
    font-size: 13px;
    font-weight: 600;
    color: var(--pc-text);
    line-height: 1.2;
}
.pc-stack-lead {
    font-size: 12px;
    color: var(--pc-text-secondary);
    text-align: right;
    line-height: 1.2;
}
.pc-stack-lead-party {
    font-weight: 600;
    color: var(--pc-text);
    display: inline-block;
    border-left: 3px solid var(--party-color, var(--pc-nc));
    padding-left: 6px;
    margin-right: 4px;
}
@media (max-width: 600px) {
    .pc-stack-row {
        grid-template-columns: 1fr auto;
        grid-template-areas: "label lead" "bar bar";
        column-gap: 12px;
        row-gap: 6px;
        align-items: baseline;
    }
    .pc-stack-rowlabel { grid-area: label; }
    .pc-stack-row .pc-stack { grid-area: bar; height: 26px; }
    .pc-stack-lead { grid-area: lead; }
}

/* Seat projection bar with majority marker.
   Set the marker position inline (left: %) and its label via data-label. */
.pc-seatbar-wrap {
    border: 1px solid var(--pc-border);
    padding: 20px 22px;
}
.pc-seatbar-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.pc-seatbar-verdict {
    font-family: var(--pc-serif);
    font-size: 18px;
    font-weight: 700;
    color: var(--pc-text);
}
.pc-seatbar-note {
    font-family: var(--pc-sans);
    font-size: 12px;
    color: var(--pc-text-meta);
    font-variant-numeric: tabular-nums;
}
.pc-seatbar-track { position: relative; }
.pc-seatbar {
    height: 44px;
    display: flex;
    border-radius: 2px;
    overflow: hidden;
    background: var(--pc-border-light);
}
.pc-seatbar .pc-seat-seg {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--pc-sans);
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    min-width: 0;
    overflow: hidden;
    background: var(--party-color, var(--pc-nc));
    transition: width 0.8s cubic-bezier(.4, 0, .2, 1);
}
@media (prefers-reduced-motion: reduce) {
    .pc-seatbar .pc-seat-seg { transition: none; }
}
.pc-seat-majority {
    position: absolute;
    top: -6px;
    bottom: -6px;
    width: 2px;
    background: var(--pc-text);
}
.pc-seat-majority::after {
    content: attr(data-label);
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--pc-sans);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--pc-text);
    white-space: nowrap;
}
.pc-seat-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin-top: 26px;
}
.pc-seat-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: var(--pc-sans);
    font-size: 13px;
    color: var(--pc-text-secondary);
}
.pc-seat-legend-item b {
    color: var(--pc-text);
    font-variant-numeric: tabular-nums;
}

/* Diverging swing bar (centre zero line, pos right / neg left) */
.pc-diverge {
    position: relative;
    height: 14px;
}
.pc-diverge::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 1px;
    bottom: 1px;
    width: 1px;
    background: var(--pc-text-muted);
}
.pc-diverge > span {
    position: absolute;
    top: 2px;
    bottom: 2px;
}
.pc-diverge > span.is-pos { left: 50%; background: var(--pc-positive); }
.pc-diverge > span.is-neg { right: 50%; background: var(--pc-negative); }

/* Compare-two-dates module (from gb-polls): two date cells with presets,
   snapshot lines, then a From -> To table with diverging swing bars */
.pc-compare { border: 1px solid var(--pc-border); }
.pc-compare-top {
    display: grid;
    grid-template-columns: 1fr 48px 1fr;
    align-items: center;
    border-bottom: 1px solid var(--pc-border-light);
}
.pc-compare-cell { padding: 14px 18px; }
.pc-compare-cell:first-child { border-right: 1px solid var(--pc-border-light); }
.pc-compare-cell h4 {
    font-family: var(--pc-sans);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--pc-text-meta);
    font-weight: 700;
    margin: 0 0 8px;
}
.pc-compare-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.pc-compare-snap {
    font-family: var(--pc-sans);
    font-size: 12px;
    color: var(--pc-text-meta);
    margin-top: 8px;
    font-variant-numeric: tabular-nums;
}
.pc-compare-arrow {
    text-align: center;
    color: var(--pc-text-meta);
    font-size: 22px;
}
.pc-compare-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--pc-sans);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}
.pc-compare-table th,
.pc-compare-table td {
    padding: 9px 18px;
    text-align: right;
    border-bottom: 1px solid var(--pc-border-light);
}
.pc-compare-table th:first-child,
.pc-compare-table td:first-child { text-align: left; }
.pc-compare-table thead th {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--pc-text-meta);
    font-weight: 700;
    border-bottom: 2px solid var(--pc-text);
}
.pc-cmp-name {
    font-weight: 600;
    color: var(--pc-text);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.pc-cmp-val { font-weight: 700; color: var(--pc-text); }
.pc-cmp-arr { color: var(--pc-text-muted); padding: 0 4px; }
.pc-cmp-bar, .pc-cmp-bar-h { width: 26%; }
@media (max-width: 768px) {
    .pc-compare-top { grid-template-columns: 1fr; }
    .pc-compare-cell:first-child { border-right: 0; border-bottom: 1px solid var(--pc-border-light); }
    .pc-compare-arrow { display: none; }
    .pc-compare-table th,
    .pc-compare-table td { padding: 9px 10px; }
}

/* ============ 11. Cards ============ */
/* Top-ruled poll card: 2px ink rule, label/date row, pollster, bar rows */
.pc-poll-card {
    border-top: 2px solid var(--pc-text);
    padding: 12px 0 0 0;
}
.pc-poll-card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 2px;
}
.pc-poll-card-label {
    font-family: var(--pc-sans);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--pc-text-meta);
}
.pc-poll-card-date {
    font-family: var(--pc-sans);
    font-size: 12px;
    color: var(--pc-text-meta);
}
.pc-poll-card-meta {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 10px;
}
.pc-poll-card-pollster {
    font-family: var(--pc-serif);
    font-size: 18px;
    font-weight: 700;
    color: var(--pc-text);
}
.pc-poll-card-detail {
    font-family: var(--pc-sans);
    font-size: 12px;
    color: var(--pc-text-meta);
}
.pc-poll-card-note {
    font-family: var(--pc-sans);
    font-size: 11px;
    color: var(--pc-text-meta);
    margin-top: 10px;
}

/* Bordered panel with serif head + tabular sub */
.pc-panel {
    background: var(--pc-surface);
    border: 1px solid var(--pc-border);
    padding: 18px 20px 14px;
}
.pc-panel-head-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
}
.pc-panel-head {
    font-family: var(--pc-serif);
    font-size: 18px;
    font-weight: 700;
    color: var(--pc-text);
    margin: 0;
}
.pc-panel-sub {
    font-size: 12px;
    color: var(--pc-text-meta);
    font-variant-numeric: tabular-nums;
}

/* Method cards: top-ruled serif card grid */
.pc-method-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin: 24px 0 32px;
}
.pc-method-card {
    background: var(--pc-surface);
    border: 1px solid var(--pc-border-grid);
    border-top: 3px solid var(--pc-text);
    padding: 16px 18px 18px;
}
.pc-method-card-h {
    margin: 0 0 8px;
    font-family: var(--pc-serif);
    font-weight: 700;
    font-size: 16px;
    color: var(--pc-text);
}
.pc-method-card p {
    margin: 0;
    font-family: var(--pc-serif);
    font-size: 14px;
    line-height: 1.55;
    color: var(--pc-text-body);
}
@media (max-width: 768px) {
    .pc-method-cards { grid-template-columns: 1fr; gap: 12px; }
    .pc-method-card { padding: 14px 16px; }
}

/* ============ 12. Pills, badges, tags ============ */
/* Winner pill: full-width party-colour result strip */
.pc-winner-pill {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 0;
    background: var(--party-color, var(--pc-text-meta));
    color: #fff;
    font-family: var(--pc-sans);
    font-weight: 600;
    font-size: 12px;
    text-align: center;
    width: 100%;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.pc-winner-pill.is-light-bg { color: #1f2937; text-shadow: none; }
.pc-winner-prob { float: right; font-weight: 500; font-size: 11px; opacity: 0.85; }
.pc-winner-pill.is-light-bg .pc-winner-prob { opacity: 0.7; }

/* Uncertainty / classification badge: outlined uppercase chip */
.pc-badge {
    font-family: var(--pc-sans);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 2px 7px;
    border: 1px solid var(--pc-text-secondary);
    color: var(--pc-text-secondary);
    white-space: nowrap;
}
.pc-badge.is-tossup { border-color: var(--pc-warning); color: var(--pc-warning); }
.pc-badge.is-safe { border-color: var(--pc-positive); color: var(--pc-positive); }

/* Tiny inline tag chip (MRP, REGIONAL, ...) */
.pc-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 4px;
    border: 1px solid var(--pc-border);
    border-radius: 2px;
    font-family: var(--pc-sans);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--pc-text-meta);
    vertical-align: 1px;
}

/* Change badges */
.pc-change {
    font-family: var(--pc-sans);
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.pc-change.is-pos { color: var(--pc-positive); }
.pc-change.is-neg { color: var(--pc-negative); }
.pc-change.is-nc { color: var(--pc-text-meta); }

/* Two-line selector pill (label + sub-line) */
.pc-pill {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    padding: 6px 10px;
    background: var(--pc-surface);
    border: 1px solid var(--pc-border);
    border-radius: 0;
    color: var(--pc-text-body);
    cursor: pointer;
    font-family: var(--pc-sans);
    transition: background 120ms, color 120ms, border-color 120ms;
}
.pc-pill:hover { background: var(--pc-hover-bg); color: var(--pc-text); }
.pc-pill.is-active {
    background: var(--pc-text);
    border-color: var(--pc-text);
    color: var(--pc-on-ink);
}
.pc-pill-label {
    font-size: 11px;
    font-weight: 600;
    line-height: 1.15;
}
.pc-pill-sub {
    font-size: 10px;
    font-weight: 500;
    color: var(--pc-text-meta);
    line-height: 1.15;
}
.pc-pill.is-active .pc-pill-sub { color: var(--pc-on-ink); opacity: 0.7; }

/* ============ 13. Legends, swatches, sparkgrid ============ */
.pc-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    background: var(--party-color, var(--pc-nc));
    vertical-align: middle;
    flex: 0 0 auto;
}
.pc-swatch--dot { border-radius: 50%; }

/* Plain legend */
.pc-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    font-family: var(--pc-sans);
    font-size: 12px;
    color: var(--pc-text-body);
}
.pc-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1.3;
}
.pc-legend-val {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--pc-text);
}

/* Boxed clickable legend chips with dim state */
.pc-legend--chips { gap: 8px; }
.pc-legend--chips .pc-legend-item {
    cursor: pointer;
    font-size: 13px;
    border: 1px solid var(--pc-border);
    border-radius: 3px;
    padding: 5px 10px;
    background: var(--pc-tint);
}
.pc-legend--chips .pc-legend-item:hover { border-color: var(--pc-text); }
.pc-legend--chips .pc-legend-name { color: var(--pc-text-secondary); }
.pc-legend--chips .pc-legend-item.is-dim .pc-legend-name,
.pc-legend--chips .pc-legend-item.is-dim .pc-legend-val {
    color: var(--pc-text-muted);
    font-weight: 400;
}

/* Sparkline grid / small multiples */
.pc-sparkgrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    border: 1px solid var(--pc-border);
    background: var(--pc-surface);
}
.pc-spark-cell {
    border-right: 1px solid var(--pc-border-light);
    border-bottom: 1px solid var(--pc-border-light);
    padding: 10px 12px;
    cursor: pointer;
}
.pc-spark-cell.is-active {
    background: var(--pc-tint);
    box-shadow: inset 3px 0 0 var(--pc-text);
}
.pc-spark-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}
.pc-spark-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--pc-text);
}
.pc-spark-lead {
    font-size: 11px;
    color: var(--pc-text-meta);
    font-variant-numeric: tabular-nums;
}
.pc-spark-cell svg {
    display: block;
    width: 100%;
    height: auto;
    margin-top: 4px;
}

/* ============ 14. Disclosure ============ */
/* FAQ accordion: serif question, +/- marker */
.pc-faq details {
    border-bottom: 1px solid var(--pc-border-light);
}
.pc-faq details:first-of-type { border-top: 1px solid var(--pc-border-light); }
.pc-faq summary {
    font-family: var(--pc-serif);
    font-size: 16px;
    font-weight: 700;
    color: var(--pc-text);
    padding: 16px 32px 16px 0;
    cursor: pointer;
    list-style: none;
    position: relative;
    line-height: 1.4;
}
.pc-faq summary::-webkit-details-marker { display: none; }
.pc-faq summary::after {
    content: '+';
    position: absolute;
    right: 0;
    top: 16px;
    font-family: var(--pc-sans);
    font-size: 18px;
    font-weight: 300;
    color: var(--pc-text-meta);
    line-height: 1;
}
.pc-faq details[open] summary::after { content: '\2013'; }
.pc-faq-answer {
    font-family: var(--pc-sans);
    font-size: 14px;
    line-height: 1.6;
    color: var(--pc-text-body);
    padding: 0 0 16px 0;
    max-width: 600px;
}
.pc-faq-answer p { margin: 0 0 8px 0; }
.pc-faq-answer p:last-child { margin-bottom: 0; }
@media (pointer: coarse) { .pc-faq summary { min-height: 44px; } }

/* Small disclosure: sans summary with + prefix */
.pc-disclosure {
    margin-top: 16px;
    border-top: 1px solid var(--pc-border-light);
    padding-top: 10px;
}
.pc-disclosure > summary {
    font-family: var(--pc-sans);
    font-size: 13px;
    font-weight: 600;
    color: var(--pc-text-body);
    cursor: pointer;
    list-style: none;
}
.pc-disclosure > summary::-webkit-details-marker { display: none; }
.pc-disclosure > summary::before {
    content: '+';
    display: inline-block;
    width: 14px;
    color: var(--pc-text-meta);
    font-weight: 400;
}
.pc-disclosure[open] > summary::before { content: '\2212'; }
.pc-disclosure-cap { font-weight: 400; color: var(--pc-text-meta); }
.pc-disclosure-body {
    font-family: var(--pc-sans);
    font-size: 12px;
    line-height: 1.6;
    color: var(--pc-text-secondary);
    padding: 8px 0 12px;
    max-width: 640px;
}

/* Collapsible control card: full-width toggle header + chevron */
.pc-collapse {
    background: var(--pc-surface);
    border: 1px solid var(--pc-border);
}
.pc-collapse-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: transparent;
    border: 0;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    color: var(--pc-text);
}
.pc-collapse-toggle:hover { background: var(--pc-hover-bg); }
.pc-collapse-title {
    font-family: var(--pc-serif);
    font-weight: 700;
    font-size: 16px;
    color: var(--pc-text);
}
.pc-collapse-meta {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--pc-sans);
    font-size: 11px;
    font-weight: 600;
    color: var(--pc-text-meta);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.pc-collapse-status.has-active { color: var(--pc-text); }
.pc-collapse-status.has-active::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--pc-negative);
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: 1px;
}
.pc-collapse-chevron {
    color: var(--pc-text-meta);
    font-size: 12px;
    transition: transform 160ms ease;
}
.pc-collapse.is-open .pc-collapse-chevron { transform: rotate(90deg); }
.pc-collapse-body {
    display: none;
    padding: 4px 16px 16px;
    border-top: 1px solid var(--pc-border-grid);
}
.pc-collapse.is-open .pc-collapse-body { display: block; }

/* ============ 15. Chart scaffolding ============ */
.pc-chart-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}
.pc-chart-container {
    position: relative;
    width: 100%;
}
.pc-chart-container svg {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
}

/* Responsive SVG + HTML overlay pattern */
.pc-plot-wrap { position: relative; width: 100%; }
.pc-plot-wrap svg { display: block; width: 100%; height: auto; }
.pc-plot-overlay { position: absolute; inset: 0; pointer-events: none; }
.pc-ylabel {
    position: absolute;
    left: 0;
    font-family: var(--pc-sans);
    font-size: 11px;
    color: var(--pc-text-meta);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.pc-xaxis { position: relative; height: 16px; margin-top: 2px; }
.pc-xlabel {
    position: absolute;
    font-family: var(--pc-sans);
    font-size: 11px;
    color: var(--pc-text-meta);
    white-space: nowrap;
}
.pc-endlabel {
    position: absolute;
    white-space: nowrap;
    line-height: 1;
    font-family: var(--pc-sans);
    font-size: 11.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--party-color, var(--pc-text));
}

/* Chart tooltip */
.pc-tooltip {
    position: absolute;
    pointer-events: none;
    background: var(--pc-surface);
    border: 1px solid var(--pc-border);
    border-radius: 3px;
    padding: 8px 12px;
    font-family: var(--pc-sans);
    font-size: 12px;
    z-index: 10;
    white-space: nowrap;
}
.pc-tooltip-date {
    font-weight: 700;
    color: var(--pc-text-body);
    margin-bottom: 4px;
    font-size: 11px;
}
.pc-tooltip-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 1px 0;
}
.pc-tooltip-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--party-color, var(--pc-nc));
}
.pc-tooltip-name {
    flex: 1;
    color: var(--pc-text-secondary);
    font-size: 11px;
}
.pc-tooltip-val {
    font-weight: 700;
    color: var(--pc-text);
    font-variant-numeric: tabular-nums;
    font-size: 11px;
    margin-left: auto;
}

/* Event badges: numbered ink circles + legend strip */
.pc-event-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--pc-tooltip-bg);
    color: var(--pc-tooltip-text);
    font-family: var(--pc-sans);
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
}
.pc-event-badge--overlay {
    position: absolute;
    transform: translateX(-50%);
}
.pc-event-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin: 10px 0 0;
    font-family: var(--pc-sans);
    font-size: 12px;
    color: var(--pc-text-body);
}
.pc-event-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1.3;
}

/* Map legend with gradient ramp */
.pc-map-legend {
    background: var(--pc-surface);
    border: 1px solid var(--pc-border);
    padding: 8px 12px;
    display: inline-block;
}
.pc-map-legend-title {
    font-family: var(--pc-sans);
    font-size: 10px;
    font-weight: 700;
    color: var(--pc-text-meta);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 6px;
}
.pc-map-legend-gradient {
    width: 140px;
    height: 8px;
    margin-bottom: 4px;
    border: 1px solid var(--pc-border);
}
.pc-map-legend-labels {
    display: flex;
    justify-content: space-between;
    font-family: var(--pc-sans);
    font-size: 10px;
    font-weight: 600;
    color: var(--pc-text-secondary);
    font-variant-numeric: tabular-nums;
}

/* ============ 16. Modal, toast, note boxes ============ */
.pc-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    padding: 20px;
    overflow-y: auto;
}
.pc-modal-inner {
    max-width: 600px;
    margin: 40px auto;
    background: var(--pc-surface);
    border: 1px solid var(--pc-border);
    border-radius: 2px;
    padding: 24px;
    position: relative;
    color: var(--pc-text-body);
}
.pc-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: var(--pc-hover-bg);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--pc-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}
.pc-modal-title {
    margin: 0 0 8px;
    font-size: 21px;
    color: var(--pc-text);
    font-family: var(--pc-serif);
}

.pc-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translate(-50%, 8px);
    background: var(--pc-tooltip-bg);
    color: var(--pc-tooltip-text);
    font-family: var(--pc-sans);
    font-size: 13px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms, transform 160ms;
    z-index: 9000;
}
.pc-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
    pointer-events: auto;
}
.pc-toast button {
    background: none;
    border: 1px solid var(--pc-tooltip-text);
    color: var(--pc-tooltip-text);
    font-family: var(--pc-sans);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 4px 10px;
    cursor: pointer;
}

/* Amber note/caveat box */
.pc-note {
    font-family: var(--pc-sans);
    font-size: 13px;
    line-height: 1.55;
    color: var(--pc-text-body);
    background: var(--pc-hover-bg);
    border-left: 3px solid var(--pc-warning);
    padding: 10px 14px;
    margin: 6px 0 16px;
    border-radius: 2px;
}
.pc-note strong { color: var(--pc-text); }
.pc-note[hidden] { display: none; }

/* ============ Responsive base ============ */
@media (max-width: 768px) {
    .pc-wrap { padding: 32px 16px 48px; }
    .pc-masthead-headline { font-size: 26px; }
    .pc-masthead {
        grid-template-columns: 1fr;
        grid-template-areas: "kicker" "headline" "meta";
    }
    .pc-masthead-meta { align-items: flex-start; margin-top: 14px; }
    .pc-theme-toggle { width: 28px; height: 28px; }
}
@media (max-width: 480px) {
    .pc-masthead-headline { font-size: 24px; }
}

/* ============ 17. Nation seats + map module ============ */
/* Styles for js/nation-seats-map.js (scottish-polls + welsh-polls):
   seat hero bar, constituency map + search, and the constituency
   detail card (cc- classes, ported from the demographic swingometer).
   sp- prefix kept from the first (Scottish) implementation. */
/* Seat projections hero (seat-tracker style) */
.sp-hero-labelrow {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-bottom: 14px;
    font-family: var(--pc-sans);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--pc-text-meta);
}
.sp-hero-bar {
    position: relative;
    display: flex;
    height: 76px;
    border: 1px solid var(--pc-text);
    overflow: hidden;
}
.sp-hero-seg {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-family: var(--pc-sans);
    font-size: 20px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    overflow: hidden;
    min-width: 0;
    transition: width 0.6s cubic-bezier(.4, 0, .2, 1);
}
.sp-hero-seg--dark { color: #1f2937; }
@media (prefers-reduced-motion: reduce) {
    .sp-hero-seg { transition: none; }
}
.sp-seat-legend { margin-top: 16px; }

/* ---- Scotland constituency map + detail card ---- */
.sp-map-grid {
    display: grid;
    grid-template-columns: minmax(300px, 1.2fr) minmax(260px, 1fr);
    gap: 28px;
    align-items: start;
    margin-top: 24px;
}
#sp-nation-map svg { display: block; width: 100%; height: auto; }
.sp-map-const {
    stroke: var(--pc-surface);
    stroke-width: 0.6;
    cursor: pointer;
    transition: opacity 0.1s;
}
.sp-map-const:hover { opacity: 0.8; }
.sp-map-const.is-selected {
    stroke: var(--pc-text);
    stroke-width: 1.5;
}
.sp-map-tip { display: none; z-index: 300; }

/* Constituency search (uses pc-input + pc-filter-menu from the system) */
.sp-map-search {
    position: relative;
    max-width: 320px;
    margin: 20px 0 0;
}
.sp-map-search .pc-input { width: 100%; }
.sp-map-search .sp-search-menu {
    left: 0;
    right: auto;
    width: 100%;
}
.sp-search-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--pc-text-body);
    cursor: pointer;
}
.sp-search-item:hover,
.sp-search-item.is-active {
    background: var(--pc-hover-bg);
}
.sp-search-empty {
    padding: 6px 12px;
    font-size: 12px;
    color: var(--pc-text-meta);
}

/* Constituency detail card - port of the swingometer's cc- card,
   restyled on --pc-* tokens (radius 0, hard edges) */
.sp-map-card {
    background: var(--pc-surface);
    border: 1px solid var(--pc-border-light);
    padding: 16px 18px 18px;
    position: sticky;
    top: 16px;
    font-family: var(--pc-sans);
    font-size: 13px;
}
.sp-map-card-hint {
    font-size: 13px;
    color: var(--pc-text-meta);
    margin: 0;
}
.sp-map-card .cc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--pc-border-light);
}
.sp-map-card .cc-title {
    font-family: var(--pc-serif);
    font-size: 16px;
    font-weight: 700;
    color: var(--pc-text);
    line-height: 1.2;
    margin: 0;
}
.sp-map-card .cc-title-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted var(--pc-text-meta);
    padding-bottom: 1px;
}
.sp-map-card .cc-title-link:hover { border-bottom-style: solid; }
.sp-map-card .cc-region,
.sp-map-card .cc-turnout {
    font-size: 11px;
    color: var(--pc-text-meta);
    margin-top: 2px;
}
.sp-map-card .cc-close {
    background: none;
    border: none;
    font-size: 19px;
    color: var(--pc-text-meta);
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
    flex-shrink: 0;
}
.sp-map-card .cc-close:hover { background: var(--pc-tint); color: var(--pc-text); }

.sp-map-card .cc-winner-pill {
    display: inline-block;
    padding: 4px 12px;
    color: #fff;
    font-weight: 600;
    font-size: 12px;
    text-align: center;
    width: 100%;
    margin-bottom: 6px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.sp-map-card .cc-winner-pill.light-bg { color: #1f2937; text-shadow: none; }
.sp-map-card .cc-result { font-size: 11.5px; font-weight: 700; margin-bottom: 10px; }
.sp-map-card .cc-result.gain { color: var(--pc-positive); }
.sp-map-card .cc-result.hold { color: var(--pc-text-meta); }

.sp-map-card .cc-mp-section {
    padding: 8px 0 6px;
    border-bottom: 1px solid var(--pc-border-light);
    margin-bottom: 6px;
}
.sp-map-card .cc-mp-row { display: flex; gap: 10px; align-items: flex-start; }
.sp-map-card .cc-mp-photo {
    width: 48px;
    height: 48px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--pc-tint);
}
.sp-map-card .cc-mp-info { flex: 1; min-width: 0; }
.sp-map-card .cc-mp-name {
    font-family: var(--pc-serif);
    font-size: 14px;
    font-weight: 700;
    color: var(--pc-text);
}
.sp-map-card .cc-mp-link { color: var(--pc-text-meta); text-decoration: none; font-size: 12px; }
.sp-map-card .cc-mp-link:hover { color: var(--pc-text); }
.sp-map-card .cc-mp-party { font-size: 12px; color: var(--pc-text-meta); }
.sp-map-card .cc-mp-role { font-size: 11.5px; color: var(--pc-text-body); font-weight: 600; }
.sp-map-card .cc-mp-majority,
.sp-map-card .cc-mp-tenure { font-size: 11.5px; color: var(--pc-text-meta); margin-top: 2px; }
.sp-map-card .cc-mp-vacant { font-size: 13px; color: var(--pc-text-meta); font-style: italic; }
.sp-map-card .cc-mp-notes { font-size: 11.5px; color: var(--pc-text-meta); margin-top: 2px; }

.sp-map-card .cc-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 10px;
    border-bottom: 2px solid var(--pc-border);
}
.sp-map-card .cc-tab {
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 600;
    color: var(--pc-text-meta);
    cursor: pointer;
    border: 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    background: none;
    font-family: inherit;
    transition: color 0.15s;
}
.sp-map-card .cc-tab:hover { color: var(--pc-text-body); }
.sp-map-card .cc-tab.active { color: var(--pc-text); border-bottom-color: var(--pc-text); }
.sp-map-card .cc-tab-content { display: none; }
.sp-map-card .cc-tab-content.active { display: block; }

.sp-map-card .cc-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0 3px 0;
    margin-bottom: 2px;
    border-bottom: 1px solid var(--pc-border-light);
}
.sp-map-card .cc-results-col-labels { display: flex; align-items: center; gap: 6px; }
.sp-map-card .cc-results-col-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--pc-text-meta);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    min-width: 38px;
    text-align: right;
}
.sp-map-card .cc-change-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid var(--pc-border-grid);
}
.sp-map-card .cc-change-row:last-child { border-bottom: none; }
.sp-map-card .cc-change-party { font-size: 11.5px; font-weight: 600; }
.sp-map-card .cc-change-vals {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}
.sp-map-card .cc-change-proj { font-weight: 700; color: var(--pc-text); min-width: 38px; text-align: right; }
.sp-map-card .cc-change-delta { font-weight: 700; font-size: 11.5px; min-width: 38px; text-align: right; }
.sp-map-card .cc-change-delta.up { color: var(--pc-positive); }
.sp-map-card .cc-change-delta.down { color: var(--pc-negative); }
.sp-map-card .cc-change-delta.flat { color: var(--pc-text-meta); }

.sp-map-card .cc-section-title {
    font-size: 10px;
    font-weight: 600;
    color: var(--pc-text-meta);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 8px 0 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--pc-border-light);
}
.sp-map-card .cc-demo-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
}
.sp-map-card .cc-demo-label { font-size: 11px; color: var(--pc-text-secondary); }
.sp-map-card .cc-demo-val-wrap { display: flex; align-items: center; gap: 6px; }
.sp-map-card .cc-demo-bar {
    width: 50px;
    height: 5px;
    background: var(--pc-tint);
    overflow: hidden;
}
.sp-map-card .cc-demo-bar-fill { display: block; height: 100%; background: var(--pc-text); }
.sp-map-card .cc-demo-val {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--pc-text);
    min-width: 36px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.sp-map-card .cc-demo-empty { font-size: 11.5px; color: var(--pc-text-meta); padding: 8px 0; }

.sp-map-card .cc-similar-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
    cursor: pointer;
    border-bottom: 1px solid var(--pc-border-grid);
    transition: background 0.1s;
}
.sp-map-card .cc-similar-item:last-of-type { border-bottom: none; }
.sp-map-card .cc-similar-item:hover { background: var(--pc-tint); }
.sp-map-card .cc-similar-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}
.sp-map-card .cc-similar-name {
    flex: 1;
    font-size: 11px;
    color: var(--pc-text-body);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sp-map-card .cc-similar-winner { font-size: 10px; font-weight: 700; flex-shrink: 0; }

.sp-map-card .cc-profile-cta {
    display: block;
    margin-top: 10px;
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--pc-text);
    background: var(--pc-tint);
    text-align: center;
    text-decoration: none;
    border: 1px solid var(--pc-border-light);
}
.sp-map-card .cc-profile-cta:hover { background: var(--pc-hover-bg); }

@media (max-width: 768px) {
    .sp-hero-bar { height: 56px; }
    .sp-hero-seg { font-size: 15px; }
    .sp-map-grid { grid-template-columns: 1fr; }
    .sp-map-card { position: static; }
}

