:root {
    --ink: #0d1b2a;
    --ink-soft: #324a5f;
    --paper: #f2f4f8;
    --card: #ffffff;
    --line: #d9dee7;
    --accent: #f05a28;
    --accent-soft: #ffd8c2;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", "Trebuchet MS", sans-serif;
    color: var(--ink);
    background: radial-gradient(circle at 0% 0%, #fff7ee 0%, var(--paper) 55%), linear-gradient(130deg, #fff3ea, #ecf5ff 70%);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

.bg-shape {
    position: fixed;
    z-index: 0;
    border-radius: 999px;
    filter: blur(60px);
    opacity: 0.35;
}

.bg-shape-1 {
    width: 320px;
    height: 320px;
    background: #ffb485;
    top: -120px;
    right: -80px;
}

.bg-shape-2 {
    width: 300px;
    height: 300px;
    background: #8bc8ff;
    bottom: -120px;
    left: -120px;
}

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 30px 20px 70px;
    position: relative;
    z-index: 1;
}

.hero {
    margin-bottom: 22px;
    animation: reveal 0.8s ease;
}

.hero h1 {
    margin: 0;
    font-size: clamp(1.1rem, 2.8vw, 1.9rem);
    letter-spacing: 0.3px;
}

.hero p {
    margin-top: 8px;
    color: var(--ink-soft);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 8px 22px rgba(13, 27, 42, 0.06);
    animation: reveal 0.9s ease;
}

.card h2 {
    margin: 0 0 12px;
    font-size: 1.02rem;
}

.filter-card {
    margin-bottom: 14px;
}

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    align-items: end;
}

.filters label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.86rem;
    color: var(--ink-soft);
}

.filters select,
.filters input[type="text"] {
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 9px 10px;
    background: #fff;
    color: var(--ink);
    width: 100%;
}

.filter-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.filter-actions button {
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

.reset-link {
    color: var(--ink-soft);
    text-decoration: none;
    font-size: 0.9rem;
}

.reset-link:hover {
    text-decoration: underline;
}

.kpi h3 {
    margin: 0;
    font-size: 0.9rem;
    color: var(--ink-soft);
}

.kpi p {
    margin: 8px 0 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.grid-2 {
    margin-top: 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

.table-wrap {
    overflow-x: auto;
}

th,
td {
    text-align: left;
    padding: 9px 8px;
    border-bottom: 1px solid var(--line);
    font-size: 0.92rem;
}

th {
    color: var(--ink-soft);
    background: linear-gradient(90deg, #fff7f1, #f8fbff);
}

.card-error {
    border-color: #db4c3f;
    background: #fff4f1;
}

.card-error pre {
    background: #fff;
    padding: 10px;
    border: 1px solid #ffcabf;
    border-radius: 8px;
    overflow-x: auto;
}

@keyframes reveal {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Navigation ── */
.nav {
    display: flex;
    gap: 6px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}

.nav-link {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 10px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ink-soft);
    border: 1px solid var(--line);
    background: var(--card);
    transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
    background: var(--accent-soft);
    color: var(--accent);
}

.nav-link.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ── Scope badge ── */
.scope-badge {
    display: inline-block;
    margin-bottom: 14px;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 0.88rem;
    font-weight: 600;
}

/* ── KPI highlight ── */
.kpi.highlight p {
    color: #16a34a;
}

/* ── Vote bar ── */
.vote-bar {
    height: 10px;
    background: var(--line);
    border-radius: 5px;
    overflow: hidden;
}

.vote-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 5px;
    transition: width 0.4s ease;
}

/* ── Position badges ── */
.pos {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 700;
    background: var(--line);
    color: var(--ink-soft);
}

.pos.top-1 { background: #fbbf24; color: #7c4a00; }
.pos.top-2 { background: #9ca3af; color: #fff; }
.pos.top-3 { background: #d97706; color: #fff; }

/* ── Table helpers ── */
.num {
    text-align: right;
}

.soft {
    color: var(--ink-soft);
    font-size: 0.88rem;
}

/* ── Drill link ── */
.drill-link {
    display: inline-block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    white-space: nowrap;
}

.drill-link:hover {
    text-decoration: underline;
}

/* ── Mesa code ── */
.mesa-code {
    font-family: monospace;
    font-size: 0.9rem;
    background: #f0f4ff;
    border: 1px solid #d0daf5;
    border-radius: 5px;
    padding: 2px 6px;
}

/* ── Status badge ── */
.status-badge {
    font-size: 0.78rem;
    background: #ecfdf5;
    color: #166534;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    padding: 2px 8px;
    white-space: nowrap;
}

/* ── No data ── */
.no-data {
    color: var(--ink-soft);
    font-style: italic;
    font-size: 0.9rem;
}

/* ── Cascade filters extra layout ── */
.filters-cascade {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.mode-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 8px;
}

.mode-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    text-decoration: none;
    background: rgba(255, 255, 255, 0.7);
    color: var(--ink-soft);
    font-weight: 700;
}

.mode-tab.active {
    background: var(--card);
    color: var(--accent);
    border-color: var(--accent-soft);
    box-shadow: 0 8px 22px rgba(13, 27, 42, 0.06);
}

.mode-tab-indicator {
    height: 4px;
    width: 50%;
    margin-bottom: 16px;
    border-radius: 999px;
    background: var(--accent);
    transition: margin-left 0.2s ease;
}

.mode-tab-indicator.is-mesa {
    margin-left: 50%;
}

.check-grid {
    display: grid;
    gap: 10px;
}

.filter-check {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fffaf6;
    color: var(--ink);
}

.filter-check input {
    margin: 0;
}

.filter-disabled {
    opacity: 0.55;
}

.scope-breadcrumb {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 999px;
    padding: 7px 14px;
    font-size: 0.88rem;
    font-weight: 700;
}

.alert-note {
    margin: 12px 0 0;
    padding: 12px 14px;
    border-radius: 10px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    font-size: 0.92rem;
}

@media (max-width: 900px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

/* ── Candidate images ── */
.candidate-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
}

.candidate-face {
     width: 60px;
     height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--line);
    flex-shrink: 0;
}

.party-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    text-align: center;
}

.party-logo {
     height: 60px;
     width: 60px;
    object-fit: contain;
    flex-shrink: 0;
}

