:root {
    --bg: #f4f7fb;
    --card: #ffffff;
    --text: #102033;
    --muted: #667085;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --line: #e4e7ec;
    --danger: #b42318;
    --success: #067647;
    --warning: #b54708;
    --shadow: 0 20px 50px rgba(16, 24, 40, .08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, Arial, sans-serif;
}

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

.app-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: #0b1220;
    color: #fff;
    padding: 24px 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 34px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), #14b8a6);
    font-weight: 800;
}

.brand span {
    display: block;
    color: #aeb8c8;
    font-size: 13px;
}

.nav {
    display: grid;
    gap: 8px;
}

.nav a {
    padding: 12px 14px;
    border-radius: 12px;
    color: #cbd5e1;
}

.nav a:hover,
.nav a.active {
    background: rgba(255, 255, 255, .10);
    color: #fff;
}

.main {
    padding: 26px;
    overflow: auto;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    margin-bottom: 22px;
}

.topbar h1 {
    margin: 0;
    font-size: 28px;
}

.topbar p {
    margin: 6px 0 0;
    color: var(--muted);
}

.user-pill {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 10px 14px;
    display: grid;
    gap: 2px;
    text-align: right;
    min-width: 170px;
}

.user-pill small {
    color: var(--muted);
}

.grid {
    display: grid;
    gap: 18px;
}

.kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.kpi-title {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -.03em;
}

.kpi-note {
    color: var(--muted);
    margin-top: 6px;
    font-size: 13px;
}

.table-card {
    margin-top: 18px;
}

.table-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.table-actions h2,
.card h2 {
    margin: 0;
    font-size: 19px;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

th, td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
}

th {
    font-size: 12px;
    color: #475467;
    text-transform: uppercase;
    background: #f9fafb;
}

tr:hover td {
    background: #fcfcfd;
}

.badge {
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge.verified {
    background: #dcfae6;
    color: var(--success);
}

.badge.submitted {
    background: #d1e9ff;
    color: #175cd3;
}

.badge.pending {
    background: #fef0c7;
    color: var(--warning);
}

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    border: 0;
    border-radius: 12px;
    padding: 11px 14px;
    cursor: pointer;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
}

.btn:hover {
    background: var(--primary-dark);
}

.btn.secondary {
    background: #eef2f6;
    color: #344054;
}

.btn.danger {
    background: var(--danger);
}

.input, select, textarea {
    width: 100%;
    border: 1px solid #d0d5dd;
    border-radius: 12px;
    padding: 12px 13px;
    font: inherit;
    background: #fff;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.form-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 7px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.alert {
    padding: 13px 15px;
    border-radius: 14px;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    background: #fff;
}

.alert.error {
    background: #fef3f2;
    color: var(--danger);
    border-color: #fecdca;
}

.alert.success {
    background: #ecfdf3;
    color: var(--success);
    border-color: #abefc6;
}

.bar-track {
    width: 100%;
    height: 12px;
    border-radius: 999px;
    background: #edf2f7;
    overflow: hidden;
    margin-top: 10px;
}

.bar-fill {
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, rgba(20, 184, 166, .18), transparent 34%),
        var(--bg);
}

.login-card {
    width: min(440px, 100%);
    background: #fff;
    padding: 30px;
    border-radius: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--line);
}

.login-card h1 {
    margin: 0 0 8px;
}

.login-card p {
    margin: 0 0 24px;
    color: var(--muted);
}

.notice {
    color: var(--muted);
    font-size: 13px;
    margin-top: 16px;
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
    }

    .kpi-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .user-pill {
        text-align: left;
    }
}

.badge.quarantined {
    background: #fee4e2;
    color: var(--danger);
}

/* Modern dashboard upgrade */
.main {
    background:
        radial-gradient(circle at top right, rgba(15, 118, 110, .08), transparent 32%),
        linear-gradient(180deg, #f8fafc 0%, var(--bg) 100%);
}

.hero-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 24px;
    align-items: center;
    padding: 28px;
    margin-bottom: 20px;
    color: #fff;
    border-radius: 28px;
    background:
        radial-gradient(circle at 12% 20%, rgba(45, 212, 191, .28), transparent 28%),
        linear-gradient(135deg, #0b1220 0%, #0f766e 100%);
    box-shadow: 0 26px 70px rgba(15, 23, 42, .18);
    overflow: hidden;
    position: relative;
}

.hero-panel::after {
    content: "";
    position: absolute;
    inset: auto -70px -120px auto;
    width: 280px;
    height: 280px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .09);
}

.hero-copy,
.progress-orb {
    position: relative;
    z-index: 1;
}

.hero-copy h2 {
    font-size: clamp(30px, 4vw, 48px);
    line-height: 1.02;
    margin: 8px 0 12px;
    letter-spacing: -.05em;
}

.hero-copy p {
    max-width: 720px;
    color: rgba(255, 255, 255, .78);
    line-height: 1.65;
    margin: 0;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #0f766e;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .11em;
}

.hero-panel .eyebrow {
    color: #99f6e4;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 24px;
}

.btn.ghost {
    background: rgba(255, 255, 255, .12);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .20);
}

.btn.ghost:hover {
    background: rgba(255, 255, 255, .20);
}

.btn.slim {
    padding: 9px 12px;
    font-size: 13px;
}

.progress-orb {
    display: grid;
    place-items: center;
    gap: 14px;
    text-align: center;
}

.progress-ring {
    display: grid;
    place-items: center;
    align-content: center;
    width: 190px;
    height: 190px;
    border-radius: 999px;
    background:
        radial-gradient(circle closest-side, #0b1220 76%, transparent 78% 100%),
        conic-gradient(#5eead4 calc(var(--progress) * 1%), rgba(255, 255, 255, .20) 0);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .13), 0 22px 50px rgba(0, 0, 0, .20);
}

.progress-ring strong {
    display: block;
    font-size: 34px;
    letter-spacing: -.05em;
}

.progress-ring span,
.progress-orb p {
    color: rgba(255, 255, 255, .75);
    margin: 0;
}

.enhanced-kpis {
    margin-bottom: 20px;
}

.metric-card {
    display: flex;
    gap: 15px;
    align-items: flex-start;
    padding: 20px;
    border-radius: 22px;
    background: var(--card);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    background: var(--metric-accent, var(--primary));
}

.metric-icon {
    flex: 0 0 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    color: var(--metric-accent, var(--primary));
    background: color-mix(in srgb, var(--metric-accent, var(--primary)) 12%, white);
    font-weight: 900;
}

.accent-teal { --metric-accent: #0f766e; }
.accent-blue { --metric-accent: #2563eb; }
.accent-purple { --metric-accent: #7c3aed; }
.accent-orange { --metric-accent: #ea580c; }

.kpi-value.compact {
    font-size: 22px;
    line-height: 1.15;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(360px, .9fr);
    gap: 18px;
    align-items: start;
}

.lower-grid {
    grid-template-columns: minmax(0, 1.5fr) minmax(340px, .8fr);
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
}

.section-heading h2 {
    margin: 5px 0 0;
    font-size: 20px;
    letter-spacing: -.02em;
}

.soft-pill {
    display: inline-flex;
    align-items: center;
    padding: 7px 10px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475467;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.scoreboard-card,
.attention-card,
.activity-card {
    min-height: 100%;
}

.candidate-list {
    display: grid;
    gap: 18px;
}

.candidate-row {
    padding: 16px;
    border-radius: 18px;
    background: #f8fafc;
    border: 1px solid #eef2f6;
}

.candidate-meta {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    align-items: center;
}

.candidate-meta strong,
.candidate-meta b {
    font-size: 17px;
}

.candidate-meta small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
}

.bar-track.tall {
    height: 16px;
}

.bar-track.small {
    height: 9px;
    margin-top: 12px;
}

.candidate-two .bar-fill {
    background: #2563eb;
}

.race-summary,
.status-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 18px;
}

.race-summary div,
.status-strip div {
    padding: 13px;
    border-radius: 16px;
    background: #f8fafc;
    border: 1px solid #eef2f6;
}

.race-summary span,
.status-strip span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 5px;
}

.race-summary strong,
.status-strip strong {
    display: block;
    font-size: 16px;
}

.attention-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.attention-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid #eef2f6;
    border-radius: 16px;
    background: #fff;
    transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.attention-item:hover {
    transform: translateY(-1px);
    border-color: #99f6e4;
    box-shadow: 0 14px 30px rgba(15, 118, 110, .08);
}

.attention-item small {
    display: block;
    color: var(--muted);
    margin-top: 3px;
}

.empty-state {
    display: grid;
    gap: 5px;
    padding: 18px;
    border-radius: 16px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    color: #475467;
}

.empty-state strong {
    color: var(--text);
}

.cluster-card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.cluster-mini-card {
    padding: 16px;
    border: 1px solid #eef2f6;
    background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
    border-radius: 18px;
}

.cluster-mini-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.cluster-mini-top strong,
.cluster-mini-top span {
    display: block;
    font-weight: 800;
}

.cluster-mini-top small {
    display: block;
    color: var(--muted);
    margin-top: 4px;
}

.cluster-mini-stats {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 12px;
    margin: 10px 0 14px;
}

.cluster-leader {
    display: grid;
    gap: 3px;
    padding-top: 12px;
    border-top: 1px solid #eef2f6;
}

.cluster-leader small,
.cluster-leader span {
    color: var(--muted);
    font-size: 12px;
}

.timeline {
    display: grid;
    gap: 14px;
}

.timeline-item {
    display: grid;
    grid-template-columns: 16px 1fr;
    gap: 12px;
}

.timeline-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--primary);
    margin-top: 6px;
    box-shadow: 0 0 0 5px rgba(15, 118, 110, .10);
}

.timeline-item p {
    margin: 4px 0;
    color: #475467;
    line-height: 1.5;
}

.timeline-item small {
    color: var(--muted);
}

@media (max-width: 1180px) {
    .kpi-grid,
    .cluster-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-grid,
    .lower-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .main {
        padding: 18px;
    }

    .hero-panel {
        grid-template-columns: 1fr;
        padding: 22px;
    }

    .progress-ring {
        width: 160px;
        height: 160px;
    }

    .kpi-grid,
    .cluster-card-grid,
    .race-summary,
    .status-strip {
        grid-template-columns: 1fr;
    }

    .section-heading,
    .candidate-meta,
    .attention-item {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media print {
    .sidebar,
    .hero-actions,
    .topbar .user-pill,
    .btn {
        display: none !important;
    }

    .app-shell,
    .dashboard-grid,
    .lower-grid,
    .hero-panel,
    .kpi-grid,
    .cluster-card-grid {
        display: block;
    }

    .main {
        padding: 0;
        background: #fff;
    }

    .card,
    .metric-card,
    .hero-panel,
    .cluster-mini-card {
        box-shadow: none;
        break-inside: avoid;
        margin-bottom: 14px;
    }

    .hero-panel {
        color: #111827;
        background: #fff;
        border: 1px solid #e5e7eb;
    }

    .hero-copy p,
    .progress-orb p,
    .progress-ring span,
    .hero-panel .eyebrow {
        color: #475467;
    }
}
