:root {
    --blue-900: #0f1c6e;
    --blue-700: #16299e;
    --blue-600: #1d3fd6;
    --blue-500: #2f5bff;
    --blue-100: #e8edff;
    --bg: #f2f4fb;
    --card: #ffffff;
    --border: #e1e4f0;
    --text: #101425;
    --text-muted: #5b6482;
    --green: #22b366;
    --amber: #f5a623;
    --gold: #fcd34d;
    --red: #e5484d;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --radius-pill: 999px;
    --shadow: 0 2px 10px rgba(20, 30, 60, .06);
    --shadow-lg: 0 12px 32px rgba(20, 30, 60, .14);
    --header-h: 72px;
    --font-display: "Sora", system-ui, sans-serif;
    --font-body: "Manrope", system-ui, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family: var(--font-body);
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 700;
}

[hidden] {
    display: none !important;
}

/* Header */

.main-header {
    position: sticky;
    top: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: var(--header-h);
    padding: 0 24px;
    background: linear-gradient(120deg, var(--blue-700), var(--blue-600) 130%);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-logo {
    height: 52px;
    width: auto;
    border-radius: 10px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    color: #ffffff;
    line-height: 1.2;
}

.brand-text strong {
    font-family: var(--font-display);
    font-size: 16px;
}

.brand-text small {
    font-size: 12px;
    opacity: .75;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .12);
}

.nav-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: #ffffff;
    font: 600 14px var(--font-body);
    cursor: pointer;
    transition: background-color .15s ease;
}

.nav-pill:hover {
    background: rgba(255, 255, 255, .14);
}

.nav-pill.is-active {
    background: #ffffff;
    color: var(--blue-600);
}

.nav-logout {
    display: contents;
}

/* Mensagens */

.messages-container {
    position: fixed;
    top: calc(var(--header-h) + 16px);
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(380px, calc(100vw - 32px));
    pointer-events: none;
}

.message {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--card);
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .12);
    pointer-events: auto;
    animation: message-in .3s ease forwards;
}

.message-error { border-color: #f6c9cb; background: #fdecec; color: var(--red); }
.message-success { border-color: #b7ecc9; background: #e8f8ee; color: #15803d; }
.message-warning { border-color: #f5dba3; background: #fef6e7; color: #b45309; }
.message-info { border-color: #c7d9f7; background: #eaf1ff; color: var(--blue-600); }
.message-fading { animation: message-out .3s ease forwards; }

@keyframes message-in {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes message-out {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(20px); }
}

/* Estrutura */

.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px 24px 64px;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.page-header h1 {
    font-size: 22px;
}

.subtitle {
    margin-top: 4px;
    font-size: 14px;
    color: var(--text-muted);
}

.empty-state {
    padding: 32px;
    text-align: center;
    color: var(--text-muted);
    background: var(--card);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    grid-column: 1 / -1;
}

/* Botões e campos */

.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 46px;
    padding: 0 22px;
    border-radius: var(--radius-sm);
    font: 700 15px var(--font-body);
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease;
}

.btn-primary {
    border: none;
    background: var(--blue-600);
    color: #ffffff;
}

.btn-primary:hover { background: var(--blue-700); }
.btn-primary:disabled { opacity: .7; cursor: wait; }

.btn-secondary {
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
}

.btn-secondary:hover { border-color: var(--blue-500); color: var(--blue-600); }

.btn-block { width: 100%; }

.btn-link {
    border: none;
    background: none;
    color: var(--blue-600);
    font: 600 13px var(--font-body);
    cursor: pointer;
    white-space: nowrap;
}

.btn-link:hover { text-decoration: underline; }

.input {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #f8f9fd;
    color: var(--text);
    font: 500 16px var(--font-body);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.input:focus {
    outline: none;
    border-color: var(--blue-500);
    background: #ffffff;
    box-shadow: 0 0 0 3px var(--blue-100);
}

.input-error { border-color: var(--red); }

.help-text,
.field-error {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    font-size: 13px;
    color: var(--text-muted);
}

.help-text i { color: var(--blue-600); }
.field-error { color: var(--red); font-weight: 600; }

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 700;
}

/* Avatar */

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
    color: #ffffff;
    font: 700 20px var(--font-display);
    object-fit: cover;
    box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--blue-100);
}

.avatar-sm {
    width: 42px;
    height: 42px;
    font-size: 14px;
}

/* Hero */

.hero {
    position: relative;
    overflow: hidden;
    padding: 48px 24px;
    border-radius: var(--radius-lg);
    background:
        radial-gradient(circle at 15% 10%, rgba(47, 91, 255, .45), transparent 45%),
        radial-gradient(circle at 90% 90%, rgba(124, 58, 237, .35), transparent 40%),
        linear-gradient(120deg, var(--blue-900), var(--blue-600));
    color: #ffffff;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    border: 1px solid rgba(255, 255, 255, .3);
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, .1);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.hero-badge i { color: var(--gold); }

.hero-title {
    margin: 18px auto 12px;
    max-width: 960px;
    font-size: clamp(28px, 5vw, 50px);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -.02em;
}

.hero-highlight {
    color: var(--gold);
    white-space: nowrap;
}

.hero-subtitle {
    max-width: 640px;
    margin: 0 auto;
    font-size: 16px;
    line-height: 1.6;
    opacity: .9;
}

.hero-deadline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    font-size: 14px;
    font-weight: 700;
}

.identify-card {
    max-width: 640px;
    margin: 32px auto 0;
    padding: 22px 24px;
    border-radius: var(--radius-lg);
    background: var(--card);
    color: var(--text);
    text-align: left;
    box-shadow: var(--shadow-lg);
    scroll-margin-top: calc(var(--header-h) + 24px);
}

.identify-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--blue-700);
}

.identify-row {
    display: flex;
    gap: 12px;
}

.identify-voter,
.identify-closed {
    display: flex;
    align-items: center;
    gap: 14px;
}

.identify-voter-text { flex: 1; }

.identify-voter p,
.identify-closed p {
    margin-top: 2px;
    font-size: 14px;
    color: var(--text-muted);
}

.identify-closed i {
    font-size: 22px;
    color: var(--text-muted);
}

/* Candidatos */

.candidates { margin-top: 32px; }

.candidates-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.search {
    display: flex;
    align-items: center;
    gap: 10px;
    width: min(400px, 100%);
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--text-muted);
    box-shadow: var(--shadow);
}

.search:focus-within { border-color: var(--blue-500); }

.search input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: none;
    font: 500 15px var(--font-body);
    color: var(--text);
}

.candidates-count {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
}

.candidate-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.candidate-card {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--card);
    box-shadow: var(--shadow);
    transition: transform .15s ease, box-shadow .15s ease;
}

.candidate-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.candidate-header {
    display: flex;
    align-items: center;
    gap: 16px;
}

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

.candidate-info h3 {
    font-size: 17px;
    line-height: 1.3;
}

.candidate-role {
    margin-top: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--blue-600);
}

.btn-vote {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    margin-top: auto;
    border: 1px solid #c7d4fb;
    border-radius: var(--radius-sm);
    background: var(--blue-100);
    color: var(--blue-600);
    font: 700 14px var(--font-body);
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}

.btn-vote:hover {
    background: #dbe3ff;
}

.btn-vote.is-ready {
    border-color: var(--blue-600);
    background: var(--blue-600);
    color: #ffffff;
}

.btn-vote.is-ready:hover { background: var(--blue-700); }

.btn-vote:disabled {
    border-color: var(--border);
    background: #f1f2f6;
    color: var(--text-muted);
    cursor: not-allowed;
}

.candidate-card.is-chosen {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px var(--blue-100), var(--shadow);
}

.btn-vote.is-chosen,
.btn-vote.is-chosen:hover {
    border-color: var(--green);
    background: var(--green);
    color: #ffffff;
}

.identify-done {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--green);
}

/* Barra dos votos escolhidos */

.vote-tray {
    position: sticky;
    bottom: 16px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    max-width: 720px;
    margin: 28px auto 0;
    padding: 14px 16px 14px 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--card);
    box-shadow: var(--shadow-lg);
}

.vote-tray.is-active { border-color: var(--blue-500); }

.vote-tray-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.vote-tray-info strong { font-size: 16px; }

.vote-tray-info span {
    font-size: 13px;
    color: var(--text-muted);
}

.vote-tray .btn-primary { flex-shrink: 0; }

/* Modal */

.modal {
    width: min(420px, calc(100vw - 32px));
    margin: auto;
    padding: 28px;
    border: none;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.modal::backdrop {
    background: rgba(16, 20, 37, .55);
}

.modal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin-bottom: 14px;
    border-radius: 50%;
    background: #fef6e7;
    color: var(--amber);
    font-size: 24px;
}

.modal h2 {
    font-size: 20px;
    margin-bottom: 8px;
}

.modal p {
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-muted);
}

.modal p strong { color: var(--text); }

.modal-vote-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 12px 0 4px;
    padding: 0;
    list-style: none;
    font-size: 15px;
    color: var(--text-muted);
}

.modal-vote-list strong { color: var(--text); }

.modal-note {
    margin-top: 8px;
    font-size: 13px !important;
}

.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 24px;
}

/* Resultados */

.results-page {
    max-width: 860px;
    margin: 0 auto;
}

.live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 4px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse 1.6s ease infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 179, 102, .5); }
    50% { box-shadow: 0 0 0 6px rgba(34, 179, 102, 0); }
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 18px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.stat-value {
    font: 800 28px var(--font-display);
}

.stat-bar,
.ranking-bar {
    display: block;
    height: 6px;
    border-radius: var(--radius-pill);
    background: var(--blue-100);
    overflow: hidden;
}

.stat-bar span,
.ranking-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--blue-600);
    transition: width .4s ease;
}

.ranking {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ranking-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow);
}

.ranking-position {
    width: 32px;
    flex-shrink: 0;
    text-align: center;
    font: 700 15px var(--font-display);
    color: var(--text-muted);
}

.podium-1 .ranking-position { color: #eab308; font-size: 22px; }
.podium-2 .ranking-position { color: #94a3b8; font-size: 20px; }
.podium-3 .ranking-position { color: #c2410c; font-size: 18px; }

.podium-1 {
    border-color: #f5dba3;
    background: linear-gradient(90deg, #fffbeb, var(--card) 60%);
}

.podium-1 .ranking-bar span { background: var(--amber); }

.ranking-body {
    flex: 1;
    min-width: 0;
}

.ranking-line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.ranking-line strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ranking-votes {
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
}

/* Login */

.login-card {
    max-width: 400px;
    margin: 40px auto;
    padding: 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--card);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-card form {
    margin-top: 24px;
    text-align: left;
}

.login-card h1 { font-size: 20px; }

.login-card .field-error { margin: 0 0 16px; }

.login-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin-bottom: 14px;
    border-radius: 50%;
    background: var(--blue-100);
    color: var(--blue-600);
    font-size: 22px;
}

/* Celular */

@media (max-width: 720px) {
    .main-header { padding: 0 16px; }
    .brand-logo { height: 42px; }
    .brand-text small { display: none; }
    .nav-pill span { display: none; }

    .page { padding: 16px 16px 48px; }
    .hero { padding: 32px 18px; }
    .hero-subtitle { font-size: 15px; }
    .identify-card { padding: 18px; }
    .identify-row { flex-direction: column; }
    .identify-voter { flex-wrap: wrap; }

    .candidates-toolbar { flex-direction: column; align-items: stretch; }
    .search { width: 100%; }
    .candidate-grid { grid-template-columns: 1fr; }
    .vote-tray { bottom: 12px; padding: 12px 12px 12px 16px; }

    .stats { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; }
}
