/* Mobile contract: one responsive layer after the legacy desktop stylesheet. */
@media (max-width: 900px) {
  body.md3 { --mobile-bar-height: 116px; }
  body.md3 .exact-topbar.m2-topbar,
  body.md3 .exact-topbar .nav-container {
    height: var(--mobile-bar-height) !important;
    min-height: var(--mobile-bar-height) !important;
  }
  body.md3 .exact-topbar .nav-container {
    grid-template-columns: minmax(0, 1fr) auto !important;
    grid-template-rows: 48px 44px !important;
    grid-template-areas: "brand actions" "search search" !important;
    gap: 6px 8px !important;
    padding: 8px 10px !important;
    width: 100% !important;
  }
  body.md3 .nav-brand { grid-area: brand !important; min-width: 0 !important; gap: 6px !important; }
  body.md3 .brand-copy { min-width: 0; }
  body.md3 .nav-brand .nav-title { font-size: 17px !important; white-space: nowrap; }
  body.md3 .nav-subtitle { display: none !important; }
  body.md3 .nav-actions {
    grid-area: actions !important;
    width: auto !important; min-width: 0 !important; gap: 4px !important;
  }
  body.md3 .m2-global-search {
    grid-area: search !important;
    display: flex !important; width: 100% !important; min-width: 0 !important;
    max-width: none !important; height: 44px !important;
    padding: 0 10px !important; gap: 8px !important;
  }
  body.md3 .m2-global-search input { min-width: 0 !important; padding-right: 4px !important; }
  body.md3 .m2-global-search kbd,
  body.md3 .global-search-scope { display: none !important; }
  body.md3 .top-auth { display: inline-flex !important; min-height: 44px !important; padding: 0 8px !important; }
  body.md3 .top-auth[style*="display:none"],
  body.md3 .top-auth[style*="display: none"] { display: none !important; }
  body.md3 .notification-button,
  body.md3 .mobile-sidebar-toggle,
  body.md3 .top-user { min-height: 44px !important; min-width: 44px !important; }
  /* Fixed icon boxes keep text fallbacks from breaking navigation if CDN fonts fail. */
  body.md3 .material-symbols-rounded { max-width: 28px; overflow: hidden; flex-shrink: 0; }
  body.md3 .dashboard-sidebar,
  body.md3 .exact-sidebar,
  body.md3 .admin-dashboard .dashboard-sidebar {
    top: var(--mobile-bar-height) !important; bottom: 0 !important;
    display: flex !important; flex-direction: column !important;
    width: min(86vw, 320px) !important; min-width: 0 !important;
    height: calc(100dvh - var(--mobile-bar-height)) !important;
    max-height: calc(100dvh - var(--mobile-bar-height)) !important;
    min-height: 0 !important; margin: 0 !important;
    overflow-y: auto !important; padding: 12px !important;
  }
  body.md3 .mobile-sidebar-scrim { inset: var(--mobile-bar-height) 0 0 !important; }
  body.md3 .dashboard-sidebar .sidebar-nav {
    display: flex !important; flex-direction: column !important;
    width: 100% !important; min-width: 0 !important;
    overflow: visible !important; flex-shrink: 0; gap: 4px !important;
  }
  body.md3 .dashboard-sidebar .sidebar-nav .tab-btn {
    display: flex !important; flex-direction: row !important;
    width: 100% !important; min-width: 0 !important;
    height: auto !important; min-height: 48px !important;
    flex: 0 0 auto !important; justify-content: flex-start !important;
    gap: 10px !important; padding: 10px 12px !important;
  }
  body.md3 .dashboard-sidebar .sidebar-nav .tab-btn > span:nth-child(2) {
    display: block !important; max-width: none !important;
    font-size: 14px !important; line-height: 1.35 !important;
    white-space: normal !important; text-overflow: clip !important;
    flex: 1; text-align: left !important;
  }
  body.md3 .dashboard-sidebar .tab-icon { width: 24px !important; min-width: 24px !important; }
  body.md3 .mobile-bottom-nav { grid-template-columns: repeat(5, minmax(0, 1fr)) !important; }
  body.md3 .mobile-nav-item { min-width: 0; min-height: 44px; overflow: hidden; }
  body.md3:not(.fps-user-session) .mobile-bottom-nav,
  body.md3:not(.fps-user-session) .mobile-more-sheet { display: none !important; }
  body.md3 .notification-panel,
  body.md3 .profile-drawer-card {
    top: calc(var(--mobile-bar-height) + 4px) !important;
    right: 8px !important; width: calc(100vw - 16px) !important;
    max-height: calc(100dvh - var(--mobile-bar-height) - 12px) !important;
    overflow-y: auto !important; z-index: 220 !important;
  }
  body.md3 .profile-drawer-body { min-height: 0; }
  body.md3 .settings-dialog {
    width: calc(100vw - 24px); max-width: 500px;
    max-height: calc(100dvh - 24px); overflow-y: auto;
  }
  body.md3 .detail-modal { inset: 0 !important; padding: 12px !important; z-index: 250 !important; }
  body.md3 .detail-modal-card {
    width: 100% !important; max-width: 760px !important;
    max-height: calc(100dvh - 24px) !important; min-width: 0 !important;
  }
  body.md3 .detail-modal-body { min-height: 0; overflow: auto; }
  body.md3 .auth-overlay { padding: 12px !important; overflow-y: auto !important; }
  body.md3 .first-run-card {
    width: 100% !important; height: auto !important;
    max-height: calc(100dvh - 24px) !important; overflow-y: auto !important;
  }
  body.md3 .onboarding-header { gap: 8px; }
  body.md3 .onboarding-header > div { min-width: 0; }
  body.md3 .onboarding-header h2 { overflow-wrap: anywhere; }
  body.md3 .onboarding-progress-rail { overflow-x: auto; }
  body.md3 .admin-profile-actions { grid-template-columns: 1fr !important; }
  body.md3 .admin-profile-action { min-height: 44px; }
  body.md3 .admin-actions { flex-wrap: wrap; gap: 8px; }
  body.md3 .admin-actions select,
  body.md3 .table-action-btn { min-height: 44px !important; min-width: 44px; }
  body.md3 .overview-selectors { min-width: 0 !important; grid-template-columns: 1fr !important; }
  body.md3 .table-responsive { max-width: 100%; overflow-x: auto; }
  body.md3 .dashboard-workspace { min-width: 0 !important; }
  body.md3 .report-head-actions { flex-wrap: wrap; }
  body.md3 .export-menu-popover { max-width: calc(100vw - 32px); }
  body.md3 .toast { pointer-events: none; max-width: calc(100vw - 24px); }
}
