:root {
    /* Light mode colors - refined palette */
    --navy-dark: #1e3a8a;
    --navy-medium: #3b82f6;
    --purple-medium: #8b5cf6;
    --teal-medium: #06b6d4;
    --orange-medium: #f59e0b;
    --burgundy-medium: #dc2626;
    --green-medium: #10b981;
    --pink-accent: #ec4899;
    --slate-darkest: #0f172a;
    --slate-dark: #1e293b;
    --slate-medium: #64748b;
    --slate-light: #94a3b8;
    --slate-lighter: #cbd5e1;
    --slate-lightest: #f1f5f9;
    --gray-bg: #f8fafc;
    --white: #ffffff;
}

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

body {
    font-family: 'Inter', 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--slate-darkest);
    background: linear-gradient(135deg, #e0e7ff 0%, #f1f5f9 50%, #e0f2fe 100%);
    min-height: 100vh;
    padding: 30px 20px;
    transition: background 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: var(--white);
    border-radius: 16px;
    padding: 50px;
    box-shadow: 0 20px 60px rgba(30, 58, 138, 0.12);
    border: 1px solid var(--slate-lighter);
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin-bottom: 45px;
    padding-bottom: 35px;
    border-bottom: 3px solid var(--slate-lighter);
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    width: 100%;
}

h1 {
    color: var(--navy-dark);
    font-size: 2.5em;
    font-weight: 800;
    margin-bottom: 15px;
    text-align: center;
    letter-spacing: -0.5px;
}

.subtitle {
    text-align: center;
    color: var(--slate-medium);
    font-size: 1.1em;
    line-height: 1.8;
}

.theme-toggle {
    padding: 10px 20px;
    border-radius: 999px;
    border: 2px solid var(--slate-lighter);
    background: var(--white);
    color: var(--slate-darkest);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(15,23,42,0.08);
    transition: all 0.2s ease-in-out;
    white-space: nowrap;
}

.theme-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(15,23,42,0.15);
    border-color: var(--navy-medium);
}

a {
    color: var(--navy-medium);
    text-decoration: none;
    transition: color 0.2s ease;
    font-weight: 500;
}

a:hover {
    color: var(--purple-medium);
}

a:visited {
    color: var(--burgundy-medium);
}

.controls {
    background: var(--gray-bg);
    padding: 35px;
    border-radius: 12px;
    margin-bottom: 40px;
    border: 1px solid var(--slate-lighter);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.controls h3 {
    color: var(--navy-dark);
    margin: 0 0 28px 0;
    font-size: 1.4em;
    font-weight: 700;
}

.control-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.control-group {
    display: flex;
    flex-direction: column;
}

label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    font-weight: 600;
    font-size: 0.95em;
    color: var(--slate-dark);
}

input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: var(--slate-lighter);
    outline: none;
    transition: background 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--navy-medium);
    cursor: pointer;
    border: 3px solid var(--white);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
    transition: all 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.6);
}

input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--navy-medium);
    border: 3px solid var(--white);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.value-display {
    display: inline-block;
    background: var(--white);
    padding: 6px 14px;
    border-radius: 6px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-weight: 700;
    color: var(--navy-dark);
    border: 2px solid var(--slate-lighter);
    min-width: 70px;
    text-align: center;
    font-size: 0.95em;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
    margin: 35px 0;
}

.metric-card {
    background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy-medium) 100%);
    color: var(--white);
    padding: 28px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 6px 20px rgba(30, 58, 138, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(30, 58, 138, 0.3);
}

.metric-value {
    font-size: 2.5em;
    font-weight: 800;
    margin-bottom: 10px;
    font-family: 'Monaco', 'Courier New', monospace;
}

.metric-label {
    font-size: 0.9em;
    opacity: 0.95;
    font-weight: 500;
}

.regime-bar-section {
    background: var(--gray-bg);
    padding: 35px;
    border-radius: 12px;
    margin: 35px 0;
    border: 1px solid var(--slate-lighter);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.regime-bar-section h2 {
    color: var(--navy-dark);
    margin: 0 0 25px 0;
    font-size: 1.5em;
    font-weight: 700;
}

.regime-bar-container {
    background: var(--white);
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 25px;
    border: 1px solid var(--slate-lighter);
    transition: background 0.3s ease, border-color 0.3s ease;
}

#regime-bar {
    width: 100%;
    height: auto;
}

.regime-legend {
    display: flex;
    justify-content: center;
    gap: 28px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.regime-legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9em;
    color: var(--slate-medium);
    font-weight: 500;
}

.regime-legend-color {
    width: 24px;
    height: 24px;
    border-radius: 5px;
    border: 2px solid var(--slate-lighter);
}

.status-box {
    padding: 24px 28px;
    border-radius: 10px;
    margin: 25px 0;
    border-left: 5px solid;
    font-size: 1em;
    line-height: 1.8;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.status-box strong {
    font-weight: 700;
    display: block;
    margin-bottom: 8px;
    font-size: 1.05em;
}

.status-danger {
    background: #fef2f2;
    border-color: #ef4444;
    color: #991b1b;
}

.status-success {
    background: #f0fdf4;
    border-color: #10b981;
    color: #065f46;
}

.status-warning {
    background: #fffbeb;
    border-color: #f59e0b;
    color: #92400e;
}

.status-info {
    background: #eff6ff;
    border-color: var(--navy-medium);
    color: var(--navy-dark);
}

.viz-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 35px;
    margin-top: 40px;
}

.viz-card {
    background: var(--gray-bg);
    border-radius: 12px;
    padding: 35px;
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.08);
    border: 1px solid var(--slate-lighter);
    transition: all 0.3s ease;
}

.viz-card:hover {
    box-shadow: 0 8px 24px rgba(30, 58, 138, 0.12);
}

.viz-card h2 {
    margin: 0 0 22px 0;
    color: var(--navy-dark);
    font-size: 1.5em;
    font-weight: 700;
    border-bottom: 3px solid var(--navy-medium);
    padding-bottom: 14px;
}

.viz-description {
    font-size: 0.95em;
    color: var(--slate-medium);
    line-height: 1.8;
    margin-top: 18px;
}

.viz-description strong {
    color: var(--slate-darkest);
    font-weight: 600;
}

svg {
    width: 100%;
    height: auto;
    background: var(--white);
    border-radius: 8px;
    border: 1px solid var(--slate-lighter);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.findings {
    background: var(--gray-bg);
    padding: 40px;
    border-radius: 12px;
    margin-top: 45px;
    border: 1px solid var(--slate-lighter);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.findings h2 {
    color: var(--navy-dark);
    margin: 0 0 30px 0;
    font-size: 1.8em;
    font-weight: 700;
}

.finding-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-top: 30px;
}

.finding-columns h3 {
    color: var(--navy-medium);
    margin: 0 0 18px 0;
    font-size: 1.25em;
    font-weight: 700;
}

.finding-columns ul {
    line-height: 2;
    padding-left: 24px;
}

.finding-columns li {
    margin-bottom: 14px;
}

.chart-legend, .region-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.legend-item, .legend-region {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85em;
    color: var(--slate-medium);
    font-weight: 500;
}

.legend-color, .legend-box {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid var(--slate-lighter);
}

.legend-box {
    width: 28px;
    height: 20px;
}

footer {
    margin-top: 45px;
    padding-top: 30px;
    border-top: 2px solid var(--slate-lighter);
    text-align: center;
    color: var(--slate-medium);
    font-size: 0.95em;
}

.zoom-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.90);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    cursor: zoom-out;
    backdrop-filter: blur(8px);
    transition: opacity 0.3s ease-in-out;
}

.zoom-overlay svg {
    background: white;
    border-radius: 16px;
    padding: 30px;
    max-width: 92vw;
    max-height: 90vh;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.4);
    cursor: zoom-out;
}

.viz-card svg {
    cursor: zoom-in;
    transition: transform 0.2s ease-in-out;
}

.viz-card svg:hover {
    transform: scale(1.02);
}

/* ========== DARK MODE ========== */

body.dark-theme {
    /* Dark mode base colors */
    --white: #1a1a1a;
    --gray-bg: #1e1e1e;
    --slate-lightest: #2a2a2a;
    --slate-lighter: #3a3a3a;
    --slate-light: #4a4a4a;
    --slate-medium: #9ca3af;
    --slate-dark: #d1d5db;
    --slate-darkest: #f3f4f6;

    /* Dark mode accent colors - more vibrant */
    --navy-dark: #60a5fa;
    --navy-medium: #93c5fd;
    --purple-medium: #a78bfa;
    --teal-medium: #5eead4;
    --orange-medium: #fbbf24;
    --burgundy-medium: #fca5a5;
    --green-medium: #34d399;
    --pink-accent: #f472b6;

    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    color: var(--slate-darkest);
}

body.dark-theme .container,
body.dark-theme .controls,
body.dark-theme .viz-card,
body.dark-theme .findings,
body.dark-theme .regime-bar-section {
    background: #1e1e1e;
    border-color: #3a3a3a;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
}

body.dark-theme .regime-bar-container,
body.dark-theme svg {
    background: #252525;
    border-color: #3a3a3a;
}

body.dark-theme .metric-card {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
}

body.dark-theme h1,
body.dark-theme h2,
body.dark-theme h3 {
    color: var(--slate-darkest);
}

body.dark-theme .subtitle,
body.dark-theme .metric-label {
    color: var(--slate-medium);
}

body.dark-theme input[type="range"] {
    background: #3a3a3a;
}

body.dark-theme input[type="range"]::-webkit-slider-thumb {
    background: var(--purple-medium);
    box-shadow: 0 2px 8px rgba(167, 139, 250, 0.5);
}

body.dark-theme input[type="range"]::-moz-range-thumb {
    background: var(--purple-medium);
    box-shadow: 0 2px 8px rgba(167, 139, 250, 0.5);
}

body.dark-theme .value-display {
    background: #252525;
    border-color: #3a3a3a;
    color: var(--slate-darkest);
}

body.dark-theme .theme-toggle {
    background: var(--purple-medium);
    color: #1a1a1a;
    border-color: #a78bfa;
    font-weight: 700;
}

body.dark-theme .theme-toggle:hover {
    background: #9333ea;
    transform: translateY(-2px);
}

body.dark-theme a {
    color: var(--teal-medium);
}

body.dark-theme a:hover {
    color: var(--pink-accent);
}

body.dark-theme a:visited {
    color: var(--purple-medium);
}

body.dark-theme .axis-label,
body.dark-theme .axis-title,
body.dark-theme .regime-label,
body.dark-theme .delta-label,
body.dark-theme .regime-title {
    fill: var(--slate-dark) !important;
}

body.dark-theme .zoom-overlay {
    background: rgba(10, 10, 10, 0.95);
}

body.dark-theme .zoom-overlay svg {
    background: #252525;
}

body.dark-theme .status-danger {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #fca5a5;
}

body.dark-theme .status-success {
    background: rgba(16, 185, 129, 0.15);
    border-color: #10b981;
    color: #6ee7b7;
}

body.dark-theme .status-warning {
    background: rgba(245, 158, 11, 0.15);
    border-color: #f59e0b;
    color: #fcd34d;
}

body.dark-theme .status-info {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--navy-medium);
    color: var(--navy-medium);
}

/* Smooth transitions */
body, .container, svg, .viz-card, .controls, .findings, .regime-bar-section {
    transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

@media (max-width: 768px) {
    .container { 
        padding: 30px 20px; 
    }
    .finding-columns, .viz-grid { 
        grid-template-columns: 1fr; 
    }
    h1 { 
        font-size: 2em; 
    }
    .header-row {
        flex-direction: column;
        align-items: center;
    }
}