/* ══════════════════════════════════════════════════════════════════════
   ADAPTIVE LAYOUT STYLESHEET  v3.0 — Compose Model
   ══════════════════════════════════════════════════════════════════════
   Complete rewrite: CSS-first responsive design using @media queries.
   No longer depends on JS data-attributes for layout.

   FIXES: FOUC — layout now applies instantly via media queries,
   no waiting for JavaScript DOMContentLoaded.

   SIZE CLASSES (Google Compose Window Size Classes):
     compact  → <600px  (phones portrait)
     medium   → 600–839px (tablets portrait, landscape phones)
     expanded → 840–1199px (tablets landscape)
     large+   → ≥1200px (desktop — default)

   LOAD ORDER:
     1. ds.css        (tokens + components)
     2. adaptive.css   (THIS FILE — responsive)
   ══════════════════════════════════════════════════════════════════════ */


/* ══════════════════════════════════════════════════════════════════════
   1. ADAPTIVE DESIGN TOKENS
   ══════════════════════════════════════════════════════════════════════ */
:root {
  --adaptive-nav-width: 240px;
  --adaptive-content-padding: 20px;
  --adaptive-content-gap: 16px;
  --adaptive-section-gap: 20px;
  --adaptive-grid-columns: 4;
  --adaptive-stat-columns: 4;
  --adaptive-form-columns: 3;
  --adaptive-feed-columns: 3;
  --adaptive-touch-target: 34px;
  --adaptive-modal-width: 520px;
  --adaptive-drawer-width: 480px;
  --adaptive-table-font: 13px;
  --adaptive-bottom-nav-height: 0px;
}

/* Medium: 600–839px */
@media (min-width: 600px) and (max-width: 839px) {
  :root {
    --adaptive-nav-width: 72px;
    --adaptive-content-padding: 16px;
    --adaptive-content-gap: 12px;
    --adaptive-grid-columns: 2;
    --adaptive-stat-columns: 3;
    --adaptive-form-columns: 2;
    --adaptive-touch-target: 44px;
    --adaptive-modal-width: 480px;
    --adaptive-drawer-width: 380px;
    --adaptive-bottom-nav-height: 0px;
  }
}

/* Compact: <600px */
@media (max-width: 599px) {
  :root {
    --adaptive-nav-width: 0px;
    --adaptive-content-padding: 12px;
    --adaptive-content-gap: 10px;
    --adaptive-section-gap: 14px;
    --adaptive-grid-columns: 1;
    --adaptive-stat-columns: 2;
    --adaptive-form-columns: 1;
    --adaptive-touch-target: 44px;
    --adaptive-modal-width: 100vw;
    --adaptive-drawer-width: 100vw;
    --adaptive-table-font: 12px;
    --adaptive-bottom-nav-height: 64px;
  }
}


/* ══════════════════════════════════════════════════════════════════════
   1b. VISIBILITY UTILITIES (all screen sizes)
   ══════════════════════════════════════════════════════════════════════ */
/* Hide on desktop by default — shown in compact block below */
@media (min-width: 600px) {
  .mobile-only  { display: none !important; }
  .compact-show { display: none !important; }
}


/* ══════════════════════════════════════════════════════════════════════
   2. BASE — Compact overrides (typography, touch targets, buttons)
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  /* ── Touch targets ── */
  .btn, button,
  a.btn, input[type="submit"], input[type="button"],
  .chip, .badge-btn { min-height: 36px; }

  .form-select, select { min-height: 34px; }

  .btn-sm { min-height: 32px; padding: 4px 12px; }

  /* ── Typography ── */
  .page-title, .t-headline-small { font-size: 18px; }
  .section-title-text, .t-title-medium { font-size: 14px; }

  /* ── Buttons ── */
  .btn { padding: 8px 16px; font-size: 13px; border-radius: 10px; }
  .btn-icon { width: 36px; height: 36px; }

  /* ── Form inputs ── */
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="password"],
  input[type="date"],
  input[type="search"],
  textarea,
  .form-input,
  .form-select,
  select {
    font-size: 16px;        /* prevents iOS auto-zoom */
    min-height: 36px;
    padding: 6px 10px;
    border-radius: 8px;
  }
  textarea { min-height: 80px; }

  /* ── Chips ── */
  .chip { font-size: 11px; padding: 4px 12px; min-height: 28px; border-radius: 16px; }

  /* ── Visibility utilities ── */
  .desktop-only { display: none !important; }
  .mobile-only  { display: flex !important; }
  .compact-hide { display: none !important; }
  .compact-show { display: flex !important; }

  /* ── Tables compact ── */
  table { font-size: 12px; }
  th, td { padding: 8px 10px; }
}


/* ══════════════════════════════════════════════════════════════════════
   3. TOPBAR — Adaptive header
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .gs-topbar,
  .topbar,
  header.topbar {
    height: 52px; padding: 0 12px; gap: 8px; position: sticky; top: 0; z-index: 200;
  }
  .topbar-title, .gs-topbar-title { font-size: 16px; font-weight: 700; }
  .topbar-sub, .gs-topbar-sub { display: none; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .btn { min-height: 36px; padding: 6px 12px; font-size: 12px; border-radius: 8px; }
  .topbar-actions .btn .btn-label { display: none; }
  .topbar-actions .btn .btn-icon-only { display: inline-flex; }
  .gs-topbar .back-btn, .topbar .back-btn { display: none; }
}

@media (min-width: 600px) and (max-width: 839px) {
  .gs-topbar,
  .topbar,
  header.topbar {
    padding: 0 16px; gap: 10px;
  }
  .topbar-actions .btn .btn-label { display: none; }
}


/* ══════════════════════════════════════════════════════════════════════
   4. HAMBURGER — Always hidden (bottom nav replaces it)
   ══════════════════════════════════════════════════════════════════════ */
#mobile-hamburger-btn { display: none !important; }


/* ══════════════════════════════════════════════════════════════════════
   4b. SIDEBAR COMPONENTS — Brand, nav, footer, user info
   Shared styles for sidebar (both page-defined and injected by mobile-nav.v4.js)
   ══════════════════════════════════════════════════════════════════════ */
.sidebar {
  width: 240px;
  position: fixed; top: 0; left: 0; bottom: 0;
  background: var(--md-sys-color-surface, #fff);
  display: flex; flex-direction: column; z-index: 100;
  border-right: 1px solid var(--md-sys-color-outline-variant, #e0e0e0);
}
.sidebar .brand {
  height: 52px; padding: 0 16px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant, #e0e0e0);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.sidebar .brand-icon {
  width: 36px; height: 36px;
  background: var(--md-sys-color-primary);
  border-radius: var(--r-md, 12px);
  display: flex; align-items: center; justify-content: center;
  color: var(--md-sys-color-on-primary, #fff); font-size: 15px; font-weight: 700;
  font-family: var(--font); flex-shrink: 0;
}
.sidebar .brand-name { font-size: 15px; font-weight: 600; color: var(--md-sys-color-on-surface, #1f1f1f); font-family: var(--font); }
.sidebar .brand-slug { font-size: 11px; color: var(--md-sys-color-outline, #888); font-family: var(--font); }

.sidebar nav { flex: 1; padding: 8px 12px; overflow-y: auto; }
.sidebar .nav-label {
  font-size: 11px; font-weight: 600; color: var(--md-sys-color-outline, #888);
  text-transform: uppercase; letter-spacing: .07em;
  padding: 16px 16px 8px;
}
.sidebar nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px; height: 40px;
  color: var(--md-sys-color-on-surface-variant, #444);
  font-size: 14px; font-weight: 500;
  border-radius: var(--r-pill, 20px);
  text-decoration: none; cursor: pointer;
  transition: all var(--t, 0.15s);
  font-family: var(--md-ref-typeface-brand, var(--font));
  margin-bottom: 2px;
}
.sidebar nav a:hover {
  color: var(--md-sys-color-on-surface, #1f1f1f);
  background: var(--md-sys-color-surface-container, #f3f3f3);
}
.sidebar nav a.active {
  color: var(--md-sys-color-on-primary-container, #1a73e8);
  background: var(--md-sys-color-primary-container, #d2e3fc);
  font-weight: 600;
}

.sidebar .sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--md-sys-color-outline-variant, #e0e0e0);
  flex-shrink: 0;
}
.sidebar .sidebar-footer .user-info strong {
  display: block; font-size: 13px;
  color: var(--md-sys-color-on-surface, #1f1f1f);
  font-family: var(--font);
}
.sidebar .sidebar-footer .user-info span {
  font-size: 11px;
  color: var(--md-sys-color-outline, #888);
  font-family: var(--font);
}
.sidebar .sidebar-footer .role-badge {
  display: inline-block; margin-top: 4px;
  background: var(--md-sys-color-primary-container, #d2e3fc);
  color: var(--md-sys-color-on-primary-container, #1a73e8);
  padding: 2px 8px; border-radius: var(--r-pill, 20px);
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; font-family: var(--font);
}
.sidebar .sidebar-footer .btn-logout {
  width: 100%; margin-top: 8px; height: 36px;
  background: transparent;
  border: 1px solid var(--md-sys-color-outline-variant, #e0e0e0);
  color: var(--md-sys-color-on-surface-variant, #444);
  border-radius: var(--r-pill, 20px);
  cursor: pointer; font-size: 12px; font-family: var(--font);
  transition: all var(--t, 0.15s);
}
.sidebar .sidebar-footer .btn-logout:hover {
  background: var(--md-sys-color-surface-container, #f3f3f3);
  color: var(--md-sys-color-on-surface, #1f1f1f);
}


/* ══════════════════════════════════════════════════════════════════════
   5. SIDEBAR — Slide-out navigation
   On compact/medium, sidebar is ALWAYS hidden off-screen by default.
   !important overrides inline page styles (tenant-admin, marketing, etc.)
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .sidebar, .gs-sidebar {
    position: fixed !important; top: 0 !important; left: 0 !important; bottom: 0 !important;
    width: 280px !important;
    z-index: 600 !important; background: #fff !important;
    transform: translateX(-100%) !important;
    transition: transform 0.28s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: none; overflow-y: auto; -webkit-overflow-scrolling: touch;
    display: flex; flex-direction: column;
    flex-shrink: 0;
  }
  .sidebar.open, .gs-sidebar.open {
    transform: translateX(0) !important;
    box-shadow: var(--md-sys-elevation-4, 0 4px 16px rgba(0,0,0,.18));
  }

  /* Sidebar brand */
  .sidebar .brand, .gs-sidebar .brand {
    padding: 16px; gap: 10px; border-bottom: 1px solid var(--md-sys-color-outline-variant, #e0e0e0);
  }
  .sidebar .brand-name, .gs-sidebar .brand-name { font-size: 16px; }

  /* Nav links inside sidebar */
  .sidebar nav a, .gs-sidebar nav a {
    padding: 12px 16px; font-size: 14px; min-height: 48px;
    display: flex; align-items: center; gap: 12px; border-radius: 0;
    transition: background 0.15s ease;
  }
  .sidebar nav a:active, .gs-sidebar nav a:active { background: rgba(0,0,0,.06); }
  .sidebar nav a.active, .gs-sidebar nav a.active { background: var(--md-sys-color-secondary-container, #e8f0fe); font-weight: 700; }
  .sidebar .nav-label, .gs-sidebar .nav-label {
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.5px; padding: 16px 16px 6px; color: #888;
  }

  /* Sidebar overlay */
  .adaptive-sidebar-overlay {
    position: fixed; inset: 0; z-index: 599;
    background: rgba(0,0,0,0.4);
    opacity: 0; pointer-events: none;
    transition: opacity 0.28s cubic-bezier(0.4, 0.0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
  }
  .adaptive-sidebar-overlay.open {
    opacity: 1; pointer-events: auto;
  }

  /* Sidebar footer */
  .sidebar .sidebar-footer, .gs-sidebar .sidebar-footer {
    margin-top: auto; padding: 16px; border-top: 1px solid var(--md-sys-color-outline-variant, #e0e0e0);
  }
}

/* Medium: sidebar hidden but openable */
@media (min-width: 600px) and (max-width: 839px) {
  .sidebar, .gs-sidebar {
    position: fixed !important; top: 0 !important; left: 0 !important; bottom: 0 !important;
    width: 280px !important;
    z-index: 600 !important; background: #fff !important;
    transform: translateX(-100%) !important;
    transition: transform 0.28s cubic-bezier(0.4, 0.0, 0.2, 1);
    overflow-y: auto; display: flex; flex-direction: column;
    flex-shrink: 0;
  }
  .sidebar.open, .gs-sidebar.open {
    transform: translateX(0) !important;
    box-shadow: var(--md-sys-elevation-4, 0 4px 16px rgba(0,0,0,.18));
  }
  .adaptive-sidebar-overlay {
    position: fixed; inset: 0; z-index: 599;
    background: rgba(0,0,0,0.4);
    opacity: 0; pointer-events: none;
    transition: opacity 0.28s ease;
  }
  .adaptive-sidebar-overlay.open { opacity: 1; pointer-events: auto; }
}

/* Desktop: sidebar overlay should never appear (sidebar is always visible) */
@media (min-width: 840px) {
  .adaptive-sidebar-overlay { display: none !important; }
}


/* ══════════════════════════════════════════════════════════════════════
   6. BOTTOM NAVIGATION BAR — Material 3 (compact only)
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .adaptive-bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 300;
    background: var(--md-sys-color-surface, #fff);
    border-top: 1px solid var(--md-sys-color-outline-variant, #e0e0e0);
    min-height: 48px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .adaptive-bottom-nav-items {
    display: flex; justify-content: space-around; align-items: stretch;
    padding: 6px 4px;
    padding-bottom: max(6px, env(safe-area-inset-bottom, 0px));
    max-width: 600px; margin: 0 auto;
  }
  .adaptive-bottom-nav-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    flex: 1; min-width: 48px; max-width: 88px; height: 48px;
    gap: 2px; text-decoration: none; color: var(--md-sys-color-on-surface-variant, #666);
    background: transparent; border: none; cursor: pointer;
    padding: 0 6px; border-radius: 0;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.2s ease;
  }
  .adaptive-bottom-nav-item.active { color: var(--md-sys-color-primary, #1976d2); }
  .adaptive-bottom-nav-item .nav-icon {
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 8px; font-size: 20px;
    transition: background-color 0.2s ease, transform 0.15s ease;
    flex-shrink: 0;
  }
  .adaptive-bottom-nav-item.active .nav-icon {
    background: var(--md-sys-color-secondary-container, #e8f0fe);
  }
  .adaptive-bottom-nav-item .nav-label { display: none; }
}

/* Hide bottom nav on medium+ */
@media (min-width: 600px) {
  .adaptive-bottom-nav { display: none; }
}


/* ══════════════════════════════════════════════════════════════════════
   7. NAVIGATION RAIL — Medium (600–839px)
   ══════════════════════════════════════════════════════════════════════ */
@media (min-width: 600px) and (max-width: 839px) {
  .adaptive-nav-rail {
    position: fixed; top: 0; left: 0; bottom: 0; width: 72px;
    z-index: 100; background: var(--md-sys-color-surface, #fff);
    border-right: 1px solid var(--md-sys-color-outline-variant, #e0e0e0);
    display: flex; flex-direction: column; align-items: center;
    padding: 12px 0; gap: 4px; overflow-y: auto;
  }
  .adaptive-nav-rail-brand { padding: 12px 0 16px; }
  .adaptive-nav-rail-brand img { width: 28px; height: 28px; display: block; }
  .adaptive-nav-rail-items { display: flex; flex-direction: column; gap: 2px; flex: 1; width: 100%; }
  .adaptive-nav-rail-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; padding: 8px 0; text-decoration: none;
    color: var(--md-sys-color-on-surface-variant, #666);
    transition: color 0.15s ease;
  }
  .adaptive-nav-rail-item.active { color: var(--md-sys-color-primary, #1976d2); }
  .adaptive-nav-rail-item .nav-icon {
    display: flex; align-items: center; justify-content: center;
    width: 48px; height: 32px; border-radius: 16px; font-size: 22px;
    transition: background 0.2s ease;
  }
  .adaptive-nav-rail-item.active .nav-icon { background: var(--md-sys-color-secondary-container, #e8f0fe); }
  .adaptive-nav-rail-item .nav-label { font-size: 11px; font-weight: 600; line-height: 1; }
}

/* Hide rail outside medium range */
@media (max-width: 599px) {
  .adaptive-nav-rail { display: none; }
}
@media (min-width: 840px) {
  .adaptive-nav-rail { display: none; }
}


/* ══════════════════════════════════════════════════════════════════════
   8. MAIN CONTENT AREA — Responsive margins
   ══════════════════════════════════════════════════════════════════════ */

/*
   Desktop/medium body offset for pages where mobile-nav.v4.js
   INJECTS a sidebar (pages that don't have one in their HTML).
   The JS adds `.nav-injected` to <body> so CSS can shift content.
   Pages that already have a sidebar + margin-left in their own
   styles (tenant-admin, platform-admin, marketing, etc.) are
   NOT affected — ensureSidebar() skips them.
*/

/* --- Desktop (≥840px): fixed sidebar is 240px --- */
@media (min-width: 840px) {
  body.nav-injected { padding-left: 240px; }
}

/* --- Medium (600–839px): nav rail is 72px --- */
@media (min-width: 600px) and (max-width: 839px) {
  body.nav-injected { padding-left: 72px; }
  /* Override inline margin-left from pages with built-in sidebars */
  .main, .gs-main, .main-panel, .page-content, .page-body {
    margin-left: 0 !important;
    width: 100% !important;
  }
  body {
    display: block !important;
    overflow: auto !important;
    height: auto !important;
  }
}

/* --- Compact (<600px): no offset, extra bottom padding for bottom nav --- */
@media (max-width: 599px) {
  /* Override body flex layout from tenant-admin, platform-admin, marketing
     so sidebar + main don't sit side-by-side on mobile */
  body {
    display: block !important;
    overflow: auto !important;
    height: auto !important;
    min-height: 100vh;
  }
  /* Reset margin-left from .main on ALL pages — !important overrides inline styles */
  .main, .gs-main, .main-panel, .page-content, .page-body {
    margin-left: 0 !important;
    width: 100% !important;
    min-width: 0;
    padding-bottom: calc(var(--adaptive-content-padding) + var(--adaptive-bottom-nav-height));
  }
}


/* ══════════════════════════════════════════════════════════════════════
   9. STAT CARDS / SUMMARY STRIPS
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .stat-strip, .sum-strip, .stats-strip, .stat-grid, .rp .stat-strip {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  }
  .stat-card, .sum-card, .stat-box, .rp .stat-card {
    padding: 10px 12px; border-radius: 10px;
  }
  .stat-card-val, .stat-val, .sum-card-val, .rp .stat-card-val { font-size: 22px; }
  .stat-card-lbl, .stat-lbl, .sum-card-lbl { font-size: 10px; text-transform: uppercase; }
  .stat-card-sub, .stat-sub, .sum-card-sub { font-size: 10px; }
}

@media (min-width: 600px) and (max-width: 839px) {
  .stat-strip, .sum-strip, .stats-strip, .stat-grid, .rp .stat-strip {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  }
  .stat-card, .sum-card, .stat-box, .rp .stat-card { padding: 12px; }
}


/* ══════════════════════════════════════════════════════════════════════
   10. TOOLBAR & FILTERS
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .toolbar, .gs-toolbar, .rp .toolbar, .list-toolbar {
    flex-direction: row; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 12px;
  }
  .filter-row, .filter-bar, .gs-filter-bar {
    overflow-x: auto; display: flex; gap: 6px; padding-bottom: 4px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .filter-row::-webkit-scrollbar, .filter-bar::-webkit-scrollbar, .gs-filter-bar::-webkit-scrollbar { display: none; }
  .filter-row .chip, .filter-bar .chip, .pill-filter {
    flex-shrink: 0; white-space: nowrap; font-size: 12px; padding: 6px 14px;
    border-radius: 20px; min-height: 36px;
  }
  .toolbar select, .toolbar input, .toolbar .form-input, .toolbar .form-select,
  .gs-toolbar select, .gs-toolbar input {
    height: 34px !important; font-size: 12px !important; border-radius: 8px;
    min-height: 34px !important; padding: 4px 8px !important;
  }
  .toolbar .btn, .gs-toolbar .btn { height: 34px; font-size: 12px; padding: 4px 12px; }
  .search-input, .toolbar input[type="search"], .gs-toolbar input[type="search"] {
    width: 100%; min-width: 0;
  }
  .toolbar .spacer { display: none; }
  .toolbar label { font-size: 11px !important; padding: 4px 8px !important; min-height: 34px !important; }
}

@media (min-width: 600px) and (max-width: 839px) {
  .toolbar, .gs-toolbar { flex-wrap: wrap; gap: 8px; }
}


/* ══════════════════════════════════════════════════════════════════════
   11. DATA TABLES
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .table-wrap, .table-responsive, .gs-table-wrap, .rp .table-wrap {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    margin: 0 -12px; padding: 0 12px;
  }
  .table-wrap table, .gs-table-wrap table, .rp .table-wrap table { min-width: 600px; }
  table, .data-table { font-size: 12px; }
  th { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap; }
  th, td { padding: 8px 10px; }
  td .btn-sm, td .btn-icon { min-height: 30px; padding: 4px 8px; }
  thead th { position: sticky; top: 0; z-index: 2; background: var(--md-sys-color-surface, #fff); }
}


/* ══════════════════════════════════════════════════════════════════════
   12. PANELS & CARDS
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .card, .panel, .rp,
  .gs-card, .gs-panel {
    border-radius: 12px; padding: 12px; margin-bottom: 10px;
    box-shadow: none; border: 1px solid var(--md-sys-color-outline-variant, #e8e8e8);
  }
  .card-header, .panel-header { padding: 10px 12px; }
  .card-header-title, .panel-title { font-size: 14px; font-weight: 700; }
  .card-body, .panel-body { padding: 10px 12px; }
  .card:hover, .panel:hover { transform: none; box-shadow: none; }
}


/* ══════════════════════════════════════════════════════════════════════
   13. DRAWERS — Full-screen on compact, modal on medium
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .drawer, .gs-drawer, .detail-drawer, .slide-panel, .rp .drawer {
    position: fixed; inset: 0; width: 100% !important; max-width: 100% !important;
    height: 100%; z-index: 500; border-radius: 0;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
  }
  .drawer-head, .gs-drawer-head, .detail-drawer-head, .slide-panel-head {
    position: sticky; top: 0; z-index: 10; background: #fff;
    padding: 14px 16px; border-bottom: 1px solid #f0f0f0;
  }
  .drawer-overlay, .gs-drawer-overlay, .rp .drawer-overlay {
    position: fixed; inset: 0; z-index: 499;
    background: rgba(0,0,0,.4);
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .drawer-overlay.show, .drawer-overlay.open,
  .gs-drawer-overlay.show, .gs-drawer-overlay.open,
  .rp .drawer-overlay.show { opacity: 1; pointer-events: auto; }
}

@media (min-width: 600px) and (max-width: 839px) {
  .drawer, .gs-drawer, .detail-drawer, .slide-panel { max-width: var(--adaptive-drawer-width); }
}


/* ══════════════════════════════════════════════════════════════════════
   14. MODALS — Bottom sheet on compact
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .modal-wrap, .modal-overlay, .gs-modal, .modal-backdrop {
    align-items: flex-end;
  }
  .modal, .modal-box, .mbox, .gs-dialog {
    width: 100%; max-width: 100%;
    border-radius: 16px 16px 0 0; margin: 0;
    max-height: 92vh; max-height: 92dvh;
    padding: 20px 16px; overflow-y: auto;
  }
}


/* ══════════════════════════════════════════════════════════════════════
   15. SEARCH
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .search-box, .search-wrapper, .gs-search-box {
    width: 100%; max-width: 100%;
  }
}


/* ══════════════════════════════════════════════════════════════════════
   16. TABS — Horizontal scroll on compact
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .tabs, .tab-bar, .gs-tabs {
    overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .tabs::-webkit-scrollbar, .tab-bar::-webkit-scrollbar, .gs-tabs::-webkit-scrollbar { display: none; }
  .tab, .tab-btn, .gs-tab { white-space: nowrap; flex-shrink: 0; }
}


/* ══════════════════════════════════════════════════════════════════════
   17. GRID UTILITIES — Collapse on compact
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .form-grid, .field-grid, .gs-form-grid { grid-template-columns: 1fr; gap: 10px; }
  .two-col, .three-col, .four-col { grid-template-columns: 1fr; }
}


/* ══════════════════════════════════════════════════════════════════════
   18. TOAST / SNACKBAR — Above bottom nav
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .toast, .snackbar, #toast, #snackbar, .gs-toast {
    bottom: calc(var(--adaptive-bottom-nav-height, 64px) + 12px);
    left: 12px; right: 12px; max-width: none; border-radius: 12px;
  }
}


/* ══════════════════════════════════════════════════════════════════════
   19. FAB — Above bottom nav
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .fab, .gs-fab, .adaptive-fab {
    bottom: calc(var(--adaptive-bottom-nav-height, 64px) + 16px);
    right: 16px;
  }
}


/* ══════════════════════════════════════════════════════════════════════
   20. PAGINATION
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .pagination, #pagination, .pager {
    padding: 12px 0; gap: 4px; flex-wrap: wrap; justify-content: center;
    font-size: 12px;
  }
  .pagination .btn, .pager .btn { min-height: 36px; min-width: 36px; padding: 0 8px; }
}


/* ══════════════════════════════════════════════════════════════════════
   21. SCROLL & BODY LOCK
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  body.sidebar-open { overflow: hidden; position: fixed; width: 100%; }
  body.drawer-open  { overflow: hidden; }
}


/* ══════════════════════════════════════════════════════════════════════
   22. COMPACT SPACING & TYPOGRAPHY ADJUSTMENTS
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .page-header { padding: 10px 12px; gap: 8px; }
  .section-gap, .gs-section-gap { margin-bottom: var(--adaptive-section-gap); }
  .empty-state { padding: 40px 20px; }
  .empty-state .empty-icon { font-size: 48px; }
  .empty-state .empty-text { font-size: 14px; }
}


/* ══════════════════════════════════════════════════════════════════════
   PAGE-SPECIFIC: LEADS
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .lead-detail, .ld-panel, .lead-detail-panel {
    position: fixed; inset: 0; z-index: 300; overflow-y: auto; width: 100% !important;
    background: #fff;
  }
  .lead-detail-head, .ld-head { padding: 10px 12px; position: sticky; top: 0; z-index: 10; background: #fff; }
  .ld-name, .lead-detail-name { font-size: 18px; }
  .ld-field label, .lead-detail-field label { font-size: 10px; }
  .ld-field .val, .lead-detail-field .val { font-size: 13px; }
  .ld-tabs, .lead-detail-tabs {
    overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none;
    border-bottom: 2px solid #f0f0f0; position: sticky; top: 52px; z-index: 9; background: #fff;
  }
  .ld-tabs::-webkit-scrollbar, .lead-detail-tabs::-webkit-scrollbar { display: none; }
  .ld-tab, .lead-detail-tab { white-space: nowrap; flex-shrink: 0; padding: 10px 14px; font-size: 12px; font-weight: 600; }

  /* MTO drawer */
  .mto-drawer { width: 100% !important; }
  .mto-panel { padding: 12px; }
  .mto-line { font-size: 12px; padding: 10px 0; }
  .mto-line .sku { font-size: 11px; }

  /* Quick actions */
  .qa-bar, .quick-actions { overflow-x: auto; gap: 6px; scrollbar-width: none; padding: 0 2px 4px; }
  .qa-bar::-webkit-scrollbar, .quick-actions::-webkit-scrollbar { display: none; }
  .qa-btn, .quick-action-btn { min-width: 0; flex-shrink: 0; font-size: 11px; padding: 6px 10px; white-space: nowrap; }

  /* Leads stat strips */
  .lead-stat-strip { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .lead-stat-card { padding: 8px 10px; border-radius: 8px; }
  .lead-stat-val { font-size: 20px; }
  .lead-stat-lbl { font-size: 9px; }
}


/* ══════════════════════════════════════════════════════════════════════
   PAGE-SPECIFIC: ORDERS
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .order-layout { flex-direction: column; }
  .order-sidebar, .order-filters-panel { width: 100%; border-right: none; }
  .order-controls { flex-wrap: wrap; gap: 6px; }
  .order-controls select, .order-controls input { width: 100%; }
  .order-tabs {
    overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none;
    gap: 0; padding: 0;
  }
  .order-tabs::-webkit-scrollbar { display: none; }
  .order-tab { white-space: nowrap; flex-shrink: 0; padding: 10px 14px; font-size: 12px; }

  /* Order detail drawer */
  .order-drawer, .order-detail { position: fixed; inset: 0; z-index: 500; width: 100% !important; }
  .order-drawer-head { padding: 12px 16px; position: sticky; top: 0; background: #fff; z-index: 10; }

  /* Order items grid */
  .item-grid { grid-template-columns: 1fr; gap: 6px; }
  .item-card { padding: 10px 12px; border-radius: 10px; }
  .item-name { font-size: 13px; font-weight: 600; }
  .item-sku { font-size: 10px; color: #888; }
  .item-price { font-size: 14px; }
  .item-qty { font-size: 12px; }
  .item-total { font-size: 13px; font-weight: 700; }

  /* Create Order (MTO) form */
  .pay-method-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .pay-btn { padding: 10px 6px; font-size: 12px; border-radius: 10px; }
  .ship-service-bar { flex-wrap: wrap; }
  .ship-btn { min-width: 0; flex: 1; font-size: 11px; padding: 8px 6px; border-radius: 10px; }
  .intent-bar { gap: 6px; }
  .intent-btn { padding: 10px 8px; font-size: 12px; border-radius: 10px; }
  .intent-btn kbd { display: none; }
  .submit-area { padding: 12px 16px; position: sticky; bottom: 0; z-index: 50; background: #fff; }
  .submit-btn { height: 48px; border-radius: 12px; font-size: 15px; font-weight: 700; }
  .kbd-hint { display: none; }
  .advance-cod-panel { padding: 10px 12px; border-radius: 10px; }
  .advance-cod-row { flex-wrap: wrap; gap: 6px; font-size: 12px; }
  .cod-delivery-badge { margin-left: 0; font-size: 11px; }
  .section-title { font-size: 11px; margin: 14px 0 8px; }
  .parse-box { padding: 10px 12px; border-radius: 10px; }
  .phone-match { font-size: 12px; padding: 8px 10px; border-radius: 8px; }
  .nc-reason { border-radius: 10px; padding: 10px 12px; }
  #bulkActionBar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
}


/* ══════════════════════════════════════════════════════════════════════
   PAGE-SPECIFIC: CUSTOMERS
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .cust-avatar { width: 32px; height: 32px; font-size: 12px; }
  .cust-name { font-size: 13px; }
  .cust-code { font-size: 9px; }
  #detailView { position: fixed; inset: 0; overflow-y: auto; z-index: 150; }
  .detail-topbar { padding: 8px 12px; height: 52px; gap: 8px; flex-wrap: nowrap; }
  .detail-topbar h2 { font-size: 15px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .detail-topbar-actions { display: flex; gap: 4px; flex-shrink: 0; flex-wrap: wrap; }
  .detail-action-btn { padding: 6px 10px; font-size: 11px; border-radius: 8px; }
  .detail-hero { padding: 20px 16px; gap: 12px; flex-direction: column; align-items: center; text-align: center; }
  .hero-avatar { width: 56px; height: 56px; font-size: 22px; }
  .hero-name { font-size: 20px; }
  .hero-code { font-size: 11px; }
  .hero-badges { justify-content: center; gap: 6px; flex-wrap: wrap; }
  .hero-metrics { width: 100%; margin-left: 0; flex-wrap: wrap; justify-content: space-around; gap: 8px; }
  .hero-metric { flex: 1; padding: 0 8px; border-right: none; }
  .hm-val { font-size: 18px; }
  .eng-strip { grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px; }
  .eng-card { padding: 10px; }
  .eng-card .ev { font-size: 16px; }
  .eng-card .el { font-size: 9px; }
  .info-grid { grid-template-columns: 1fr; gap: 8px; padding: 12px; }
  .info-card { padding: 12px; }
  .bulk-bar { padding: 8px 12px; flex-wrap: wrap; gap: 6px; height: auto; }
}


/* ══════════════════════════════════════════════════════════════════════
   PAGE-SPECIFIC: WHATSAPP
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .wa-layout { flex-direction: column; height: auto; overflow: visible; }
  .wa-sidebar {
    width: 100%; flex-direction: row; overflow-x: auto; overflow-y: hidden;
    height: auto; border-right: none; border-bottom: 1px solid #eee; flex-shrink: 0;
    scrollbar-width: none; padding: 0; position: sticky; top: 52px; z-index: 50; background: #fff;
  }
  .wa-sidebar::-webkit-scrollbar { display: none; }
  .wa-nav-section { display: none; }
  .wa-nav-item {
    flex-shrink: 0; white-space: nowrap; height: 44px; padding: 0 14px; border-radius: 0;
    font-size: 12px; font-weight: 500; display: flex; align-items: center; gap: 5px;
    border-bottom: 2px solid transparent; border-left: none;
  }
  .wa-nav-item.active { border-bottom-color: var(--md-sys-color-primary); background: #e8f0fe; border-left: none; }
  .wa-nav-badge { font-size: 9px; padding: 1px 6px; }
  .wa-main { flex: 1; overflow-y: auto; padding: 12px; }
  .wa-section { padding: 0; }
  #sec-inbox { height: calc(100vh - 52px - 44px); height: calc(100dvh - 52px - 44px); }
  .tpl-grid { grid-template-columns: 1fr; gap: 10px; }
  .send-panel { grid-template-columns: 1fr; gap: 16px; }
  .lm-inbox-body { flex-direction: column; }
  .lm-inbox-body #lm-sidebar { position: relative; width: 100%; border-right: none; border-bottom: 1px solid #eee; max-height: 50vh; }
  .lm-inbox-body #lm-chat { width: 100%; flex: 1; }
}

@media (min-width: 600px) and (max-width: 839px) {
  .wa-sidebar { width: 200px; }
}


/* ══════════════════════════════════════════════════════════════════════
   PAGE-SPECIFIC: LEAD-MESSAGES / INBOX
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  #lm-root { height: 100dvh; height: 100vh; }
  #lm-topbar { padding: 8px 12px; gap: 8px; }
  #lm-topbar h1 { font-size: 15px; }
  #lm-body { flex-direction: column; position: relative; }
  #lm-sidebar {
    width: 100%; position: fixed; inset: 0; z-index: 200;
    display: none; flex-direction: column; background: #fff;
  }
  #lm-sidebar.mobile-show,
  #lm-sidebar.show { display: flex; }
  #lm-chat { width: 100%; flex: 1; }
  #lm-chat-hdr #lm-mobile-back { display: flex; }
  .lm-topbar-back { display: inline-flex; }
  .lm-inbox-body { flex-direction: column; }
  .lm-inbox-body #lm-sidebar {
    position: fixed; inset: 0; z-index: 200; width: 100%; display: none;
  }
  .lm-inbox-body #lm-sidebar.mobile-show { display: flex; }
  .lm-inbox-body #lm-chat { width: 100%; }
  #lm-bubbles { display: none; }
  #lm-msgs { flex: 1; }
  .lm-msg { max-width: 88%; }
  .lm-conv-item { padding: 12px 14px; gap: 10px; }
  .lm-conv-name { max-width: 180px; font-size: 14px; }
  #lm-compose { padding: 8px 10px; }
  #lm-compose textarea { min-height: 40px; font-size: 14px; }
  #lm-mode-bar { padding: 6px 12px; gap: 4px; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  #lm-mode-bar::-webkit-scrollbar { display: none; }
  .lm-mode-btn { font-size: 11px; padding: 4px 10px; flex-shrink: 0; }
  #lm-tabs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  #lm-tabs::-webkit-scrollbar { display: none; }
}

@media (min-width: 600px) and (max-width: 839px) {
  .inbox-list { width: 280px; }
}


/* ══════════════════════════════════════════════════════════════════════
   PAGE-SPECIFIC: GST
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .gst-layout { flex-direction: column; height: auto; overflow: visible; }
  .gst-sidebar {
    width: 100%; border-right: none; border-bottom: 1px solid #eee;
    flex-direction: column; overflow: visible; height: auto; padding: 12px; gap: 10px; flex-shrink: 0;
  }
  .gst-main { padding: 12px; gap: 12px; }
  .month-chips { gap: 4px; }
  .mchip { padding: 6px 10px; font-size: 11px; }
  .toggle-chips { gap: 4px; }
  .tchip { padding: 8px 6px; font-size: 11px; }
  .tab-bar { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; gap: 0; }
  .tab-bar::-webkit-scrollbar { display: none; }
  .tab-btn { padding: 10px 14px; font-size: 12px; white-space: nowrap; flex-shrink: 0; }
  .gst-panel { border-radius: 12px; border: 1px solid #f0f0f0; }
  .tax-totals-box { padding: 12px 14px; margin: 12px; }
  .ttrow { font-size: 12px; padding: 5px 0; }
  .ttrow.grand { font-size: 14px; }
  .profile-box { padding: 10px 12px; border-radius: 10px; }
  .sb-field input,
  .sb-field select { height: 40px; font-size: 13px; border-radius: 8px; }
  .gen-btn { height: 44px; border-radius: 12px; font-size: 14px; }
  .reset-btn { height: 38px; border-radius: 10px; }
}

@media (min-width: 600px) and (max-width: 839px) {
  .gst-sidebar { width: 240px; }
}


/* ══════════════════════════════════════════════════════════════════════
   PAGE-SPECIFIC: MARKETING
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .pg-tabs {
    overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none;
    gap: 0; margin-bottom: 12px; border-bottom: 1px solid #f0f0f0;
    margin: 0 -12px 12px -12px; padding: 0 12px;
  }
  .pg-tabs::-webkit-scrollbar { display: none; }
  .pg-tab {
    padding: 10px 16px; font-size: 13px; font-weight: 600; white-space: nowrap;
    flex-shrink: 0; border-radius: 0; border-bottom: 3px solid transparent; margin-bottom: -1px;
  }
  .pg-tab.active { border-bottom-color: var(--md-sys-color-primary, #1976d2); }

  .stats-strip {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px;
  }
  .stat-sub { display: none; }

  .aud-sub-tabs {
    overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none;
    border-bottom: 2px solid #f0f0f0; margin-bottom: 12px;
  }
  .aud-sub-tabs::-webkit-scrollbar { display: none; }
  .aud-sub-tab { padding: 10px 16px; font-size: 12px; font-weight: 600; white-space: nowrap; flex-shrink: 0; }

  .aud-layout { flex-direction: column; gap: 12px; align-items: flex-start; }
  .aud-filters {
    width: 100%; position: static; padding: 12px 14px; background: #fafafa;
    border: 1px solid #f0f0f0; border-radius: 10px; margin-bottom: 0; max-height: none;
  }
  .aud-filters h4 { font-size: 12px; font-weight: 700; margin-bottom: 12px; }
  .filter-section { margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid #e0e0e0; }
  .filter-section:last-child { border-bottom: none; padding-bottom: 0; }
  .filter-label { font-size: 10px; font-weight: 700; text-transform: uppercase; color: #666; margin-bottom: 6px; }
  .filter-chips { display: flex; flex-wrap: wrap; gap: 5px; }
  .fchip { padding: 5px 10px; font-size: 11px; font-weight: 600; border-radius: 16px; flex-shrink: 0; }
  .aud-filters .form-input,
  .aud-filters .form-select { height: 36px; padding: 0 10px; font-size: 12px; border-radius: 8px; width: 100%; }
  .aud-filters .btn { height: 36px; width: 100%; font-size: 12px; }
  .aud-right { width: 100%; }
  .aud-right > div:first-child { flex-direction: column; gap: 8px; margin-bottom: 10px; }
  .aud-right > div:first-child .form-input { width: 100%; height: 36px; font-size: 13px; }
  .action-bar { flex-wrap: wrap; gap: 6px; padding: 8px 12px; background: rgba(25,118,210,.08); border-radius: 10px; margin-bottom: 12px; }
  .sel-count { font-size: 12px; }
  .action-bar .btn { min-height: 32px; padding: 0 10px; font-size: 11px; }
  .lbl-board { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; }
  .lbl-board-card { padding: 12px 14px; min-width: 0; border-radius: 10px; cursor: pointer; }
  .lbl-card-name { font-size: 12px; font-weight: 700; }
  .lbl-card-count { font-size: 20px; font-weight: 800; margin: 4px 0 0; }
  .lbl-card-sub { font-size: 10px; }
  #lblModal { align-items: flex-end; justify-content: center; }
  #lblModal .lbl-box { width: 100%; max-width: 100%; border-radius: 16px 16px 0 0; max-height: 85vh; padding: 20px 16px; }
  .lbl-tag-row { gap: 6px; min-height: 28px; }
  .lbl-edit-chip { padding: 4px 10px; font-size: 11px; }
  .mbk { align-items: flex-end; }
  .modal-ov { align-items: flex-end; }
  .modal-ov .modal-box { width: 100%; max-width: 100%; border-radius: 16px 16px 0 0; max-height: 88vh; padding: 20px 16px; }
  .modal-head h3 { font-size: 16px; }
  .modal-foot { flex-wrap: wrap; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-card { margin-bottom: 12px; }
  .settings-card-head { padding: 12px 14px; }
  .settings-card-body { padding: 12px 14px; }
  .field-row { grid-template-columns: 1fr; }
  .provider-radio-group { flex-direction: column; gap: 10px; }
  .provider-radio { flex: 0; width: 100%; padding: 10px 12px; }
  .webhook-url-text { font-size: 10px; padding: 6px 8px; }
  .rule-table { font-size: 11px; }
  .rule-table th { padding: 6px 8px; font-size: 9px; }
  .rule-table td { padding: 6px 8px; }
  .chat-ov { background: rgba(0,0,0,.4); }
  .chat-drawer {
    width: 100%; max-width: 100%; height: 88vh; height: 88dvh;
    border-radius: 16px 16px 0 0; border-left: none; border-top: 1px solid #f0f0f0;
    right: 0; bottom: 0; top: auto;
  }
  .chat-drawer.open { transform: translateY(0); }
  .chat-head { padding: 12px 16px; }
  .chat-head-name { font-size: 14px; }
  .chat-head-phone { font-size: 11px; }
  .chat-messages { padding: 12px 16px; }
  .cbub { max-width: 84%; padding: 8px 12px; font-size: 12px; }
  .ctm { font-size: 9px; }
  .chat-input-wrap { padding: 10px 12px; gap: 6px; }
  .chat-input-wrap .form-input { height: 36px; font-size: 13px; }
  .camp-row { padding: 10px 12px; gap: 10px; }
  .camp-icon { width: 32px; height: 32px; font-size: 15px; }
  .camp-meta { flex: 1; min-width: 0; }
  .camp-name { font-size: 13px; }
  .camp-sub { font-size: 11px; }
  .camp-stat { font-size: 11px; }
}

@media (min-width: 600px) and (max-width: 839px) {
  .mkt-sidebar,
  .marketing-sidebar { width: 220px; }
}


/* ══════════════════════════════════════════════════════════════════════
   PAGE-SPECIFIC: PROFIT & LOSS
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .charts-grid { grid-template-columns: 1fr; gap: 10px; }
  .chart-panel { padding: 12px; }
  canvas { max-height: 200px; }
  .stat-strip { flex-direction: row; flex-wrap: wrap; }
  .panel .toolbar {
    flex-direction: column; align-items: stretch; gap: 10px; overflow-x: visible; flex-wrap: wrap;
  }
  .panel .toolbar > div { flex-wrap: wrap; gap: 8px; width: 100%; }
  .panel .toolbar select,
  .panel .toolbar input[type="date"],
  .panel .toolbar input[type="text"] { width: 100%; max-width: none; flex: 1; }

  .pl-layout { flex-direction: column; }
  .pl-sidebar { width: 100%; border-right: none; }
}


/* ══════════════════════════════════════════════════════════════════════
   PAGE-SPECIFIC: INVOICES
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .inv-topbar-back { display: none; }
  .inv-topbar { padding: 0 12px; }
  .inv-topbar-title { font-size: 14px; }
}


/* ══════════════════════════════════════════════════════════════════════
   PAGE-SPECIFIC: LOGIN
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .login-card,
  .auth-card {
    margin: 20px 16px; padding: 24px 20px; width: auto; max-width: 100%; border-radius: 16px;
  }
  .login-card h1 { font-size: 18px; }
  .login-subtitle { font-size: 13px; margin-bottom: 20px; }
  .login-logo-name { font-size: 16px; }
}


/* ══════════════════════════════════════════════════════════════════════
   PAGE-SPECIFIC: PRODUCTS
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .cat-tabs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; margin-bottom: 10px; gap: 4px; padding-bottom: 8px; }
  .cat-tabs::-webkit-scrollbar { display: none; }
  .cat-tab { flex-shrink: 0; padding: 5px 12px; font-size: 11px; white-space: nowrap; }
  .gst-preview { flex-direction: column; gap: 4px; padding: 8px 10px; font-size: 11px; }
  .stock-current .sv { font-size: 28px; }
  #pagination { padding: 12px 0; gap: 4px; flex-wrap: wrap; justify-content: center; }
}


/* ══════════════════════════════════════════════════════════════════════
   PAGE-SPECIFIC: VENDORS
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .page-tabs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; padding: 0 12px; gap: 0; }
  .page-tabs::-webkit-scrollbar { display: none; }
  .page-tab { padding: 10px 14px; font-size: 12px; white-space: nowrap; flex-shrink: 0; }
  .drawer-tabs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .drawer-tabs::-webkit-scrollbar { display: none; }
  .drawer-tab { padding: 10px 8px; font-size: 11px; white-space: nowrap; flex-shrink: 0; }
  .drawer-panel { padding: 14px 16px; }
  .drawer-head { padding: 14px 16px; }
  .dl-row { flex-direction: column; gap: 2px; margin-bottom: 10px; }
  .dl-lbl { min-width: 0; font-size: 10px; }
  .dl-val { font-size: 13px; }
  .sourcing-card { padding: 12px; }
  .sourcing-price-big { font-size: 18px; }
  .sourcing-meta { gap: 8px; flex-wrap: wrap; }
  .po-card { padding: 10px; }
  .po-number { font-size: 12px; }
  .price-row { flex-direction: column; align-items: flex-start; gap: 4px; }
  .price-cost { text-align: left; }
}


/* ══════════════════════════════════════════════════════════════════════
   PAGE-SPECIFIC: DASHBOARD (TENANT-ADMIN / PLATFORM-ADMIN)
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  .content { padding: 10px 12px; }
  .emp-limit-bar { flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px 12px; }
  .progress-track { width: 100%; }
  .report-card { padding: 14px; }
  .report-card .r-title { font-size: 13px; }
  .btn-sm-edit,
  .btn-sm-deact,
  .btn-sm-act,
  .btn-sm-reset { padding: 4px 10px; font-size: 11px; border-radius: 6px; min-height: 28px; }
}


/* ══════════════════════════════════════════════════════════════════════
   PAGE-SPECIFIC: WA CHATBOX
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  #wa-chatbox-overlay { align-items: flex-end; }
  #wa-chatbox-panel,
  .wa-chatbox-panel,
  #waChatPanel {
    width: 100%; max-width: 100%; height: 92vh; height: 92dvh;
    border-radius: 16px 16px 0 0; right: 0; left: 0;
  }
}


/* ══════════════════════════════════════════════════════════════════════
   ULTRA-SMALL SCREENS (<400px)
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 400px) {
  .gs-topbar,
  .topbar,
  header.topbar { padding: 0 8px; }
  .stat-strip,
  .sum-strip,
  .stats-strip { grid-template-columns: 1fr 1fr; }
  .rp .stat-strip { grid-template-columns: 1fr 1fr; }
  .stat-card-val,
  .stat-val,
  .sum-card-val { font-size: 18px; }
  .page-content,
  .content,
  .main-panel { padding: 8px; }
  .hero-name { font-size: 18px; }
  .eng-strip { grid-template-columns: repeat(2, 1fr); }
  .lbl-board-card { flex: 1 1 100%; }
  .btn { min-height: 42px; }
  .btn-sm { min-height: 34px; }
  .modal,
  .modal-box,
  .mbox,
  .gs-dialog { padding: 16px 12px; }
  .rp .stat-card-val { font-size: 16px; }
}


/* ══════════════════════════════════════════════════════════════════════
   DEVICE-SPECIFIC BOTTOM NAV ADJUSTMENTS
   ══════════════════════════════════════════════════════════════════════ */

/* Standard phones (>= 360px) */
@media (min-width: 360px) and (max-width: 599px) {
  .adaptive-bottom-nav-item .nav-icon {
    width: 32px;
    height: 32px;
    font-size: 22px;
  }
}

/* Small phones (< 360px) */
@media (max-width: 359px) {
  .adaptive-bottom-nav-item {
    min-width: 44px;
    max-width: 72px;
    height: 44px;
    padding: 0 4px;
  }
  .adaptive-bottom-nav-item .nav-icon {
    width: 28px;
    height: 28px;
    font-size: 18px;
  }
  .adaptive-bottom-nav-items {
    padding: 6px 0;
    padding-bottom: max(6px, env(safe-area-inset-bottom, 0px));
  }
}

/* Landscape orientation adjustments */
@media (max-height: 500px) and (orientation: landscape) {
  .adaptive-bottom-nav {
    min-height: 48px;
  }
  .adaptive-bottom-nav-item {
    height: 48px;
    gap: 2px;
  }
  .adaptive-bottom-nav-item .nav-label {
    font-size: 10px;
  }
  .adaptive-bottom-nav-item .nav-icon {
    width: 28px;
    height: 28px;
    font-size: 18px;
  }
  .adaptive-bottom-nav-items {
    padding: 4px 0;
  }
}

/* Notch devices (iPhone X+) */
@supports (padding: max(0px)) {
  .adaptive-bottom-nav {
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  }
}


/* ══════════════════════════════════════════════════════════════════════
   ACCESSIBILITY
   ══════════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}


/* ══════════════════════════════════════════════════════════════════════
   PRINT — Hide adaptive nav elements
   ══════════════════════════════════════════════════════════════════════ */
@media print {
  .adaptive-bottom-nav,
  .adaptive-nav-rail,
  .adaptive-fab,
  .sidebar, .gs-sidebar,
  .topbar, .gs-topbar,
  .toolbar, #mobile-hamburger-btn { display: none !important; }
  .main { margin-left: 0 !important; }
}
