/* ============================================================================
   Ascend OS — shared responsive layer. Loaded AFTER each page's inline <style>
   so these win at mobile widths. Turns the fixed 220px-sidebar desktop layout
   into a phone-friendly one: sidebar → slide-in drawer, grids → single column,
   tables → horizontal scroll, controls wrap, bigger tap targets.
   ============================================================================ */
.mobile-hamburger { display: none; }
.mobile-backdrop  { display: none; }

@media (max-width: 860px) {
  /* ── Sidebar becomes an off-canvas drawer ── */
  .sb {
    position: fixed !important; top: 0; left: 0; bottom: 0; height: 100% !important;
    width: 268px !important; min-width: 268px !important;
    transform: translateX(-100%); transition: transform .28s cubic-bezier(.4,0,.2,1);
    z-index: 1000; box-shadow: 0 0 48px rgba(0,0,0,.55);
  }
  body.nav-open .sb { transform: translateX(0); }
  .mobile-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(6,3,1,.55);
    opacity: 0; pointer-events: none; transition: opacity .28s; z-index: 999;
  }
  body.nav-open .mobile-backdrop { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }

  /* ── Main fills the screen ── */
  .main { width: 100% !important; min-width: 0 !important; }

  /* ── Hamburger in the topbar ── */
  .mobile-hamburger {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; flex-shrink: 0; margin-right: 4px;
    border-radius: 9px; border: 1px solid rgba(255,122,46,.2);
    background: rgba(36,23,16,.6); color: #ff8a3d; cursor: pointer; padding: 0;
  }
  .topbar {
    height: auto !important; min-height: 56px;
    padding: 8px 12px !important; gap: 8px !important; flex-wrap: wrap;
  }
  /* keep the profile/right cluster from forcing overflow */
  .topbar-right { margin-left: auto; }

  /* ── Content padding down ── */
  .content { padding: 16px 13px 26px !important; }

  /* ── Multi-column grids stack ── */
  .kpi-strip, .cards-grid, .chart-row, .kpi-grid, .cards-3, .grid-2, .grid-3,
  .split, .two-col, .three-col { grid-template-columns: 1fr !important; }
  .perf-banner, .sb-hero-meta { grid-template-columns: 1fr !important; gap: 14px !important; }
  .stat-strip, .kpi-row { flex-wrap: wrap !important; }

  /* ── Wide tables scroll horizontally rather than overflowing the page ── */
  .tbl-wrap, .table-wrap, .chart-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { display: block; overflow-x: auto; white-space: nowrap; max-width: 100%; }

  /* ── Control bars / toggles wrap instead of clipping ── */
  .period-toggle, .bkc, .filterbar, .segment, .scope-toggle, .tabs, .tab-row,
  .toolbar, .actions { flex-wrap: wrap !important; }

  /* ── Charts don't force width ── */
  canvas { max-width: 100% !important; }

  /* ── Comfortable tap targets ── */
  .nav-item { padding: 12px 14px !important; }
  button, .btn { min-height: 38px; }
}

@media (max-width: 520px) {
  .content { padding: 14px 11px 24px !important; }
  .page-title { font-size: 13px !important; }
  /* hide decorative breadcrumb on the smallest screens to save the row */
  .breadcrumb { display: none !important; }
}
