:root {
    --bg-main: #0a0f1d;
    --bg-card: rgba(18, 24, 39, 0.82);
    --bg-card-hover: rgba(28, 38, 59, 0.9);
    --bg-subtle: rgba(255, 255, 255, 0.03);
    
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(59, 130, 246, 0.5);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.25);
    
    --emerald: #10b981;
    --emerald-glow: rgba(16, 185, 129, 0.2);
    --amber: #f59e0b;
    --amber-glow: rgba(245, 158, 11, 0.25);
    --purple: #8b5cf6;
    --purple-glow: rgba(139, 92, 246, 0.2);
    --pink: #ec4899;
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    
    --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5), 0 0 1px 1px rgba(255, 255, 255, 0.05);
    --shadow-glow: 0 0 25px rgba(59, 130, 246, 0.15);
}

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

body {
    background-color: var(--bg-main);
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.12) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.1) 0px, transparent 50%),
        radial-gradient(at 50% 100%, rgba(16, 185, 129, 0.08) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px 32px 64px;
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

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

.brand-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

.brand-badge {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: #60a5fa;
    text-transform: uppercase;
}

.brand-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.02em;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

/* PROMINENT LAST VOTE PILL */
.last-vote-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 8px 16px;
    border-radius: var(--radius-full);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.15);
}

.live-dot {
    width: 10px;
    height: 10px;
    background: var(--emerald);
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 10px var(--emerald);
}

.live-dot.pulse {
    animation: pulseBeacon 2s infinite ease-in-out;
}

@keyframes pulseBeacon {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.35); opacity: 0.6; }
}

.pill-content {
    display: flex;
    flex-direction: column;
}

.pill-label {
    font-size: 0.68rem;
    color: #6ee7b7;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.pill-value {
    font-size: 0.88rem;
    color: #f0fdf4;
    font-family: var(--font-mono);
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font-sans);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #60a5fa 0%, #2563eb 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.45);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

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

.btn-ghost:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-subtle);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.78rem;
}

.toggle-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--emerald);
    display: inline-block;
    box-shadow: 0 0 6px var(--emerald);
}

.toggle-indicator.off {
    background: var(--text-muted);
    box-shadow: none;
}

/* ==========================================================================
   KPI CARDS
   ========================================================================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: flex-start;
    gap: 16px;
    position: relative;
    overflow: hidden;
    transition: transform 0.25s ease, border-color 0.25s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.15);
}

.kpi-card-focus {
    border-color: rgba(245, 158, 11, 0.4);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5), 0 0 20px rgba(245, 158, 11, 0.15);
}

.leader-card {
    border-color: rgba(16, 185, 129, 0.35);
}

.kpi-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.bg-blue-subtle { background: rgba(59, 130, 246, 0.15); }
.bg-emerald-subtle { background: rgba(16, 185, 129, 0.15); }
.bg-amber-subtle { background: rgba(245, 158, 11, 0.15); }
.bg-purple-subtle { background: rgba(139, 92, 246, 0.15); }

.kpi-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.kpi-label-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.kpi-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-accent {
    font-size: 0.65rem;
    font-weight: 700;
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.15);
    padding: 2px 7px;
    border-radius: var(--radius-full);
}

.kpi-number {
    font-size: 2.2rem;
    font-weight: 800;
    font-family: var(--font-mono);
    color: #fff;
    line-height: 1.1;
    margin: 4px 0;
}

.kpi-highlight {
    font-size: 1.45rem;
    font-weight: 800;
    color: #10b981;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 4px 0;
}

.kpi-timestamp {
    font-size: 1.15rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: #fbbf24;
    margin: 4px 0;
}

.kpi-value-sm {
    font-size: 1.35rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: #c4b5fd;
    margin: 4px 0;
}

.kpi-subtext {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ==========================================================================
   MAIN DASHBOARD (CHARTS + CARDS)
   ========================================================================== */
.dashboard-main {
    display: grid;
    grid-template-columns: 1.8fr 1.2fr;
    gap: 24px;
    margin-bottom: 32px;
}

@media (max-width: 1024px) {
    .dashboard-main {
        grid-template-columns: 1fr;
    }
}

.panel {
    background: var(--bg-card);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.panel-title {
    font-size: 1.18rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.01em;
}

.panel-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Chart tabs */
.chart-tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    padding: 3px;
    border-radius: var(--radius-md);
    gap: 2px;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: var(--font-sans);
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: #fff;
}

.tab-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.chart-container-wrapper {
    position: relative;
    height: 380px;
    width: 100%;
}

/* Candidates Card List */
.candidates-cards-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chapa-card {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.chapa-card:hover {
    background: rgba(255, 255, 255, 0.045);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateX(3px);
}

.chapa-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.chapa-rank-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.chapa-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
}

.chapa-stats-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
}

.chapa-votes-count {
    font-family: var(--font-mono);
    font-size: 1.35rem;
    font-weight: 700;
    color: #fff;
}

.chapa-votes-count small {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-weight: 500;
}

.chapa-percentage {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: 700;
}

.chapa-progress-bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.chapa-progress-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   CONSOLIDATED SECTION (BOTTOM)
   ========================================================================== */
.consolidated-section {
    margin-top: 36px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.section-heading {
    margin-bottom: 8px;
}

.heading-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: #38bdf8;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.section-title {
    font-size: 1.55rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.02em;
}

.section-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.panel-stamp {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.25);
    padding: 6px 14px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 8px;
}

.stamp-label {
    font-size: 0.72rem;
    color: #fcd34d;
    text-transform: uppercase;
    font-weight: 600;
}

.stamp-time {
    font-size: 0.88rem;
    color: #fff;
    font-family: var(--font-mono);
}

/* TABLES */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    text-align: left;
}

.data-table th {
    padding: 12px 16px;
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.015);
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    vertical-align: middle;
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.025);
}

.data-table tfoot td {
    background: rgba(255, 255, 255, 0.03);
    font-weight: 700;
    border-top: 2px solid var(--border-subtle);
}

/* Table elements */
.rank-badge-cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: 800;
    font-size: 0.85rem;
}

.rank-gold { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.4); }
.rank-silver { background: rgba(148, 163, 184, 0.2); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.4); }
.rank-bronze { background: rgba(180, 83, 9, 0.2); color: #d97706; border: 1px solid rgba(180, 83, 9, 0.4); }

.chapa-table-name {
    font-weight: 700;
    font-size: 0.98rem;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chapa-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.table-progress-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-progress-bg {
    flex-grow: 1;
    height: 7px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.table-progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
}

.status-badge {
    display: inline-flex;
    padding: 3px 10px;
    font-size: 0.74rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    text-transform: uppercase;
}

.status-won {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-second {
    background: rgba(148, 163, 184, 0.12);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.25);
}

/* AUDIT FILTERS */
.audit-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
}

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-size: 0.82rem;
    font-family: var(--font-sans);
    width: 190px;
}

.select-filter {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    font-family: var(--font-sans);
    outline: none;
    cursor: pointer;
}

.select-filter option {
    background: #0f172a;
    color: #fff;
}

.select-compact {
    padding: 4px 8px;
    font-size: 0.78rem;
}

/* Pagination */
.table-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    margin-top: 8px;
    border-top: 1px solid var(--border-subtle);
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-info {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-page {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-page:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.btn-page:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-indicator {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Vote Tag in Audit table */
.vote-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
}

.mono-cell {
    font-family: var(--font-mono);
    color: #cbd5e1;
}

/* FOOTER */
.main-footer {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.footer-meta {
    margin-top: 6px;
    font-size: 0.78rem;
}

.footer-meta strong {
    color: #fcd34d;
    font-family: var(--font-mono);
}

/* MODAL */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(5, 8, 16, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    background: #111827;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 520px;
    padding: 24px 28px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.75);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: #fff;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: #fff;
}

.modal-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.drop-zone {
    border: 2px dashed rgba(59, 130, 246, 0.4);
    background: rgba(59, 130, 246, 0.04);
    border-radius: var(--radius-md);
    padding: 36px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    transform: scale(1.01);
}

.drop-zone h4 {
    margin: 12px 0 4px;
    font-size: 0.95rem;
    color: #fff;
}

.drop-zone p {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.upload-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 16px;
    color: #60a5fa;
    font-size: 0.85rem;
}

.upload-error {
    margin-top: 14px;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    font-size: 0.82rem;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(59, 130, 246, 0.2);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   PRINT LAYOUT (ATA OFICIAL DE APURAÇÃO)
   ========================================================================== */
.print-report {
    display: none;
}

@media print {
    body {
        background: #fff !important;
        color: #000 !important;
    }
    
    .app-container {
        display: none !important;
    }
    
    .print-report {
        display: block !important;
        padding: 40px;
        font-family: Arial, sans-serif;
    }
    
    .print-header {
        text-align: center;
        border-bottom: 2px solid #000;
        padding-bottom: 16px;
        margin-bottom: 24px;
    }
    
    .print-header h2 {
        font-size: 18pt;
        margin-bottom: 6px;
    }
    
    .print-header h3 {
        font-size: 14pt;
        color: #333;
    }
    
    .print-meta-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        margin-bottom: 24px;
        padding: 16px;
        background: #f8fafc;
        border: 1px solid #ccc;
    }
    
    .print-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 40px;
    }
    
    .print-table th, .print-table td {
        border: 1px solid #333;
        padding: 10px;
        text-align: left;
    }
    
    .print-table th {
        background: #e2e8f0;
    }
    
    .print-signatures {
        display: flex;
        justify-content: space-between;
        margin-top: 60px;
    }
    
    .sig-box {
        text-align: center;
        width: 30%;
    }
    
    .sig-line {
        border-top: 1px solid #000;
        margin-bottom: 8px;
    }
    
    .sig-box span {
        font-size: 9pt;
        color: #333;
    }
}
