/* ==========================================================================
   UAVLOGBOOK — Global Mobile Responsive Layer  (v2 — full audit)
   ===========================================================================
   ADDITIVE ONLY — every rule sits inside a @media block so desktop is safe.
   Breakpoints used:
     1024 px — tablets landscape / small laptops
      768 px — tablets portrait / large phones
      480 px — phones landscape / small tablets
      375 px — standard phones (iPhone SE-class)
      320 px — compact phones
   ========================================================================== */

/* =========================================================================
   §0  GLOBAL SAFETY
   ========================================================================= */
@media (max-width: 1024px) {
  html, body {
    overflow-x: hidden !important;
    -webkit-text-size-adjust: 100%;
  }
}

/* =========================================================================
   §1  MOBILE NAVIGATION — hamburger + sidebar drawer
   =========================================================================
   JS (mobile-nav.js) adds a hamburger button and converts the sidebar into
   a slide-out drawer at ≤768 px.  All styling is here.
   ========================================================================= */

/* ── 1a  Hamburger button (injected by JS into .app-topbar) ─────────── */
.mobile-nav-hamburger {
  display: none;                               /* hidden on desktop */
}

@media (max-width: 768px) {
  .mobile-nav-hamburger {
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 10px;
    cursor: pointer;
    padding: 0;
    z-index: 100;
    transition: background 0.2s ease, border-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    order: -1;                                 /* always first in topbar */
  }

  .mobile-nav-hamburger:hover,
  .mobile-nav-hamburger:focus-visible {
    background: rgba(75,142,255,0.15);
    border-color: rgba(173,198,255,0.35);
    outline: none;
  }

  .mobile-nav-hamburger__bar {
    display: block;
    width: 20px;
    height: 2px;
    border-radius: 2px;
    background: #e1e2eb;
    transition: transform 0.28s cubic-bezier(.4,0,.2,1),
                opacity   0.22s ease;
    pointer-events: none;
  }

  /* Animate to X when open */
  .mobile-nav-hamburger.mobile-nav-open .mobile-nav-hamburger__bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  .mobile-nav-hamburger.mobile-nav-open .mobile-nav-hamburger__bar:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
  }
  .mobile-nav-hamburger.mobile-nav-open .mobile-nav-hamburger__bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }
}

/* ── 1b  Sidebar → slide-out drawer on phone ────────────────────────── */

/* Tablet: icon rail */
@media (max-width: 1024px) {
  .app-sidebar {
    width: 72px !important;
    overflow-x: hidden !important;
    padding-left: 0.35rem !important;
    padding-right: 0.35rem !important;
  }

  .app-sidebar .text-sm,
  .app-sidebar > div:first-child h1,
  .app-sidebar > div:first-child p,
  .app-sidebar p,
  .app-sidebar button span:not(.material-symbols-outlined),
  .app-sidebar a .text-sm,
  .app-sidebar nav > a > span:not(.material-symbols-outlined) {
    display: none !important;
  }

  .app-sidebar nav > a {
    justify-content: center !important;
    padding-left: 0.35rem !important;
    padding-right: 0.35rem !important;
    gap: 0 !important;
  }

  .app-sidebar .mt-auto a,
  .app-sidebar .mt-auto button {
    justify-content: center !important;
    padding-left: 0.35rem !important;
    padding-right: 0.35rem !important;
  }

  .app-main {
    margin-left: 72px !important;
    min-width: 0 !important;
  }

  html[dir="rtl"] .app-main {
    margin-left: 0 !important;
    margin-right: 72px !important;
  }

  html[dir="rtl"] .app-sidebar {
    left: auto !important;
    right: 0 !important;
  }
}

/* Phone: sidebar becomes off-screen drawer
   ────────────────────────────────────────────
   MUST override theme-overrides.css which sets:
     top: 1rem; left: 1rem; border-radius: 1.5rem;
     height: calc(100vh - 2rem); max-height: calc(100vh - 2rem);
     border: 1px solid …; background: rgba(…,0.75); backdrop-filter; z-index: 1040;
   All overrides spelled out explicitly below.
   ──────────────────────────────────────────── */
@media (max-width: 768px) {
  /*
   * iOS Safari / WebKit: a fixed sidebar nested under overflow:hidden (e.g.
   * #fleetDashboardRoot.fleet-premium-shell) can composite *under* later
   * body-level layers. Also beat in-shell UI such as .fleet-notify-panel (10000).
   * Drawer uses 29k–30k; Bootstrap/modals use 31k+ (above fleet FAB / troubleshooting).
   */
  #fleetDashboardRoot.fleet-premium-shell,
  #activeFlightsFleetShell.fleet-premium-shell,
  #adminHomeRoot.fleet-premium-shell,
  #statisticsRoot.fleet-premium-shell {
    overflow: visible !important;
  }

  .app-sidebar {
    /* Core drawer positioning */
    display: flex !important;
    flex-direction: column !important;
    position: fixed !important;
    width: 280px !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    min-height: 0 !important;
    top: 0 !important;
    left: 0 !important;
    right: auto !important;
    bottom: 0 !important;
    z-index: 30000 !important;
    isolation: isolate;

    /* Override theme-overrides.css floating glass panel */
    border-radius: 0 !important;
    border: none !important;
    background: rgba(14, 21, 37, 0.97) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;

    /* Slide off-screen left (LTR default) */
    transform: translateX(-100%) !important;
    transition: transform 0.32s cubic-bezier(.4,0,.2,1),
                box-shadow 0.32s ease !important;
    box-shadow: none !important;

    /* Scroll & spacing */
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    padding-left: 0 !important;
    padding-right: 0 !important;
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
    scrollbar-gutter: stable;
  }

  /* When mobile-nav.js reparents the aside to body, keep the same stacking */
  body > #app-sidebar.app-sidebar {
    z-index: 30000 !important;
  }

  /* RTL (Hebrew) — sidebar slides from right */
  html[dir="rtl"] .app-sidebar {
    left: auto !important;
    right: 0 !important;
    transform: translateX(100%) !important;
  }

  /* Show labels back inside drawer (undo tablet icon-rail) */
  .app-sidebar .text-sm,
  .app-sidebar > div:first-child h1,
  .app-sidebar > div:first-child p,
  .app-sidebar p,
  .app-sidebar button span:not(.material-symbols-outlined),
  .app-sidebar a .text-sm,
  .app-sidebar nav > a > span:not(.material-symbols-outlined) {
    display: revert !important;
  }

  .app-sidebar nav > a {
    justify-content: flex-start !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    gap: 0.75rem !important;
  }

  .app-sidebar .mt-auto a,
  .app-sidebar .mt-auto button {
    justify-content: flex-start !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  /* ── Drawer OPEN state (toggled by mobile-nav.js) ── */
  .app-sidebar.mobile-nav-open {
    transform: translateX(0) !important;
    box-shadow: 8px 0 32px rgba(0,0,0,0.55) !important;
  }

  html[dir="rtl"] .app-sidebar.mobile-nav-open {
    transform: translateX(0) !important;
    box-shadow: -8px 0 32px rgba(0,0,0,0.55) !important;
  }

  /* Main area — full width, no offset */
  .app-main {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  html[dir="rtl"] .app-main {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /*
   * dashboard.css @media (max-width: 1024px) sets #fleetDashboardRoot .app-main
   * margin-left/right with !important (86px icon rail). Its selector uses .app-main,
   * which outranks our #fleetDashboardRoot > main rule — leaving a blank strip on RTL
   * phones. Mirror the same specificity here (mobile-responsive loads after dashboard).
   */
  #fleetDashboardRoot .app-main,
  #activeFlightsFleetShell .app-main,
  #clientDashboardShell .app-main,
  #componentsTrackingShell .app-main,
  #userSettingsShell .app-main,
  #adminHomeRoot .app-main,
  #statisticsRoot .app-main {
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
    max-width: none !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }

  html[dir="rtl"] #fleetDashboardRoot .app-main,
  html[dir="rtl"] #activeFlightsFleetShell .app-main,
  html[dir="rtl"] #clientDashboardShell .app-main,
  html[dir="rtl"] #componentsTrackingShell .app-main,
  html[dir="rtl"] #userSettingsShell .app-main,
  html[dir="rtl"] #adminHomeRoot .app-main,
  html[dir="rtl"] #statisticsRoot .app-main {
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
    max-width: none !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }

  /* Also override theme-overrides min-width 1024px main margins */
  .app-shell > main,
  #fleetDashboardRoot > main,
  #activeFlightsFleetShell > main,
  #componentsTrackingShell > main,
  #userSettingsShell > main,
  .app-shell #fleetMainArea {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  html[dir="rtl"] .app-shell > main,
  html[dir="rtl"] #fleetDashboardRoot > main,
  html[dir="rtl"] #activeFlightsFleetShell > main,
  html[dir="rtl"] #componentsTrackingShell > main,
  html[dir="rtl"] #userSettingsShell > main,
  html[dir="rtl"] .app-shell #fleetMainArea {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* Shell flex row: use full viewport when sidebar is portaled off to body */
  #fleetDashboardRoot.app-shell,
  #activeFlightsFleetShell.app-shell,
  #clientDashboardShell.app-shell,
  #componentsTrackingShell.app-shell,
  #userSettingsShell.app-shell,
  #adminHomeRoot.app-shell,
  #statisticsRoot.app-shell {
    width: 100% !important;
    max-width: 100% !important;
  }

  /*
   * Premium shells: icon-rail inset (86px) up to 1024px — on phones the drawer is off-canvas;
   * reading progress must span full width (components + user settings).
   */
  #componentsTrackingShell .ct-scroll-progress {
    left: 0 !important;
    right: 0 !important;
  }

  html[dir="rtl"] #componentsTrackingShell .ct-scroll-progress {
    left: 0 !important;
    right: 0 !important;
  }

  #userSettingsShell .us-scroll-progress {
    left: 0 !important;
    right: 0 !important;
  }

  html[dir="rtl"] #userSettingsShell .us-scroll-progress {
    left: 0 !important;
    right: 0 !important;
  }
}

/* ── 1c  Overlay backdrop ────────────────────────────────────────────── */
.mobile-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 29800;
  background: rgba(0,0,0,0);
  backdrop-filter: blur(0px);
  transition: background 0.32s ease, backdrop-filter 0.32s ease;
  pointer-events: none;
}

.mobile-nav-overlay.mobile-nav-open {
  display: block;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  pointer-events: auto;
}

/* ── 1d  Body lock while drawer is open ──────────────────────────────── */
body.mobile-nav-body-lock {
  overflow: hidden !important;
  touch-action: none !important;
}

/* Top bar / minibar above dim overlay so hamburger stays visible & tappable */
body.mobile-nav-body-lock .app-topbar,
body.mobile-nav-body-lock .cd-app-shell-topbar,
body.mobile-nav-body-lock .mobile-nav-minibar {
  z-index: 29900 !important;
}

/* ── 1e  Mini-bar (injected by JS when no app-topbar exists) ─────────── */
.mobile-nav-minibar {
  display: none;
}

@media (max-width: 768px) {
  .mobile-nav-minibar {
    display: flex !important;
    align-items: center;
    padding: 0.5rem 0.75rem;
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(11, 14, 20, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
}

/* =========================================================================
   §2  TOP BAR  — wrap on small screens, make room for hamburger
   =========================================================================
   Dashboard topbar structure (from template):
     <header class="app-topbar … flex justify-between items-center h-16 px-8">
       <div class="flex items-center gap-4 flex-1">      ← search wrapper
         <div class="relative w-full max-w-md group">   ← search input
       </div>
       <div class="flex items-center gap-6">             ← right elements
         lang-switcher | deploy-btn | notify+tune
       </div>
     </header>
   ========================================================================= */
@media (max-width: 768px) {
  .app-topbar,
  .cd-app-shell-topbar {
    flex-wrap: wrap !important;
    row-gap: 0.5rem !important;
    column-gap: 0.4rem !important;
    padding: 0.5rem 0.65rem !important;
    min-height: auto !important;
    height: auto !important;
  }

  /* ── Left group (contains search) ─────────── */
  /* Make search wrapper stop consuming all space in the first row,
     instead push it to a second row. */
  .app-topbar > div:first-child {
    flex: 0 0 100% !important;
    order: 10 !important;            /* push to end → wraps to new row */
  }

  .app-topbar .relative.w-full.max-w-md,
  .app-topbar .relative.w-full {
    max-width: 100% !important;
    width: 100% !important;
  }

  .app-topbar input[type="text"],
  .app-topbar input[type="search"] {
    max-width: 100% !important;
    width: 100% !important;
    font-size: max(0.875rem, 16px) !important;
  }

  /* ── Right group (lang switcher, deploy, notify, tune) ── */
  .app-topbar > div:last-child {
    flex-wrap: nowrap !important;
    gap: 0.35rem !important;
    flex-shrink: 1 !important;
    align-items: center !important;
  }

  /* Deploy button — hide on phone, nav drawer has CTA */
  .fleet-topbar-upgrade #fleetDeployUavBtn {
    display: none !important;
  }

  /* Customize button — hide on phone */
  #fleetDashboardCustomizeBtn {
    display: none !important;
  }

  /* Notification button — smaller */
  .fleet-notify-btn,
  #fleetNotifyBtn {
    padding: 0.35rem !important;
    width: 36px !important;
    height: 36px !important;
  }

  /* Language switcher — compact */
  .app-language-switcher {
    gap: 1px !important;
  }

  .app-lang-btn {
    padding: 4px 8px !important;
    font-size: max(0.7rem, 12px) !important;
    min-height: 32px !important;
  }

  /* User menu — truncate name */
  .cd-user-menu__name {
    max-width: min(8rem, 30vw) !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
}

@media (max-width: 480px) {
  .app-topbar,
  .cd-app-shell-topbar {
    padding: 0.4rem 0.5rem !important;
  }

  .app-lang-btn {
    padding: 3px 6px !important;
    font-size: max(0.65rem, 11px) !important;
  }

  .fleet-notify-btn,
  #fleetNotifyBtn {
    width: 32px !important;
    height: 32px !important;
    padding: 0.25rem !important;
  }
}



/* =========================================================================
   §3  FLEET DASHBOARD  (#fleetDashboardRoot)
   ========================================================================= */
@media (max-width: 1024px) {
  #fleetDashboardRoot {
    padding: 0.75rem !important;
  }

  .fleet-hero {
    padding: 1rem 1.15rem !important;
  }

  .fleet-hero-status-row {
    flex-wrap: wrap !important;
    gap: 0.65rem !important;
  }
}

@media (max-width: 768px) {
  #fleetDashboardRoot {
    padding: 0.5rem !important;
    border-radius: 0 !important;
  }

  .fleet-hero {
    padding: 0.85rem 1rem !important;
    border-radius: 12px !important;
    margin-bottom: 0.75rem !important;
  }

  .fleet-hero-status-row {
    flex-direction: column !important;
    align-items: flex-start !important;
  }

  .fleet-kpi-strip,
  .fleet-stats-row {
    flex-direction: column !important;
    gap: 0.65rem !important;
  }

  /* Notification panel — full width on phone */
  .fleet-notify-panel {
    right: 8px !important;
    left: 8px !important;
    width: auto !important;
    max-width: none !important;
  }

  .fleet-toast-area {
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
  }

  .fleet-type-group-grid,
  .fleet-uav-grid {
    grid-template-columns: 1fr !important;
  }

  .fleet-donut-wrap {
    width: 100% !important;
    max-width: 200px !important;
    margin: 0 auto !important;
  }

  /* Dashboard content — reduce padding */
  .dashboard-content {
    padding: 1rem 0.65rem !important;
  }

  /* KPI grid — 2 columns on phone, 1 on tiny */
  .dashboard-content .grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-4 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.65rem !important;
  }

  /* Action flex row */
  .dashboard-content .flex.flex-wrap.gap-4 {
    gap: 0.5rem !important;
  }

  .dashboard-content .flex.flex-wrap.gap-4 > * {
    min-width: 0 !important;
    flex: 1 1 100% !important;
  }
}

@media (max-width: 480px) {
  .fleet-hero {
    padding: 0.65rem 0.75rem !important;
  }

  .fleet-system-status {
    padding: 0.3rem 0.45rem !important;
    font-size: 0.78rem !important;
  }
}

/* =========================================================================
   §4  FLEET — takeoff modal
   ========================================================================= */
@media (max-width: 768px) {
  #recordTakeoffModal .modal-dialog,
  #recordTakeoffModal.fleet-takeoff-modal .modal-dialog {
    margin: 0.5rem !important;
    max-width: calc(100vw - 1rem) !important;
    width: auto !important;
  }

  /* No overflow clipping on modal shell — crew autocomplete is position:absolute and must escape the box */
  #recordTakeoffModal .modal-content {
    max-height: none !important;
    overflow: visible !important;
  }

  #recordTakeoffModal.fleet-takeoff-modal .modal-body {
    max-height: none !important;
    overflow: visible !important;
  }

  #recordTakeoffModal #takeoff-aircraft-list-af {
    max-height: 45vh !important;
    overflow-y: auto !important;
  }
}

/* =========================================================================
   §5  ADMIN HOME  (index.html  #adminHomeRoot, .admin-home-page)
   ========================================================================= */
@media (max-width: 768px) {
  .admin-home-page .ah-shell {
    padding: 1rem 0.75rem 2rem !important;
  }

  .admin-home-page .ah-hero {
    min-height: 160px !important;
    border-radius: 12px !important;
  }

  .admin-home-page .ah-hero-content {
    padding: 1.25rem 1rem !important;
  }

  .admin-home-page .ah-hero-title {
    font-size: 1.5rem !important;
  }

  .admin-home-page .ah-hero-sub {
    font-size: 0.9rem !important;
  }

  .admin-home-page .ah-kpi-row {
    grid-template-columns: 1fr !important;
    gap: 0.85rem !important;
  }

  .admin-home-page .ah-layout-grid {
    grid-template-columns: 1fr !important;
  }

  .admin-home-page .ah-panel {
    padding: 1.15rem !important;
    border-radius: 12px !important;
  }

  .admin-home-page .ah-quick-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .admin-home-page .ah-navbar {
    padding: 0.5rem 0 !important;
  }

  .admin-home-page .ah-nav-inner {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
}

@media (max-width: 480px) {
  .admin-home-page .ah-kpi-value {
    font-size: 1.75rem !important;
  }

  .admin-home-page .ah-quick-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.65rem !important;
  }

  .admin-home-page .ah-quick-btn {
    padding: 0.85rem 0.5rem !important;
    font-size: 0.62rem !important;
  }
}

/* =========================================================================
   §6  UAV LIST PAGE
   ========================================================================= */
@media (max-width: 768px) {
  .uav-list-fleet-content {
    padding: 0.75rem 0.65rem 2rem !important;
  }

  .uav-list-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
  }

  .uav-list-title {
    font-size: 1.5rem !important;
  }

  .uav-ref-stats-grid {
    grid-template-columns: 1fr !important;
    gap: 0.85rem !important;
  }

  .uav-ref-filters-grid,
  .search-filters-container {
    grid-template-columns: 1fr !important;
  }

  .uav-ref-filter-cell--search {
    grid-column: span 1 !important;
  }

  .uav-ref-hero-banner__content {
    padding: 1.15rem 1rem 1.35rem !important;
  }

  .uav-ref-hero-banner__title {
    font-size: 1.35rem !important;
  }

  .uav-ref-table-shell {
    border-radius: 12px !important;
    overflow: hidden !important;
  }

  .uav-ref-table-scroll {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .uav-table th,
  .uav-table td {
    padding: 0.85rem 0.75rem !important;
    font-size: 0.82rem !important;
  }

  .uav-table th {
    font-size: 0.58rem !important;
    white-space: nowrap !important;
  }

  .uav-ref-hero-banner__actions .add-uav-btn {
    width: 100% !important;
    justify-content: center !important;
  }
}

/* =========================================================================
   §7  UAV DETAILS PAGE
   ========================================================================= */
@media (max-width: 768px) {
  .uav-details-hero {
    padding: 1.15rem 1rem !important;
    border-radius: 1rem !important;
  }

  .uav-details-hero__icon {
    width: 3.5rem !important;
    height: 3.5rem !important;
    font-size: 1.5rem !important;
  }

  .uav-details-hero__title {
    font-size: 1.5rem !important;
  }

  .uav-details-hero__stats {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem !important;
  }

  .uav-details-hero__stats--aside {
    border-inline-start: none !important;
    padding-inline-start: 0 !important;
    border-top: 1px solid rgba(255,255,255,0.06) !important;
    padding-top: 1rem !important;
    margin-top: 1rem !important;
  }

  .uav-details-command-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.5rem !important;
  }

  .uav-details-command-bar__actions {
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
  }

  body.uav-details-premium .uav-cmd-btn {
    flex: 1 1 auto !important;
    min-width: 120px !important;
    justify-content: center !important;
    text-align: center !important;
  }

  .uav-asset-grid {
    grid-template-columns: 1fr !important;
  }

  .uav-airframe-card {
    padding: 1rem !important;
  }

  .uav-airframe-card__body {
    flex-direction: column !important;
  }

  .uav-airframe-ring-wrap {
    margin-bottom: 1rem !important;
  }

  body.uav-details-premium .premium-card {
    border-radius: 1rem !important;
  }

  body.uav-details-premium .section {
    border-radius: 1rem !important;
    padding: 1rem !important;
  }

  body.uav-details-premium .table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  body.uav-details-premium .table {
    min-width: 600px !important;
  }

  body.uav-details-premium .modal-dialog {
    margin: 0.5rem !important;
    max-width: calc(100vw - 1rem) !important;
  }

  body.uav-details-premium .modal-content {
    max-height: calc(100vh - 1rem) !important;
    overflow-y: auto !important;
    border-radius: 0.85rem !important;
  }

  body.uav-details-premium .container {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
}

@media (max-width: 480px) {
  .uav-details-hero__stats {
    grid-template-columns: 1fr !important;
  }

  .uav-details-hero__stat-value {
    font-size: 1.35rem !important;
  }
}

/* =========================================================================
   §8  ISSUE TRACKING PAGE
   ========================================================================= */

/*
 * GitHub issue #16 — mobile Chrome could not scroll /issue-tracking.
 * - dashboard.css sets #fleetDashboardRoot { overflow: hidden }; §1 above only
 *   overrides .fleet-premium-shell at max-width 768px — tablets (769–1024px)
 *   still kept overflow:hidden, which can break document scrolling with the
 *   flex shell. Scoped to issue-tracking only.
 * - Flex + min-h-screen: allow main/.cd-wrap to participate in normal document
 *   flow (min-height: 0) so content height propagates to the scroll root.
 */
@media (max-width: 1024px) {
  body.issue-tracking-page #fleetDashboardRoot.fleet-premium-shell {
    overflow: visible !important;
  }
}

@media (max-width: 768px) {
  body.issue-tracking-page {
    -webkit-overflow-scrolling: touch;
  }

  body.issue-tracking-page #fleetDashboardRoot > main.app-main {
    min-height: 0 !important;
    overflow: visible !important;
  }

  body.issue-tracking-page #fleetDashboardRoot .cd-wrap {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  body.issue-tracking-page .it-page-container {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }

  body.issue-tracking-page .stats-card {
    border-radius: 0.85rem !important;
  }

  body.issue-tracking-page .filter-section {
    position: static !important;
    border-radius: 0.85rem !important;
    padding: 1rem !important;
  }

  body.issue-tracking-page .filter-section .row {
    flex-direction: column !important;
  }

  body.issue-tracking-page .filter-section .row > [class*="col"] {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
    margin-bottom: 0.75rem !important;
  }

  body.issue-tracking-page .critical-highlight-panel {
    flex-direction: column !important;
    text-align: center !important;
    gap: 0.65rem !important;
  }

  body.issue-tracking-page .it-issue-card .card-body {
    padding: 0.85rem !important;
  }

  body.issue-tracking-page .pagination .page-link {
    padding: 10px 14px !important;
    font-size: 0.85rem !important;
  }

  #newIssueModal .modal-dialog {
    width: calc(100vw - 1rem) !important;
    max-width: none !important;
    max-height: calc(100vh - 1rem) !important;
  }

  #issueSuccessModal .modal-dialog {
    width: calc(100vw - 1rem) !important;
    max-width: none !important;
  }
}

/* =========================================================================
   §9  COMPONENTS TRACKING PAGE
   ========================================================================= */
@media (max-width: 768px) {
  .ct-page-container {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }

  .ct-stats-grid {
    grid-template-columns: 1fr !important;
  }

  .ct-component-card {
    border-radius: 0.85rem !important;
  }

  .ct-table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .ct-table-wrap .table {
    min-width: 650px !important;
  }

  .ct-filter-row {
    flex-direction: column !important;
    gap: 0.5rem !important;
  }

  .ct-filter-row > * {
    width: 100% !important;
  }
}

/* =========================================================================
   §10  CLIENT DASHBOARD
   ========================================================================= */
@media (max-width: 768px) {
  .cd-wrap {
    padding: 1rem 0.75rem 2rem !important;
  }

  .cd-hero {
    gap: 1rem !important;
  }

  .cd-hero h1,
  .cd-hero .cd-title {
    font-size: 1.5rem !important;
  }

  .cd-hero-actions {
    flex-direction: column !important;
    width: 100% !important;
  }

  .cd-hero-actions > * {
    width: 100% !important;
    justify-content: center !important;
  }

  .cd-stats {
    grid-template-columns: 1fr !important;
  }

  .cd-main-split {
    grid-template-columns: 1fr !important;
  }

  .cd-sidebar {
    position: static !important;
  }

  .cd-sidebar-inner {
    max-height: none !important;
  }

  .cd-glass {
    padding: 1rem 1.15rem !important;
    border-radius: 1rem !important;
  }

  .cd-client-row {
    flex-direction: column !important;
  }

  .cd-client-field {
    max-width: 100% !important;
    width: 100% !important;
  }
}

/* =========================================================================
   §11  SETTINGS PAGE
   ========================================================================= */
@media (max-width: 768px) {
  .settings-tabs,
  .nav-tabs {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
  }

  .settings-tabs::-webkit-scrollbar,
  .nav-tabs::-webkit-scrollbar {
    display: none !important;
  }

  .settings-tabs .nav-link,
  .nav-tabs .nav-link {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    padding: 0.5rem 0.85rem !important;
    font-size: 0.85rem !important;
  }

  .setting-section {
    padding: 0 0.25rem !important;
  }
}

/* =========================================================================
   §12  LOGIN / AUTH PAGES
   ========================================================================= */
@media (max-width: 768px) {
  .login-container,
  .auth-container {
    padding: 1rem !important;
    margin: 0 auto !important;
    max-width: 100% !important;
  }

  .login-card,
  .auth-card {
    border-radius: 12px !important;
    padding: 1.5rem 1.15rem !important;
    margin: 0.5rem !important;
  }
}

/* =========================================================================
   §13  GLOBAL TABLE RESPONSIVENESS
   ========================================================================= */
@media (max-width: 768px) {
  .table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    border-radius: 8px !important;
  }

  .table-responsive > .table {
    min-width: 580px;
  }

  .table td,
  .table th {
    padding: 0.65rem 0.55rem !important;
    font-size: 0.82rem !important;
  }
}

/* =========================================================================
   §14  GLOBAL MODAL FIXES
   ========================================================================= */
@media (max-width: 768px) {
  .modal-dialog {
    margin: 0.5rem !important;
    max-width: calc(100vw - 1rem) !important;
  }

  .modal-content {
    max-height: calc(100vh - 1rem) !important;
    border-radius: 0.85rem !important;
  }

  .modal-body {
    overflow-y: auto !important;
    max-height: calc(100vh - 8rem) !important;
  }

  .modal-lg,
  .modal-xl {
    max-width: calc(100vw - 1rem) !important;
  }

  .custom-modal-dialog {
    width: calc(100% - 1rem) !important;
    margin: 0.5rem auto !important;
  }

  .modal-footer {
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
  }

  .modal-footer .btn {
    flex: 1 1 auto !important;
    min-width: 100px !important;
  }

  /* Fixed-position modals (issue/takeoff success) — clamp to viewport */
  .modal .modal-dialog[style*="position: fixed"],
  .modal .modal-dialog[style*="position:fixed"] {
    max-width: calc(100vw - 1.5rem) !important;
  }
}

/* =========================================================================
   §15  GLOBAL FORM USABILITY
   ========================================================================= */
@media (max-width: 768px) {
  /* Prevent iOS zoom on input focus (16px min) */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  input[type="url"],
  input[type="search"],
  input[type="date"],
  input[type="datetime-local"],
  select,
  textarea,
  .form-control,
  .form-select {
    font-size: max(0.875rem, 16px) !important;
  }

  .form-control,
  .form-select,
  .btn {
    min-height: 44px !important;
  }

  .form-group .row,
  .form-row {
    flex-direction: column !important;
  }

  .form-group .row > [class*="col"],
  .form-row > [class*="col"] {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
    margin-bottom: 0.65rem !important;
  }
}

/* =========================================================================
   §16  GLOBAL CARD FIXES
   ========================================================================= */
@media (max-width: 768px) {
  .card {
    border-radius: 10px !important;
    margin-bottom: 0.85rem !important;
  }

  .card-header {
    padding: 0.85rem 1rem !important;
  }

  .card-body {
    padding: 1rem !important;
  }
}

/* =========================================================================
   §17  BOOTSTRAP GRID — force stacking below md
   ========================================================================= */
@media (max-width: 767.98px) {
  .row > .col-md-4,
  .row > .col-md-6,
  .row > .col-md-3,
  .row > .col-md-8,
  .row > .col-md-9,
  .row > .col-lg-4,
  .row > .col-lg-6,
  .row > .col-lg-3 {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
  }
}

/* =========================================================================
   §18  BUTTONS — touch-friendly
   ========================================================================= */
@media (max-width: 768px) {
  .btn {
    padding: 0.5rem 1rem !important;
    font-size: 0.875rem !important;
  }

  .btn-sm {
    padding: 0.4rem 0.75rem !important;
    min-height: 38px !important;
  }

  .action-buttons,
  .btn-group {
    flex-wrap: wrap !important;
    gap: 0.35rem !important;
  }
}

/* =========================================================================
   §19  NAVIGATION — legacy Bootstrap navbar (dashboard, non-sidebar pages)
   ========================================================================= */
@media (max-width: 768px) {
  .navbar {
    padding: 0.5rem 0.65rem !important;
  }

  .navbar-brand {
    font-size: 1rem !important;
  }

  .navbar-collapse {
    max-height: 80vh !important;
    overflow-y: auto !important;
  }

  .nav-links {
    flex-direction: column !important;
    gap: 0.25rem !important;
  }

  .nav-link {
    padding: 0.65rem 0.75rem !important;
    width: 100% !important;
  }

  .admin-home-page .nav-links {
    background: rgba(16, 19, 26, 0.97) !important;
    border-radius: 0 0 12px 12px !important;
  }
}

/* =========================================================================
   §20  STATISTICS PAGE
   ========================================================================= */
@media (max-width: 768px) {
  #statisticsRoot .app-main {
    padding: 0.75rem !important;
  }

  .chart-container,
  .ah-chart-wrap {
    height: auto !important;
    min-height: 220px !important;
  }

  canvas {
    max-width: 100% !important;
    height: auto !important;
  }
}

/* =========================================================================
   §21  USER / TENANT MANAGEMENT (admin table pages)
   ========================================================================= */
@media (max-width: 768px) {
  .container,
  .container-fluid {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }

  dl.row > dt,
  dl.row > dd {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
  }
}

/* =========================================================================
   §22  LODGING / FIELD MEALS / VEHICLES
   ========================================================================= */
@media (max-width: 768px) {
  .table-responsive {
    border: 0 !important;
  }

  .badge {
    white-space: normal !important;
    word-break: break-word !important;
  }
}

/* =========================================================================
   §23  CONNECTION LIMITS
   ========================================================================= */
@media (max-width: 768px) {
  .conn-limit-card {
    padding: 1rem !important;
  }
}

/* =========================================================================
   §24  LANDING PAGE
   ========================================================================= */
@media (max-width: 480px) {
  .hero {
    padding: 2.5rem 0 3rem !important;
  }

  .hero-title {
    font-size: 1.75rem !important;
  }

  .hero-cta {
    flex-direction: column !important;
  }

  .hero-cta .btn-hero {
    width: 100% !important;
    text-align: center !important;
  }

  .cta-buttons {
    flex-direction: column !important;
  }

  .cta-buttons .btn-cta {
    width: 100% !important;
    text-align: center !important;
  }

  .feature-card .card-body {
    padding: 1.35rem !important;
  }

  footer.landing-footer {
    text-align: center !important;
  }

  .landing-footer .footer-legal {
    flex-direction: column !important;
    gap: 0.35rem !important;
  }
}

/* =========================================================================
   §25  LANDING NAV
   ========================================================================= */
@media (max-width: 991.98px) {
  .navbar-landing .navbar-collapse {
    background: #0f172a !important;
    border-radius: 0 0 12px 12px !important;
    padding: 0.75rem !important;
    margin-top: 0.5rem !important;
  }

  .navbar-landing .navbar-nav .nav-link {
    padding: 0.65rem 0.85rem !important;
    border-radius: 8px !important;
  }
}

/* =========================================================================
   §26  FORGOT PASSWORD
   ========================================================================= */
@media (max-width: 768px) {
  .forgot-password-container {
    padding: 1rem !important;
  }
}

/* =========================================================================
   §27  ERROR / 404
   ========================================================================= */
@media (max-width: 768px) {
  .error-container {
    padding: 2rem 1rem !important;
  }

  .error-code {
    font-size: 4rem !important;
  }
}

/* =========================================================================
   §28  COOKIE CONSENT
   ========================================================================= */
@media (max-width: 768px) {
  .cookie-consent-banner {
    padding: 0.85rem 1rem !important;
    flex-direction: column !important;
    gap: 0.65rem !important;
  }

  .cookie-consent-banner .cookie-consent-actions {
    flex-direction: column !important;
    width: 100% !important;
  }

  .cookie-consent-banner .cookie-consent-actions .btn {
    width: 100% !important;
  }
}

/* =========================================================================
   §29  LANGUAGE SWITCHER
   ========================================================================= */
@media (max-width: 768px) {
  .language-switcher {
    margin: 0 !important;
  }

  .language-switcher .btn {
    min-width: 80px !important;
    font-size: 0.82rem !important;
  }

  .app-language-switcher {
    gap: 2px !important;
  }

  .app-lang-btn {
    padding: 6px 10px !important;
    font-size: max(0.72rem, 14px) !important;
  }
}

/* =========================================================================
   §30  ALERTS / TOAST
   ========================================================================= */
@media (max-width: 768px) {
  .toast {
    right: 0.5rem !important;
    left: 0.5rem !important;
    bottom: 0.5rem !important;
    min-width: unset !important;
    width: auto !important;
  }

  .alert {
    padding: 0.75rem 1rem !important;
    font-size: 0.875rem !important;
    border-radius: 8px !important;
  }
}

/* =========================================================================
   §31  PAGINATION
   ========================================================================= */
@media (max-width: 768px) {
  .pagination {
    flex-wrap: wrap !important;
    gap: 0.35rem !important;
    justify-content: center !important;
  }

  .page-link {
    padding: 0.5rem 0.75rem !important;
    min-width: 40px !important;
    min-height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
}

/* =========================================================================
   §32  FLEET TAKEOFF SUCCESS MODAL
   ========================================================================= */
@media (max-width: 768px) {
  .fleet-takeoff-success-modal .modal-dialog {
    margin: 0 !important;
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: calc(100vw - 1.5rem) !important;
    max-width: none !important;
  }
}

/* =========================================================================
   §33  SUMMARY CARDS / KPI PANELS
   ========================================================================= */
@media (max-width: 768px) {
  .summary-card {
    padding: 1rem !important;
  }

  .summary-card .number {
    font-size: 2rem !important;
  }

  .summary-card .icon {
    font-size: 1.5rem !important;
  }
}

/* =========================================================================
   §34  ACTIVE FLIGHTS
   ========================================================================= */
@media (max-width: 768px) {
  .active-flights-container {
    padding: 0.75rem !important;
  }

  .flight-card {
    border-radius: 10px !important;
  }

  .map-container,
  #flightsMap {
    height: 250px !important;
    min-height: 200px !important;
  }
}

/* =========================================================================
   §35  USER SETTINGS
   ========================================================================= */
@media (max-width: 768px) {
  .user-settings-container {
    padding: 0.75rem !important;
  }

  .user-profile-card {
    flex-direction: column !important;
    text-align: center !important;
  }

  .user-avatar-large {
    margin: 0 auto 1rem !important;
  }
}

/* =========================================================================
   §36  ADMIN SUMMARY
   ========================================================================= */
@media (max-width: 768px) {
  .admin-summary-grid {
    grid-template-columns: 1fr !important;
  }
}

/* =========================================================================
   §37  SEARCH BAR
   ========================================================================= */
@media (max-width: 768px) {
  .search-box,
  input[type="search"],
  .search-input {
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* =========================================================================
   §38  DROPDOWNS
   ========================================================================= */
@media (max-width: 768px) {
  .dropdown-menu {
    max-height: 60vh !important;
    overflow-y: auto !important;
  }
}

/* =========================================================================
   §39  STICKY ELEMENTS
   ========================================================================= */
@media (max-width: 768px) {
  .sticky-top,
  [style*="position: sticky"],
  [style*="position:sticky"] {
    top: 0 !important;
  }
}

/* =========================================================================
   §40  ONBOARDING
   ========================================================================= */
@media (max-width: 768px) {
  .onboarding-step {
    padding: 1rem !important;
  }

  .onboarding-progress {
    flex-wrap: wrap !important;
  }
}

/* =========================================================================
   §41  PRINT SAFE
   ========================================================================= */
@media print {
  .app-sidebar {
    display: none !important;
  }
  .app-main {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}

/* =========================================================================
   §42  iPad landscape (769–1024 px)
   ========================================================================= */
@media (min-width: 769px) and (max-width: 1024px) {
  .cd-stats {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .uav-ref-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .admin-home-page .ah-kpi-row {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .uav-details-hero__stats {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

/* =========================================================================
   §43  iPhone safe-area insets
   ========================================================================= */
@supports (padding: env(safe-area-inset-bottom)) {
  @media (max-width: 768px) {
    .app-main {
      padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    }

    .modal-content {
      padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0px)) !important;
    }

    .toast,
    .floating-demo-cta,
    #back-to-top {
      bottom: max(0.75rem, env(safe-area-inset-bottom, 16px)) !important;
    }

    /* Drawer — pad bottom for home indicator */
    .app-sidebar {
      padding-bottom: max(1.5rem, env(safe-area-inset-bottom, 0px)) !important;
    }
  }
}

/* =========================================================================
   §44  Compact phone (≤375 px)
   ========================================================================= */
@media (max-width: 375px) {
  body {
    font-size: 14px !important;
  }

  .fleet-hero {
    padding: 0.5rem 0.65rem !important;
  }

  .uav-details-hero {
    padding: 0.85rem 0.75rem !important;
  }

  .uav-details-hero__title {
    font-size: 1.25rem !important;
  }

  .cd-hero h1,
  .cd-hero .cd-title {
    font-size: 1.25rem !important;
  }

  .admin-home-page .ah-hero-title {
    font-size: 1.25rem !important;
  }

  .btn {
    padding: 0.45rem 0.85rem !important;
    font-size: 0.82rem !important;
  }

  .card-body {
    padding: 0.85rem !important;
  }

  /* Hamburger — slightly smaller */
  .mobile-nav-hamburger {
    width: 38px !important;
    height: 38px !important;
  }
}

/* =========================================================================
   §45  Landscape phone (height ≤500 px)
   ========================================================================= */
@media (max-height: 500px) and (orientation: landscape) {
  .modal-body {
    max-height: calc(100vh - 6rem) !important;
  }

  .hero {
    min-height: auto !important;
    padding: 2rem 0 !important;
  }

  .admin-home-page .ah-hero {
    min-height: auto !important;
  }

  .app-sidebar {
    height: 100vh !important;
    height: 100dvh !important;
  }
}

/* =========================================================================
   §46-§50  Remaining page types
   ========================================================================= */

/* 46 — Admin registration requests */
@media (max-width: 768px) {
  .registration-requests-container {
    padding: 0.75rem !important;
  }
}

/* 47 — Troubleshooting management */
@media (max-width: 768px) {
  .troubleshooting-container {
    padding: 0.75rem !important;
  }
}

/* 48 — Logs */
@media (max-width: 768px) {
  .logs-container {
    padding: 0.75rem !important;
  }

  .logs-table-wrapper {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
}

/* 49 — Flatpickr date picker */
@media (max-width: 768px) {
  .flatpickr-calendar {
    max-width: calc(100vw - 1rem) !important;
    left: 0.5rem !important;
    right: 0.5rem !important;
  }
}

/* 50 — Platform support */
@media (max-width: 768px) {
  .platform-support-container {
    padding: 0.75rem !important;
  }

  .support-card {
    border-radius: 10px !important;
  }
}

/* =========================================================================
   §51  Dashboard legacy shell — show navbar on mobile phones
   =========================================================================
   The legacy Bootstrap navbar is hidden via .fleet-legacy-shell { display:none }
   in dashboard.css. On pages that have the sidebar drawer, this is OK because
   mobile-nav.js provides navigation. But on *other* dashboard subpages that
   use the legacy navbar, we need it visible on mobile.
   NOTE: This is only needed for pages with fleet-legacy-shell that do NOT
   have .app-sidebar — those are gracefully handled by the drawer instead.
   ========================================================================= */

/* =========================================================================
   §52  Tailwind utility overrides — prevent overflow from fixed-width classes
   ========================================================================= */
@media (max-width: 768px) {
  /* w-64 on sidebar is 16rem = 256px, already handled by drawer */

  /* ml-64 on main is 16rem, override to zero */
  .ml-64 {
    margin-left: 0 !important;
  }

  html[dir="rtl"] .ml-64 {
    margin-left: 0 !important;
  }

  /* mr-64 RTL equivalent */
  .mr-64 {
    margin-right: 0 !important;
  }

  /* Fixed widths that break mobile (Tailwind arbitrary: min-w-[10rem]) */
  [class~="min-w-[10rem]"] {
    min-width: 0 !important;
  }

  /* Padding p-8 → reduce on mobile */
  .p-8 {
    padding: 1rem !important;
  }

  .px-8 {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }

  /* Spacing utilities */
  .space-y-10 > :not([hidden]) ~ :not([hidden]) {
    margin-top: 1.5rem !important;
  }

  /* Gap utilities — tighten on mobile */
  .gap-8 {
    gap: 1rem !important;
  }

  .gap-6 {
    gap: 0.75rem !important;
  }
}

/* =========================================================================
   §53  Active flights page — inline styles & custom shell
   ========================================================================= */
@media (max-width: 768px) {
  #activeFlightsFleetShell .app-sidebar {
    display: flex !important;
    width: 280px !important;
    transform: translateX(-100%) !important;
    transition: transform 0.32s cubic-bezier(.4,0,.2,1) !important;
    z-index: 30000 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  html[dir="rtl"] #activeFlightsFleetShell .app-sidebar {
    transform: translateX(100%) !important;
  }

  #activeFlightsFleetShell .app-sidebar.mobile-nav-open {
    transform: translateX(0) !important;
    box-shadow: 8px 0 32px rgba(0,0,0,0.55) !important;
  }

  #activeFlightsFleetShell .app-main {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* Restore text labels in drawer */
  #activeFlightsFleetShell .app-sidebar .text-sm,
  #activeFlightsFleetShell .app-sidebar p,
  #activeFlightsFleetShell .app-sidebar button span:not(.material-symbols-outlined) {
    display: revert !important;
  }
}

/* =========================================================================
   §54  Client dashboard premium shell overrides
   ========================================================================= */
@media (max-width: 768px) {
  /* The client dashboard has its own shell top-bar */
  .cd-app-shell-topbar {
    padding: 0.5rem 0.75rem !important;
    min-height: auto !important;
  }

  .cd-app-shell-topbar .cd-topbar-left {
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
  }

  .cd-app-shell-topbar .cd-topbar-right {
    flex-wrap: wrap !important;
    gap: 0.35rem !important;
  }
}

/* =========================================================================
   §55  Misc — prevent overflow on dynamic elements
   ========================================================================= */
@media (max-width: 768px) {
  /* Prevent absolutely positioned elements from causing horizontal scroll */
  .fleet-dashboard,
  .fleet-premium-main,
  #fleetDashboardRoot,
  .it-page-container,
  .ct-page-container {
    overflow-x: hidden !important;
  }

  /* Ensure breadcrumbs / path labels wrap */
  .breadcrumb {
    flex-wrap: wrap !important;
    font-size: 0.82rem !important;
  }

  /* Long text in tables — ellipsis */
  .table td {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* In-shell fleet chrome — stay below mobile drawer (see dashboard.css) */
  .fleet-notify-panel {
    z-index: 9500 !important;
  }

  .fleet-toast-area {
    z-index: 9400 !important;
  }

  /* Fix stacking: drawer ~30k; modals must sit above drawer */
  .modal-backdrop {
    z-index: 31000 !important;
  }

  .modal {
    z-index: 31100 !important;
  }

  /* dashboard.html uses !important on id — beat it on small screens */
  #checklistFullscreenModal,
  #checklistFullscreenModal.show {
    z-index: 31200 !important;
  }

  #checklistFullscreenModal .modal-dialog {
    z-index: 31210 !important;
  }

  body.modal-open #checklistFullscreenModal.show ~ .modal-backdrop {
    z-index: 31190 !important;
  }

  .troubleshooting-modal {
    z-index: 31300 !important;
  }

  .troubleshooting-modal .modal-dialog {
    z-index: 31310 !important;
  }

  .troubleshooting-modal .modal-content {
    z-index: 31320 !important;
  }
}

/* ══════════════════════════════════════════════════════════════
   MOBILE FIELD VIEW — Technician / Operator on mobile (≤768px)
   Body class `mobile-field-view` is set by dashboard.js
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    /* — Hide desktop-heavy sections — */
    body.mobile-field-view #fleetHeroSection,
    body.mobile-field-view #fleetKpiGrid,
    body.mobile-field-view #fleetShortcutsRow,
    body.mobile-field-view #fleetNoPfBelowFleetSlot,
    body.mobile-field-view #fleetRecentActivitySection,
    body.mobile-field-view .fleet-status-presentation-column {
        display: none !important;
    }

    /* — Reveal quick-actions block — */
    body.mobile-field-view #mfdQuickActions {
        display: grid !important;
    }

    /* — Quick action button style — */
    .mfd-qa-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 6px;
        min-height: 72px;
        padding: 12px 8px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 12px;
        color: rgba(255, 255, 255, 0.85);
        text-decoration: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: background 0.15s;
        text-align: center;
    }

    .mfd-qa-btn:active {
        background: rgba(0, 122, 255, 0.12);
        transform: scale(0.96);
    }

    /* — Sidebar takes full width — */
    body.mobile-field-view #fleetSidebarColumnInner {
        display: block !important;
        width: 100%;
        padding: 0;
    }

    /* — Personal tasks section spacing — */
    body.mobile-field-view #fleetPersonalTasksSection {
        padding: 12px 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }

    /* — Hide priority alerts (replaced by system messages) — */
    body.mobile-field-view #fleetPriorityAlertsSection {
        display: none !important;
    }

    /* — System messages section — */
    body.mobile-field-view #mfdSystemMessages {
        display: block !important;
        padding: 12px 0;
    }

    .mfd-sys-msg {
        display: flex;
        align-items: flex-start;
        gap: 10px;
        padding: 10px 12px;
        border-radius: 8px;
        margin-bottom: 6px;
        font-size: 13px;
        line-height: 1.4;
    }
    .mfd-sys-msg--info     { background: rgba(59,130,246,0.10); border: 1px solid rgba(59,130,246,0.2); color: #93c5fd; }
    .mfd-sys-msg--warning  { background: rgba(245,158,11,0.10); border: 1px solid rgba(245,158,11,0.2); color: #fcd34d; }
    .mfd-sys-msg--critical { background: rgba(239,68,68,0.12);  border: 1px solid rgba(239,68,68,0.25); color: #f87171; }
    .mfd-sys-msg-empty     { padding: 12px; text-align: center; color: rgba(255,255,255,0.35); font-size: 13px; }
}
/* END MOBILE FIELD VIEW */
