/* Global Guidance — phone layout. Applies only on screens up to 820px wide; desktop and tablet-landscape are untouched.
 * The menu becomes a slide-in drawer, the top bar is trimmed to what matters on a phone, and wide grids/tables stack or scroll. */
@media (max-width: 820px) {
  html, body { overflow-x: hidden; -webkit-text-size-adjust: 100%; }
  body input, body select, body textarea, body .form-input { font-size: 16px !important; }   /* stops iPhone zooming into fields */

  /* menu drawer */
  body #sidebar { transform: translateX(-102%); transition: transform .22s cubic-bezier(.4,0,.2,1); width: min(84vw, 310px) !important; z-index: 1300; box-shadow: none; }
  body.gg-m-open #sidebar { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.55); }
  body #main, body.sidebar-collapsed #main { margin-left: 0 !important; }
  body #ggMScrim { position: fixed; inset: 0; background: rgba(2,6,23,.55); z-index: 1250; display: none; }
  body.gg-m-open #ggMScrim { display: block; }
  body.gg-m-open { overflow: hidden; }
  body .nav-item { padding: 11px 18px; font-size: 14px; }
  body .nav-item i { font-size: 13px; }

  /* top bar */
  body .topbar { padding: 8px 10px; flex-wrap: wrap; row-gap: 8px; padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
  body .topbar-left { gap: 8px; min-width: 0; flex: 1; }
  body .topbar-title { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body .topbar-actions { gap: 4px; }
  body #topRolePill, body .tb-branch, body .tb-alert, body .tb-quick, body .tb-ai, body .date-badge, body .online-dot, body .tb-att-state, body .tb-att-timer { display: none !important; }
  body .topbar-actions .tb-icon-btn:has(#tbThemeIcon) { display: none; }
  body .global-search-wrap { order: 3; flex: 1 1 100%; max-width: none !important; margin: 0 !important; }
  body .global-search-input { width: 100%; }
  body .tb-pop { position: fixed; left: 8px !important; right: 8px !important; top: 58px !important; max-width: none !important; max-height: 78vh; overflow-y: auto; }

  /* content */
  body .content { padding: 14px 12px calc(24px + env(safe-area-inset-bottom, 0px)); }
  body .section-header { flex-direction: column; align-items: flex-start !important; gap: 10px; }
  body .card, body .table-wrap { overflow-x: auto; max-width: 100%; }
  body [style*="grid-template-columns"]:not([style*="auto-fill"]):not([style*="auto-fit"]) { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important; }
  body .grid-2, body .grid-3, body .grid-4, body .stats-grid, body .kpi-grid { grid-template-columns: 1fr !important; }
  body .data-table { display: block; overflow-x: auto; white-space: nowrap; max-width: 100%; }
  body .modal { max-width: 96vw !important; width: 96vw !important; margin: 0 auto; max-height: 92vh; }
  body .modal-body { max-height: 70vh; overflow-y: auto; }
  body .btn { min-height: 38px; }
}
