@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=Inter:ital,wght@0,300;0,400;0,500;1,300&family=DM+Mono:wght@400;500&display=swap');

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

html, body { overflow-x: hidden; max-width: 100vw; }

body {
    font-family: 'Inter', sans-serif;
    background: #F6F2EC;
    color: #1A1008;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ───────────────────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: 224px; min-width: 224px;
    background: #EEE8DC;
    border-right: 1px solid #D8CEB8;
    padding: 1.75rem 1.25rem;
    position: fixed; top: 0; left: 0; bottom: 0;
    overflow-y: auto; z-index: 100;
}
.sidebar-inner {
    display: flex; flex-direction: column;
    gap: 0.15rem; height: 100%;
}
.nav-item {
    display: block; padding: 0.5rem 0.85rem;
    border-radius: 3px; color: #6A5A38;
    text-decoration: none; font-size: 0.875rem;
    font-weight: 400; transition: all 0.15s ease;
    border-left: 2px solid transparent;
    font-family: 'Inter', sans-serif;
}
.nav-item:hover {
    background: rgba(200,148,58,0.08);
    color: #1A1008;
    text-decoration: none;
    border-left: 2px solid #C8943A;
}
.nav-item.active {
    background: rgba(200,148,58,0.15);
    color: #1A1008;
    border-left: 2px solid #C8943A;
    font-weight: 500;
}
.nav-section-label {
    font-family: 'Syne', sans-serif;
    font-size: 9px;
    font-weight: 600;
    color: #B8A880;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 0.5rem 0.85rem 0.2rem;
    margin-top: 0.5rem;
}
.main-content {
    margin-left: 224px; flex: 1;
    padding: 2.5rem 3rem;
}
.page-content { width: 100%; max-width: 1100px; }

/* ── Typography ───────────────────────────────────────────── */
h1, h2, h3, h4 {
    font-family: 'Syne', sans-serif;
    color: #1A1008;
}
h2 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 1.1rem; font-weight: 700; }
h4 { font-size: 0.95rem; font-weight: 600; }

/* ── KPI-grid ─────────────────────────────────────────────── */
.kpi-grid {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem; margin-bottom: 1.5rem;
}
.kpi {
    background: #FDFAF4; border: 0.5px solid #DDD5C0;
    border-radius: 4px; padding: 1.1rem 1.3rem;
}
.kpi-label {
    font-family: 'Syne', sans-serif;
    font-size: 0.67rem; font-weight: 600; color: #A89060;
    text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 0.4rem;
}
.kpi-value {
    font-size: 1.6rem; font-weight: 700;
    font-family: 'DM Mono', monospace; color: #1A1008; line-height: 1.2;
}
.kpi-sub {
    font-size: 0.7rem; color: #A89060;
    margin-top: 0.25rem; font-family: 'DM Mono', monospace;
}

/* ── Section titles ───────────────────────────────────────── */
.section-title {
    font-family: 'Syne', sans-serif;
    font-size: 0.72rem; font-weight: 700; color: #A89060;
    margin: 1.5rem 0 0.75rem; text-transform: uppercase; letter-spacing: 0.1em;
}

/* ── Cards ────────────────────────────────────────────────── */
.company-row {
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0; border-bottom: 1px solid #EDE5D0;
}
.company-row:last-child { border-bottom: none; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-block; padding: 2px 10px; border-radius: 2px;
    font-size: 0.7rem; font-weight: 600; font-family: 'DM Mono', monospace;
}
.badge-green { background: #EAF3DE; color: #27500A; }
.badge-red   { background: #FCEBEB; color: #791F1F; }
.badge-gray  { background: #EEE8DC; color: #6A5A38; }

/* ── Plotly ───────────────────────────────────────────────── */
.js-plotly-plot {
    border-radius: 4px; border: 0.5px solid #DDD5C0;
    overflow: hidden; background: #FDFAF4;
}

/* ── Dropdown ─────────────────────────────────────────────── */
.Select-control {
    font-family: 'Inter', sans-serif !important;
    border-radius: 3px !important; border: 0.5px solid #DDD5C0 !important;
    background: #FDFAF4 !important;
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #C8B48A; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #A89060; }

/* ── Sector card hover ────────────────────────────────────── */
.sector-card-link > div {
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.sector-card-link:hover > div {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

/* ── Responsive helpers ───────────────────────────────────── */
.col-2-mobile { }
.col-3-mobile { }
.flex-mobile  { }
.hide-mobile  { }

/* ── Company grid ─────────────────────────────────────────── */
.company-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

/* ── Sector card grid ─────────────────────────────────────── */
.sector-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

/* ── Landing page sections ────────────────────────────────── */
.landing-section      { padding: 3rem; border-top: 0.5px solid #DDD5C0; }
.landing-section-sm   { padding: 0 3rem 3rem; border-top: 0.5px solid #DDD5C0; }
.landing-grid-3 {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem;
}
.landing-grid-4 {
    display: grid; grid-template-columns: repeat(4, 1fr);
    border-top: 0.5px solid #DDD5C0; border-bottom: 0.5px solid #DDD5C0;
    margin: 0 3rem;
}
.landing-hero {
    text-align: center; padding: 5rem 2rem 4rem; background: #F6F2EC;
}
.landing-hero h1 { font-size: 44px; font-family: 'Syne', sans-serif; }
.landing-nav {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1.25rem 3rem; border-bottom: 0.5px solid #DDD5C0;
    background: #EEE8DC; position: sticky; top: 0; z-index: 100;
}
.landing-footer {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1.25rem 3rem; border-top: 0.5px solid #DDD5C0;
    font-size: 12px; color: #9A8A68; flex-wrap: wrap; gap: 1rem;
}

/* ── Hamburger button ─────────────────────────────────────── */
.hamburger-btn {
    display: none;
    position: fixed; top: 12px; left: 12px; z-index: 1001;
    background: #EEE8DC; border: 1px solid #D8CEB8;
    border-radius: 4px; padding: 8px 12px; cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    font-size: 18px; line-height: 1; color: #1A1008;
}

/* ── Sidebar overlay ──────────────────────────────────────── */
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.3); z-index: 999;
    opacity: 0; transition: opacity 0.2s ease;
}
.sidebar-overlay.open { display: block; opacity: 1; }

/* ══════════════════════════════════════════════════════════════
   TABLET  ≤ 1024px
══════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .main-content { padding: 1.5rem; }
    .landing-section { padding: 2rem; }
    .landing-section-sm { padding: 0 2rem 2rem; }
    .landing-grid-4 { margin: 0 2rem; }
    .landing-nav { padding: 1rem 2rem; }
    .landing-footer { padding: 1rem 2rem; }
    .landing-hero { padding: 3rem 2rem; }
}

/* ══════════════════════════════════════════════════════════════
   MOBILE  ≤ 768px
══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

    .hamburger-btn { display: block; }

    .sidebar {
        width: 260px; height: 100vh;
        top: 0; left: -260px; bottom: 0;
        padding: 1.5rem 1.25rem;
        overflow-y: auto; z-index: 1000;
        transition: left 0.25s ease; min-width: unset;
    }
    .sidebar.open {
        left: 0;
        box-shadow: 4px 0 24px rgba(0,0,0,0.10);
    }
    .sidebar-inner {
        flex-direction: column; height: auto;
        gap: 0.15rem; align-items: stretch; justify-content: flex-start;
    }
    .nav-item {
        flex: unset; text-align: left;
        padding: 0.55rem 0.85rem;
        border-left: 2px solid transparent;
        border-top: none; font-size: 0.875rem;
        white-space: normal; overflow: visible; text-overflow: clip;
    }
    .nav-item:hover, .nav-item.active {
        border-left: 2px solid #C8943A; border-top: none;
        background: rgba(200,148,58,0.15);
    }

    .main-content {
        margin-left: 0; margin-bottom: 0;
        padding: 3.5rem 0.75rem 1rem;
        max-width: 100vw; overflow-x: hidden; box-sizing: border-box;
    }
    .page-content {
        padding: 0; max-width: 100%; overflow-x: hidden; box-sizing: border-box;
    }
    .page-content > div { max-width: 100%; box-sizing: border-box; }

    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
    .kpi-value { font-size: 1.2rem; }
    .kpi { padding: 0.85rem 1rem; }

    .company-grid { grid-template-columns: 1fr; }
    .sector-grid { grid-template-columns: 1fr; }
    .flex-mobile { flex-direction: column !important; }
    .hide-mobile { display: none !important; }

    .momentum-tables { flex-direction: column !important; }
    .momentum-tables > div { margin-right: 0 !important; margin-bottom: 1.5rem; }

    .momentum-section {
        width: 100% !important; min-width: unset !important;
        border-right: none !important; border-bottom: 1px solid #EDE5D0;
        padding-right: 0 !important; margin-right: 0 !important;
        padding-bottom: 0.75rem; margin-bottom: 0.75rem;
    }
    .movers-wrapper { width: 100% !important; flex: unset !important; }

    .landing-hero { padding: 2.5rem 1rem 2rem; }
    .landing-hero h1 { font-size: 26px !important; line-height: 1.3; }
    .landing-grid-3 { grid-template-columns: 1fr; }
    .landing-grid-4 { grid-template-columns: repeat(2, 1fr); margin: 0 1rem; }
    .landing-section { padding: 1.5rem 1rem; }
    .landing-section-sm { padding: 0 1rem 1.5rem; }
    .landing-nav { padding: 0.75rem 1rem; }
    .landing-footer {
        padding: 1rem; flex-direction: column;
        align-items: flex-start; gap: 0.75rem;
    }

    .search-sticky-bar { position: sticky; top: 0; z-index: 50; background: #F6F2EC; }
    .sector-chips { gap: 0.3rem !important; }
    .col-hide-mobile { display: none !important; }
    .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    #bt-run { width: 100% !important; margin-top: 0.5rem; }

    .js-plotly-plot, .plot-container, .plotly, .svg-container {
        max-width: 100% !important; width: 100% !important; overflow: hidden !important;
    }
    .page-content div { min-width: 0; box-sizing: border-box; }

    /* Landing mobile */
    .landing-nav { padding: 1rem 1.25rem !important; }
    .landing-section { padding: 2.5rem 1.25rem !important; }
    .signal-grid { grid-template-columns: 1fr !important; }
    .squeeze-grid { grid-template-columns: 1fr !important; }
    .proof-stats { flex-direction: row !important; flex-wrap: wrap !important; }
    .proof-stats > div { flex: 1 1 140px !important; }
    .proof-grid { grid-template-columns: 1fr !important; }
    .features-grid { grid-template-columns: 1fr !important; gap: 0 !important; }
    .pricing-grid { grid-template-columns: 1fr !important; }
}

/* ══════════════════════════════════════════════════════════════
   SMALL MOBILE  ≤ 480px
══════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .kpi-grid { gap: 0.4rem; }
    .kpi-value { font-size: 1.1rem; }
    .kpi { padding: 0.75rem 0.85rem; }
    .landing-hero h1 { font-size: 22px !important; }
    .landing-grid-4 { grid-template-columns: repeat(2, 1fr); }
    .main-content { padding: 3.5rem 0.4rem 0.5rem; }
}
