* { box-sizing: border-box; }

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

body {
    font-family: Arial, Helvetica, sans-serif;
    background: #edf3f4;
    color: #1d2933;
}

.skip-link {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 10000;
    padding: 10px 14px;
    border-radius: 6px;
    background: #ffffff;
    color: #1d2933;
    font-weight: 800;
    transform: translateY(-150%);
}

.skip-link:focus {
    outline: 3px solid #b8613c;
    outline-offset: 2px;
    transform: translateY(0);
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible {
    outline: 3px solid #8fc8ff;
    outline-offset: 3px;
}

.masthead {
    width: 100%;
    background: #174a7e;
    color: #ffffff;
    border-bottom: 1px solid rgba(255,255,255,0.10);
}

.masthead-inner {
    width: calc(100% - 80px);
    max-width: 1380px;
    margin: 0 auto;
    padding: 26px 0 27px;
    text-align: center;
}

.site-name {
    margin-bottom: 12px;
}

.site-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #f5f8fb;
    text-decoration: none;
}

.site-brand-mark {
    display: block;
    width: 56px;
    height: 40px;
    object-fit: contain;
}

.site-brand-screen {
    position: relative;
    display: inline-grid;
    min-width: 164px;
    padding: 7px 11px 6px;
    overflow: hidden;
    border: 1px solid rgba(53, 214, 111, 0.62);
    border-radius: 3px;
    background: #102522;
    box-shadow:
        inset 0 0 12px rgba(0, 0, 0, 0.62),
        inset 0 0 22px rgba(53, 214, 111, 0.08),
        0 0 9px rgba(53, 214, 111, 0.16);
    isolation: isolate;
}

.site-brand-screen::before {
    position: absolute;
    inset: 0;
    z-index: 2;
    background-image:
        radial-gradient(circle, rgba(210, 231, 214, 0.2) 0 0.7px, transparent 0.9px),
        radial-gradient(circle, rgba(53, 214, 111, 0.16) 0 0.6px, transparent 0.9px),
        repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, 0.22) 2px 3px);
    background-position: 0 0, 0 0, 0 0;
    background-size: 3px 3px, 5px 5px, 100% 3px;
    content: "";
    mix-blend-mode: screen;
    opacity: 0.38;
    pointer-events: none;
    animation: site-wordmark-static 260ms steps(2, end) infinite;
}

.site-brand-screen::after {
    position: absolute;
    top: 0;
    right: -8%;
    left: -8%;
    z-index: 3;
    height: 26%;
    background: linear-gradient(
        to bottom,
        transparent,
        rgba(53, 214, 111, 0.15),
        rgba(210, 231, 214, 0.3),
        transparent
    );
    content: "";
    filter: blur(0.6px);
    opacity: 0.75;
    pointer-events: none;
    animation: site-wordmark-roll 4.2s linear infinite;
}

.site-brand-wordmark {
    position: relative;
    z-index: 1;
    color: #d2e7d6;
    font-family: "Courier New", Courier, monospace;
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 0.12em;
    line-height: 1;
    text-shadow:
        -1px 0 rgba(53, 214, 111, 0.48),
        1px 0 rgba(210, 231, 214, 0.42),
        0 0 5px rgba(53, 214, 111, 0.68),
        0 0 13px rgba(53, 214, 111, 0.3);
}

.site-brand-wordmark::before,
.site-brand-wordmark::after {
    position: absolute;
    inset: 0;
    content: attr(data-text);
    pointer-events: none;
}

.site-brand-wordmark::before {
    color: rgba(53, 214, 111, 0.64);
    animation: site-wordmark-glitch-a 4.8s steps(1, end) infinite;
}

.site-brand-wordmark::after {
    color: rgba(210, 231, 214, 0.68);
    animation: site-wordmark-glitch-b 5.6s steps(1, end) infinite;
}

.site-brand:hover .site-brand-screen,
.site-brand:focus-visible .site-brand-screen {
    border-color: rgba(53, 214, 111, 0.94);
    box-shadow:
        inset 0 0 12px rgba(0, 0, 0, 0.62),
        inset 0 0 24px rgba(53, 214, 111, 0.13),
        0 0 13px rgba(53, 214, 111, 0.3);
}

@keyframes site-wordmark-static {
    0% { background-position: 0 0, 0 0, 0 0; }
    25% { background-position: 1px -1px, -2px 1px, 0 2px; }
    50% { background-position: -1px 2px, 1px -1px, 0 -1px; }
    75% { background-position: 2px 1px, -1px -2px, 0 1px; }
    100% { background-position: 0 0, 0 0, 0 0; }
}

@keyframes site-wordmark-roll {
    from { transform: translateY(-145%); }
    to { transform: translateY(430%); }
}

@keyframes site-wordmark-glitch-a {
    0%, 84%, 100% { clip-path: inset(0); opacity: 0; transform: translate(0); }
    85% { clip-path: inset(10% 0 68% 0); opacity: 0.72; transform: translate(-2px, 0); }
    87% { clip-path: inset(62% 0 13% 0); opacity: 0.5; transform: translate(2px, 0); }
    89% { opacity: 0; }
}

@keyframes site-wordmark-glitch-b {
    0%, 91%, 100% { clip-path: inset(0); opacity: 0; transform: translate(0); }
    92% { clip-path: inset(38% 0 37% 0); opacity: 0.58; transform: translate(2px, 0); }
    94% { clip-path: inset(74% 0 6% 0); opacity: 0.46; transform: translate(-1px, 0); }
    96% { opacity: 0; }
}

.race-switcher {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 0 14px 0;
}

.race-title h1 {
    margin: 0 0 8px 0;
    font-size: 32px;
    line-height: 1.1;
    font-weight: 700;
    letter-spacing: -0.4px;
    color: #ffffff;
}

.race-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    font-size: 15px;
    color: #c8d0da;
}

.meta-divider { color: #7f8b9c; }

main {
    width: calc(100% - 80px);
    max-width: 1380px;
    margin: 0 auto;
    padding: 24px 0 46px 0;
}

.map-wrapper {
    position: relative;
    width: 100%;
    border-radius: 10px;
    box-shadow: 0 3px 14px rgba(24, 34, 53, 0.12);
}

#map {
    width: 100%;
    height: 62vh;
    min-height: 520px;
    max-height: 700px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #c9ced4;
    background: #dfe3e7;
}

#map:focus-visible {
    outline: 4px solid #2463a9;
    outline-offset: 3px;
}

.map-coverage-key {
    position: absolute;
    right: 14px;
    bottom: 14px;
    z-index: 950;
    display: grid;
    gap: 5px;
    min-width: 185px;
    padding: 9px 11px;
    border: 1px solid rgba(40, 61, 75, 0.32);
    border-radius: 6px;
    background: rgba(249, 249, 246, 0.94);
    color: #334955;
    box-shadow: 0 3px 10px rgba(18, 35, 48, 0.14);
    font-size: 10px;
    line-height: 1.25;
    pointer-events: none;
}

.map-coverage-key[hidden],
.map-coverage-key-item[hidden] {
    display: none !important;
}

.map-coverage-key > strong {
    color: #173147;
    font-family: var(--monitor-mono, monospace);
    font-size: 9px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.map-coverage-key-item {
    display: flex;
    align-items: center;
    gap: 7px;
}

.map-coverage-key-item:not([data-coverage-kind="precinct-result"])::after {
    content: " (" attr(data-count) ")";
    margin-left: -4px;
    color: #66747c;
}

.map-coverage-key-item i {
    flex: 0 0 18px;
    height: 10px;
    border: 1px solid #526b78;
    background: #477391;
}

.map-coverage-key[data-party="republican"] [data-coverage-kind="precinct-result"] i {
    background: #8c484d;
}

.map-coverage-key[data-party="general"] [data-coverage-kind="precinct-result"] i {
    background: linear-gradient(90deg, #477391 0 50%, #8c484d 50% 100%);
}

.map-coverage-key [data-coverage-kind="county-aggregate-only"] i {
    border-color: #607873;
    border-style: dashed;
}

.map-coverage-key [data-coverage-kind="source-access-blocked"] i {
    border-color: #718a84;
    border-style: solid;
}

.map-coverage-key [data-coverage-kind="publication-removed"] i {
    border-color: #667d78;
    border-style: dotted;
}

.map-coverage-key [data-coverage-kind="precinct-not-published"] i,
.map-coverage-key [data-coverage-kind="map-unit-unavailable"] i {
    border-color: #58706c;
    border-style: dashed;
}

.map-coverage-key[data-party="democratic"] .map-coverage-key-item:not([data-coverage-kind="precinct-result"]) i {
    background: repeating-linear-gradient(135deg, #1c292b 0 7px, #5f86a3 7px 8px, #1c292b 8px 15px);
}

.map-coverage-key[data-party="republican"] .map-coverage-key-item:not([data-coverage-kind="precinct-result"]) i {
    background: repeating-linear-gradient(135deg, #1c292b 0 7px, #9d5d61 7px 8px, #1c292b 8px 15px);
}

.map-coverage-key[data-party="general"] .map-coverage-key-item:not([data-coverage-kind="precinct-result"]) i {
    background: repeating-linear-gradient(135deg, #1c292b 0 7px, #4d8f69 7px 8px, #1c292b 8px 15px);
}

.results-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 370px;
    max-width: calc(100% - 40px);
    background: rgba(255,255,255,0.96);
    padding: 18px;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.06);
    z-index: 1000;
    box-shadow: 0 2px 12px rgba(0,0,0,0.18);
}

.results-heading {
    margin-top: 0;
    margin-bottom: 5px;
    font-size: 18px;
    font-weight: 700;
    color: #20252b;
}

.reporting-line {
    margin-bottom: 13px;
    padding-bottom: 11px;
    border-bottom: 1px solid #d7dce1;
    color: #68717b;
    font-size: 12px;
    line-height: 1.4;
}

.reporting-line strong {
    color: #343c45;
}

.primary-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 17px;
    padding: 4px;
    background: #edf0f3;
    border-radius: 7px;
}

.primary-toggle-button {
    appearance: none;
    border: none;
    border-radius: 5px;
    padding: 9px 8px;
    background: transparent;
    color: #5d6670;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    cursor: pointer;
}

.primary-toggle-button.democratic.active {
    background: #477391;
    color: #ffffff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.primary-toggle-button.republican.active {
    background: #8c484d;
    color: #ffffff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.party-results.hidden { display: none; }

.party-label {
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
}

.party-label.democratic { color: #7898ae; }
.party-label.republican { color: #ad7678; }
.party-label.general { color: #394651; }

.candidate {
    display: grid;
    grid-template-columns: 46px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid #dddddd;
}

.candidate:last-child { border-bottom: none; }

.candidate-photo-wrapper {
    width: 42px;
    height: 42px;
    position: relative;
}

.candidate-photo,
.candidate-photo-fallback {
    position: absolute;
    top: 0;
    left: 0;
    width: 42px;
    height: 42px;
    border-radius: 50%;
}

.candidate-photo {
    object-fit: cover;
    display: block;
    border: 1px solid #cccccc;
    z-index: 2;
}

.candidate-photo-fallback {
    background: #e1e4e8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    color: #555d66;
    border: 1px solid #c9ced4;
    z-index: 1;
}

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

.candidate-name {
    margin-bottom: 2px;
    font-weight: 700;
    color: #20252b;
}

.candidate-votes {
    font-size: 13px;
    color: #68717b;
}

.candidate-affiliation {
    margin-top: 2px;
    color: #59636e;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.35px;
    text-transform: uppercase;
}

.candidate-percent {
    font-size: 18px;
    font-weight: 700;
    white-space: nowrap;
    color: #20252b;
}

.leaflet-tooltip {
    border: 1px solid #c9ced4;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    color: #222222;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    line-height: 1.45;
}

/* County assembly, trust, source, and reporting-simulation controls beneath the map. */
.county-stitch-panel,
.trust-panel,
.dev-panel {
    margin-top: 15px;
    padding: 14px 16px;
    border: 1px solid #d2d8df;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 1px 5px rgba(24,34,53,0.06);
}

.county-stitch-panel[hidden] {
    display: none;
}

.county-stitch-panel {
    color: #253142;
}

.county-stitch-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
}

.county-stitch-eyebrow {
    margin: 0 0 3px;
    color: #637083;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.county-stitch-header h2 {
    margin: 0;
    color: #1d2933;
    font-size: 17px;
}

.county-stitch-summary {
    margin: 2px 0 0;
    max-width: 470px;
    color: #33445a;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.45;
    text-align: right;
}

.county-stitch-explainer {
    margin: 9px 0 12px;
    color: #596575;
    font-size: 12px;
    line-height: 1.5;
}

.county-stitch-list {
    display: grid;
    gap: 7px;
}

.county-stitch-row {
    display: grid;
    grid-template-columns: minmax(190px, 1.3fr) auto minmax(180px, 0.8fr);
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid #dce2e8;
    border-radius: 7px;
    background: #f8fafc;
}

.county-stitch-identity {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.county-stitch-county {
    color: #1d2933;
    font-size: 13px;
}

.county-stitch-detail,
.county-stitch-contribution {
    color: #667283;
    font-size: 11px;
    line-height: 1.4;
}

.county-stitch-contribution {
    color: #33445a;
    text-align: right;
}

.county-stitch-status {
    border: 1px solid #c9d1dc;
    border-radius: 999px;
    padding: 4px 8px;
    background: #eef2f6;
    color: #596575;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.county-stitch-status.validated {
    border-color: #b4d4c1;
    background: #eaf6ee;
    color: #23613a;
}

.county-stitch-status.unavailable {
    border-color: #e0c2bc;
    background: #fff0ed;
    color: #8b3428;
}

.county-stitch-status.loading {
    border-color: #c5d5e7;
    background: #edf4fb;
    color: #315d8a;
}

.trust-panel {
    color: #39424d;
    font-size: 12px;
    line-height: 1.55;
}

.trust-heading {
    margin: 0 0 5px;
    color: #1d2933;
    font-size: 13px;
    font-weight: 700;
}

.trust-panel p { margin: 5px 0; }

.trust-panel .source-quality-notice {
    margin: 10px 0 7px;
    padding: 9px 11px;
    border-left: 3px solid #b98219;
    background: #fff8e7;
    color: #5f491b;
    font-weight: 650;
    line-height: 1.5;
}

.trust-panel details { margin-top: 8px; }

.trust-panel summary {
    color: #254f7a;
    cursor: pointer;
    font-weight: 700;
}

.source-attribution-list {
    margin: 8px 0 6px;
    padding-left: 19px;
}

.source-attribution-list li { margin: 4px 0; }

.trust-links a,
.source-attribution-list a {
    color: #254f7a;
    font-weight: 700;
}

.simulation-warning {
    margin-top: 9px;
    padding: 9px 10px;
    border-left: 3px solid #b98219;
    background: #fff8e7;
    color: #5f491b;
    font-size: 12px;
    line-height: 1.45;
}

.dev-title {
    margin-bottom: 9px;
    font-size: 13px;
    font-weight: 700;
}

.dev-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.dev-button {
    appearance: none;
    border: 1px solid #bfc7d0;
    border-radius: 5px;
    padding: 7px 10px;
    background: #f6f7f9;
    color: #28313b;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.dev-button:hover { background: #eceff3; }

.dev-button.primary {
    background: #174a7e;
    color: #ffffff;
    border-color: #174a7e;
}

.dev-status {
    margin-left: auto;
    color: #68717b;
    font-size: 12px;
}

.source-output {
    display: none;
    margin: 12px 0 0;
    max-height: 240px;
    overflow: auto;
    padding: 10px;
    border-radius: 5px;
    background: #f5f6f8;
    border: 1px solid #d8dde3;
    white-space: pre-wrap;
    font: 11px/1.45 Consolas, Monaco, monospace;
}

@media (max-width: 950px) {
    .masthead-inner, main {
        width: calc(100% - 48px);
    }
}

@media (max-width: 700px) {
    .masthead-inner {
        width: calc(100% - 32px);
        padding: 21px 0 22px;
    }

    .race-title h1 { font-size: 25px; }

    .race-switcher {
        margin-bottom: 12px;
    }

    .race-switcher select {
        min-width: 170px;
    }

    .county-stitch-header {
        display: block;
    }

    .county-stitch-summary {
        margin-top: 7px;
        max-width: none;
        text-align: left;
    }

    .county-stitch-row {
        grid-template-columns: 1fr auto;
    }

    .county-stitch-contribution {
        grid-column: 1 / -1;
        text-align: left;
    }

    main {
        width: calc(100% - 24px);
        padding-top: 14px;
    }

    #map {
        height: 68vh;
        min-height: 550px;
        max-height: none;
    }

    .map-coverage-key {
        right: 11px;
        bottom: 11px;
        min-width: 0;
        max-width: calc(100% - 22px);
        padding: 7px 9px;
        font-size: 9px;
    }

    .results-panel {
        top: 12px;
        left: 12px;
        width: calc(100% - 24px);
        max-width: 340px;
        padding: 15px;
    }

    .dev-status {
        width: 100%;
        margin-left: 0;
    }
}

/* =========================================================
   MONITOR MI CUSTOM HOUSE DISTRICT PICKER
   ========================================================= */

.masthead-inner {
    position: relative;
}

.race-switcher {
    position: absolute;
    top: 26px;
    right: 0;
    display: block;
    margin: 0;
    text-align: left;
}

.district-picker-label {
    margin-bottom: 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: #aeb8c5;
}

.district-picker {
    position: relative;
    width: 190px;
}

.district-picker-button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 11px;
    border: 1px solid rgba(255,255,255,0.20);
    border-radius: 6px;
    background: rgba(255,255,255,0.08);
    color: #ffffff;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.district-picker-button:hover {
    background: rgba(255,255,255,0.13);
}

.district-picker-button:focus {
    outline: 2px solid rgba(255,255,255,0.28);
    outline-offset: 2px;
}

.district-picker-arrow {
    width: 0;
    height: 0;
    margin-left: 12px;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #c8d0da;
}

.district-picker-menu {
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    width: 100%;

    /* Three districts visible, then scroll */
    max-height: 108px;
    overflow-y: auto;
    overflow-x: hidden;

    border: 1px solid rgba(255,255,255,0.20);
    border-radius: 6px;
    background: #174a7e;
    box-shadow: 0 8px 22px rgba(0,0,0,0.28);
    z-index: 2000;
}

.district-picker-menu[hidden] {
    display: none;
}

.district-picker-option {
    width: 100%;
    height: 36px;
    display: flex;
    align-items: center;
    padding: 0 11px;
    border: 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: transparent;
    color: #ffffff;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.district-picker-option:last-child {
    border-bottom: 0;
}

.district-picker-option:hover,
.district-picker-option:focus {
    background: rgba(255,255,255,0.12);
}

.district-picker-option:focus-visible {
    position: relative;
    outline: 2px solid #8fc8ff;
    outline-offset: -3px;
}

@media (max-width: 1050px) {
    .race-switcher {
        position: static;
        margin: 0 0 14px 0;
        text-align: center;
    }

    .district-picker-label {
        text-align: center;
    }

    .district-picker {
        width: 190px;
        margin: 0 auto;
    }
}


/* MONITOR MI IN-PAGE MICHIGAN OVERVIEW */

.michigan-overview-button {
    display: block;
    width: 100%;
    margin: 8px 0 0;
    padding: 7px 12px;
    border: 1px solid rgba(255,255,255,0.42);
    border-radius: 5px;
    background: rgba(255,255,255,0.08);
    color: #ffffff;
    font: inherit;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.03em;
    cursor: pointer;
}

.michigan-overview-button:hover {
    background: rgba(255,255,255,0.16);
}

.district-transition-status {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: grid;
    place-items: center;
    background: rgba(15, 24, 38, 0.38);
    color: #ffffff;
    font-size: 15px;
    font-weight: 750;
    letter-spacing: 0.02em;
    opacity: 0;
    pointer-events: none;
    transition: opacity 140ms ease-out;
}

@view-transition {
    navigation: auto;
}

html {
    --district-transition-exit-x: -7vw;
    --district-transition-enter-x: 7vw;
    --district-transition-exit-yaw: -4deg;
    --district-transition-enter-yaw: 4deg;
}

html.district-transition-backward {
    --district-transition-exit-x: 7vw;
    --district-transition-enter-x: -7vw;
    --district-transition-exit-yaw: 4deg;
    --district-transition-enter-yaw: -4deg;
}

html.district-transition-entering::view-transition-old(root) {
    animation: monitor-mi-globe-exit 280ms cubic-bezier(0.4, 0, 1, 1) both;
    transform-origin: 50% 50%;
}

html.district-transition-entering::view-transition-new(root) {
    animation: monitor-mi-globe-enter 360ms cubic-bezier(0.16, 1, 0.3, 1) both;
    transform-origin: 50% 50%;
}

@keyframes monitor-mi-globe-exit {
    from {
        opacity: 1;
        filter: blur(0) saturate(1);
        transform: perspective(1200px) translate3d(0, 0, 0) rotateY(0) scale(1);
    }
    to {
        opacity: 0.2;
        filter: blur(8px) saturate(0.7);
        transform:
            perspective(1200px)
            translate3d(var(--district-transition-exit-x), 0, 0)
            rotateY(var(--district-transition-exit-yaw))
            scale(0.975);
    }
}

@keyframes monitor-mi-globe-enter {
    from {
        opacity: 0.2;
        filter: blur(9px) saturate(0.72);
        transform:
            perspective(1200px)
            translate3d(var(--district-transition-enter-x), 0, 0)
            rotateY(var(--district-transition-enter-yaw))
            scale(1.025);
    }
    to {
        opacity: 1;
        filter: blur(0) saturate(1);
        transform: perspective(1200px) translate3d(0, 0, 0) rotateY(0) scale(1);
    }
}

body.district-transitioning .district-transition-status {
    opacity: 1;
}

body.district-transitioning .map-shell,
body.district-transitioning .results-panel {
    opacity: 0.66;
    filter: blur(2px);
    transform: translate3d(var(--district-transition-exit-x), 0, 0) scale(0.99);
    transition:
        opacity 140ms ease-out,
        filter 140ms ease-out,
        transform 140ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
    .district-transition-status,
    body.district-transitioning .map-shell,
    body.district-transitioning .results-panel,
    html.district-transition-entering::view-transition-old(root),
    html.district-transition-entering::view-transition-new(root),
    ::view-transition-group(root) {
        transition: none;
        animation-duration: 0.01ms;
    }

    .site-brand-screen::before,
    .site-brand-screen::after,
    .site-brand-wordmark::before,
    .site-brand-wordmark::after {
        animation: none !important;
    }

    .site-brand-wordmark::before,
    .site-brand-wordmark::after {
        display: none;
    }
}

/* =========================================================
   ELECTION CYCLE SELECTOR + GENERAL-ELECTION FEED STAGING
   ========================================================= */

.election-selector {
    display: grid;
    gap: 6px;
    margin: 0 0 13px;
}

.election-selector-label {
    color: var(--console-muted, #9bb1ae);
    font: 800 8px/1 var(--monitor-mono);
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.election-selector-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    padding: 4px;
    border: 1px solid var(--console-line, #284344);
    border-radius: 7px;
    background: #071114;
    box-shadow: inset 0 1px 6px rgba(0, 0, 0, 0.42);
}

.election-selector-button {
    min-height: 36px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--console-muted, #9bb1ae);
    font: 800 10px/1.1 var(--monitor-mono);
    letter-spacing: 0.04em;
    cursor: pointer;
}

.election-selector-button:hover,
.election-selector-button:focus-visible {
    border-color: var(--console-signal-dim, #47735a);
    color: var(--console-signal, #73e69b);
}

.election-selector-button.active {
    border-color: var(--console-signal-dim, #47735a);
    background: #173128;
    color: var(--console-signal, #73e69b);
    box-shadow: inset 0 0 16px rgba(115, 230, 155, 0.08);
}

.general-feed-status {
    display: grid;
    gap: 7px;
    margin: 0 0 13px;
    padding: 11px 12px;
    border: 1px solid #556a63;
    border-left: 3px solid var(--console-signal, #73e69b);
    background: #0d1b1c;
    color: var(--console-muted, #9bb1ae);
    font: 600 10px/1.45 var(--monitor-mono);
}

.general-feed-status[hidden] {
    display: none;
}

.general-feed-status strong {
    color: var(--console-signal, #73e69b);
    font-size: 10px;
    letter-spacing: 0.08em;
}

.general-feed-status button {
    justify-self: start;
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid var(--console-signal-dim, #47735a);
    border-radius: 4px;
    background: #132823;
    color: var(--console-signal, #73e69b);
    font: 800 9px/1 var(--monitor-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
}

.general-feed-status.test-active {
    border-color: #b67f4f;
    border-left-color: #f0b066;
    background: #291b10;
    color: #f1d5b5;
}

.general-feed-status.test-active strong {
    color: #ffc37d;
}

body.general-election-staging #general-results .candidate {
    box-shadow: inset 3px 0 #47675d;
}

body.general-test-feed-active #general-results .candidate:first-child {
    box-shadow: inset 3px 0 var(--console-signal, #73e69b);
}

@media (max-width: 900px) {
    .election-selector-button {
        min-height: 44px;
    }
}

/* A single SVG echo supplies depth on hover while the base map stays on the
   faster Canvas renderer. This avoids turning thousands of precincts into DOM
   nodes merely to animate the one geography a visitor is inspecting. */
.monitor-mi-map-hover-pane {
    pointer-events: none;
}

.monitor-mi-map-hover-pane .monitor-mi-lifted-geometry {
    transform: translateY(-4px) scale(1.004);
    transform-box: fill-box;
    transform-origin: center;
    filter: drop-shadow(0 5px 4px rgba(0, 0, 0, 0.68)) drop-shadow(0 0 4px rgba(115, 230, 155, 0.24));
    animation: monitor-mi-map-lift 130ms ease-out both;
}

@keyframes monitor-mi-map-lift {
    from {
        transform: translateY(0) scale(1);
        filter: drop-shadow(0 0 0 rgba(0, 0, 0, 0));
    }
    to {
        transform: translateY(-4px) scale(1.004);
    }
}

@media (prefers-reduced-motion: reduce) {
    .monitor-mi-map-hover-pane .monitor-mi-lifted-geometry {
        animation: none;
        transform: none;
    }
}

/* =========================================================
   CIVIC FIELD TERMINAL FOUNDATION
   Restrained instrument styling inspired by field equipment.
   Brand blue is Michigan-inspired, not an official flag match;
   copper is decorative while party colors retain data meaning.
   ========================================================= */

body {
    background-color: #edf3f4;
    background-image:
        linear-gradient(rgba(23, 74, 126, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(23, 74, 126, 0.025) 1px, transparent 1px);
    background-size: 32px 32px;
}

.masthead {
    background:
        radial-gradient(circle at 12% 0%, rgba(114, 177, 224, 0.3), transparent 34%),
        linear-gradient(125deg, #123c68, #174a7e 64%, #1f5c96);
    border-bottom: 3px solid #b8613c;
    box-shadow: 0 4px 16px rgba(18, 49, 79, 0.22);
}

.masthead-inner {
    padding-top: 18px;
    padding-bottom: 19px;
}

.site-brand-mark {
    filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.22));
}

.race-title h1,
.results-heading,
.county-stitch-header h2,
.trust-heading {
    font-family: Georgia, "Times New Roman", serif;
}

.race-title h1 {
    font-weight: 600;
    letter-spacing: -0.25px;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.24);
}

.race-meta {
    color: #c8d5df;
    font-size: 13px;
    letter-spacing: 0.015em;
}

.district-picker-label {
    color: #c5d2dc;
    letter-spacing: 0.12em;
}

.district-picker-button,
.michigan-overview-button {
    border-color: rgba(225, 235, 242, 0.34);
    border-bottom-color: rgba(8, 18, 27, 0.72);
    background: linear-gradient(rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.055));
    box-shadow:
        inset 0 1px rgba(255, 255, 255, 0.09),
        0 2px 4px rgba(0, 0, 0, 0.2);
}

.district-picker-button:active,
.michigan-overview-button:active {
    transform: translateY(1px);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.22);
}

.district-picker-menu {
    border-color: #6688a8;
    background: #123c68;
    box-shadow: 0 12px 28px rgba(9, 20, 29, 0.34);
}

main {
    padding-top: 22px;
}

.map-wrapper {
    padding: 8px;
    border: 1px solid #315f88;
    border-bottom: 4px solid #b8613c;
    border-radius: 14px;
    background: #123c68;
    box-shadow:
        0 14px 34px rgba(22, 38, 51, 0.18),
        inset 0 1px rgba(255, 255, 255, 0.08);
}

#map {
    border: 0;
    border-radius: 8px;
    background:
        linear-gradient(rgba(255, 255, 255, 0.055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.055) 1px, transparent 1px),
        #9fbfce;
    background-size: 32px 32px;
    box-shadow: inset 0 0 0 1px rgba(12, 28, 40, 0.28);
}

.leaflet-bar {
    border: 1px solid #435b6b !important;
    border-radius: 7px !important;
    box-shadow: 0 4px 10px rgba(13, 30, 42, 0.2) !important;
}

.leaflet-bar a,
.leaflet-bar a:hover {
    border-bottom-color: #d6dde1;
    background: #f7f7f2;
    color: #173147;
}

.results-panel {
    top: 18px;
    left: 18px;
    overflow: hidden;
    border: 1px solid #8599a8;
    border-top: 4px solid #b8613c;
    border-radius: 8px;
    background: rgba(250, 250, 246, 0.985);
    box-shadow:
        0 10px 26px rgba(13, 29, 41, 0.24),
        inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.results-heading {
    margin-bottom: 6px;
    color: #182a39;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.reporting-line {
    position: relative;
    padding-left: 14px;
    border-bottom-color: #cdd6dc;
    color: #52616c;
}

.reporting-line::before {
    content: "";
    position: absolute;
    top: 4px;
    left: 0;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #41805d;
    box-shadow: 0 0 0 3px rgba(65, 128, 93, 0.13);
}

.primary-toggle {
    border: 1px solid #ccd5db;
    border-bottom-color: #aab7c0;
    background: #e5eaed;
    box-shadow: inset 0 1px 3px rgba(18, 36, 49, 0.08);
}

.primary-toggle-button {
    border: 1px solid transparent;
    color: #4b5a65;
    letter-spacing: 0.07em;
}

.primary-toggle-button:active {
    transform: translateY(1px);
}

.primary-toggle-button.democratic.active {
    border-color: #315f85;
    background: linear-gradient(#477fab, #376c96);
    box-shadow: 0 2px 5px rgba(35, 75, 106, 0.25);
}

.primary-toggle-button.republican.active {
    border-color: #8b4642;
    background: linear-gradient(#b6645f, #9e514d);
    box-shadow: 0 2px 5px rgba(116, 54, 50, 0.24);
}

.party-label {
    letter-spacing: 0.11em;
}

.candidate {
    margin: 0 -4px;
    padding: 9px 6px;
    border-bottom-color: #d7dee2;
    border-radius: 5px;
}

#democratic-results .candidate:first-child {
    background: #edf4f8;
    box-shadow: inset 3px 0 #477da6;
}

#republican-results .candidate:first-child {
    background: #f8eeee;
    box-shadow: inset 3px 0 #a85752;
}

#general-results .candidate:first-child {
    background: #eef1f2;
    box-shadow: inset 3px 0 #667781;
}

.candidate-name {
    color: #172b3b;
}

.candidate-percent {
    color: #172b3b;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.leaflet-tooltip {
    border-color: #8398a7;
    border-top: 3px solid #b8613c;
    border-radius: 6px;
    background: #fafaf6;
    box-shadow: 0 7px 18px rgba(13, 30, 42, 0.22);
    color: #172b3b;
}

.county-stitch-panel,
.trust-panel,
.dev-panel {
    border-color: #c3cdd4;
    border-radius: 8px;
    background: #fbfbf7;
    box-shadow: 0 4px 12px rgba(24, 40, 52, 0.07);
}

.county-stitch-panel {
    border-top: 3px solid #174a7e;
}

.county-stitch-eyebrow {
    color: #587084;
    letter-spacing: 0.13em;
}

.county-stitch-row {
    border-color: #ced7dd;
    border-left: 3px solid #8da1af;
    background: #f4f7f8;
}

.county-stitch-status {
    border-radius: 5px;
    letter-spacing: 0.06em;
}

.county-stitch-status.validated {
    border-color: #9fc5af;
    background: #e5f1e9;
    color: #275f3d;
}

.trust-panel {
    border-left: 3px solid #8a9aa6;
}

.dev-panel {
    border-left: 3px solid #b8613c;
}

.dev-button {
    border-color: #aebac2;
    border-bottom-color: #8797a2;
    background: linear-gradient(#fafaf8, #e9edef);
    box-shadow: 0 2px 4px rgba(20, 37, 49, 0.1);
}

.dev-button:active {
    transform: translateY(1px);
    box-shadow: inset 0 2px 4px rgba(20, 37, 49, 0.12);
}

@media (min-width: 781px) {
    .site-name {
        position: absolute;
        top: 15px;
        left: 0;
        margin: 0;
    }

    .race-switcher {
        top: 17px;
    }

    .race-title {
        padding: 1px 215px 0;
    }
}

@media (max-width: 780px) {
    .site-name {
        position: static;
        margin-bottom: 11px;
    }
}

@media (max-width: 700px) {
    .masthead-inner {
        display: grid;
        grid-template-columns: auto minmax(165px, 1fr);
        align-items: start;
        gap: 12px 14px;
        padding-top: 16px;
        padding-bottom: 18px;
        text-align: left;
    }

    .site-name {
        justify-self: start;
        margin: 0;
    }

    .site-brand {
        gap: 7px;
    }

    .site-brand-mark {
        width: 38px;
        height: 28px;
    }

    .site-brand-screen {
        min-width: 122px;
        padding: 6px 8px 5px;
    }

    .site-brand-wordmark {
        font-size: 14px;
        letter-spacing: 0.08em;
    }

    .race-switcher {
        justify-self: end;
        margin: 0;
    }

    .district-picker-label {
        text-align: left;
    }

    .district-picker {
        width: 165px;
        margin: 0;
    }

    .race-title {
        grid-column: 1 / -1;
        text-align: center;
    }

    .map-wrapper {
        padding: 5px;
        border-radius: 11px;
    }

    #map {
        border-radius: 7px;
    }

    .results-panel {
        top: 12px;
        left: 12px;
    }

    .county-stitch-panel,
    .trust-panel,
    .dev-panel {
        border-radius: 7px;
    }
}

@media (max-width: 360px) {
    .masthead-inner {
        display: block;
        text-align: center;
    }

    .site-name {
        margin-bottom: 10px;
    }

    .race-switcher {
        margin-bottom: 12px;
    }

    .district-picker-label {
        text-align: center;
    }

    .district-picker {
        width: 165px;
        margin: 0 auto;
    }
}

/* =========================================================
   RETRO MONITOR CONSOLE LAYER
   Lightweight instrument language: segmented controls,
   status lamps, screen rails, and a static scanline texture.
   ========================================================= */

:root {
    --monitor-mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
}

.monitor-rail {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    width: calc(100% - 80px);
    max-width: 1380px;
    min-height: 24px;
    margin: 0 auto;
    padding: 5px 0 4px;
    border-top: 1px solid rgba(218, 232, 243, 0.22);
    color: #dbe8f2;
    font-family: var(--monitor-mono);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.09em;
    line-height: 1.2;
    text-transform: uppercase;
}

.monitor-rail-channel {
    color: #c4d7e7;
}

.monitor-rail-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.monitor-rail-status::before,
.results-console-channel::before {
    content: "";
    width: 6px;
    height: 6px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #70b88b;
    box-shadow: 0 0 0 2px rgba(112, 184, 139, 0.16);
}

.results-console-channel::before {
    background: #d77a55;
    box-shadow: 0 0 0 2px rgba(215, 122, 85, 0.14);
}

.district-picker-label,
.race-meta,
.results-console-label,
.reporting-line,
.party-label,
.county-stitch-eyebrow,
.county-stitch-status,
.dev-title,
.dev-status {
    font-family: var(--monitor-mono);
}

.map-wrapper {
    padding-top: 30px;
    border-radius: 7px;
    box-shadow:
        0 14px 34px rgba(22, 38, 51, 0.18),
        inset 0 0 0 2px rgba(181, 210, 231, 0.09),
        inset 0 1px rgba(255, 255, 255, 0.12);
}

.map-console-label {
    position: absolute;
    top: 8px;
    left: 17px;
    z-index: 1100;
    color: #d6e4ef;
    font-family: var(--monitor-mono);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.1em;
    line-height: 1;
    text-transform: uppercase;
    pointer-events: none;
}

.map-wrapper::after {
    content: "";
    position: absolute;
    top: 9px;
    right: 18px;
    z-index: 1100;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #70b88b;
    box-shadow:
        -14px 0 #d77a55,
        -28px 0 rgba(210, 226, 238, 0.52);
    pointer-events: none;
}

#map {
    border-radius: 3px;
}

.map-scanlines {
    position: absolute;
    inset: 30px 8px 8px;
    z-index: 750;
    border-radius: 3px;
    background:
        repeating-linear-gradient(
            0deg,
            rgba(12, 48, 79, 0.035) 0,
            rgba(12, 48, 79, 0.035) 1px,
            transparent 1px,
            transparent 4px
        );
    box-shadow: inset 0 0 38px rgba(12, 48, 79, 0.08);
    pointer-events: none;
}

.results-panel {
    top: 40px;
    border-radius: 4px;
    box-shadow:
        0 10px 26px rgba(13, 29, 41, 0.24),
        inset 0 0 0 2px rgba(23, 74, 126, 0.06);
}

.results-console-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: -2px 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #cbd7df;
    color: #526b7e;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.results-console-channel {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #7b543f;
    white-space: nowrap;
}

.results-heading {
    margin-top: 0;
}

.primary-toggle {
    gap: 3px;
    border-width: 1px;
    border-radius: 4px;
}

.primary-toggle-button {
    border-radius: 2px;
    font-family: var(--monitor-mono);
    font-size: 10px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.candidate-photo,
.candidate-photo-fallback {
    border-radius: 8px;
}

.county-stitch-panel,
.trust-panel,
.dev-panel {
    position: relative;
    border-radius: 4px;
    box-shadow:
        0 4px 12px rgba(24, 40, 52, 0.07),
        inset 0 0 0 1px rgba(23, 74, 126, 0.035);
}

.panel-module-label {
    position: absolute;
    top: 11px;
    right: 13px;
    color: #7a8d9a;
    font-family: var(--monitor-mono);
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.11em;
    line-height: 1;
    text-transform: uppercase;
}

.county-stitch-row {
    border-radius: 2px;
    background:
        linear-gradient(90deg, rgba(23, 74, 126, 0.025), transparent 45%),
        #f4f7f8;
}

.dev-button {
    border-radius: 3px;
    font-family: var(--monitor-mono);
    font-size: 10px;
    letter-spacing: 0.025em;
}

.dev-title > span {
    color: #9c563a;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

@media (max-width: 700px) {
    .monitor-rail {
        width: calc(100% - 32px);
    }

    .monitor-rail-channel {
        display: none;
    }

    .map-wrapper {
        padding-top: 27px;
        border-radius: 6px;
    }

    .map-console-label {
        top: 8px;
        left: 13px;
    }

    .map-wrapper::after {
        top: 9px;
        right: 14px;
    }

    .map-scanlines {
        inset: 27px 5px 5px;
    }

    .panel-module-label {
        display: none;
    }
}

@media (max-width: 420px) {
    .monitor-rail {
        justify-content: flex-end;
    }

    .monitor-rail > span:first-child {
        display: none;
    }
}

/* =========================================================
   WARM CIVIC INSTRUMENT REFINEMENT
   Editorial hierarchy and useful data marks add personality;
   the only ambient motion is the accessible CRT brand treatment.
   ========================================================= */

body {
    background-color: #edf2f1;
    background-image:
        radial-gradient(circle at 94% 3%, rgba(184, 97, 60, 0.065), transparent 24rem),
        linear-gradient(rgba(23, 74, 126, 0.023) 1px, transparent 1px),
        linear-gradient(90deg, rgba(23, 74, 126, 0.023) 1px, transparent 1px);
}

.site-brand-wordmark {
    font-size: 20px;
    letter-spacing: 0.12em;
}

.race-context {
    display: inline-flex;
    align-items: center;
    margin: 0 auto 7px;
    border: 1px solid rgba(217, 231, 241, 0.28);
    border-radius: 3px;
    background: rgba(8, 36, 62, 0.22);
    color: #dce8f0;
    font-family: var(--monitor-mono);
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.12em;
    line-height: 1;
    text-transform: uppercase;
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.055);
}

.race-context span {
    padding: 5px 8px 4px;
}

.race-context span + span {
    border-left: 2px solid #d77a55;
    color: #f3c1aa;
}

.race-title h1 {
    margin-bottom: 7px;
}

.map-wrapper {
    border-color: #244f73;
    border-bottom-width: 5px;
}

.results-panel {
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.82), transparent 42%),
        rgba(249, 248, 242, 0.985);
}

.results-panel::after {
    content: "";
    position: absolute;
    right: 7px;
    bottom: 7px;
    width: 11px;
    height: 11px;
    border-right: 2px solid rgba(184, 97, 60, 0.38);
    border-bottom: 2px solid rgba(184, 97, 60, 0.38);
    pointer-events: none;
}

.candidate {
    grid-template-columns: 46px minmax(0, 1fr) auto;
    padding-top: 10px;
    padding-bottom: 10px;
}

.candidate-votes {
    color: #60707b;
    font-variant-numeric: tabular-nums;
}

.candidate-share-track {
    height: 4px;
    margin-top: 6px;
    overflow: hidden;
    border: 1px solid rgba(74, 94, 107, 0.16);
    border-radius: 1px;
    background: #dfe5e5;
    box-shadow: inset 0 1px 1px rgba(31, 51, 65, 0.08);
}

.candidate-share-fill {
    display: block;
    width: 0;
    height: 100%;
    background: #667781;
}

.candidate-percent-known {
    text-decoration: underline dotted rgba(74, 94, 107, 0.58);
    text-underline-offset: 3px;
}

.candidate-share-note {
    margin: 8px 2px 2px;
    color: #60707b;
    font-size: 0.69rem;
    line-height: 1.35;
}

#democratic-results .candidate-share-fill {
    background: #477da6;
}

#republican-results .candidate-share-fill {
    background: #a85752;
}

.county-stitch-panel,
.trust-panel,
.dev-panel {
    margin-top: 18px;
    padding: 18px 19px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.84), transparent 44%),
        #faf9f4;
    box-shadow:
        0 5px 15px rgba(24, 40, 52, 0.075),
        inset 0 1px rgba(255, 255, 255, 0.9),
        inset 0 0 0 1px rgba(23, 74, 126, 0.025);
}

.county-stitch-panel::before,
.trust-panel::before,
.dev-panel::before {
    content: "";
    position: absolute;
    top: -1px;
    left: 17px;
    width: 34px;
    height: 3px;
    background: #b8613c;
}

.county-stitch-row {
    padding: 12px 13px;
    border-left-color: #6f8798;
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.8);
}

.county-stitch-header h2,
.trust-heading {
    color: #183247;
}

@media (max-width: 700px) {
    .race-context {
        margin-bottom: 6px;
    }

    .site-brand-wordmark {
        font-size: 14px;
    }

    .county-stitch-panel,
    .trust-panel,
    .dev-panel {
        padding: 16px;
    }
}

/* =========================================================
   MOBILE-FIRST MAP AND RESULTS FLOW
   The district map remains fully usable on touch screens;
   detailed results follow it in normal document flow.
   ========================================================= */

@media (max-width: 900px) {
    .primary-toggle-button,
    .district-picker-button,
    .michigan-overview-button,
    .district-picker-option,
    .dev-button {
        min-height: 44px;
    }

    .district-picker-option {
        height: 44px;
    }

    .district-picker-menu {
        max-height: 132px;
    }

    .leaflet-bar a {
        width: 38px;
        height: 38px;
        line-height: 38px;
    }
}

@media (max-width: 700px) {
    main {
        width: calc(100% - 16px);
        padding-top: 10px;
    }

    .map-wrapper {
        padding: 27px 5px 5px;
    }

    #map {
        height: 50vh;
        height: 50svh;
        min-height: 360px;
        max-height: 500px;
    }

    .map-scanlines {
        display: none;
    }

    .candidate {
        min-height: 62px;
    }

    .county-stitch-panel,
    .trust-panel,
    .dev-panel {
        margin-top: 12px;
    }

    body.district-transitioning .map-shell,
    body.district-transitioning .results-panel {
        filter: none;
        transform: none;
        transition: opacity 120ms ease-out;
    }
}

@media (max-width: 420px) {
    .race-title h1 {
        font-size: 23px;
    }

    .race-meta {
        font-size: 11px;
    }

    .candidate {
        grid-template-columns: 44px minmax(0, 1fr) auto;
        gap: 8px;
    }
}

@keyframes monitor-mi-mobile-exit {
    from { opacity: 1; transform: translate3d(0, 0, 0); }
    to { opacity: 0.35; transform: translate3d(-10px, 0, 0); }
}

@keyframes monitor-mi-mobile-enter {
    from { opacity: 0.35; transform: translate3d(10px, 0, 0); }
    to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@media (max-width: 700px) and (prefers-reduced-motion: no-preference) {
    html.district-transition-entering::view-transition-old(root) {
        animation: monitor-mi-mobile-exit 150ms ease-out both;
    }

    html.district-transition-entering::view-transition-new(root) {
        animation: monitor-mi-mobile-enter 190ms ease-out both;
    }
}

/* =========================================================
   TWO-PANEL DISTRICT CONSOLE
   Desktop follows the approved control/results + map device.
   ========================================================= */

main {
    max-width: 1480px;
}

.district-console-shell {
    display: grid;
    grid-template-columns: minmax(290px, 0.78fr) 34px minmax(540px, 1.45fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 16px 14px;
    align-items: stretch;
}

.district-control-panel {
    position: relative;
    grid-column: 1;
    grid-row: 1;
    min-height: 142px;
    padding: 30px 20px 16px;
    border: 1px solid #244f73;
    border-bottom: 4px solid #b8613c;
    border-radius: 7px;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.1), transparent 42%),
        #174a7e;
    box-shadow: 0 10px 24px rgba(22, 38, 51, 0.16), inset 0 0 0 2px rgba(181, 210, 231, 0.08);
    color: #fff;
}

.device-panel-label {
    position: absolute;
    top: 11px;
    left: 20px;
    color: #d6e4ef;
    font: 800 8px/1 var(--monitor-mono);
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.district-control-panel .race-switcher {
    position: static;
    margin: 0;
    text-align: left;
}

.district-control-panel .district-picker {
    width: 100%;
    margin: 0;
}

.district-control-panel .district-picker-label {
    color: #c9d9e6;
    text-align: left;
}

.district-control-panel .district-picker-button {
    min-height: 43px;
    padding: 10px 13px;
    background: rgba(7, 31, 52, 0.42);
    font-family: var(--monitor-mono);
    font-size: 13px;
}

.district-control-status {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
    color: #c7d9e6;
    font: 700 8px/1 var(--monitor-mono);
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.district-control-status span:last-child::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 6px;
    border-radius: 50%;
    background: #70b88b;
    box-shadow: 0 0 0 2px rgba(112, 184, 139, 0.16);
}

.district-console-shell > .results-panel {
    position: relative;
    inset: auto;
    grid-column: 1;
    grid-row: 2;
    width: 100%;
    max-width: none;
    min-height: 0;
    max-height: 614px;
    padding: 18px;
    overflow: auto;
}

.district-console-hinge {
    position: relative;
    grid-column: 2;
    grid-row: 1 / 3;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    width: 18px;
    margin: 20px auto;
    border: 1px solid #315f88;
    border-radius: 9px;
    background: linear-gradient(90deg, #11395f, #2a6596 48%, #0d3458);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.06), 0 5px 12px rgba(18, 38, 54, 0.18);
}

.district-console-hinge span {
    width: 7px;
    height: 7px;
    border: 1px solid #d08a6c;
    border-radius: 50%;
    background: #b8613c;
}

.district-console-shell > .map-wrapper {
    grid-column: 3;
    grid-row: 1 / 3;
    min-width: 0;
}

.district-console-shell #map {
    height: clamp(610px, 72vh, 760px);
    min-height: 610px;
    max-height: 760px;
}

@media (max-width: 900px) {
    .district-console-shell {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto auto auto;
        gap: 12px;
    }

    .district-control-panel,
    .district-console-shell > .map-wrapper,
    .district-console-shell > .results-panel {
        grid-column: 1;
    }

    .district-control-panel { grid-row: 1; min-height: 0; }
    .district-console-shell > .map-wrapper { grid-row: 2; }
    .district-console-shell > .results-panel { grid-row: 3; max-height: none; }
    .district-console-hinge { display: none; }

    .district-console-shell #map {
        height: 52vh;
        height: 52svh;
        min-height: 400px;
        max-height: 560px;
    }
}

@media (max-width: 420px) {
    .district-control-panel { padding: 29px 14px 14px; }
    .device-panel-label { left: 14px; }
    .district-console-shell #map { min-height: 360px; }
}

/* =========================================================
   UNIFIED STATEWIDE SCANNER CONSOLE
   House now shares the Governor and Senate monitor language.
   No image mark is used on race pages; the CRT wordmark is the
   sole linked identity treatment.
   ========================================================= */

:root {
    color-scheme: dark;
    --console-ink: #e7eee9;
    --console-muted: #9caaa2;
    --console-panel: #0b1518;
    --console-panel-soft: #111f22;
    --console-line: #2b4747;
    --console-signal: #73e69b;
    --console-signal-dim: #2f8d59;
    --console-background: #061013;
}

html,
body {
    background: var(--console-background);
    color: var(--console-ink);
}

body {
    background-image:
        radial-gradient(circle at 50% -20%, #173033 0, transparent 44%),
        linear-gradient(rgba(115, 230, 155, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(115, 230, 155, 0.025) 1px, transparent 1px);
    background-size: auto, 28px 28px, 28px 28px;
}

.masthead {
    min-height: 116px;
    border-bottom: 1px solid var(--console-line);
    background: rgba(5, 13, 16, 0.96);
    box-shadow: 0 12px 38px rgba(0, 0, 0, 0.35);
}

.masthead-inner {
    width: min(1480px, calc(100% - 2rem));
    min-height: 91px;
    padding: 15px 0 13px;
}

.site-brand {
    color: var(--console-signal);
}

.site-brand-screen {
    min-width: 0;
    padding: 9px 12px 8px;
    border-color: #4d8f69;
    border-radius: 2px;
    background: #07140e;
    box-shadow:
        inset 0 0 16px rgba(115, 230, 155, 0.14),
        0 0 10px rgba(115, 230, 155, 0.12);
}

.site-brand-wordmark {
    color: var(--console-signal);
    font-size: clamp(1rem, 2vw, 1.45rem);
    letter-spacing: 0.11em;
    text-shadow:
        1px 0 #d8ffe4,
        -1px 0 #278f4d,
        0 0 12px rgba(115, 230, 155, 0.8);
}

.site-brand:hover .site-brand-screen,
.site-brand:focus-visible .site-brand-screen {
    border-color: var(--console-signal);
    box-shadow:
        inset 0 0 18px rgba(115, 230, 155, 0.18),
        0 0 14px rgba(115, 230, 155, 0.2);
}

.race-context {
    border-color: var(--console-line);
    background: #071114;
    color: var(--console-muted);
}

.race-context span + span {
    border-left-color: var(--console-signal-dim);
    color: var(--console-signal);
}

.race-title h1 {
    color: var(--console-ink);
    font-weight: 750;
    text-shadow: none;
}

.race-meta,
.district-picker-label {
    color: var(--console-muted);
}

.monitor-rail {
    width: min(1480px, calc(100% - 2rem));
    border-top-color: var(--console-line);
    color: var(--console-muted);
}

.monitor-rail-channel,
.monitor-rail-status {
    color: var(--console-muted);
}

.monitor-rail-status::before,
.district-control-status span:last-child::before {
    background: var(--console-signal);
    box-shadow: 0 0 0 2px rgba(115, 230, 155, 0.14), 0 0 8px rgba(115, 230, 155, 0.3);
}

main {
    width: min(1540px, calc(100% - 2rem));
    padding-top: 20px;
}

.district-console-shell {
    grid-template-columns: minmax(300px, 380px) 28px minmax(0, 1fr);
    gap: 18px 12px;
}

.district-control-panel,
.district-console-shell > .results-panel,
.district-console-shell > .map-wrapper {
    border: 1px solid var(--console-line);
    border-radius: 12px;
    background: linear-gradient(145deg, rgba(17, 31, 34, 0.98), rgba(7, 16, 19, 0.98));
    box-shadow:
        0 18px 52px rgba(0, 0, 0, 0.28),
        inset 0 0 28px rgba(115, 230, 155, 0.025);
}

.district-control-panel {
    min-height: 142px;
    padding: 34px 20px 17px;
    color: var(--console-ink);
}

.device-panel-label,
.map-console-label {
    color: var(--console-signal);
}

.district-control-panel .district-picker-label {
    color: var(--console-muted);
}

.district-control-panel .district-picker-button,
.michigan-overview-button {
    border: 1px solid var(--console-line);
    background: #071114;
    color: var(--console-ink);
    box-shadow: inset 0 0 16px rgba(115, 230, 155, 0.025);
}

.district-control-panel .district-picker-button:hover,
.district-control-panel .district-picker-button:focus-visible,
.michigan-overview-button:hover,
.michigan-overview-button:focus-visible {
    border-color: var(--console-signal-dim);
    color: var(--console-signal);
}

.district-picker-menu {
    border-color: var(--console-line);
    background: #081316;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
}

.district-picker-option {
    color: var(--console-ink);
}

.district-picker-option:hover,
.district-picker-option:focus-visible,
.district-picker-option[aria-current="true"] {
    background: #15292a;
    color: var(--console-signal);
}

.district-control-status {
    color: var(--console-muted);
}

.district-console-hinge {
    border-color: var(--console-line);
    background: linear-gradient(90deg, #071114, #203737 48%, #071114);
    box-shadow: inset 0 0 0 2px rgba(115, 230, 155, 0.035), 0 5px 14px rgba(0, 0, 0, 0.34);
}

.district-console-hinge span {
    border-color: var(--console-signal-dim);
    background: var(--console-signal-dim);
}

.district-console-shell > .results-panel {
    max-height: 614px;
    padding: 18px;
    color: var(--console-ink);
}

.district-console-shell > .results-panel::after {
    border-color: rgba(115, 230, 155, 0.26);
}

.results-console-label {
    border-bottom-color: var(--console-line);
    color: var(--console-muted);
}

.results-console-channel {
    color: var(--console-signal);
}

.results-console-channel::before {
    background: var(--console-signal);
    box-shadow: 0 0 0 2px rgba(115, 230, 155, 0.14);
}

.results-heading,
.candidate-name,
.candidate-percent,
.county-stitch-header h2,
.trust-heading {
    color: var(--console-ink);
}

.candidate-votes,
.candidate-share-note,
.county-stitch-summary,
.county-stitch-explainer,
.trust-panel p,
.dev-status,
.simulation-warning {
    color: var(--console-muted);
}

.reporting-line {
    border-bottom-color: var(--console-line);
    color: var(--console-signal);
}

.reporting-line strong {
    color: inherit;
}

.reporting-line::before {
    background: var(--console-signal);
    box-shadow: 0 0 0 3px rgba(115, 230, 155, 0.1);
}

.primary-toggle {
    border-color: var(--console-line);
    background: #071114;
    box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.36);
}

.primary-toggle-button {
    color: var(--console-muted);
}

.primary-toggle-button.democratic.active {
    border-color: #7898ae;
    background: #294b61;
    color: #d3e2ec;
}

.primary-toggle-button.republican.active {
    border-color: #ad7678;
    background: #5b3237;
    color: #edd1d2;
}

.party-label {
    color: var(--console-muted);
}

.candidate {
    border-bottom-color: #20383a;
    background: #091518;
}

#democratic-results .candidate:first-child {
    background: #102431;
    box-shadow: inset 3px 0 #477391;
}

#republican-results .candidate:first-child {
    background: #2b1719;
    box-shadow: inset 3px 0 #8c484d;
}

#general-results .candidate:first-child {
    background: #142022;
    box-shadow: inset 3px 0 #72817d;
}

.candidate-share-track {
    border-color: #294143;
    background: #111f22;
}

.district-console-shell > .map-wrapper {
    padding: 54px 1px 1px;
    overflow: hidden;
}

.map-console-label {
    top: 21px;
    left: 21px;
    font-size: 10px;
}

.map-wrapper::after {
    top: 23px;
    right: 22px;
    background: var(--console-signal);
    box-shadow: -14px 0 #477391, -28px 0 rgba(231, 238, 233, 0.34);
}

.district-console-shell #map {
    height: clamp(610px, 72vh, 760px);
    border-radius: 0 0 11px 11px;
    background: radial-gradient(circle at 50% 45%, #17272a, #071013 72%);
    box-shadow: inset 0 0 0 1px rgba(115, 230, 155, 0.05);
}

.map-scanlines {
    inset: 54px 1px 1px;
    border-radius: 0 0 11px 11px;
    background: repeating-linear-gradient(0deg, rgba(115, 230, 155, 0.025) 0 1px, transparent 1px 4px);
    box-shadow: inset 0 0 38px rgba(115, 230, 155, 0.035);
}

.leaflet-bar {
    border-color: var(--console-line) !important;
    box-shadow: 0 5px 14px rgba(0, 0, 0, 0.34) !important;
}

.leaflet-bar a,
.leaflet-bar a:hover {
    border-bottom-color: var(--console-line);
    background: #0b1719;
    color: var(--console-ink);
}

.leaflet-tooltip {
    border-color: var(--console-signal-dim);
    border-top-color: var(--console-signal);
    background: rgba(4, 13, 15, 0.96);
    color: var(--console-ink);
    box-shadow: 0 9px 24px rgba(0, 0, 0, 0.42);
}

.map-coverage-key {
    border-color: var(--console-line);
    background: rgba(4, 13, 15, 0.94);
    color: var(--console-muted);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.38);
}

.county-stitch-panel,
.trust-panel,
.dev-panel {
    border: 1px solid var(--console-line);
    border-radius: 8px;
    background: linear-gradient(145deg, rgba(17, 31, 34, 0.98), rgba(7, 16, 19, 0.98));
    color: var(--console-ink);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22), inset 0 0 24px rgba(115, 230, 155, 0.02);
}

.county-stitch-panel::before,
.trust-panel::before,
.dev-panel::before {
    background: var(--console-signal-dim);
}

.county-stitch-eyebrow,
.panel-module-label {
    color: var(--console-signal);
}

.county-stitch-row {
    border-color: var(--console-line);
    border-left-color: var(--console-signal-dim);
    background: #0a1719;
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.025);
}

.county-stitch-status.validated {
    border-color: var(--console-signal-dim);
    background: #10281b;
    color: var(--console-signal);
}

.trust-panel a,
.county-stitch-panel a,
.dev-panel a {
    color: var(--console-signal);
}

.dev-button {
    border-color: var(--console-line);
    background: #0c191b;
    color: var(--console-muted);
    box-shadow: inset 0 0 12px rgba(115, 230, 155, 0.018);
}

.dev-button:hover:not(:disabled),
.dev-button:focus-visible:not(:disabled),
.dev-button.primary:not(:disabled) {
    border-color: var(--console-signal-dim);
    color: var(--console-signal);
}

@media (max-width: 900px) {
    .district-console-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .district-console-shell > .map-wrapper {
        padding-top: 50px;
    }

    .map-scanlines {
        inset: 50px 1px 1px;
    }
}

@media (max-width: 700px) {
    .masthead-inner {
        width: calc(100% - 1rem);
        min-height: 0;
    }

    .site-brand-wordmark {
        font-size: 1rem;
    }

    main {
        width: calc(100% - 1rem);
    }

    .district-console-shell > .map-wrapper {
        padding: 46px 1px 1px;
    }

    .map-console-label {
        top: 19px;
        left: 15px;
    }

    .map-wrapper::after {
        top: 20px;
        right: 16px;
    }

    .map-scanlines {
        display: block;
        inset: 46px 1px 1px;
    }

    .district-console-shell #map {
        border-radius: 0 0 10px 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .site-brand-screen::before,
    .site-brand-screen::after,
    .site-brand-wordmark::before,
    .site-brand-wordmark::after {
        animation: none !important;
    }
}

/* Race status line and table view (race-status.js, A2 wording) */
.race-status { margin: 6px 0 10px; padding: 7px 10px; border-left: 3px solid #5d7f96; background: #f3f7fa; color: #26343d; font-size: 0.78rem; line-height: 1.45; }
.race-status[data-delivery="stale"], .race-status[data-delivery="unavailable"] { border-left-color: #b98219; background: #fff8e7; color: #5f491b; }
.results-table-view { margin-top: 10px; font-size: 0.78rem; }
.results-table-view summary { cursor: pointer; font-weight: 650; }
.results-table { width: 100%; margin-top: 8px; border-collapse: collapse; }
.results-table caption { text-align: left; font-weight: 700; padding: 4px 0; }
.results-table th, .results-table td { padding: 4px 6px; border-bottom: 1px solid #d9e2e8; text-align: left; }
.results-table td { text-align: right; font-variant-numeric: tabular-nums; }
