:root {
    --app-radius: 18px;
}

body {
    min-height: 100vh;
    background: color-mix(in srgb, var(--bs-body-bg) 94%, var(--bs-primary) 6%);
}

.app-nav {
    background: color-mix(in srgb, var(--bs-body-bg) 92%, transparent);
    backdrop-filter: blur(14px);
}

.live-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--bs-danger);
    box-shadow: 0 0 0 5px color-mix(in srgb, var(--bs-danger) 18%, transparent);
}

.hero-card,
.location-card,
.stat-card,
.waiting-card,
.candidate-card {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--app-radius);
    box-shadow: 0 10px 35px rgba(0,0,0,.05);
}

.hero-card {
    padding: 1.4rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.hero-meta {
    text-align: right;
    display: grid;
}

.location-card {
    padding: 1rem 1.1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.location-copy {
    display: grid;
    min-width: 210px;
}

.location-controls {
    display: flex;
    align-items: center;
    gap: .65rem;
    flex: 1;
    justify-content: flex-end;
}

.location-controls .form-select {
    max-width: 420px;
}

.stat-card {
    padding: 1.1rem;
    height: 100%;
}

.stat-label {
    display: block;
    color: var(--bs-secondary-color);
    font-size: .82rem;
    margin-bottom: .35rem;
}

.stat-value {
    font-size: 1.55rem;
    line-height: 1.1;
}

.waiting-card {
    padding: 3rem 1.5rem;
    text-align: center;
}

.candidate-grid {
    display: grid;
    gap: .85rem;
}

.candidate-card {
    padding: 1rem;
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: center;
}

.candidate-photo {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--bs-border-color);
    background: var(--bs-tertiary-bg);
}

.candidate-name {
    font-weight: 700;
    line-height: 1.15;
}

.candidate-subtitle {
    font-size: .85rem;
    color: var(--bs-secondary-color);
}

.candidate-status {
    opacity: .78;
    font-size: .78rem;
}

.candidate-result {
    text-align: right;
    min-width: 130px;
}

.candidate-percent {
    display: block;
    font-size: 1.25rem;
    font-weight: 800;
}

.candidate-votes {
    font-size: .82rem;
    color: var(--bs-secondary-color);
}

.candidate-progress {
    height: 6px;
    margin-top: .55rem;
}

.elected-badge {
    font-size: .7rem;
    vertical-align: .1em;
}

.search-box { min-width: min(320px, 80vw); }
.row-limit { width: auto; }

.panel-footer {
    border-top: 1px solid var(--bs-border-color);
    padding-top: 1rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: .82rem;
    color: var(--bs-secondary-color);
}

@media (max-width: 768px) {
    .location-card,
    .location-controls {
        align-items: stretch;
        flex-direction: column;
    }
    .location-controls .form-select {
        max-width: none;
    }
}

@media (max-width: 640px) {
    .hero-card { align-items: flex-start; }
    .hero-meta { text-align: left; }
    .candidate-card {
        grid-template-columns: 52px minmax(0, 1fr);
    }
    .candidate-photo { width: 52px; height: 52px; }
    .candidate-result {
        grid-column: 1 / -1;
        text-align: left;
        min-width: 0;
    }
    .panel-footer { flex-direction: column; }
}

/* Seletor Estado > Cidade do painel principal */
.chooser-open { overflow: hidden; }

.location-chooser {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    padding: 1.25rem;
    background: rgba(5, 12, 24, .72);
    backdrop-filter: blur(10px);
}

.location-chooser.d-none { display: none !important; }

.location-chooser-card {
    width: min(760px, 100%);
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 24px;
    box-shadow: 0 28px 90px rgba(0,0,0,.28);
    padding: clamp(1.4rem, 4vw, 2.5rem);
}

.location-chooser-kicker {
    color: var(--bs-primary);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: .78rem;
    margin-bottom: .55rem;
}

.chooser-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1.5rem;
}

.location-chooser-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .75rem;
    margin-top: 1.5rem;
}

.location-controls #panelStateSelect { max-width: 250px; }
.location-controls #locationSelect { max-width: 360px; }

@media (max-width: 768px) {
    .chooser-grid { grid-template-columns: 1fr; }
    .location-controls #panelStateSelect,
    .location-controls #locationSelect { max-width: none; }
    .location-chooser-actions { flex-direction: column-reverse; align-items: stretch; }
}

/* Perfil do candidato (v9) */
.candidate-card-clickable {
    cursor: pointer;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.candidate-card-clickable:hover,
.candidate-card-clickable:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 14px 42px rgba(0,0,0,.10);
    border-color: color-mix(in srgb, var(--bs-primary) 48%, var(--bs-border-color));
    outline: none;
}

.profile-open { overflow: hidden; }

.candidate-profile {
    position: fixed;
    inset: 0;
    z-index: 2200;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.candidate-profile.d-none { display: none !important; }

.candidate-profile-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(6, 12, 24, .74);
    backdrop-filter: blur(10px);
}

.candidate-profile-card {
    --profile-accent: #f4bd00;
    position: relative;
    width: min(470px, 100%);
    max-height: min(92vh, 820px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #fff;
    color: #343434;
    border-radius: 24px;
    box-shadow: 0 30px 95px rgba(0,0,0,.38);
    isolation: isolate;
}

.candidate-profile-hero {
    position: relative;
    flex: 0 0 170px;
    min-height: 170px;
    overflow: visible;
    background: #6675ad;
}

.candidate-profile-wave {
    position: absolute;
    left: -8%;
    width: 116%;
    border-radius: 45% 55% 0 0 / 30% 30% 0 0;
    transform: rotate(-1.5deg);
}

.candidate-profile-wave.wave-one {
    top: 44px;
    height: 74px;
    background: #4d9ac0;
}

.candidate-profile-wave.wave-two {
    top: 89px;
    height: 70px;
    background: #f4a21c;
    transform: rotate(1.2deg);
}

.candidate-profile-wave.wave-three {
    top: 127px;
    height: 65px;
    background: #ffc400;
    transform: rotate(-1deg);
}

.candidate-profile-hero::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 28px;
    background: #95bd20;
    clip-path: polygon(0 0, 100% 0, 100% 55%, 92% 42%, 84% 67%, 75% 45%, 66% 68%, 56% 45%, 46% 68%, 36% 43%, 27% 66%, 18% 42%, 9% 64%, 0 48%);
    z-index: 2;
}

.candidate-profile-close {
    position: absolute;
    top: 12px;
    right: 14px;
    z-index: 10;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: rgba(0,0,0,.14);
    color: #fff;
    font-size: 2rem;
    font-weight: 300;
    line-height: 1;
}

.candidate-profile-close:hover { background: rgba(0,0,0,.25); }

.candidate-profile-photo-wrap {
    position: absolute;
    z-index: 8;
    left: 50%;
    bottom: -18px;
    width: 126px;
    height: 126px;
    transform: translateX(-50%);
    border-radius: 50%;
    padding: 6px;
    background: #fff;
    box-shadow: 0 7px 24px rgba(0,0,0,.18);
}

.candidate-profile-photo {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background: #e9ecef;
    border: 5px solid #4d9ac0;
}

.candidate-profile-body {
    overflow-y: auto;
    padding: 36px 16px 18px;
}

.candidate-profile-result {
    display: grid;
    justify-items: center;
    text-align: center;
    gap: .22rem;
    margin-bottom: 1rem;
}

.candidate-profile-result strong {
    color: #e5a900;
    font-size: 1.3rem;
    line-height: 1.2;
}

.candidate-profile-result > span:not(.badge) {
    font-size: 1.05rem;
    font-weight: 800;
}

.candidate-profile-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .8rem;
    margin-bottom: 1.1rem;
}

.btn-profile-primary {
    border: 0;
    border-radius: 999px;
    background: var(--profile-accent);
    color: #111;
    font-weight: 800;
    text-transform: uppercase;
    box-shadow: 0 4px 10px rgba(0,0,0,.12);
}

.btn-profile-primary:hover,
.btn-profile-primary:focus {
    background: #dba900;
    color: #111;
}

.candidate-profile-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 1.2rem;
}

.profile-detail {
    min-width: 0;
}

.profile-detail.profile-detail-wide {
    grid-column: 1 / -1;
}

.profile-detail strong {
    display: block;
    font-size: 1.06rem;
    line-height: 1.18;
    overflow-wrap: anywhere;
}

.profile-detail small {
    display: block;
    margin-top: .22rem;
    color: #6b6b6b;
    font-size: .72rem;
    letter-spacing: .02em;
}

.profile-companion-list {
    margin: .15rem 0 0;
    padding: 0;
    list-style: none;
}

.profile-companion-list li + li { margin-top: .45rem; }

.candidate-profile-nav {
    flex: 0 0 auto;
    min-height: 66px;
    display: grid;
    grid-template-columns: 56px 1fr 56px;
    align-items: center;
    background: var(--profile-accent);
    color: #111;
}

.candidate-profile-nav button {
    height: 100%;
    border: 0;
    background: transparent;
    color: #111;
    font-size: 1.65rem;
}

.candidate-profile-nav button:disabled {
    opacity: .28;
    cursor: not-allowed;
}

.candidate-profile-nav div {
    text-align: center;
    display: grid;
    line-height: 1.05;
}

.candidate-profile-nav small { font-size: .78rem; }
.candidate-profile-nav strong { font-size: 1.2rem; }

@media (max-width: 520px) {
    .candidate-profile { padding: 0; place-items: stretch; }
    .candidate-profile-card {
        width: 100%;
        max-height: 100dvh;
        height: 100dvh;
        border-radius: 0;
    }
    .candidate-profile-hero { flex-basis: 176px; }
    .candidate-profile-body { flex: 1 1 auto; }
}
