:root {
    --wall-bg: #070b16;
    --wall-card: #10172a;
    --wall-card-2: #151e34;
    --wall-line: rgba(255,255,255,.12);
    --wall-muted: #aeb9d4;
    --wall-accent: #60a5fa;
    --wall-success: #49d17d;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    background: radial-gradient(circle at top, #15213c 0, var(--wall-bg) 42%);
    color: #f8faff;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.wall-header {
    padding: clamp(1rem, 2vw, 2rem) clamp(1rem, 2.8vw, 3rem);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    border-bottom: 1px solid var(--wall-line);
    background: rgba(5,9,20,.78);
    backdrop-filter: blur(18px);
    position: sticky;
    top: 0;
    z-index: 5;
}

.wall-kicker { color: var(--wall-muted); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; font-size: .78rem; }
.wall-header h1 { margin: .25rem 0 0; font-size: clamp(1.8rem, 3.2vw, 3.4rem); font-weight: 850; letter-spacing: -.04em; }
.wall-subtitle { color: var(--wall-muted); font-size: clamp(.82rem, 1.2vw, 1rem); }
.live-dot { display:inline-block; width:.62rem; height:.62rem; border-radius:50%; background:#ff4d5a; box-shadow:0 0 0 .35rem rgba(255,77,90,.14); margin-right:.45rem; }

.wall-actions { display:flex; align-items:center; justify-content:flex-end; gap:.65rem; flex-wrap:wrap; }
.wall-clock { display:grid; text-align:right; margin-right:.45rem; }
.wall-clock span { font-size: clamp(1.25rem, 2vw, 2rem); font-weight:800; font-variant-numeric: tabular-nums; }
.wall-clock small { color:var(--wall-muted); }

.wall-main { padding: clamp(1rem, 2vw, 2rem) clamp(1rem, 2.8vw, 3rem) 5rem; }
.wall-message { max-width: 1200px; margin: 0 auto 1rem; padding: .9rem 1rem; border:1px solid rgba(255,193,7,.35); background:rgba(255,193,7,.1); color:#ffe08a; border-radius:14px; }
.wall-loading { min-height: 55vh; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:1rem; color:var(--wall-muted); }

.office-grid { display:grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: clamp(.8rem, 1.3vw, 1.35rem); max-width: 1900px; margin: 0 auto; }
.office-panel { min-width:0; background: linear-gradient(180deg, rgba(21,30,52,.97), rgba(12,18,34,.97)); border:1px solid var(--wall-line); border-radius:22px; padding:clamp(1rem, 1.5vw, 1.45rem); box-shadow:0 20px 50px rgba(0,0,0,.24); }
.office-head { display:flex; align-items:flex-start; justify-content:space-between; gap:.8rem; }
.office-eyebrow { color:var(--wall-muted); text-transform:uppercase; letter-spacing:.08em; font-size:.7rem; font-weight:700; }
.office-head h2 { margin:.18rem 0 0; font-size:clamp(1.35rem, 2vw, 2rem); font-weight:800; }
.section-pill { white-space:nowrap; border:1px solid rgba(96,165,250,.35); background:rgba(96,165,250,.12); color:#b9d8ff; border-radius:999px; padding:.42rem .65rem; font-size:.72rem; font-weight:700; }
.section-pill.waiting { border-color:var(--wall-line); background:rgba(255,255,255,.05); color:var(--wall-muted); }
.office-section-progress, .wall-progress { overflow:hidden; background:rgba(255,255,255,.08); border-radius:999px; }
.office-section-progress { height:7px; margin-top:1rem; }
.office-section-progress span, .wall-progress span { display:block; height:100%; background:linear-gradient(90deg, #3b82f6, #60a5fa); border-radius:inherit; }
.office-meta { display:flex; justify-content:space-between; gap:.5rem; color:var(--wall-muted); font-size:.72rem; margin:.55rem 0 1rem; }

.wall-candidate-list { display:grid; gap:.7rem; }
.wall-candidate { display:grid; grid-template-columns: 28px 58px minmax(0,1fr) auto; align-items:center; gap:.7rem; border:1px solid var(--wall-line); background:rgba(255,255,255,.025); border-radius:16px; padding:.7rem; }
.wall-candidate.leader { background:linear-gradient(90deg, rgba(73,209,125,.11), rgba(255,255,255,.025)); border-color:rgba(73,209,125,.26); }
.candidate-rank { color:var(--wall-muted); font-size:.78rem; font-weight:800; text-align:center; }
.wall-photo { width:58px; height:58px; border-radius:50%; object-fit:cover; background:#20283d; border:2px solid rgba(255,255,255,.16); }
.candidate-copy { min-width:0; }
.candidate-topline { display:flex; align-items:center; gap:.35rem; min-width:0; }
.candidate-topline strong { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; font-size:clamp(.9rem, 1.15vw, 1.05rem); }
.candidate-meta { color:var(--wall-muted); font-size:.74rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.wall-progress { height:5px; margin-top:.48rem; }
.candidate-score { text-align:right; min-width:90px; }
.candidate-score strong { display:block; font-size:clamp(1.02rem, 1.5vw, 1.35rem); }
.candidate-score span { display:block; color:var(--wall-muted); font-size:.68rem; }
.result-badge { display:inline-block; border-radius:999px; padding:.12rem .35rem; font-size:.58rem; font-weight:700; color:#dce5fa; background:rgba(255,255,255,.08); white-space:nowrap; }
.result-badge.elected { color:#baf5cd; background:rgba(73,209,125,.14); }

.office-stats { display:grid; grid-template-columns:repeat(4,1fr); gap:.45rem; border-top:1px solid var(--wall-line); margin-top:1rem; padding-top:.9rem; }
.office-stats span { display:grid; }
.office-stats small { color:var(--wall-muted); font-size:.63rem; }
.office-stats strong { font-size:.83rem; font-variant-numeric:tabular-nums; }
.office-waiting { min-height:360px; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; color:var(--wall-muted); gap:.45rem; }
.office-waiting > span { font-size:2.4rem; }
.office-waiting.compact { min-height:230px; }

.wall-footer { position:fixed; bottom:0; left:0; right:0; display:flex; justify-content:space-between; gap:1rem; padding:.6rem clamp(1rem, 2.8vw, 3rem); color:var(--wall-muted); background:rgba(5,9,20,.9); border-top:1px solid var(--wall-line); font-size:.72rem; backdrop-filter:blur(14px); }

@media (max-width: 1250px) {
    .office-grid { grid-template-columns:1fr; }
    .office-panel { max-width:1000px; width:100%; margin:0 auto; }
    .office-waiting { min-height:220px; }
}
@media (max-width: 700px) {
    .wall-header { align-items:flex-start; flex-direction:column; }
    .wall-actions { width:100%; justify-content:flex-start; }
    .wall-clock { text-align:left; margin-right:auto; }
    .wall-candidate { grid-template-columns:24px 50px minmax(0,1fr); }
    .wall-photo { width:50px; height:50px; }
    .candidate-score { grid-column:2 / -1; text-align:left; display:flex; align-items:baseline; gap:.5rem; }
    .office-stats { grid-template-columns:repeat(2,1fr); }
    .office-meta { flex-direction:column; }
}

:fullscreen .wall-header { position:static; }
:fullscreen .wall-main { padding-top:1rem; }

/* Seleção de cidade do telão */
body.chooser-open { overflow: hidden; }
.city-chooser {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(3, 6, 15, .88);
    backdrop-filter: blur(18px);
}
.city-chooser.d-none { display: none !important; }
.city-chooser-card {
    width: min(860px, 100%);
    border: 1px solid var(--wall-line);
    border-radius: 24px;
    padding: clamp(1.4rem, 4vw, 2.4rem);
    background: linear-gradient(180deg, rgba(21,30,52,.99), rgba(9,14,28,.99));
    box-shadow: 0 30px 90px rgba(0,0,0,.5);
}
.city-chooser-kicker {
    color: var(--wall-accent);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.city-chooser-card h2 {
    margin: .4rem 0 .6rem;
    font-size: clamp(1.65rem, 4vw, 2.55rem);
    line-height: 1.08;
    font-weight: 850;
    letter-spacing: -.035em;
}
.city-chooser-card p { color: var(--wall-muted); margin-bottom: 1.4rem; }

.chooser-grid {
    display: grid;
    grid-template-columns: 1fr 1.35fr;
    gap: .9rem;
}
.city-chooser-card .form-label { color: #eef3ff; font-weight: 700; }
.city-chooser-card .form-select {
    color: #f8faff;
    background-color: #111a30;
    border-color: rgba(255,255,255,.18);
}
.city-chooser-card .form-select:focus {
    border-color: var(--wall-accent);
    box-shadow: 0 0 0 .25rem rgba(96,165,250,.15);
}
.city-chooser-message {
    margin-top: .8rem;
    padding: .75rem .9rem;
    border: 1px solid rgba(255,193,7,.3);
    border-radius: 12px;
    background: rgba(255,193,7,.08);
    color: #ffe08a;
}
.city-chooser-actions {
    display: flex;
    justify-content: flex-end;
    gap: .7rem;
    margin-top: 1.2rem;
}
@media (max-width: 680px) {
    .chooser-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
    .city-chooser-actions { flex-direction: column-reverse; }
    .city-chooser-actions .btn { width: 100%; }
}

/* Identidade visual v12 */
.wall-brand-logo {
    width: clamp(58px, 6vw, 88px);
    height: clamp(58px, 6vw, 88px);
    object-fit: contain;
    border-radius: 16px;
    background: rgba(255,255,255,.08);
    padding: 6px;
}

/* v13.5 — Deputados no Destaque + visualização expandida */
.office-head-actions {
    display: flex;
    align-items: flex-end;
    gap: .45rem;
    flex-direction: column;
}
.office-expand-btn {
    border: 1px solid rgba(255,255,255,.2);
    background: rgba(255,255,255,.055);
    color: #eef4ff;
    border-radius: 999px;
    padding: .35rem .7rem;
    font-size: .7rem;
    font-weight: 800;
    transition: background .15s ease, border-color .15s ease;
}
.office-expand-btn:hover,
.office-expand-btn:focus-visible {
    background: rgba(96,165,250,.16);
    border-color: rgba(96,165,250,.55);
    outline: none;
}
.proportional-card-note {
    margin: -.2rem 0 .75rem;
    padding: .55rem .7rem;
    border-radius: 11px;
    border: 1px solid rgba(96,165,250,.16);
    background: rgba(96,165,250,.07);
    color: #c6d5ee;
    font-size: .69rem;
    line-height: 1.4;
}

body.expansion-open { overflow: hidden; }
.office-expansion {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: clamp(.55rem, 2vw, 1.5rem);
}
.office-expansion.d-none { display: none !important; }
.office-expansion-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2,5,13,.9);
    backdrop-filter: blur(16px);
}
.office-expansion-card {
    position: relative;
    z-index: 1;
    width: min(1500px, 100%);
    max-height: calc(100vh - clamp(1.1rem, 4vw, 3rem));
    overflow: auto;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 24px;
    background: linear-gradient(180deg, #111a30 0%, #090f1f 100%);
    box-shadow: 0 28px 90px rgba(0,0,0,.55);
    padding: clamp(1rem, 2.6vw, 2rem);
}
.office-expansion-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--wall-line);
}
.office-expansion-header h2 {
    margin: .2rem 0 .25rem;
    font-size: clamp(1.65rem, 3.5vw, 2.75rem);
    font-weight: 850;
    letter-spacing: -.035em;
}
.office-expansion-header p {
    margin: 0;
    color: var(--wall-muted);
}
.office-expansion-close {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 50%;
    color: #fff;
    background: rgba(255,255,255,.06);
    font-size: 1.65rem;
    line-height: 1;
}
.office-expansion-close:hover,
.office-expansion-close:focus-visible {
    background: rgba(255,255,255,.13);
    outline: 2px solid rgba(96,165,250,.7);
    outline-offset: 2px;
}
.office-expansion-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .7rem;
    margin: 1rem 0;
}
.office-expansion-summary span {
    display: grid;
    gap: .15rem;
    min-width: 0;
    border: 1px solid var(--wall-line);
    background: rgba(255,255,255,.035);
    border-radius: 14px;
    padding: .75rem .85rem;
}
.office-expansion-summary small {
    color: var(--wall-muted);
    font-size: .67rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.office-expansion-summary strong {
    font-size: clamp(1.05rem, 2vw, 1.45rem);
    font-variant-numeric: tabular-nums;
}
.office-expansion-notice {
    margin: 0 0 1rem;
    padding: .85rem 1rem;
    border: 1px solid rgba(255,193,7,.25);
    background: rgba(255,193,7,.08);
    color: #ffe4a3;
    border-radius: 14px;
    font-size: .82rem;
    line-height: 1.5;
}
.expanded-section + .expanded-section {
    margin-top: 1.35rem;
    padding-top: 1.35rem;
    border-top: 1px solid var(--wall-line);
}
.expanded-section-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .75rem;
}
.expanded-section-title h3 {
    margin: .15rem 0 0;
    font-size: clamp(1.15rem, 2vw, 1.55rem);
    font-weight: 800;
}
.expanded-section-help {
    margin: -.25rem 0 .8rem;
    color: var(--wall-muted);
    font-size: .78rem;
}
.expanded-candidate-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .6rem;
}
.expanded-candidate {
    display: grid;
    grid-template-columns: 34px 58px minmax(0, 1fr) auto;
    align-items: center;
    gap: .7rem;
    min-width: 0;
    padding: .7rem;
    border: 1px solid var(--wall-line);
    border-radius: 15px;
    background: rgba(255,255,255,.028);
}
.expanded-candidate.is-elected {
    border-color: rgba(73,209,125,.34);
    background: rgba(73,209,125,.075);
}
.expanded-rank {
    color: var(--wall-muted);
    font-size: .75rem;
    font-weight: 850;
    text-align: center;
}
.expanded-candidate-copy { min-width: 0; }
.expanded-score {
    min-width: 90px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.expanded-score strong { display: block; font-size: 1rem; }
.expanded-score span { display: block; color: var(--wall-muted); font-size: .7rem; }
.result-badge.partial {
    color: #ffe2a0;
    background: rgba(255,193,7,.12);
}

@media (max-width: 980px) {
    .expanded-candidate-grid { grid-template-columns: 1fr; }
    .office-expansion-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
    .office-head-actions { align-items: flex-end; }
    .office-expansion { padding: 0; }
    .office-expansion-card {
        max-height: 100vh;
        min-height: 100vh;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
    }
    .office-expansion-summary { grid-template-columns: 1fr 1fr; }
    .expanded-section-title { flex-direction: column; }
    .expanded-candidate {
        grid-template-columns: 28px 50px minmax(0, 1fr);
    }
    .expanded-candidate .wall-photo { width: 50px; height: 50px; }
    .expanded-score {
        grid-column: 2 / -1;
        min-width: 0;
        text-align: left;
        display: flex;
        gap: .5rem;
        align-items: baseline;
    }
}

/* v13.8 — cores partidárias fixas no gráfico e mapa */
.chart-title-row,
.map-title-row { align-items: flex-end; }
.chart-controls {
    display: flex;
    flex-wrap: wrap;
    gap: .55rem;
    justify-content: flex-end;
}
.chart-controls label {
    display: grid;
    gap: .25rem;
    color: var(--wall-muted);
    font-size: .68rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.wall-select {
    min-width: 170px;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 10px;
    padding: .48rem .7rem;
    color: #f6f8ff;
    background: #10192e;
    font-size: .78rem;
    text-transform: none;
    letter-spacing: normal;
}
.wall-select:focus {
    outline: 2px solid rgba(96,165,250,.7);
    outline-offset: 2px;
}
.visual-status,
.history-empty,
.history-note {
    padding: .75rem .9rem;
    border: 1px solid var(--wall-line);
    border-radius: 12px;
    color: var(--wall-muted);
    background: rgba(255,255,255,.025);
    font-size: .78rem;
}
.history-chart {
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
}
.history-chart svg {
    display: block;
    width: 100%;
    height: auto;
    min-height: 250px;
    border: 1px solid var(--wall-line);
    border-radius: 16px;
    background: rgba(3,7,17,.34);
}
.chart-grid-line { stroke: rgba(255,255,255,.08); stroke-width: 1; }
.chart-axis-line { stroke: rgba(255,255,255,.22); stroke-width: 1; }
.chart-axis-label { fill: #8e9ab4; font-size: 13px; font-family: system-ui, sans-serif; }
.chart-point { stroke: #07101f; stroke-width: 2; }
.history-legend {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem .9rem;
    margin-top: .65rem;
    padding: .65rem;
    max-height: 220px;
    overflow: auto;
    border: 1px solid var(--wall-line);
    border-radius: 12px;
    color: #dfe7f7;
    background: rgba(3,7,17,.22);
    font-size: .72rem;
    scrollbar-width: thin;
}
.history-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.history-legend i,
.map-legend i,
.party-dot {
    width: .72rem;
    height: .72rem;
    flex: 0 0 .72rem;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid rgba(255,255,255,.22);
}
.history-note { margin-top: .55rem; }

.map-progress-wrap {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: .25rem 0 .8rem;
    color: var(--wall-muted);
    font-size: .72rem;
}
.map-progress {
    flex: 1 1 auto;
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255,255,255,.08);
}
.map-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #60a5fa, #49d17d);
    transition: width .25s ease;
}
.state-map-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(240px, .7fr);
    gap: 1rem;
    align-items: start;
}
.state-map {
    min-height: 440px;
    border: 1px solid var(--wall-line);
    border-radius: 18px;
    background: radial-gradient(circle at 50% 45%, rgba(32,45,75,.55), rgba(4,8,18,.62));
    padding: .45rem;
    overflow: hidden;
}
.state-map svg {
    display: block;
    width: 100%;
    height: auto;
    max-height: 690px;
}
.municipality-shape {
    stroke: rgba(4,8,18,.76);
    stroke-width: .7;
    vector-effect: non-scaling-stroke;
    transition: opacity .12s ease, stroke .12s ease;
    cursor: pointer;
}
.municipality-shape:hover,
.municipality-shape:focus {
    opacity: .78;
    stroke: #fff;
    stroke-width: 2;
    outline: none;
}
.map-side {
    display: grid;
    gap: 1rem;
    position: sticky;
    top: 0;
}
.map-side h4 {
    margin: 0 0 .55rem;
    font-size: .85rem;
    color: #f4f7ff;
}
.map-city-detail {
    display: grid;
    gap: .3rem;
    min-height: 132px;
    padding: .85rem;
    border: 1px solid var(--wall-line);
    border-radius: 14px;
    background: rgba(255,255,255,.035);
    color: var(--wall-muted);
    font-size: .76rem;
}
.map-city-detail strong { color: #fff; font-size: 1rem; }
.map-city-detail b { color: #dce6fa; font-size: .86rem; }
.map-city-detail span { display: flex; align-items: center; gap: .4rem; }
.map-city-detail small { color: #8e9ab4; }
.map-legend {
    display: grid;
    gap: .35rem;
    max-height: 360px;
    overflow: auto;
    padding-right: .2rem;
}
.map-legend > span {
    display: grid;
    grid-template-columns: 14px minmax(0, 1fr) auto;
    gap: .4rem;
    align-items: center;
    padding: .42rem .5rem;
    border-radius: 9px;
    background: rgba(255,255,255,.025);
    color: #dce6fa;
    font-size: .72rem;
}
.map-legend small { color: var(--wall-muted); }
.map-legend em { color: var(--wall-muted); font-size: .72rem; }

@media (max-width: 900px) {
    .chart-title-row,
    .map-title-row { align-items: flex-start; flex-direction: column; }
    .chart-controls { width: 100%; justify-content: flex-start; }
    .chart-controls label { flex: 1 1 200px; }
    .wall-select { width: 100%; min-width: 0; }
    .state-map-layout { grid-template-columns: 1fr; }
    .map-side { position: static; }
    .state-map { min-height: 320px; }
}
@media (max-width: 560px) {
    .map-progress-wrap { align-items: stretch; flex-direction: column; }
    .history-chart { overflow-x: auto; }
    .history-chart svg { min-width: 680px; }
    .state-map { padding: .2rem; border-radius: 12px; }
}

/* v13.8 — referência da paleta partidária */
.party-color-source {
    display: inline-flex;
    margin-top: .45rem;
    color: #b9d8ff;
    font-size: .72rem;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.party-color-source:hover { color: #fff; }

/* v13.10 — Destaque presidencial nacional + mapa do Brasil */
.office-panel-national {
    grid-column: 1 / -1;
    border-color: rgba(96,165,250,.28);
    background: linear-gradient(135deg, rgba(24,38,70,.98), rgba(12,18,34,.98));
}
.office-panel-national .wall-candidate-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.office-panel-national .wall-candidate {
    min-width: 0;
}
.brazil-map {
    min-height: 520px;
}
.state-shape {
    stroke: rgba(3,7,17,.9);
    stroke-width: 1.35;
}
.state-shape:hover,
.state-shape:focus {
    stroke-width: 2.4;
}
.national-map-section .map-city-detail {
    min-height: 150px;
}
@media (max-width: 1250px) {
    .office-panel-national .wall-candidate-list { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .brazil-map { min-height: 380px; }
}
