/* Fleet 1232: phone fixes for the top bar, form fields / tap targets, Live Map
   and the Routes/ZIPs panel. Everything here is inside one phone-width media
   query so desktop, tablet and landscape layouts are untouched. Selectors use
   "html body:not(#_)" so they outrank the layered !important rules they fix.
   Companion script: fleet-mobile-fixes-1232.js (ZIP bottom-sheet handle). */
@media (max-width:720px){
  /* ---------- 1. Top bar: fit 390px, nothing removed ---------- */
  html:not(#_),html body:not(#_){overflow-x:clip!important}
  html body:not(#_) .layout>.main>.top{
    display:flex!important;flex-wrap:nowrap!important;align-items:center!important;
    gap:4px!important;width:100%!important;max-width:100vw!important;min-width:0!important;
    padding:6px 8px!important;overflow:visible!important;box-sizing:border-box!important;
  }
  html body:not(#_) .top>.fleet-top-brand-wrap{
    flex:1 1 auto!important;width:auto!important;min-width:0!important;max-width:none!important;
    overflow:hidden!important;margin:0!important;padding:0 2px!important;
  }
  html body:not(#_) .top>.fleet-top-brand-wrap .adi-top-brand,
  html body:not(#_) .top>.fleet-top-brand-wrap .adi-top-brand svg,
  html body:not(#_) .top>.fleet-top-brand-wrap .adi-top-brand img{
    max-width:100%!important;width:auto!important;height:24px!important;min-width:0!important;
  }
  /* Search collapses to a 44px icon and opens across the bar when focused. */
  html body:not(#_) .top>.search{
    position:static!important;flex:0 0 44px!important;width:44px!important;min-width:44px!important;
    height:44px!important;margin:0!important;padding:0!important;
  }
  html body:not(#_) .top>.search>input#global-search{
    width:44px!important;min-width:44px!important;height:44px!important;min-height:44px!important;
    padding:0!important;margin:0!important;border-radius:12px!important;font-size:16px!important;
    color:transparent!important;caret-color:transparent!important;cursor:pointer!important;
    background:transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='m16 16 4 4'/%3E%3C/svg%3E") center/20px no-repeat!important;
    border:1px solid transparent!important;box-shadow:none!important;
  }
  html body:not(#_) .top>.search>input#global-search::placeholder{color:transparent!important}
  html body:not(#_) .top>.search:focus-within>input#global-search{
    position:absolute!important;left:8px!important;right:8px!important;top:7px!important;z-index:30!important;
    width:auto!important;padding:0 12px 0 40px!important;color:inherit!important;caret-color:auto!important;
    cursor:text!important;background-color:var(--panel,#fff)!important;background-position:12px center!important;
    border-color:rgba(100,116,139,.35)!important;box-shadow:0 6px 18px rgba(15,23,42,.12)!important;
  }
  html[data-theme="dark"] body:not(#_) .top>.search:focus-within>input#global-search{background-color:#111a22!important}
  html body:not(#_) .top>.search:focus-within>input#global-search::placeholder{color:#94a3b8!important}
  html body:not(#_) .top>.search>#global-results{
    position:absolute!important;left:8px!important;right:8px!important;top:56px!important;
    width:auto!important;max-width:none!important;z-index:31!important;
  }
  html body:not(#_) .top>.fleet-head-tools{flex:0 0 auto!important;display:flex!important;gap:2px!important;margin:0!important}
  html body:not(#_) .top .head-tool{
    width:44px!important;min-width:44px!important;height:44px!important;min-height:44px!important;
    padding:0!important;margin:0!important;
  }
  /* Account menu stays reachable as an avatar button. */
  html body:not(#_) .top>.account-wrap{
    display:flex!important;flex:0 0 44px!important;align-items:center!important;justify-content:center!important;
    width:44px!important;min-width:44px!important;height:44px!important;padding:0!important;margin:0!important;
    border:0!important;background:transparent!important;box-shadow:none!important;cursor:pointer!important;
  }
  html body:not(#_) .top>.account-wrap .account-copy{display:none!important}
  html body:not(#_) .top>.account-wrap .account-avatar{width:34px!important;height:34px!important;min-width:34px!important;margin:0!important}

  /* ---------- 2. Fields: 16px so iOS doesn't zoom; tap targets 44px ---------- */
  html body:not(#_) input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]):not([type=file]):not([type=hidden]),
  html body:not(#_) select,html body:not(#_) textarea{font-size:16px!important}
  html body:not(#_) input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]):not([type=file]):not([type=hidden]),
  html body:not(#_) select{min-height:44px!important}
  html body:not(#_) button,html body:not(#_) .btn,html body:not(#_) [role=button],html body:not(#_) input[type=button],
  html body:not(#_) input[type=submit],html body:not(#_) input[type=reset]{min-height:44px!important}
  /* Width is only raised on controls the script measured as narrower than 44px,
     so text buttons in tab rows keep their natural width. */
  html body:not(#_) .fleet-tap44{min-width:44px!important}
  /* Checkboxes and radios: 44px hit area, 20px drawn box, same footprint in dense rows. */
  html body:not(#_) input[type=checkbox]:not(.fleet-module-switch input),html body:not(#_) input[type=radio]:not(.fleet-module-switch input){
    -webkit-appearance:none!important;appearance:none!important;position:relative!important;flex:0 0 auto!important;
    width:44px!important;height:44px!important;min-width:44px!important;min-height:44px!important;
    margin:-12px!important;padding:0!important;border:0!important;background:transparent!important;
    box-shadow:none!important;outline-offset:-10px!important;vertical-align:middle!important;cursor:pointer!important;
  }
  html body:not(#_) input[type=checkbox]:not(.fleet-module-switch input)::before,html body:not(#_) input[type=radio]:not(.fleet-module-switch input)::before{
    content:""!important;position:absolute!important;left:12px!important;top:12px!important;width:20px!important;height:20px!important;
    box-sizing:border-box!important;border:1.5px solid #94a3b8!important;border-radius:5px!important;background:#fff!important;
  }
  html body:not(#_) input[type=radio]:not(.fleet-module-switch input)::before{border-radius:50%!important}
  html body:not(#_) input[type=checkbox]:not(.fleet-module-switch input):checked::before,
  html body:not(#_) input[type=radio]:not(.fleet-module-switch input):checked::before{border-color:#1f2937!important;background:#1f2937!important}
  html body:not(#_) input[type=checkbox]:not(.fleet-module-switch input):checked::after{
    content:""!important;position:absolute!important;left:19px!important;top:15px!important;width:6px!important;height:11px!important;
    border:solid #fff!important;border-width:0 2px 2px 0!important;transform:rotate(45deg)!important;
  }
  html body:not(#_) input[type=radio]:not(.fleet-module-switch input):checked::after{
    content:""!important;position:absolute!important;left:19px!important;top:19px!important;width:6px!important;height:6px!important;
    border-radius:50%!important;background:#fff!important;
  }
  html body:not(#_) input[type=checkbox]:disabled,html body:not(#_) input[type=radio]:disabled{opacity:.5!important;cursor:default!important}
  html[data-theme="dark"] body:not(#_) input[type=checkbox]:not(.fleet-module-switch input)::before,
  html[data-theme="dark"] body:not(#_) input[type=radio]:not(.fleet-module-switch input)::before{background:#0f172a!important;border-color:#64748b!important}
  html[data-theme="dark"] body:not(#_) input[type=checkbox]:not(.fleet-module-switch input):checked::before,
  html[data-theme="dark"] body:not(#_) input[type=radio]:not(.fleet-module-switch input):checked::before{background:#e2e8f0!important;border-color:#e2e8f0!important}
  html[data-theme="dark"] body:not(#_) input[type=checkbox]:not(.fleet-module-switch input):checked::after{border-color:#0f172a!important}
  html[data-theme="dark"] body:not(#_) input[type=radio]:not(.fleet-module-switch input):checked::after{background:#0f172a!important}
  html body:not(#_) .leaflet-touch .leaflet-bar a{width:44px!important;height:44px!important;line-height:44px!important}

  /* Drawer opens above the map toolbar and the ZIP sheet. */
  html body.fleet-mnav-open:not(#_) .layout>.side{z-index:5000!important}
  html body.fleet-mnav-open:not(#_)>.fleet-mnav-backdrop{z-index:4990!important}

  /* ---------- 3. Live Map: full-width, full-height map ---------- */
  html body[data-page="tracking"]:not(#_) .layout{display:block!important;grid-template-columns:none!important}
  html body[data-page="tracking"]:not(#_) .layout>.main{width:100%!important;min-width:0!important;max-width:100vw!important;margin:0!important}
  html body[data-page="tracking"]:not(#_) .track-map{
    position:fixed!important;left:0!important;right:0!important;top:56px!important;bottom:0!important;
    width:100%!important;height:auto!important;min-height:0!important;max-height:none!important;
    margin:0!important;border:0!important;border-radius:0!important;z-index:1!important;
  }
  @supports (height:100dvh){
    html body[data-page="tracking"]:not(#_) .track-map{bottom:auto!important;height:calc(100dvh - 56px)!important}
  }
  html body[data-page="tracking"]:not(#_) .track-map>#map{
    position:absolute!important;inset:0!important;width:100%!important;height:100%!important;
    min-height:0!important;max-height:none!important;border-radius:0!important;
  }
  /* One menu button: the top bar's. The toolbar becomes a scrollable chip row. */
  html body:not(#_)>.tracking-focus-toolbar .tracking-menu-btn,
  html body:not(#_)>.tracking-focus-toolbar .toolbar-sep,
  html body:not(#_)>.tracking-focus-toolbar .tracking-toolbar-title{display:none!important}
  html body:not(#_)>.tracking-focus-toolbar{
    position:fixed!important;top:62px!important;left:8px!important;right:8px!important;
    width:auto!important;max-width:none!important;height:auto!important;min-height:0!important;
    display:flex!important;flex-wrap:nowrap!important;align-items:center!important;gap:6px!important;
    padding:6px!important;overflow-x:auto!important;overflow-y:hidden!important;
    -webkit-overflow-scrolling:touch;scrollbar-width:none;overscroll-behavior-x:contain;
    border-radius:14px!important;box-sizing:border-box!important;z-index:1200!important;
  }
  html body:not(#_)>.tracking-focus-toolbar::-webkit-scrollbar{display:none}
  html body:not(#_)>.tracking-focus-toolbar>*{flex:0 0 auto!important}
  html body:not(#_)>.tracking-focus-toolbar button{min-height:44px!important;white-space:nowrap!important}
  /* Map panels fit the phone width below the toolbar. */
  html body[data-page="tracking"]:not(#_) .track-list,
  html body[data-page="tracking"]:not(#_) .track-stops,
  html body[data-page="tracking"]:not(#_) .map-layers,
  html body[data-page="tracking"]:not(#_) .track-detail{
    left:8px!important;right:8px!important;width:auto!important;max-width:none!important;min-width:0!important;
    max-height:calc(100dvh - 136px)!important;box-sizing:border-box!important;
  }
  html body[data-page="tracking"]:not(#_) .track-list,
  html body[data-page="tracking"]:not(#_) .track-stops,
  html body[data-page="tracking"]:not(#_) .map-layers,
  html body[data-page="tracking"]:not(#_) .content>.kpis{top:126px!important}
  html body[data-page="tracking"]:not(#_) .content>.kpis{left:8px!important;right:8px!important;width:auto!important;max-width:none!important}
  /* An older phone rule hid the driver list outright; it now opens like the other panels. */
  html body[data-page="tracking"]:not(#_) .track-list{display:block!important;bottom:auto!important;height:calc(100dvh - 136px)!important}

  /* ---------- 4. Routes/ZIPs: collapsible bottom sheet ---------- */
  html body:not(#_)>aside.fleet-zip-command.fleet-zsheet{
    position:fixed!important;left:0!important;right:0!important;bottom:0!important;top:auto!important;
    width:100%!important;max-width:none!important;height:auto!important;max-height:78dvh!important;
    margin:0!important;padding-top:0!important;padding-bottom:env(safe-area-inset-bottom,0px)!important;
    border-radius:16px 16px 0 0!important;overflow-y:auto!important;overscroll-behavior:contain;
    box-sizing:border-box!important;box-shadow:0 -8px 28px rgba(15,23,42,.18)!important;
    transform:none!important;transition:transform .22s ease!important;z-index:1150!important;
  }
  html body:not(#_)>aside.fleet-zip-command.fleet-zsheet.is-collapsed{
    overflow:hidden!important;transform:translateY(calc(100% - 60px - env(safe-area-inset-bottom,0px)))!important;
  }
  html body:not(#_)>aside.fleet-zip-command.fleet-zsheet>.fleet-zsheet-handle{
    position:sticky!important;top:0!important;z-index:5!important;display:flex!important;flex-direction:column!important;
    align-items:center!important;justify-content:center!important;gap:6px!important;flex:0 0 auto!important;
    width:100%!important;min-height:60px!important;margin:0!important;padding:8px 16px 10px!important;
    border:0!important;border-bottom:1px solid rgba(100,116,139,.18)!important;border-radius:16px 16px 0 0!important;
    background:inherit!important;background-color:var(--panel,#fff)!important;color:inherit!important;
    font-family:inherit!important;font-size:14px!important;font-weight:600!important;line-height:1.2!important;cursor:pointer!important;touch-action:manipulation;
  }
  html[data-theme="dark"] body:not(#_)>aside.fleet-zip-command.fleet-zsheet>.fleet-zsheet-handle{background-color:#111a22!important}
  html body:not(#_) .fleet-zsheet-handle .fleet-zsheet-grip{display:block;width:40px;height:5px;border-radius:3px;background:#cbd5e1}
  html body:not(#_) .fleet-zsheet-handle .fleet-zsheet-hint{font-weight:500;font-size:12px;color:#64748b}
  html body:not(#_)>aside.fleet-zip-command.fleet-zsheet>.zip-head{position:static!important}
  html body.fleet-zsheet-active:not(#_) .map-status{bottom:68px!important}
}
/* The sheet handle exists only on phones; never show it at wider widths. */
.fleet-zsheet-handle{display:none}
