/* ── Fonts ─────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

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

/* ── Root variables ────────────────────────────────────────────── */
:root {
    --bg: #F5F5F3;
    --bg-card: #111318;
    --text: #111318;
    --text-muted: #6B7280;
    --text-light: #9CA3AF;
    --border: #E5E5E3;
    --accent: #1B2B4B;
    --white: #FFFFFF;
    --nav-bg: rgba(245, 245, 243, 0.92);
    --nav-border: rgba(0, 0, 0, 0.06);
    --hero-title: #111318;
}

html.dark {
    --bg: #0B0D11;
    --bg-card: #111318;
    --text: #F3F4F6;
    --text-muted: #9CA3AF;
    --text-light: #6B7280;
    --border: #1F2937;
    --accent: #60A5FA;
    --white: #FFFFFF;
    --nav-bg: rgba(11, 13, 17, 0.92);
    --nav-border: rgba(255, 255, 255, 0.06);
    --hero-title: #F3F4F6;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Outfit', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* ── Page container ────────────────────────────────────────────── */
.dashboard {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Hero section ──────────────────────────────────────────────── */
.hero {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    text-align: left;
    padding: 6rem 4rem 4rem;
    min-height: 55vh;
    overflow: hidden;
}

/* Spline 3D animation background */
.hero-animation-slot {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: auto;
}

.hero-animation-slot iframe {
    display: block;
    width: 100%;
    height: 100%;
}


.hero-content {
    position: relative;
    z-index: 1;
    max-width: 520px;
    pointer-events: none;
}

.title {
    font-size: 4.5rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1.0;
    color: var(--hero-title);
    margin-bottom: 1.25rem;
    transition: color 0.4s ease;
}

.subtitle {
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--text-muted);
    max-width: 420px;
    line-height: 1.7;
}

/* ── Main content area ─────────────────────────────────────────── */
.main-content {
    position: relative;
    z-index: 1;
    max-width: 1060px;
    width: 100%;
    margin: 0 auto;
    padding: 0 2rem 4rem;
}

/* ── KPI row ───────────────────────────────────────────────────── */
.kpi-row {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 1rem 1.25rem;
}

.kpi-value {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.35rem;
    font-weight: 600;
    color: #F3F4F6;
    line-height: 1.2;
}

.kpi-label {
    font-size: 0.68rem;
    font-weight: 500;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 0.2rem;
}

/* ── Chart section ─────────────────────────────────────────────── */
.chart-section {
    background: rgba(17, 19, 24, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 2.5rem;
    margin-bottom: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.chart-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #F3F4F6;
    margin-bottom: 0.4rem;
}

.chart-description {
    font-size: 0.82rem;
    color: #6B7280;
    line-height: 1.55;
    max-width: 560px;
    margin-bottom: 0.6rem;
}

.chart-insight {
    font-size: 0.88rem;
    color: #D1D5DB;
    margin-bottom: 1.75rem;
    line-height: 1.6;
    max-width: 600px;
}

.last-updated {
    font-size: 0.72rem;
    font-family: 'IBM Plex Mono', monospace;
    color: #4B5563;
    margin-top: 0.75rem;
    text-align: right;
}

/* ── Loading skeleton ──────────────────────────────────────────── */
.loading-skeleton {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 1rem 0;
}

.skeleton-row {
    height: 38px;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.02) 25%,
        rgba(255, 255, 255, 0.05) 50%,
        rgba(255, 255, 255, 0.02) 75%
    );
    background-size: 200% 100%;
    border-radius: 6px;
    animation: skeleton-pulse 1.8s ease-in-out infinite;
}

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

/* ── Site navigation ──────────────────────────────────────────── */
.site-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    background: var(--nav-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--nav-border);
    transform: translateY(-100%);
    transition: transform 0.3s ease, background 0.4s ease;
}

.site-nav.visible {
    transform: translateY(0);
}

.site-nav .nav-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 2rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    font-family: 'Outfit', system-ui, sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: -0.02em;
    color: var(--accent);
    text-decoration: none;
    white-space: nowrap;
    transition: opacity 0.2s;
}

.nav-brand:hover {
    opacity: 0.7;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-links {
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    max-width: 700px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 0.25rem 0;
}

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

.nav-link {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    white-space: nowrap;
    transition: color 0.2s, background 0.2s;
}

.nav-link:hover {
    color: var(--text);
    background: rgba(0, 0, 0, 0.05);
}

html.dark .nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
}

.nav-link.active {
    color: var(--accent);
    background: rgba(27, 43, 75, 0.1);
}

html.dark .nav-link.active {
    background: rgba(96, 165, 250, 0.12);
}

.theme-toggle {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--nav-border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: border-color 0.2s, background 0.2s;
    flex-shrink: 0;
}

.theme-toggle:hover {
    border-color: var(--accent);
}

/* ── Mobile hamburger ─────────────────────────────────────────── */
.mobile-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.hamburger-icon {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text-muted);
    position: relative;
    transition: background 0.2s;
}

.hamburger-icon::before,
.hamburger-icon::after {
    content: '';
    position: absolute;
    left: 0;
    width: 18px;
    height: 2px;
    background: var(--text-muted);
    transition: transform 0.3s;
}

.hamburger-icon::before { top: -5px; }
.hamburger-icon::after { top: 5px; }

.mobile-toggle.active .hamburger-icon {
    background: transparent;
}

.mobile-toggle.active .hamburger-icon::before {
    transform: rotate(45deg) translate(3.5px, 3.5px);
}

.mobile-toggle.active .hamburger-icon::after {
    transform: rotate(-45deg) translate(3.5px, -3.5px);
}

/* ── Scroll offset for anchor targets ─────────────────────────── */
[id$="-container"] {
    scroll-margin-top: 72px;
}

/* ── Footer ────────────────────────────────────────────────────── */
.footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 2rem;
    margin-top: auto;
}

.footer p {
    font-size: 0.8rem;
    color: var(--text-light);
}

.footer a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: opacity 200ms ease;
}

.footer a:hover {
    opacity: 0.7;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .hero {
        padding: 3rem 1.5rem 2rem;
        min-height: 35vh;
    }

    .hero-content {
        max-width: 280px;
    }

    .title {
        font-size: 2.2rem;
    }

    .subtitle {
        font-size: 0.9rem;
        max-width: 260px;
    }

    .main-content {
        padding: 0 0.75rem 3rem;
    }

    .kpi-row {
        gap: 0.4rem;
    }

    .kpi-card {
        padding: 0.6rem 0.75rem;
    }

    .kpi-value {
        font-size: 1rem;
    }

    .kpi-label {
        font-size: 0.6rem;
    }

    .chart-section {
        padding: 1rem;
        border-radius: 12px;
        margin-bottom: 1rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .chart-title {
        font-size: 1.05rem;
    }

    .chart-description {
        font-size: 0.75rem;
    }

    .chart-insight {
        font-size: 0.78rem;
        margin-bottom: 1rem;
    }

    .last-updated {
        font-size: 0.65rem;
    }

    /* Plotly graphs: allow horizontal scroll on small screens */
    .js-plotly-plot, .plotly {
        min-width: 500px;
    }

    .footer p {
        font-size: 0.7rem;
    }

    .mobile-toggle {
        display: block;
    }

    .site-nav .nav-inner {
        padding: 0 1rem;
    }

    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 56px;
        left: 0;
        width: 100%;
        background: var(--nav-bg);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        padding: 1rem 1.5rem;
        border-bottom: 1px solid var(--nav-border);
        gap: 0.5rem;
        max-width: 100%;
        overflow-x: visible;
    }

    .nav-links.open {
        display: flex;
    }

    .nav-link {
        font-size: 0.75rem;
        padding: 0.5rem 0.75rem;
    }
}

@media (max-width: 480px) {
    .kpi-row {
        flex-direction: column;
    }

    .title {
        font-size: 1.8rem;
    }

    .hero {
        padding: 2.5rem 1.25rem 1.5rem;
        min-height: 30vh;
    }

    .subtitle {
        font-size: 0.85rem;
    }

    .chart-section {
        padding: 0.75rem;
    }
}

/* ── prefers-reduced-motion ────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .skeleton-row {
        animation: none;
        background: rgba(255, 255, 255, 0.03);
    }

    * {
        transition-duration: 0.01ms !important;
    }
}
