/* ── THEME TOKENS ── */
:root, [data-theme="light"] {
    --red:            #D93025;
    --amber:          #C97A00;
    --green:          #1A7F44;
    --blue:           #0063CC;

    --bg:             #F5F4F0;
    --surface:        #FFFFFF;
    --surface2:       #F0EEE9;
    --surface3:       #E6E3DC;
    --border:         rgba(0,0,0,0.08);
    --border-strong:  rgba(0,0,0,0.14);

    --text-primary:   #1A1917;
    --text-secondary: #5C5A55;
    --text-tertiary:  #A09D97;

    --red-bg:         rgba(217,48,37,0.07);
    --red-border:     rgba(217,48,37,0.2);
    --green-bg:       rgba(26,127,68,0.07);
    --green-border:   rgba(26,127,68,0.2);
    --blue-bg:        rgba(0,99,204,0.07);
    --blue-border:    rgba(0,99,204,0.2);
    --neutral-bg:     rgba(0,0,0,0.04);
    --neutral-border: rgba(0,0,0,0.12);
}

[data-theme="dark"] {
    --red:            #FF453A;
    --amber:          #FF9F0A;
    --green:          #32D74B;
    --blue:           #0A84FF;

    --bg:             #0F1012;
    --surface:        #1A1D22;
    --surface2:       #22262D;
    --surface3:       #2C323C;
    --border:         rgba(255,255,255,0.07);
    --border-strong:  rgba(255,255,255,0.13);

    --text-primary:   #F2F2F7;
    --text-secondary: #8E8E93;
    --text-tertiary:  #b0b2b4;

    --red-bg:         rgba(255,69,58,0.12);
    --red-border:     rgba(255,69,58,0.25);
    --green-bg:       rgba(50,215,75,0.10);
    --green-border:   rgba(50,215,75,0.22);
    --blue-bg:        rgba(10,132,255,0.12);
    --blue-border:    rgba(10,132,255,0.25);
    --neutral-bg:     rgba(255,255,255,0.06);
    --neutral-border: rgba(255,255,255,0.13);
}

/* ── BASE & RESETS ── */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}


body {
    font-family: 'Space Grotesk', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background 0.2s, color 0.2s;
}

/* ── LAYOUT WRAPPERS ── */
.main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

.section-label {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 0.75rem;
}

/* ── NAVIGATION ── */
.nav {
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background 0.2s, border-color 0.2s;
}

.nav-logo {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-logo::before {
    content: '';
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--red);
    animation: pulse-dot 2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.35; }
}

@media (max-width: 800px) {
    .fund-grid { grid-template-columns: 1fr; }

    .main {
        padding: 0.2rem; /* Reduces the space inside the container */
        gap: 1rem;       /* Optional: Reduces the space between flex items */
    }
    .nav-logo {
    font-size: 10px;
    }
    .lang-toggle {
    padding: 2px 5px;
    font-size: 10px;
    font-weight: 600;
    }
}

/* ── TABLE SCROLL WRAPPER ── */
.table-scroll {
    overflow-x: auto;
}

.table-scroll::-webkit-scrollbar { height: 8px; }
.table-scroll::-webkit-scrollbar-track { background: var(--surface2); }
.table-scroll::-webkit-scrollbar-thumb { background-color: var(--border-strong); border-radius: 4px; }
.table-scroll::-webkit-scrollbar-thumb:hover { background-color: var(--text-tertiary); }

/* ── NAVIGATION LINKS ── */
.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-link {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--surface2);
}

.nav-link.active {
    color: var(--text-primary);
    background: var(--surface2);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.nav-sync {
    font-size: 10px;
    color: var(--text-tertiary);
    font-family: 'Space Mono', monospace;
    letter-spacing: 0.04em;
}

.theme-toggle,
.lang-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid var(--border-strong);
    border-radius: 7px;
    padding: 4px 10px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.theme-toggle:hover,
.lang-toggle:hover {
    border-color: var(--text-tertiary);
    color: var(--text-primary);
}

.theme-toggle svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

/* Hide hamburger by default (Desktop) */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.25rem;
    margin-left: 0.5rem;
}

.mobile-menu-btn svg {
    width: 24px;
    height: 24px;
}

/* 📱 Mobile Styles (Screens smaller than 768px) */
@media (max-width: 768px) {
    /* Show the hamburger */
    .mobile-menu-btn {
        display: block;
    }

    /* Hide the text label on the theme toggle to save space */
    #theme-label {
        display: none;
    }

    /* Turn the nav links into a hidden dropdown */
    .nav-links {
        display: none; /* Hidden by default on mobile */
        flex-direction: column;
        position: absolute;
        top: 100%; /* Pushes it exactly below the nav bar */
        left: 0;
        width: 100%;
        background: var(--surface); /* Assuming you have this CSS variable */
        border-bottom: 1px solid var(--border);
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        padding: 1rem;
        z-index: 50;
    }

    /* When the .show class is added via JS, reveal the menu */
    .nav-links.show {
        display: flex;
    }

    /* Make the links span the full width of the dropdown */
    .nav-link {
        width: 100%;
        padding: 1rem 0;
        border-bottom: 1px solid var(--border-light, #eee);
    }

    .nav-link:last-child {
        border-bottom: none;
    }
}

/* ── THAI FONT OVERRIDES ── */
/* Applied globally so all pages get correct Thai typography */
[data-lang="th"] body,
[data-lang="th"] .nav-logo,
[data-lang="th"] .section-label,
[data-lang="th"] .fund-card-label,
[data-lang="th"] .fund-card-unit,
[data-lang="th"] .dcs-label,
[data-lang="th"] .flow-card-label,
[data-lang="th"] .flow-node-name,
[data-lang="th"] .flow-node-sub,
[data-lang="th"] .flow-note,
[data-lang="th"] .chart-title,
[data-lang="th"] .chart-sub,
[data-lang="th"] .prices-title,
[data-lang="th"] .prices-legend,
[data-lang="th"] .debt-clock-eyebrow,
[data-lang="th"] .footer,
[data-lang="th"] .explorer-title,
[data-lang="th"] .explorer-subtitle,
[data-lang="th"] .form-label,
[data-lang="th"] .price-table thead th,
[data-lang="th"] .price-table td:first-child {
    font-family: 'Anuphan', sans-serif;
}

/* Thai doesn't have case; suppress latin typographic conventions */
[data-lang="th"] .nav-logo,
[data-lang="th"] .section-label,
[data-lang="th"] .fund-card-label,
[data-lang="th"] .fund-card-unit,
[data-lang="th"] .dcs-label,
[data-lang="th"] .flow-card-label,
[data-lang="th"] .flow-node-name,
[data-lang="th"] .prices-title,
[data-lang="th"] .chart-title,
[data-lang="th"] .form-label,
[data-lang="th"] .price-table thead th {
    text-transform: none;
    letter-spacing: 0.02em;
}

[data-lang="th"] .nav-logo         { letter-spacing: 0.01em; }
[data-lang="th"] .fund-card-unit   { letter-spacing: 0.01em; }
[data-lang="th"] .flow-note        { line-height: 1.9; }
[data-lang="th"] .footer           { letter-spacing: 0.01em; line-height: 1.8; }
[data-lang="th"] .debt-clock-unit  { font-family: 'Anuphan', sans-serif; }