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

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

body {
    font-family: 'DM Sans', sans-serif;
    background: #FAFAF8;
    color: #1a1a2e;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

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

.sidebar {
    width: 224px; min-width: 224px;
    background: #F5F5F2;
    border-right: 1px solid #E8E8E4;
    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: 7px; color: #4a4a6a;
    text-decoration: none; font-size: 0.875rem;
    font-weight: 500; transition: all 0.15s ease;
    border-left: 2px solid transparent;
}
.nav-item:hover {
    background: #EEEEE9; color: #1B4F8A;
    text-decoration: none; border-left: 2px solid #1B4F8A;
}
.nav-item.active {
    background: #EEF2FF; color: #1B4F8A;
    border-left: 2px solid #1B4F8A; font-weight: 600;
}
.main-content {
    margin-left: 224px; flex: 1;
    padding: 2.5rem 3rem;
}
.page-content { width: 100%; max-width: 1100px; }

/* ── KPI-grid ─────────────────────────────────────────────── */
.kpi-grid {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem; margin-bottom: 1.5rem;
}
.kpi {
    background: #fff; border: 1px solid #E8E8E4;
    border-radius: 12px; padding: 1.1rem 1.3rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.kpi-label {
    font-size: 0.67rem; font-weight: 600; color: #9ca3af;
    text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.4rem;
}
.kpi-value {
    font-size: 1.6rem; font-weight: 700;
    font-family: 'DM Mono', monospace; color: #1a1a2e; line-height: 1.2;
}
.kpi-sub {
    font-size: 0.7rem; color: #9ca3af;
    margin-top: 0.25rem; font-family: 'DM Mono', monospace;
}

/* ── Section titles ───────────────────────────────────────── */
.section-title {
    font-size: 0.72rem; font-weight: 700; color: #9ca3af;
    margin: 1.5rem 0 0.75rem; text-transform: uppercase; letter-spacing: 0.08em;
}

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

/* ── Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-block; padding: 2px 10px; border-radius: 20px;
    font-size: 0.7rem; font-weight: 600; font-family: 'DM Mono', monospace;
}
.badge-green { background: #ECFDF5; color: #065F46; }
.badge-red   { background: #FEF2F2; color: #991B1B; }
.badge-gray  { background: #F5F5F2; color: #6b7280; }

/* ── Plotly ───────────────────────────────────────────────── */
.js-plotly-plot {
    border-radius: 12px; border: 1px solid #E8E8E4;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    overflow: hidden; background: white;
}

/* ── Dropdown ─────────────────────────────────────────────── */
.Select-control {
    font-family: 'DM Sans', sans-serif !important;
    border-radius: 8px !important; border: 1px solid #E8E8E4 !important;
}

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

/* ── 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.10);
    transform: translateY(-2px);
}

/* ── Responsive helpers ───────────────────────────────────── */
.col-2-mobile { }   /* collapses to 1 col on mobile */
.col-3-mobile { }   /* collapses to 1 col on mobile */
.flex-mobile  { }   /* flex row → column on mobile  */
.hide-mobile  { }   /* hidden on mobile              */

/* ── Company grid (search page) ───────────────────────────── */
.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 #E8E8E4; }
.landing-section-sm   { padding: 0 3rem 3rem; border-top: 0.5px solid #E8E8E4; }
.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 #E8E8E4; border-bottom: 0.5px solid #E8E8E4;
    margin: 0 3rem;
}
.landing-hero {
    text-align: center; padding: 5rem 2rem 4rem; background: #FAFAF8;
}
.landing-hero h1 { font-size: 44px; }
.landing-nav {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1.25rem 3rem; border-bottom: 0.5px solid #E8E8E4;
    background: #FAFAF8; 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 #E8E8E4;
    font-size: 12px; color: #6b7280; flex-wrap: wrap; gap: 1rem;
}

/* ══════════════════════════════════════════════════════════════
   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) {

    /* Sidebar → bottom nav */
    .sidebar {
        width: 100%; height: 56px; min-width: unset;
        top: auto; bottom: 0; left: 0; right: 0;
        padding: 0; border-right: none;
        border-top: 1px solid #E8E8E4; overflow: hidden;
    }
    .sidebar-inner {
        flex-direction: row; height: 56px; gap: 0;
        align-items: center; justify-content: space-around;
    }
    .nav-item {
        flex: 1; text-align: center;
        padding: 0.4rem 0.25rem;
        border-left: none; border-top: 2px solid transparent;
        font-size: 0.65rem; white-space: nowrap;
        overflow: hidden; text-overflow: ellipsis;
    }
    .nav-item:hover, .nav-item.active {
        border-left: none; border-top: 2px solid #1B4F8A;
        background: #EEF2FF;
    }
    .main-content {
        margin-left: 0; margin-bottom: 56px; padding: 0.75rem;
    }
    .page-content { padding: 0; }

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

    /* Company cards → 1 col */
    .company-grid { grid-template-columns: 1fr; }

    /* Sector cards → 1 col */
    .sector-grid { grid-template-columns: 1fr; }

    /* Flex → column */
    .flex-mobile { flex-direction: column !important; }

    /* Hide on mobile */
    .hide-mobile { display: none !important; }

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

    /* Landing hero */
    .landing-hero { padding: 2.5rem 1rem 2rem; }
    .landing-hero h1 { font-size: 26px !important; line-height: 1.3; }

    /* Landing grids */
    .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;
    }
    .landing-footer-links { flex-wrap: wrap; gap: 1rem !important; }

    /* Search sticky bar */
    .search-sticky-bar {
        position: sticky; top: 0; z-index: 50;
        background: #FAFAF8;
    }

    /* Sector chips wrap tighter */
    .sector-chips { gap: 0.3rem !important; }

    /* Table columns – hide secondary on mobile */
    .col-hide-mobile { display: none !important; }

    /* Scrollable tables on mobile */
    .table-scroll {
        overflow-x: auto; -webkit-overflow-scrolling: touch;
    }
}

/* ══════════════════════════════════════════════════════════════
   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: 0.5rem; }
}
