/* ============================================================================
   Où Va L'Argent? — French Public Finance Transparency
   Design System: Dark theme, corruption-transparency aesthetic
   ============================================================================ */

/* === Google Fonts === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* === Design Tokens === */
:root {
    /* Backgrounds */
    --bg-darkest: #0d1117;
    --bg-card: #161b22;
    --bg-elevated: #1c2333;
    --bg-border: #21262d;

    /* Accent palette */
    --accent: #e94560;
    --accent-dim: rgba(233, 69, 96, 0.12);
    --accent-glow: rgba(233, 69, 96, 0.35);
    --info: #58a6ff;
    --info-dim: rgba(88, 166, 255, 0.12);
    --success: #3fb950;
    --success-dim: rgba(63, 185, 80, 0.12);
    --warning: #d29922;
    --warning-dim: rgba(210, 153, 34, 0.12);

    /* Text */
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #484f58;

    /* Radii */
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(233, 69, 96, 0.15);

    /* Motion */
    --transition: 0.2s ease;
    --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);

    /* Layout */
    --max-width: 1440px;
    --gutter: 2rem;

    /* Compatibility aliases (used in JS inline styles) */
    --bg-primary: #0d1117;
    --text: #e6edf3;
    --text-dim: #8b949e;
    --yellow: #d29922;
    --green: #3fb950;
}

/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-darkest);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--info);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--accent);
}

::selection {
    background: var(--accent);
    color: #fff;
}

/* === Custom Scrollbar === */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--text-muted) transparent;
}

/* ============================================================================
   HEADER
   ============================================================================ */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(13, 17, 23, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid transparent;
    border-image: linear-gradient(90deg, transparent, var(--bg-border), var(--accent-dim), var(--bg-border), transparent) 1;
}

.header-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1.25rem var(--gutter) 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.header-left h1 {
    font-size: 1.75rem;
    font-weight: 900;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    line-height: 1.2;
}

.header-left h1 .accent {
    color: var(--accent);
    text-shadow: 0 0 20px var(--accent-glow);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 400;
    margin-top: 0.2rem;
    letter-spacing: 0.01em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-top: 0.5rem;
    flex-shrink: 0;
}

.live-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.4);
    }
    50% {
        opacity: 0.7;
        box-shadow: 0 0 0 6px rgba(63, 185, 80, 0);
    }
}

.data-status {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--success);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ============================================================================
   NAVIGATION — Horizontal scrolling tabs with pill active state
   ============================================================================ */
nav {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--gutter);
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.5rem;
}

nav::-webkit-scrollbar {
    display: none;
}

.tab {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 999px;
    transition: all var(--transition);
    white-space: nowrap;
    position: relative;
}

.tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.tab.active {
    color: var(--accent);
    background: var(--accent-dim);
    font-weight: 600;
    box-shadow: 0 0 12px rgba(233, 69, 96, 0.15), inset 0 0 0 1px rgba(233, 69, 96, 0.2);
}

/* ============================================================================
   MAIN CONTENT AREA
   ============================================================================ */
main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1.5rem var(--gutter) 3rem;
    width: 100%;
}

/* === Tab Content — Show/Hide + Fade === */
.tab-content {
    display: none;
    animation: fadeIn 0.35s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================================
   COUNTER CARDS — Hero stats row
   ============================================================================ */
.counter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.counter-card {
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

/* Top accent line */
.counter-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--info), var(--info-dim));
    transition: background var(--transition);
}

/* Subtle icon watermark */
.counter-card::after {
    content: '';
    position: absolute;
    bottom: -10px;
    right: -10px;
    width: 80px;
    height: 80px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.02) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.counter-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: rgba(255, 255, 255, 0.08);
}

/* Alert variant */
.counter-card.alert::before {
    background: linear-gradient(90deg, var(--accent), var(--accent-dim));
}

.counter-card.alert {
    border-color: rgba(233, 69, 96, 0.15);
}

.counter-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    opacity: 0.9;
}

.counter-value {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.counter-card.alert .counter-value {
    color: var(--accent);
}

.counter-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
}

/* ============================================================================
   CARDS — Generic content containers with gradient border
   ============================================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: all var(--transition);
    position: relative;
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.06);
    box-shadow: var(--shadow-sm);
}

.card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: -0.01em;
}

/* ============================================================================
   CHART GRID — 2-column layout for charts
   ============================================================================ */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.chart-container {
    position: relative;
    width: 100%;
    min-height: 300px;
    aspect-ratio: 4 / 3;
}

/* ============================================================================
   TABLES — Sticky header, alternating rows, sortable
   ============================================================================ */
.table-toolbar {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.table-search {
    background: var(--bg-darkest);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 0.6rem 1rem 0.6rem 1rem;
    font-size: 0.85rem;
    font-family: 'Inter', system-ui, sans-serif;
    width: 100%;
    max-width: 400px;
    transition: all var(--transition);
}

.table-search:focus {
    outline: none;
    border-color: var(--info);
    box-shadow: 0 0 0 3px var(--info-dim);
}

.table-search::placeholder {
    color: var(--text-muted);
}

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.83rem;
}

thead th {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.68rem;
    letter-spacing: 0.07em;
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--bg-border);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
    transition: color var(--transition);
}

thead th:hover {
    color: var(--text-primary);
}

thead th .sort-arrow {
    margin-left: 0.35rem;
    opacity: 0.3;
    font-size: 0.6rem;
    transition: opacity var(--transition), color var(--transition);
}

thead th.sorted .sort-arrow {
    opacity: 1;
    color: var(--accent);
}

tbody tr {
    border-bottom: 1px solid rgba(33, 38, 45, 0.6);
    transition: background var(--transition);
}

tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.015);
}

tbody tr:hover {
    background: rgba(88, 166, 255, 0.04);
}

tbody td {
    padding: 0.65rem 1rem;
    color: var(--text-primary);
    white-space: nowrap;
}

/* Amount cells */
td.amount {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    text-align: right;
}

td.amount.high {
    color: var(--accent);
}

td.amount.normal {
    color: var(--success);
}

td.flag {
    text-align: center;
}

/* ============================================================================
   BADGES — Severity system
   ============================================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

/* Critical — pulsing red */
.badge-red,
.badge-critical {
    background: var(--accent-dim);
    color: var(--accent);
}

.badge-critical {
    animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {
    0%, 100% { box-shadow: 0 0 0 0 rgba(233, 69, 96, 0.3); }
    50% { box-shadow: 0 0 0 4px rgba(233, 69, 96, 0); }
}

/* High — orange */
.badge-orange,
.badge-high {
    background: rgba(230, 126, 34, 0.12);
    color: #e67e22;
}

/* Medium — yellow/warning */
.badge-yellow,
.badge-medium {
    background: var(--warning-dim);
    color: var(--warning);
}

/* Low — green/success */
.badge-green,
.badge-low {
    background: var(--success-dim);
    color: var(--success);
}

/* ============================================================================
   SCORE BARS — Gradient fill based on value
   ============================================================================ */
.score-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.score-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    min-width: 2px;
}

/* Score colors: green (0-25) → yellow (25-50) → orange (50-75) → red (75-100) */
.score-bar-fill.score-low { background: var(--success); }
.score-bar-fill.score-medium { background: var(--warning); }
.score-bar-fill.score-high { background: #e67e22; }
.score-bar-fill.score-critical { background: var(--accent); }

/* ============================================================================
   RESERVE INTRO — Info callout
   ============================================================================ */
.reserve-intro {
    background: var(--warning-dim);
    border-left: 3px solid var(--warning);
    padding: 0.85rem 1.15rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.5;
}

/* ============================================================================
   LOADING OVERLAY — Full-screen spinner
   ============================================================================ */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(13, 17, 23, 0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.4s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--bg-border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

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

.loading-overlay p {
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

/* ============================================================================
   SKELETON LOADING — Shimmer placeholders
   ============================================================================ */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-card) 25%,
        var(--bg-elevated) 50%,
        var(--bg-card) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
}

.skeleton-card {
    height: 120px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================================================
   VS COMPARISON — Split layout
   ============================================================================ */

/* Mode selector pills */
.vs-mode-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.vs-mode {
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    color: var(--text-secondary);
    padding: 0.55rem 1.25rem;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: 'Inter', system-ui, sans-serif;
    transition: all var(--transition);
}

.vs-mode:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.vs-mode.active {
    background: var(--accent-dim);
    border-color: rgba(233, 69, 96, 0.35);
    color: var(--accent);
    font-weight: 600;
    box-shadow: 0 0 12px rgba(233, 69, 96, 0.12);
}

/* Search row with VS divider */
.vs-search-row {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 2rem;
}

.vs-search-box {
    flex: 1;
    position: relative;
}

.vs-input {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    font-family: 'Inter', system-ui, sans-serif;
    transition: all var(--transition);
}

.vs-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.vs-input::placeholder {
    color: var(--text-muted);
}

/* Centered VS divider label */
.vs-divider-label {
    font-size: 1.75rem;
    font-weight: 900;
    color: var(--accent);
    padding-top: 0.45rem;
    text-shadow: 0 0 24px var(--accent-glow);
    flex-shrink: 0;
    letter-spacing: 0.08em;
    user-select: none;
}

/* Dropdown */
.vs-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--bg-border);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 280px;
    overflow-y: auto;
    z-index: 50;
    display: none;
    box-shadow: var(--shadow-lg);
}

.vs-dropdown.open {
    display: block;
}

.vs-dropdown-item {
    padding: 0.65rem 1rem;
    cursor: pointer;
    transition: background var(--transition);
    border-bottom: 1px solid rgba(33, 38, 45, 0.5);
}

.vs-dropdown-item:last-child {
    border-bottom: none;
}

.vs-dropdown-item:hover {
    background: rgba(233, 69, 96, 0.08);
}

.vs-dropdown-label {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.85rem;
}

.vs-dropdown-sub {
    color: var(--text-muted);
    font-size: 0.72rem;
    margin-top: 0.15rem;
}

.vs-dropdown-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.83rem;
}

/* Loading / Error states */
.vs-loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.vs-loading .spinner {
    margin: 0 auto 1rem;
}

.vs-error {
    text-align: center;
    padding: 2rem;
    color: var(--accent);
    background: var(--accent-dim);
    border-radius: var(--radius);
    border: 1px solid rgba(233, 69, 96, 0.2);
}

/* VS Cards — Split comparison header */
.vs-cards {
    display: flex;
    align-items: stretch;
    gap: 0;
    margin-bottom: 1.5rem;
}

.vs-card {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    padding: 1.5rem;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: box-shadow var(--transition);
}

.vs-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.vs-card-left {
    border-radius: var(--radius) 0 0 var(--radius);
}

.vs-card-left::before {
    background: linear-gradient(90deg, var(--accent), var(--accent-dim));
}

.vs-card-right {
    border-radius: 0 var(--radius) var(--radius) 0;
}

.vs-card-right::before {
    background: linear-gradient(90deg, var(--info-dim), var(--info));
}

.vs-card:hover {
    box-shadow: var(--shadow-glow);
}

.vs-card-header {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

/* Centered VS divider between cards */
.vs-card-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 70px;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--accent-dim), rgba(88, 166, 255, 0.06));
    color: var(--accent);
    font-size: 1.5rem;
    font-weight: 900;
    text-shadow: 0 0 18px var(--accent-glow);
    border-top: 1px solid var(--bg-border);
    border-bottom: 1px solid var(--bg-border);
}

/* VS Metrics — Matching metric rows */
.vs-metrics-card {
    margin-bottom: 1.5rem;
}

.vs-metric-row {
    display: flex;
    align-items: center;
    padding: 0.7rem 0;
    border-bottom: 1px solid rgba(33, 38, 45, 0.5);
}

.vs-metric-row:last-child {
    border-bottom: none;
}

.vs-metric-label {
    flex: 0 0 180px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.vs-metric-value {
    flex: 1;
    text-align: center;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.vs-metric-value.vs-better {
    color: var(--success);
}

.vs-metric-value.vs-worse {
    color: var(--accent);
}

.vs-metric-value.vs-higher {
    color: var(--text-primary);
    text-shadow: 0 0 8px var(--accent-glow);
}

/* VS Bar charts */
.vs-bars-card {
    margin-bottom: 1.5rem;
}

.vs-bars {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.vs-bar-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.vs-bar-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: center;
    font-weight: 600;
}

.vs-bar-row {
    display: flex;
    gap: 4px;
    align-items: center;
}

.vs-bar {
    flex: 1;
    height: 30px;
    background: rgba(255, 255, 255, 0.025);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.vs-bar-left {
    direction: rtl;
}

.vs-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    min-width: 2px;
}

.vs-bar-val {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-primary);
    padding: 0 0.5rem;
    direction: ltr;
    white-space: nowrap;
}

.vs-bar-left .vs-bar-val {
    right: 0.5rem;
    left: auto;
}

.vs-bar-right .vs-bar-val {
    left: 0.5rem;
    right: auto;
}

/* VS Lists — Side by side ranked lists */
.vs-lists {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.vs-list-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(33, 38, 45, 0.4);
    transition: background var(--transition);
}

.vs-list-item:last-child {
    border-bottom: none;
}

.vs-list-item:hover {
    background: rgba(255, 255, 255, 0.02);
}

.vs-list-rank {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: 50%;
    font-size: 0.68rem;
    font-weight: 700;
    flex-shrink: 0;
}

.vs-list-name {
    flex: 1;
    font-size: 0.83rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vs-list-amount {
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.vs-no-data {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.83rem;
    font-style: italic;
}

/* ============================================================================
   FRAUD DETAIL PANEL — Expandable with risk factor bars
   ============================================================================ */
#fraud-detail-panel {
    border-left: 3px solid var(--accent);
    animation: fadeIn 0.3s ease;
}

#fraud-detail-panel .risk-factor {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
}

#fraud-detail-panel .risk-factor-label {
    flex: 0 0 160px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

#fraud-detail-panel .risk-factor-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
}

#fraud-detail-panel .risk-factor-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* ============================================================================
   FOOTER
   ============================================================================ */
footer {
    border-top: 1px solid var(--bg-border);
    padding: 2rem var(--gutter);
    text-align: center;
    max-width: var(--max-width);
    margin: 0 auto;
}

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

.footer-content a {
    color: var(--text-secondary);
    border-bottom: 1px solid var(--text-muted);
    transition: all var(--transition);
}

.footer-content a:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.footer-note {
    margin-top: 0.4rem;
    font-style: italic;
    font-size: 0.72rem !important;
    color: var(--text-muted) !important;
}

/* ============================================================================
   ADDITIONAL LAYOUT — 3-column chart grid, tab header/description
   ============================================================================ */
.chart-grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.tab-header {
    margin-bottom: 1.5rem;
}

.tab-description {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

/* ============================================================================
   TOGGLE SWITCHES — For data filters
   ============================================================================ */
.toggle-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.toggle-label {
    font-size: 0.83rem;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.toggle-switch .toggle-checkbox {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-switch .toggle-label {
    position: absolute;
    inset: 0;
    background: var(--bg-border);
    border-radius: 999px;
    cursor: pointer;
    transition: background var(--transition);
}

.toggle-switch .toggle-label::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: transform var(--transition), background var(--transition);
}

.toggle-switch .toggle-checkbox:checked + .toggle-label {
    background: var(--accent-dim);
}

.toggle-switch .toggle-checkbox:checked + .toggle-label::after {
    transform: translateX(18px);
    background: var(--accent);
}

/* ============================================================================
   SEARCH TOGGLE — Expandable search
   ============================================================================ */
.search-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: 'Inter', system-ui, sans-serif;
}

.search-toggle:hover {
    border-color: var(--info);
    color: var(--text-primary);
}

/* ============================================================================
   FOOTER EXTRAS — Badges, sources
   ============================================================================ */
.footer-sources {
    margin-top: 0.5rem;
}

.footer-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-xs);
    font-size: 0.68rem;
    font-weight: 600;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--bg-border);
    margin: 0.15rem;
}

/* ============================================================================
   ANIMATION CLASSES
   ============================================================================ */

/* Fade in on scroll/tab */
.fade-in {
    opacity: 0;
    transform: translateY(10px);
    animation: fadeIn 0.4s ease forwards;
}

/* Count-up for numbers */
.count-up {
    display: inline-block;
    animation: countPulse 0.3s ease;
}

@keyframes countPulse {
    0% { transform: scale(0.9); opacity: 0.5; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

/* Shimmer for loading placeholders */
.shimmer {
    background: linear-gradient(
        90deg,
        var(--bg-card) 25%,
        var(--bg-elevated) 50%,
        var(--bg-card) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

/* Pulse for critical alerts */
.pulse {
    animation: pulseAlert 2s ease-in-out infinite;
}

@keyframes pulseAlert {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(233, 69, 96, 0.3);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(233, 69, 96, 0);
    }
}

/* ============================================================================
   RESPONSIVE — Mobile (<768px) and Small (<480px)
   ============================================================================ */
@media (max-width: 768px) {
    :root {
        --gutter: 1rem;
    }

    .header-content {
        padding: 1rem var(--gutter) 0.5rem;
    }

    .header-left h1 {
        font-size: 1.35rem;
    }

    nav {
        padding: 0 var(--gutter) 0.5rem;
    }

    .tab {
        padding: 0.45rem 0.75rem;
        font-size: 0.75rem;
    }

    main {
        padding: 1rem var(--gutter) 2rem;
    }

    .counter-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .counter-card {
        padding: 1rem;
    }

    .counter-value {
        font-size: 1.5rem;
    }

    .counter-label {
        font-size: 0.65rem;
    }

    .chart-grid {
        grid-template-columns: 1fr;
    }

    .chart-container {
        min-height: 250px;
    }

    .card {
        padding: 1rem;
        border-radius: var(--radius-sm);
    }

    table {
        font-size: 0.78rem;
    }

    thead th,
    tbody td {
        padding: 0.5rem 0.65rem;
    }

    .table-search {
        max-width: 100%;
    }

    /* VS responsive */
    .vs-search-row {
        flex-direction: column;
        gap: 0.75rem;
    }

    .vs-divider-label {
        text-align: center;
        font-size: 1.25rem;
        padding: 0;
    }

    .vs-cards {
        flex-direction: column;
    }

    .vs-card-left {
        border-radius: var(--radius) var(--radius) 0 0;
    }

    .vs-card-right {
        border-radius: 0 0 var(--radius) var(--radius);
    }

    .vs-card-divider {
        width: 100%;
        height: 40px;
        border-left: 1px solid var(--bg-border);
        border-right: 1px solid var(--bg-border);
        border-top: none;
        border-bottom: none;
    }

    .vs-metric-row {
        flex-direction: column;
        gap: 0.25rem;
        text-align: center;
    }

    .vs-metric-label {
        flex: none;
    }

    .vs-metric-value {
        font-size: 0.95rem;
    }

    .vs-bar-row {
        flex-direction: column;
        gap: 2px;
    }

    .vs-bar-left {
        direction: ltr;
    }

    .vs-bar-left .vs-bar-val {
        left: 0.5rem;
        right: auto;
    }

    .vs-lists {
        grid-template-columns: 1fr;
    }

    .vs-mode-selector {
        gap: 0.3rem;
    }

    .vs-mode {
        font-size: 0.75rem;
        padding: 0.45rem 0.7rem;
    }
}

@media (max-width: 480px) {
    .header-right {
        display: none;
    }

    .counter-grid {
        grid-template-columns: 1fr 1fr;
    }

    .counter-card {
        padding: 0.85rem;
    }

    .counter-value {
        font-size: 1.2rem;
    }

    .counter-icon {
        font-size: 1.25rem;
        margin-bottom: 0.35rem;
    }

    .vs-card-header {
        font-size: 1rem;
    }
}

/* ============================================================================
   PRINT
   ============================================================================ */
@media print {
    header {
        position: static;
        backdrop-filter: none;
    }

    .loading-overlay,
    nav,
    .table-search,
    .vs-mode-selector {
        display: none !important;
    }

    body {
        background: #fff;
        color: #111;
    }

    .card,
    .counter-card {
        border: 1px solid #ddd;
        box-shadow: none;
    }
}

/* ============================================================================
   New tab styles (Budgets, Elections, Parties, Campaigns)
   ============================================================================ */

/* Tab header */
.tab-header {
    margin-bottom: 1.5rem;
}

.tab-header h2 {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.tab-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    line-height: 1.5;
}

/* 3-column chart grid for overview */
.chart-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 1100px) {
    .chart-grid-3 {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .chart-grid-3 {
        grid-template-columns: 1fr;
    }
}

/* Per-capita toggle */
.toggle-row {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    user-select: none;
}

.toggle-checkbox {
    display: none;
}

.toggle-switch {
    width: 36px;
    height: 20px;
    background: var(--bg-border);
    border-radius: 10px;
    position: relative;
    transition: background var(--transition);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: transform var(--transition), background var(--transition);
}

.toggle-checkbox:checked + .toggle-switch {
    background: var(--accent);
}

.toggle-checkbox:checked + .toggle-switch::after {
    transform: translateX(16px);
    background: #fff;
}

/* Search icon button in header */
.search-toggle {
    background: none;
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.search-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-dim);
}

/* Footer enhancements */
.footer-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--accent-dim);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-size: 0.8rem;
    margin-bottom: 1rem;
}

.footer-badge svg {
    color: var(--accent);
    flex-shrink: 0;
}

.footer-badge a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.footer-badge a:hover {
    text-decoration: underline;
}

.footer-sources {
    max-width: 700px;
    margin: 0 auto 0.75rem;
}

.footer-sources p {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.footer-sources strong {
    color: var(--text-secondary);
}
