/* =====================================================================
   Altstock PRO — Responsive CSS
   Breakpoints:
     Mobile  : ≤ 640px
     Tablet  : 641px – 1024px
     Desktop : ≥ 1025px  (default — no overrides needed)
   ===================================================================== */

/* Prevent horizontal body scroll from overflowing inner content */
#landing { overflow-x: hidden; }

/* Landing bottom nav: hidden on desktop/tablet, shown on mobile via media query below */
.lp-mob-bnav { display: none !important; }

/* Key Ratios: default — full labels visible, short hidden */
.kr-short { display: none; }

/* Scenario Modeler: default — full labels visible, short hidden */
.sm-short { display: none; }

/* Portfolio top row: perf + allocation side by side on desktop */
.port-top-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

/* ── TABLET (641px – 1024px) ─────────────────────────────────────────── */
@media (max-width: 1024px) {

  /* App shell: single column (sidebar is hidden by default) */
  .app {
    grid-template-columns: 1fr;
  }

  /* Main content: tighter padding */
  .main {
    padding: 12px 14px;
  }

  /* Marketplace 3-col grid → 2-col */
  .mkt-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Index ticker: 5 → 3 visible tiles */
  .idx-ticker-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Generic 3-col helpers → 2-col */
  .g3 {
    grid-template-columns: 1fr 1fr;
  }

  /* Company profile overview grid → single column */
  #cp-ov,
  #cp-fund,
  #cp-tech,
  #cp-promo,
  #cp-cd {
    grid-template-columns: 1fr;
  }

  /* Ownership + Top Shareholders: stack on tablet */
  #cp-promo .g2 {
    grid-template-columns: 1fr;
  }

  /* Top shareholders table: fit without scroll on tablet */
  #cp-promo .g2 > .panel:last-child table {
    min-width: 0 !important;
    width: 100% !important;
    table-layout: fixed !important;
  }
  #cp-promo .g2 > .panel:last-child td,
  #cp-promo .g2 > .panel:last-child th {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* Portfolio performance + allocation row → stack */
  #sec-port .g2 {
    grid-template-columns: 1fr;
  }

  /* Portfolio top row: stack on tablet */
  .port-top-row {
    grid-template-columns: 1fr !important;
  }

  /* IPO hub grid → 2-col */
  #sec-ipo [style*="repeat(3,minmax"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  /* IPO detail overview grid → stack */
  #ip-io {
    grid-template-columns: 1fr;
  }

  /* Alerts grid → stack */
  #sec-alrt [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Admin shell sidebar */
  #adm [style*="grid-template-columns:210px 1fr"] {
    grid-template-columns: 160px 1fr !important;
  }

  /* Financial Summary Metric table: horizontal scroll on tablet */
  #sec-cop .panel [style*="overflow-x:auto"][style*="border-radius:12px"][style*="border:1px solid #e8ecf2"] {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  #sec-cop .panel [style*="overflow-x:auto"][style*="border-radius:12px"][style*="border:1px solid #e8ecf2"] > table {
    min-width: 500px !important;
  }

  /* Shareholding pattern: fit without scroll on tablet */
  #cp-sh-q, #cp-sh-y {
    overflow-x: visible !important;
    overflow: visible !important;
  }
  #cp-sh-q table, #cp-sh-y table {
    min-width: 0 !important;
    width: 100% !important;
    table-layout: fixed !important;
  }
  #cp-sh-q td, #cp-sh-y td,
  #cp-sh-q th, #cp-sh-y th {
    font-size: 12px !important;
    padding: 7px 5px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* Funding rounds: remove uppercase, fit on tablet */
  #cp-cd th {
    text-transform: none !important;
    font-size: 12px !important;
    letter-spacing: normal !important;
  }
}

/* ── MOBILE (≤ 640px) ────────────────────────────────────────────────── */
@media (max-width: 640px) {

  /* ── App shell: sidebar moves to top, stacks vertically ── */
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  /* Sidebar: horizontal strip across the top */
  .sb {
    grid-row: 1;
    grid-column: 1;
    height: auto;
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
    overflow-y: visible;
    overflow-x: auto;
  }

  /* Sidebar header: tighter */
  .sb-h {
    padding: 8px 12px;
  }

  /* A25 boxes inside sidebar: row of 4 on mobile */
  .sb [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 4px !important;
  }

  .kc {
    padding: 6px 8px;
  }

  /* Hide filters panel on mobile to save space */
  .sb [style*="border-top:1px solid #e5e7eb"]:last-child {
    display: none;
  }

  /* Top nav bar: below sidebar */
  .dnav {
    grid-row: 2;
    grid-column: 1;
    padding: 0 8px;
  }

  .nb {
    padding: 8px 10px;
    font-size: 13px;
  }

  /* Main content area */
  .main {
    grid-row: 3;
    grid-column: 1;
    padding: 10px 12px;
    height: auto;
    overflow-y: visible;
    overflow-x: hidden;
    min-height: 0;
    max-width: 100vw;
  }

  /* Prevent horizontal overflow from app shell */
  .app {
    max-width: 100vw;
    overflow-x: hidden;
    padding-bottom: 64px;
  }

  /* Hide nav buttons that move to bottom strip */
  .nb[data-s="mkt"],
  .nb[data-s="opp"],
  .nb[data-s="ipo"],
  .nb[data-s="ins"],
  .nb[data-s="cal"],
  .nb[data-s="alrt"] {
    display: none !important;
  }

  /* Bottom navigation strip */
  .mob-bnav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9000;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    padding: 4px 0 env(safe-area-inset-bottom, 4px);
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 12px rgba(0,0,0,.06);
  }
  .mob-bnav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    padding: 6px 4px 4px;
    font-size: 10px;
    font-weight: 600;
    color: #94a3b8;
    cursor: pointer;
    font-family: inherit;
    transition: color .15s;
    min-width: 56px;
  }
  .mob-bnav-btn.on {
    color: #0f2444;
  }
  .mob-bnav-btn svg {
    width: 22px;
    height: 22px;
  }

  /* Cards: single column */
  .card {
    border-radius: 8px;
    padding: 10px 12px;
  }

  /* All 2-col grids → 1-col */
  .g2 {
    grid-template-columns: 1fr;
  }

  /* All 3-col grids → 1-col */
  .g3 {
    grid-template-columns: 1fr;
  }

  /* Marketplace grids → 1-col */
  .mkt-grid {
    grid-template-columns: 1fr;
  }

  /* Index ticker: 2-col on mobile */
  .idx-ticker-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Hero banner: smaller padding */
  .hero {
    padding: 14px 14px;
    border-radius: 6px;
  }

  .hero [style*="grid-template-columns:repeat(4,1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Panels: less padding */
  .panel {
    padding: 12px 12px;
    border-radius: 8px;
  }

  /* Company profile tabs: scrollable */
  #cpt,
  #ipt {
    overflow-x: auto;
    scrollbar-width: none;
  }

  /* Company profile: all content grids → 1-col */
  #cp-ov,
  #cp-fund,
  #cp-tech,
  #cp-promo,
  #cp-cd {
    grid-template-columns: 1fr;
  }

  /* Company profile stat strip: 3-col on mobile */
  .ststrip {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  /* Order book: stack bid/ask */
  #cp-md [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* IPO hub grid → 1-col */
  #sec-ipo [style*="repeat(3,minmax"] {
    grid-template-columns: 1fr !important;
  }

  /* IPO detail stat strip: 3-col */
  #ip-io + div .ststrip,
  .ststrip[style*="repeat(6,1fr)"] {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  /* IPO overview grid → 1-col */
  #ip-io {
    grid-template-columns: 1fr;
  }

  /* Screener table: horizontal scroll */
  #sec-scr .panel,
  #sec-ord .panel {
    overflow-x: auto;
  }

  /* Portfolio holdings table: horizontal scroll */
  #sec-port [style*="overflow-x:auto"] {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  #sec-port [style*="overflow-x:auto"] > div[style*="display:grid"] {
    min-width: 880px !important;
  }

  /* Portfolio watchlist: horizontal scroll */
  #port-wl-list [style*="overflow-x:auto"] {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  #port-wl-list [style*="overflow-x:auto"] > div[style*="display:grid"] {
    min-width: 820px !important;
  }

  /* Portfolio top row: stack on mobile */
  .port-top-row {
    grid-template-columns: 1fr !important;
  }

  /* Portfolio summary stat row: 3-col */
  #sec-port [style*="repeat(5,1fr)"] {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  /* Watchlist: tighten */
  #port-wl-list,
  #wl-list {
    font-size: 12px;
  }

  /* Alerts grid → 1-col */
  #sec-alrt [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Bid panel: full width */
  #bid-p > div {
    max-width: 100% !important;
    border-radius: 12px 12px 0 0 !important;
  }

  #bid-p {
    align-items: flex-end !important;
  }

  /* Bid/Ask selector: stack */
  #bid-s1 [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Share modal: full width */
  #share-modal > div {
    max-width: 100% !important;
    width: calc(100% - 16px) !important;
    padding: 16px !important;
  }


  /* Admin panel → 1-col, hide sidebar text */
  #adm [style*="grid-template-columns:210px 1fr"] {
    grid-template-columns: 48px 1fr !important;
  }

  #adm .anb span,
  #adm .anb {
    font-size: 0 !important;
    padding: 10px !important;
    justify-content: center !important;
  }

  /* Top bar actions: wrap */
  .main > div:first-child {
    flex-wrap: wrap;
    gap: 6px;
  }

  /* Reduce font sizes slightly */
  .kv { font-size: 13px; }
  td  { font-size: 12px; padding: 6px 8px; }
  th  { font-size: 10px; padding: 5px 8px; }

  /* Calendar grid: tighter cells */
  .cal-day {
    padding: 2px;
    min-height: 36px;
  }

  .cal-dh {
    font-size: 9px;
  }

  .cev {
    font-size: 9px;
    padding: 0 2px;
  }

  /* Landing page adjustments (already has its own media queries, reinforce) */
  #landing .hero {
    padding: 36px 0 40px;
  }

  #landing h1 {
    font-size: clamp(36px, 10vw, 56px);
  }

  #landing .cta {
    padding: 24px 20px;
    border-radius: 20px;
  }

  #landing .steps {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── LANDING PAGE MOBILE FIXES (≤ 640px) ────────────────────────────── */
@media (max-width: 640px) {

  /* Landing page bottom nav + padding */
  .lp-mob-bnav { display: flex !important; }
  #landing { padding-bottom: 64px; }
  #landing .lp-footer { padding-bottom: 64px; }

  /* 1) Company Discovery table: horizontal scroll like Key Financials */
  #lp-mkt-grid {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  #lp-mkt-grid > div {
    min-width: 560px !important;
    width: max-content !important;
  }

  /* 2) The Landscape: 4 icons in one row, hide descriptions */
  #landing .lp-section [style*="repeat(4,1fr)"][style*="gap:36px"] {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 16px !important;
    margin-top: 24px !important;
  }
  #landing .lp-section [style*="repeat(4,1fr)"][style*="gap:36px"] > div > p {
    display: none !important;
  }
  #landing .lp-section [style*="repeat(4,1fr)"][style*="gap:36px"] > div > h3 {
    font-size: 11px !important;
    margin: 0 !important;
  }
  #landing .lp-section [style*="repeat(4,1fr)"][style*="gap:36px"] > div [style*="width:52px"] {
    width: 44px !important;
    height: 44px !important;
    border-radius: 11px !important;
  }

  /* 3) "Speak to our team" — hide second line on mobile */
  #landing [style*="border-radius:99px"][style*="padding:26px 40px"] {
    border-radius: 16px !important;
    padding: 18px 20px !important;
    flex-direction: column !important;
    text-align: center !important;
  }
  #landing [style*="border-radius:99px"][style*="padding:26px 40px"] > div {
    font-size: 16px !important;
  }
  .mobile-hide-cta {
    display: none !important;
  }

  /* 4) Why Altstock: stack vertically, hide Get Started CTA */
  #landing [style*="grid-template-columns:1fr 1fr"][style*="gap:64px"] {
    grid-template-columns: 1fr !important;
    gap: 28px !important;
  }
  #landing [style*="grid-template-columns:1fr 1fr"][style*="gap:64px"] > div:first-child > a[style*="Get started"],
  #landing [style*="grid-template-columns:1fr 1fr"][style*="gap:64px"] > div:first-child > a[style*="inline-flex"][style*="border-radius:12px"] {
    display: none !important;
  }

  /* 5) How it works: compact tiles */
  #landing .lp-steps {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
    margin-top: 28px !important;
  }
  #landing .lp-step {
    padding: 20px 16px 18px !important;
    border-radius: 14px !important;
  }
  #landing .lp-step-ghost {
    font-size: 48px !important;
  }
  #landing .lp-step-ico {
    width: 44px !important;
    height: 44px !important;
    margin-bottom: 10px !important;
  }
  #landing .lp-step-h {
    font-size: 15px !important;
    margin-top: 10px !important;
    margin-bottom: 6px !important;
  }
  #landing .lp-step-p {
    font-size: 12.5px !important;
    line-height: 1.55 !important;
  }

  /* Featured companies: proper card tiles like desktop */
  #landing .logo-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1px !important;
    background: #e2e8f0 !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 10px !important;
    overflow: hidden !important;
  }
  #landing .logo-card {
    min-height: 68px !important;
    height: auto !important;
    max-height: none !important;
    padding: 14px 14px 14px 16px !important;
    box-sizing: border-box !important;
    background: #fff !important;
    border: none !important;
    border-radius: 0 !important;
    justify-content: flex-start !important;
    gap: 10px !important;
    min-width: 0 !important;
    overflow: hidden !important;
  }
  #landing .logo-card img {
    width: 24px !important;
    height: 24px !important;
    flex-shrink: 0 !important;
  }
  #landing .logo-card span {
    font-size: 13px !important;
    font-weight: 500 !important;
    line-height: 1.2 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  #landing .logo-card.small span {
    font-size: 12px !important;
  }
  #landing .logo-card:nth-child(n+11) {
    display: none !important;
  }

  /* Reduce gap: hero stats → featured companies (50%) */
  #landing .lp-hero { padding-bottom: 24px !important; }
  #landing .section.logo-wall-wrap { padding-top: 41px !important; }

  /* Reduce gap: company discovery → why altstock (50%) */
  #landing #lp-preview { padding-bottom: 20px !important; }
  #landing #lp-preview + .lp-section { padding-top: 20px !important; padding-bottom: 20px !important; }
  #landing #lp-preview + .lp-section + section { padding-top: 40px !important; }

  /* Reduce gap: testimonials → FAQs → news & views (50%) */
  #landing .lp-tst { padding-bottom: 50px !important; }
  #landing .lp-faq { padding-top: 44px !important; padding-bottom: 44px !important; }
  #landing .lp-articles { padding-top: 40px !important; }

  /* Hero stats strip: all three in one line */
  #landing .lp-hero-strip {
    flex-wrap: nowrap !important;
    gap: 0 !important;
    justify-content: space-between !important;
  }
  #landing .lp-hstat {
    padding: 0 !important;
    flex: 1 !important;
    text-align: center !important;
  }
  #landing .lp-hstat strong {
    font-size: 17px !important;
  }
  #landing .lp-hstat span {
    font-size: 10px !important;
  }
  #landing .lp-hstat-sep {
    display: block !important;
    height: 28px !important;
    flex-shrink: 0 !important;
  }

  /* Hero CTAs: inline on one line */
  #landing .lp-hero-btns {
    flex-wrap: nowrap !important;
    gap: 10px !important;
  }
  #landing .lp-hero-btns .lp-btn {
    padding: 12px 16px !important;
    font-size: 13px !important;
    white-space: nowrap !important;
  }

  /* Disclaimer popup: tighter spacing on mobile */
  #disc-overlay-js > div {
    padding: 20px 18px !important;
    border-radius: 14px !important;
    max-height: 85vh !important;
  }
  #disc-overlay-js [style*="padding:16px 18px"] {
    padding: 12px 14px !important;
    font-size: 12px !important;
  }
  #disc-overlay-js [style*="font-size:17px"][style*="font-weight:700"] {
    font-size: 15px !important;
  }
  #disc-overlay-js label {
    padding: 8px 10px !important;
    margin-bottom: 12px !important;
  }
  #disc-overlay-js label span {
    font-size: 11.5px !important;
  }

  /* Marketplace: A25 index full width, hide Most/Least Enquired */
  #sec-mkt [style*="grid-template-columns:1fr 1fr"][style*="gap:14px"][style*="align-items:stretch"] {
    grid-template-columns: 1fr !important;
  }
  #sec-mkt [style*="grid-template-columns:1fr 1fr"][style*="gap:10px"][style*="height:100%"] {
    display: none !important;
  }

  /* Marketplace: tile view single column on mobile */
  #sec-mkt [style*="grid-template-columns:repeat(2,minmax(0,1fr))"] {
    grid-template-columns: 1fr !important;
  }

  /* 7) Search section: wider input, tighter padding */
  #sec-mkt [style*="border-radius:18px"][style*="padding:36px"] {
    padding: 20px 14px 18px !important;
    border-radius: 14px !important;
  }
  #sec-mkt [style*="width:70%"][style*="max-width:600px"] {
    width: 100% !important;
    max-width: 100% !important;
  }
  #sec-mkt #mkt-search-inp {
    font-size: 13px !important;
    padding: 8px 0 !important;
  }
  #sec-mkt [style*="padding:12px 28px"][style*="border-radius:99px"][style*="font-size:14px"] {
    padding: 10px 18px !important;
    font-size: 13px !important;
  }
  #sec-mkt [style*="font-size:24px"][style*="font-weight:800"][style*="color:#fff"] {
    font-size: 18px !important;
  }

  /* 8) View toggle: handled in JS — default to tile on mobile */

  /* 9) "Looking for information" panel: stack and clean up */
  #sec-mkt .panel [style*="grid-template-columns:1.3fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  #sec-mkt .panel [style*="grid-template-columns:1.3fr 1fr"] > div:first-child {
    padding: 20px 16px !important;
  }
  #sec-mkt .panel [style*="grid-template-columns:1.3fr 1fr"] > div:first-child [style*="font-size:22px"] {
    font-size: 17px !important;
  }
  #sec-mkt .panel [style*="grid-template-columns:1.3fr 1fr"] > div:last-child {
    display: none !important;
  }



  /* Filter strip: scrollable */
  #sec-mkt [style*="display:flex;flex-direction:column;gap:8px;margin-bottom:10px"] {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    padding: 8px 10px !important;
  }

  /* Marketplace list view: horizontal scroll */
  #mkt-cards > [style*="border:1px solid #e5e7eb"][style*="border-radius:12px"] {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  #mkt-cards > [style*="border:1px solid #e5e7eb"][style*="border-radius:12px"] > div {
    min-width: 780px !important;
  }

  /* Opportunities: search bar full-width like company's page */
  #sec-opp [style*="width:70%"][style*="max-width:600px"] {
    width: 100% !important;
    max-width: 100% !important;
  }
  #sec-opp [style*="border-radius:18px"][style*="padding:36px"] {
    padding: 20px 14px 18px !important;
    border-radius: 14px !important;
  }
  #sec-opp [style*="font-size:24px"][style*="font-weight:800"][style*="color:#fff"] {
    font-size: 18px !important;
  }
  #sec-opp #opp-search {
    font-size: 13px !important;
    padding: 8px 0 !important;
  }
  #sec-opp [style*="padding:12px 28px"][style*="border-radius:99px"][style*="font-size:14px"] {
    padding: 10px 18px !important;
    font-size: 13px !important;
  }

  /* IPO Hub: search bar full-width like company's page */
  #sec-ipo [style*="width:70%"][style*="max-width:600px"] {
    width: 100% !important;
    max-width: 100% !important;
  }
  #sec-ipo [style*="border-radius:18px"][style*="padding:36px"] {
    padding: 20px 14px 18px !important;
    border-radius: 14px !important;
  }
  #sec-ipo [style*="font-size:24px"][style*="font-weight:800"][style*="color:#fff"] {
    font-size: 18px !important;
  }
  #sec-ipo #ipo-search {
    font-size: 13px !important;
    padding: 8px 0 !important;
  }
  #sec-ipo [style*="padding:12px 28px"][style*="border-radius:99px"][style*="font-size:14px"] {
    padding: 10px 18px !important;
    font-size: 13px !important;
  }

  /* Opportunities list view: horizontal scroll */
  #opp-grid > .panel > table {
    min-width: 780px !important;
  }
  #opp-grid > .panel {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Opportunities tile view: single column on mobile */
  #opp-grid[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  /* Opportunities filter strip: scrollable */
  #sec-opp [style*="display:flex;flex-direction:column;gap:8px;margin-bottom:14px"] {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    padding: 8px 10px !important;
  }

  /* IPO filter/view row: wrap properly */
  #sec-ipo [style*="display:flex;gap:8px;align-items:center;flex-wrap:wrap"] {
    gap: 6px !important;
    margin-bottom: 10px !important;
  }
}

/* ── COMPANY PROFILE MOBILE FIXES (≤ 640px) ─────────────────────────── */
@media (max-width: 640px) {

  /* Company overview + Express Interest: stack vertically */
  #sec-cop [style*="display:flex;gap:20px;align-items:flex-start;margin-top:24px"] {
    flex-direction: column !important;
  }

  #sec-cop [style*="display:flex;gap:20px;align-items:flex-start;margin-top:24px"] > [style*="max-width:50%"] {
    max-width: 100% !important;
  }

  #sec-cop [style*="display:flex;gap:20px;align-items:flex-start;margin-top:24px"] > [style*="width:280px"] {
    width: 100% !important;
    margin-left: 0 !important;
  }

  /* Company name: smaller on mobile */
  #sec-cop [style*="font-size:34px"] {
    font-size: 22px !important;
  }

  /* Stat strip: 2-col on mobile */
  .ststrip {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Financial Summary KPI cards: 2×2 grid */
  #cp-fund [style*="repeat(4,"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Portfolio KPI row: compact on mobile */
  .port-kpi-row > div {
    padding: 10px 8px !important;
  }
  .port-kpi-row > div > div:last-child {
    font-size: 13px !important;
  }

  .mkt-marquee {
    border-radius: 8px !important;
    margin-bottom: 4px !important;
  }
  .mkt-marquee > div:first-child {
    display: none !important;
  }
  .mq-track > div > span:last-child {
    display: none !important;
  }

  /* Hide grid3 toggle on mobile */
  .vb-grid3 {
    display: none !important;
  }

  /* Hide A25 Index panel on mobile */
  .a25-panel {
    display: none !important;
  }
  .idx-gl-row {
    grid-template-columns: 1fr !important;
  }

  /* Key Ratios: show short labels on mobile */
  .kr-full { display: none !important; }
  .kr-short { display: inline !important; }

  /* Key Ratios: 3-col compact grid */
  #cp-fund [style*="repeat(4,1fr)"] {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 5px !important;
  }
  #cp-fund [style*="repeat(4,1fr)"] > div {
    padding: 8px 10px !important;
    border-radius: 8px !important;
  }
  #cp-fund [style*="repeat(4,1fr)"] > div > div:first-child {
    font-size: 9px !important;
    margin-bottom: 2px !important;
  }
  #cp-fund [style*="repeat(4,1fr)"] > div > div:last-child {
    font-size: 12.5px !important;
  }

  /* Scenario Modeler: show short labels on mobile */
  .sm-full { display: none !important; }
  .sm-short { display: inline !important; }

  /* Implied Valuation output cards: force 3-col on mobile */
  #cp-fund #cp-val-cards {
    grid-template-columns: 1fr 1fr 1fr !important;
    gap: 6px !important;
  }
  #cp-fund #cp-val-cards > div {
    padding: 10px 8px !important;
    text-align: center !important;
    border-radius: 8px !important;
  }
  #cp-fund #cp-val-cards > div > div:first-child {
    font-size: 9px !important;
    margin-bottom: 2px !important;
  }
  #cp-fund #cp-val-cards > div > div:last-child {
    font-size: 16px !important;
  }

  /* Scenario Modeler: compact slider row on mobile */
  #cp-fund .sm-short {
    font-size: 12px !important;
    white-space: nowrap !important;
  }

  /* Funding rounds: key investors in one line */
  #cp-cd .panel:first-child td:last-child {
    white-space: nowrap !important;
  }
  #cp-cd .panel:first-child table {
    min-width: 700px !important;
  }

  /* Pricing panel: horizontal scroll on mobile */
  #cp-md [style*="border:1px solid #e5e7eb"][style*="border-radius:7px"] {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  #cp-md [style*="grid-template-columns:0.7fr"] {
    min-width: 680px !important;
  }

  /* Top shareholders: remove scroll, fit to screen */
  #cp-promo .g2 > .panel:last-child {
    overflow: visible !important;
  }
  #cp-promo .g2 > .panel:last-child table {
    min-width: 0 !important;
    width: 100% !important;
    table-layout: fixed !important;
  }
  #cp-promo .g2 > .panel:last-child th:nth-child(1),
  #cp-promo .g2 > .panel:last-child td:nth-child(1) { width: 34% !important; }
  #cp-promo .g2 > .panel:last-child th:nth-child(2),
  #cp-promo .g2 > .panel:last-child td:nth-child(2) { width: 16% !important; }
  #cp-promo .g2 > .panel:last-child th:nth-child(3),
  #cp-promo .g2 > .panel:last-child td:nth-child(3) { width: 30% !important; }
  #cp-promo .g2 > .panel:last-child th:nth-child(4),
  #cp-promo .g2 > .panel:last-child td:nth-child(4) { width: 20% !important; }
  #cp-promo .g2 > .panel:last-child td,
  #cp-promo .g2 > .panel:last-child th {
    font-size: 12px !important;
    padding: 5px 4px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  /* Registered Details: stack 3-col to 1 */
  #cp-cd [style*="grid-template-columns:1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Strengths/Weaknesses: stack */
  #cp-cd > [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* News grid: stack */
  #cp-sig [style*="repeat(3,1fr)"] {
    grid-template-columns: 1fr !important;
  }

  /* ── All data tables: touch-scrollable containers ── */
  #cp-fund .panel,
  #cp-tech .panel,
  #cp-promo .panel,
  #cp-cd .panel {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Key Financials, Shareholding Pattern, Financial Summary tables */
  #cp-fin-pl, #cp-fin-bs, #cp-fin-cf,
  #cp-sh-q, #cp-sh-y {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Set min-width on wide tables so they scroll instead of squish */
  #cp-fin-pl table, #cp-fin-bs table, #cp-fin-cf table {
    min-width: 560px;
  }

  #cp-sh-q table, #cp-sh-y table {
    min-width: 500px;
  }

  /* Top Shareholders table: scrollable */
  #cp-promo .g2 > .panel {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #cp-promo .g2 > .panel table {
    min-width: 340px;
  }

  /* Ownership donut: stack vertically on small screens */
  #cp-promo [style*="display:flex;align-items:center;gap:24px"] {
    flex-direction: column !important;
    gap: 12px !important;
  }

  /* Company header: allow wrapping */
  #sec-cop [style*="font-size:34px"] {
    font-size: 24px !important;
    word-break: break-word;
  }

  /* Hide inline Express Interest card on mobile */
  #sec-cop [style*="width:280px"][style*="flex-shrink:0"] {
    display: none !important;
  }

  /* ── Sticky Express Interest CTA bar ── */
  .ei-bar {
    position: fixed;
    left: 0; right: 0;
    bottom: 56px;
    z-index: 9990;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: linear-gradient(135deg, #0f2444 0%, #1a3a5c 100%);
    box-shadow: 0 -2px 12px rgba(0,0,0,.25);
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
  .ei-bar-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    color: #fff;
    min-width: 0;
    flex: 1;
    margin-right: 12px;
  }
  .ei-bar-name {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .ei-bar-price {
    font-size: 12px;
    font-family: monospace;
    color: #93c5fd;
  }
  .ei-bar-btn {
    flex-shrink: 0;
    padding: 10px 22px;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 0 12px rgba(37,99,235,.5), 0 0 24px rgba(37,99,235,.25);
    animation: eiPulse 2s ease-in-out infinite;
  }
  @keyframes eiPulse {
    0%, 100% { box-shadow: 0 0 12px rgba(37,99,235,.5), 0 0 24px rgba(37,99,235,.25); }
    50% { box-shadow: 0 0 20px rgba(37,99,235,.7), 0 0 40px rgba(37,99,235,.4); }
  }

  /* ── Bottom-sheet overlay ── */
  .ei-sheet-overlay {
    position: fixed;
    inset: 0;
    z-index: 99990;
    background: rgba(0,0,0,.5);
    opacity: 0;
    transition: opacity .25s ease;
  }
  .ei-sheet-overlay.on { opacity: 1; }

  /* ── Bottom-sheet panel ── */
  .ei-sheet {
    position: fixed;
    left: 0; right: 0;
    bottom: 0;
    z-index: 99991;
    background: #fff;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,.15);
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.32,.72,0,1);
    max-height: 80vh;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .ei-sheet.on { transform: translateY(0); }
  .ei-sheet-handle {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: #d1d5db;
    margin: 10px auto 0;
  }
  .ei-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 8px;
  }
  .ei-sheet-head span {
    font-size: 16px;
    font-weight: 700;
    color: #0f2444;
  }
  .ei-sheet-close {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: #f3f4f6;
    border: none;
    font-size: 16px;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
  }
  .ei-sheet-body {
    padding: 0 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .ei-sheet-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-bottom: 1px solid #e5e7eb;
  }
  .ei-sheet-tabs button {
    padding: 11px 0;
    font-size: 14px;
    background: none;
    border: none;
    border-bottom: 2.5px solid transparent;
    cursor: pointer;
    font-family: inherit;
    font-weight: 400;
    color: #9ca3af;
  }
  .ei-sheet-tabs button.on {
    font-weight: 700;
  }

  /* Compliance banner: wrap text */
  #sec-cop [style*="white-space:nowrap"] {
    white-space: normal !important;
  }

  /* Key Persons grid: keep 2-col on mobile */
  #sec-cop [style*="grid-template-columns:1fr 1fr;gap:6px"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 4px 8px !important;
  }

  /* Financial Summary Metric table: horizontal scroll on mobile */
  #sec-cop .panel [style*="overflow-x:auto"][style*="border-radius:12px"][style*="border:1px solid #e8ecf2"] {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  #sec-cop .panel [style*="overflow-x:auto"][style*="border-radius:12px"][style*="border:1px solid #e8ecf2"] > table {
    min-width: 500px !important;
  }

  /* Operational Efficiency: 3-col → stack vertically */
  #cp-fund [style*="grid-template-columns:1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  /* Price chart header: simplify 3-col layout */
  #cp-ph [style*="grid-template-columns:1fr auto 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  /* Price chart stat row: 2×2 */
  #cp-ph [style*="repeat(4,1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* SVG charts: ensure they fit viewport */
  #cp-ph svg, #cp-fund svg, #idx-ca svg {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Shareholding Pattern: scrollable */
  #cp-sh-q, #cp-sh-y {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Valuation slider: full width */
  #cp-fund input[type="range"] {
    width: 100% !important;
  }

  /* IPO detail sidebar: full width on mobile */
  #sec-ipr [style*="width:280px"] {
    width: 100% !important;
    flex-shrink: 1 !important;
  }

  /* IPO key ratios: 2-col */
  #sec-ipr [style*="repeat(5,1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Financial Summary inner table: scrollable */
  #cp-fund [style*="overflow-x:auto"] {
    -webkit-overflow-scrolling: touch;
  }

  #cp-fund [style*="overflow-x:auto"] table {
    min-width: 420px;
  }
}

/* ── SMALL MOBILE (≤ 380px) ──────────────────────────────────────────── */
@media (max-width: 380px) {

  /* A25 boxes: 2×2 grid */
  .sb [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
  }

  .nb {
    padding: 7px 8px;
    font-size: 12px;
  }

  /* Portfolio stat row: 3+2 layout */
  #sec-port [style*="repeat(5,1fr)"] {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  #landing .steps {
    grid-template-columns: 1fr;
  }
}
