/* ================================================================
   MyFleet on a phone. Loaded on every page after mf-ui.css; everything
   here is inside the phone breakpoint, the desktop never sees it.
   The shell: the rail becomes a bottom tab bar (mf_tabbar_html), the
   page scrolls as one, the bar stays above the iPhone home indicator.
   Page-specific rules live in their own blocks below.
   ================================================================ */

.mf-tabbar, .mf-more { display: none; }

@media (max-width: 640px) {
  :root { --mf-tabbar-h: 60px; }

  /* ── shell ─────────────────────────────────────────────── */
  .mf-rail { display: none !important; }
  .mf-app { display: block; height: auto; min-height: 100vh; min-height: 100dvh; overflow: visible; }
  .mf-main { padding: 12px 12px calc(var(--mf-tabbar-h) + env(safe-area-inset-bottom) + 16px); overflow: visible; }

  .mf-tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1060;
    height: calc(var(--mf-tabbar-h) + env(safe-area-inset-bottom)); padding: 0 4px env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, .94); -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--mf-border);
  }
  .mf-tb {
    flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border: 0; background: none; padding: 6px 2px 4px; font: 500 10.5px/1.1 var(--mf-font); color: var(--mf-text-3);
    text-decoration: none; -webkit-tap-highlight-color: transparent; cursor: pointer;
  }
  /* page styles style "a", "i" and "span" in their own ways: the bar holds its shape whatever the page */
  nav.mf-tabbar > .mf-tb { height: auto !important; align-self: stretch; margin: 0 !important; box-shadow: none !important; border-radius: 0 !important; }
  nav.mf-tabbar > .mf-tb > i { font-size: 21px !important; line-height: 1 !important; width: auto !important; height: auto !important; margin: 0 !important; }
  nav.mf-tabbar > .mf-tb > span { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 10.5px !important; line-height: 1.25 !important; height: auto !important; padding: 0 0 1px !important; margin: 0 !important; }
  .mf-more .mf-more__item > i { font-size: 20px !important; line-height: 1 !important; }
  .mf-tb[aria-current="page"] { color: var(--mf-accent); font-weight: 600; }
  .mf-tb:hover, .mf-tb:focus { text-decoration: none; color: var(--mf-text); }
  .mf-tb[aria-current="page"]:hover { color: var(--mf-accent); }

  /* "More": a sheet from the bottom */
  .mf-more { display: block; position: fixed; inset: 0; z-index: 1050; background: rgba(17, 24, 39, .4); }
  .mf-more[hidden] { display: none; }
  .mf-more__sheet {
    position: absolute; left: 0; right: 0; bottom: 0; background: var(--mf-surface); border-radius: 18px 18px 0 0;
    padding: 8px 12px calc(var(--mf-tabbar-h) + env(safe-area-inset-bottom) + 8px); box-shadow: 0 -10px 30px rgba(0,0,0,.15);
    animation: mf-sheet-in .18s ease-out;
  }
  @keyframes mf-sheet-in { from { transform: translateY(24px); opacity: .4; } to { transform: none; opacity: 1; } }
  .mf-more__grab { width: 38px; height: 4px; border-radius: 4px; background: var(--mf-border); margin: 4px auto 10px; }
  .mf-more__who { font-size: 12.5px; color: var(--mf-text-muted); padding: 0 8px 6px; }
  .mf-more__item {
    display: flex; align-items: center; gap: 14px; min-height: 50px; padding: 0 10px; border-radius: 12px;
    font-size: 16px; font-weight: 500; color: var(--mf-text); text-decoration: none;
  }
  .mf-more__item i { font-size: 20px; color: var(--mf-text-3); width: 24px; text-align: center; }
  .mf-more__item:active, .mf-more__item:hover { background: var(--mf-surface-2); text-decoration: none; color: var(--mf-text); }
  .mf-more__item[aria-current="page"] { background: var(--mf-accent-soft); color: var(--mf-accent-text); }
  .mf-more__item[aria-current="page"] i { color: var(--mf-accent); }
  html.mf-more-open { overflow: hidden; }

  /* things that sat at the bottom right now sit above the tab bar */
  .mf-toast { bottom: calc(var(--mf-tabbar-h) + env(safe-area-inset-bottom) + 10px) !important; }
  #mf-demo-bar { bottom: calc(var(--mf-tabbar-h) + env(safe-area-inset-bottom) + 10px) !important; }
  #mf-viewas { top: auto !important; bottom: calc(var(--mf-tabbar-h) + env(safe-area-inset-bottom) + 10px) !important; }

  /* ── general phone rules ───────────────────────────────── */
  /* tap targets */
  .mf-ui button, .mf-ui .mf-btn, .mf-ui a.mf-btn { min-height: 40px; }
  /* no input zoom on iOS: 16px fields */
  .mf-ui input:not([type=checkbox]):not([type=radio]):not([type=range]), .mf-ui select, .mf-ui textarea { font-size: 16px; }
  /* long words and codes never push the page sideways */
  .mf-main { overflow-wrap: anywhere; }
  .mf-main img, .mf-main canvas, .mf-main svg { max-width: 100%; }
}

/* ================================================================
   Operations (template-operations.php, js/mf-operations.js mobileInit)
   ================================================================ */
.ops-mview, .ops-sheet-x, .ops-sheet-bd { display: none; }

@media (max-width: 640px) {
  /* top: greeting, then search · bell · + in one row */
  .mf-ops .mf-topbar { gap: 10px; }
  .mf-ops .ops-hello { font-size: 20px; letter-spacing: -.01em; }
  .mf-ops .mf-topbar > .mf-row { flex-wrap: nowrap !important; gap: 8px; }
  .mf-ops .mf-topbar .mf-search { flex: 1 1 auto; min-width: 0; }
  /* "+" drawn by the button itself: an icon-font glyph sits off-centre in a square button */
  .mf-ops #ops-new-trip { position: relative; font-size: 0; width: 44px; min-width: 44px; height: 44px; padding: 0; gap: 0; flex: none; }
  .mf-ops #ops-new-trip i { display: none; }
  .mf-ops #ops-new-trip::before, .mf-ops #ops-new-trip::after { content: ""; position: absolute; left: 50%; top: 50%; width: 18px; height: 2.5px;
    margin: -1.25px 0 0 -9px; border-radius: 2px; background: currentColor; }
  .mf-ops #ops-new-trip::after { transform: rotate(90deg); }
  .mf-ops #ops-bell { flex: none; width: 44px; }

  /* clocks: all five zones in one compact row — the dispatcher needs every one */
  .mf-ops .ops-clocks { order: 0; width: 100%; margin: 0; display: grid !important; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
  .mf-ops .ops-clocks .ops-clock { flex-direction: column; align-items: center; justify-content: center; gap: 1px; height: auto; min-width: 0; padding: 5px 2px !important; }
  .mf-ops .ops-clocks .ops-clock__zone { padding: 0 !important; border: 0 !important; text-align: center; display: block; }
  .mf-ops .ops-clocks .ops-clock__zone { align-items: center; }
  .mf-ops .ops-clocks .ops-clock__zone b { font-size: 10px; white-space: nowrap; }
  .mf-ops .ops-clocks .ops-clock__zone span { display: none; }
  .mf-ops .ops-clocks .ops-clock__time { font-size: 13px !important; white-space: nowrap; }
  .mf-ops .ops-clocks .ops-clock__time small { font-size: 9px; }

  /* summary: a strip you swipe */
  .mf-ops .mf-kpis { display: flex !important; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -12px; padding: 0 12px 2px; scrollbar-width: none; }
  .mf-ops .mf-kpis::-webkit-scrollbar { display: none; }
  .mf-ops .mf-kpis > .mf-kpi { flex: 0 0 auto; min-width: 156px; max-width: 220px; scroll-snap-align: start; }
  .mf-ops .mf-kpi__sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* Trucks · Map · Trips · History */
  .ops-mview { display: flex; gap: 4px; position: sticky; top: 0; z-index: 30; padding: 6px 0; margin: 0 -12px; padding-left: 12px; padding-right: 12px;
    background: var(--mf-bg); }
  .ops-mview button { flex: 1 1 0; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 6px; height: 40px; border: 1px solid var(--mf-border);
    background: var(--mf-surface); border-radius: 10px; font: 600 13px var(--mf-font); color: var(--mf-text-3); padding: 0 6px; }
  .ops-mview button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ops-mview button[aria-selected="true"] { background: var(--mf-text); border-color: var(--mf-text); color: #fff; }

  .mf-ops .mf-workspace[data-mview] > .mf-col-side,
  .mf-ops .mf-workspace[data-mview] > .mf-col-center { display: none !important; }
  .mf-ops .mf-workspace[data-mview="list"] > .mf-col-side { display: flex !important; }
  .mf-ops .mf-workspace[data-mview="map"] > .mf-col-center,
  .mf-ops .mf-workspace[data-mview="trips"] > .mf-col-center,
  .mf-ops .mf-workspace[data-mview="history"] > .mf-col-center { display: flex !important; }
  .mf-ops .mf-workspace[data-mview] > .mf-col-center > .mf-card__header { display: none; }
  /* the list, trips and history grow with the page and scroll with it — no box of their own
     (the template caps a pane at 520px under 760px: that cap is for tablets, not here) */
  .mf-ops .mf-workspace > .mf-col-side, .mf-ops .mf-workspace > .mf-col-center { height: auto !important; max-height: none !important; overflow: visible !important; }
  .mf-ops .mf-col-side .mf-panel__scroll, .mf-ops .mf-col-center .ops-pane.mf-panel__scroll { max-height: none !important; overflow: visible !important; }

  /* history: the week in one compact row, not four tall tiles */
  .mf-ops #ops-history > .mf-stats { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 8px !important; }
  .mf-ops #ops-history .mf-stat { min-width: 0; padding: 8px 10px; gap: 0; flex: none; }
  .mf-ops #ops-history .mf-stat .mf-icon-tile { display: none; }
  .mf-ops #ops-history .mf-stat__label { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mf-ops #ops-history .mf-stat__value { font-size: 16px; }
  .mf-ops #ops-history .mf-stat__sub { font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mf-ops #ops-history .mf-stat:last-child { grid-column: 1 / -1; display: flex; padding: 6px 10px; }
  .mf-ops #ops-history .mf-stat:last-child .mf-stat__body { flex: 1 !important; display: flex !important; flex-direction: row !important; align-items: center !important; justify-content: space-between !important; gap: 10px; width: 100%; text-align: left; }
  /* history cards: tighter — trip and truck on one line */
  .mf-ops #ops-history tr { padding: 10px 12px; gap: 4px 10px; }
  .mf-ops #ops-history td:first-child .mf-sub { display: inline; margin-left: 6px; }
  .mf-ops #ops-history .mf-stat:last-child .mf-bars { margin-top: 0 !important; height: 22px; }
  .mf-ops .mf-workspace[data-mview="map"] .ops-map { min-height: calc(100dvh - 250px); }
  .mf-ops .ops-side-head .mf-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .mf-ops .ops-side-head .mf-chips::-webkit-scrollbar { display: none; }
  .mf-ops .ops-side-head .mf-chip { flex: none; }

  /* the tapped truck: a sheet from the bottom */
  .mf-ops .mf-workspace > .mf-col-detail {
    display: flex !important; flex-direction: column; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1065;
    max-height: 88dvh; height: auto; margin: 0; border-radius: 18px 18px 0 0; box-shadow: 0 -12px 32px rgba(0,0,0,.18);
    transform: translateY(110%); transition: transform .22s ease-out; visibility: hidden;
  }
  html.ops-sheet-open .mf-ops .mf-workspace > .mf-col-detail { transform: none; visibility: visible; }
  .mf-ops .mf-col-detail > .mf-card__header { display: flex; align-items: center; gap: 8px; padding-top: 14px; position: relative; }
  .mf-ops .mf-col-detail > .mf-card__header::before { content: ""; position: absolute; top: 6px; left: 50%; width: 38px; height: 4px; margin-left: -19px; border-radius: 4px; background: var(--mf-border); }
  .mf-ops .mf-col-detail > .mf-card__header .mf-tabs { flex: 1; min-width: 0; }
  .mf-ops .mf-col-detail .ops-pane { overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: env(safe-area-inset-bottom); }
  .mf-ops .ops-sheet-x { display: inline-flex; flex: none; }
  html.ops-sheet-open .ops-sheet-bd { display: block; position: fixed; inset: 0; z-index: 1064; background: rgba(17, 24, 39, .4); }
  html.ops-sheet-open { overflow: hidden; }

  /* New trip and the trip card: the whole screen, above the tab bar */
  .mf-ops .ops-drawer, .mf-ops .ops-drawer.is-wide { width: 100vw; z-index: 1070; border-left: 0; }
}

@media (max-width: 640px) {
  /* active trips and history: a card per row instead of a wide table */
  .mf-ops #ops-trips .mf-table-wrap, .mf-ops #ops-history .mf-table-wrap { overflow: visible; border: 0; }
  .mf-ops #ops-trips table, .mf-ops #ops-history table { display: block; width: 100%; border: 0; }
  .mf-ops #ops-trips thead, .mf-ops #ops-history thead { display: none; }
  .mf-ops #ops-trips tbody, .mf-ops #ops-history tbody { display: flex; flex-direction: column; gap: 8px; padding: 8px; }
  .mf-ops #ops-trips tr, .mf-ops #ops-history tr {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 10px; padding: 12px 14px;
    background: var(--mf-surface); border: 1px solid var(--mf-border); border-radius: 12px;
  }
  .mf-ops #ops-trips tr.is-selected { border-color: var(--mf-accent); box-shadow: inset 0 0 0 1px var(--mf-accent); }
  .mf-ops #ops-trips td, .mf-ops #ops-history td { display: block; padding: 0 !important; border: 0 !important; min-width: 0 !important; text-align: left !important; background: none !important; }
  /* trips: #, status / route / progress / ETA / miles · pay · $/mi */
  .mf-ops #ops-trips td:nth-child(1) { grid-column: 1 / 3; font-size: 16px; }
  .mf-ops #ops-trips td:nth-child(8) { grid-column: 3; grid-row: 1; justify-self: end; }
  .mf-ops #ops-trips td:nth-child(2), .mf-ops #ops-trips td:nth-child(3), .mf-ops #ops-trips td:nth-child(4) { grid-column: 1 / -1; }
  .mf-ops #ops-trips td:nth-child(4) { font-size: 13px; color: var(--mf-text-3); }
  .mf-ops #ops-trips td:nth-child(5)::before { content: "Miles"; }
  .mf-ops #ops-trips td:nth-child(6)::before { content: "Pay"; }
  .mf-ops #ops-trips td:nth-child(7)::before { content: "$/mi"; }
  /* history: trip / route / done · miles · gross · net */
  .mf-ops #ops-history td:nth-child(1) { grid-column: 1 / 3; }
  .mf-ops #ops-history td:nth-child(3) { grid-column: 3; grid-row: 1; justify-self: end; color: var(--mf-text-3); font-size: 13px; }
  .mf-ops #ops-history td:nth-child(2) { grid-column: 1 / -1; }
  .mf-ops #ops-history td:nth-child(4)::before { content: "Miles"; }
  .mf-ops #ops-history td:nth-child(5)::before { content: "Gross"; }
  .mf-ops #ops-history td:nth-child(6)::before { content: "Net"; }
  .mf-ops #ops-trips td:nth-child(n+5)::before, .mf-ops #ops-history td:nth-child(n+4)::before {
    display: block; font-size: 11.5px; font-weight: 500; color: var(--mf-text-muted); margin-bottom: 1px; }
  .mf-ops #ops-trips td:nth-child(n+5), .mf-ops #ops-history td:nth-child(n+4) { font-weight: 600; color: var(--mf-text); }
}

/* ================================================================
   The truck page (inc/mf-dash.php, js/mf-dash.js)
   Most important first: who and where → engine and codes → fuel →
   alerts → location and trip → tires → weight → remote → activity.
   ================================================================ */
@media (max-width: 640px) {
  .mf-dash .db-main { padding: 10px 10px 24px; }
  .mf-dash:not(.mf-dash--driver) .db-main { padding-bottom: calc(var(--mf-tabbar-h) + env(safe-area-inset-bottom) + 20px); }
  .mf-dash .db-top { margin-bottom: 8px; }

  .mf-dash .db-grid { display: grid !important; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .mf-dash .db-grid > * { grid-column: 1 / -1 !important; grid-row: auto !important; min-height: 0 !important; }
  .mf-dash .db-grid > .db-ring { grid-column: auto !important; }
  .mf-dash .db-hero { order: 1; } .mf-dash .db-minis { order: 2; } .mf-dash .db-docs { order: 3; }
  .mf-dash #db-fuel { order: 4; } .mf-dash #db-def { order: 5; } .mf-dash .db-al { order: 6; }
  .mf-dash .db-map { order: 7; } .mf-dash .db-tires { order: 8; } .mf-dash .db-axl { order: 9; }
  .mf-dash .db-feed { order: 10; } .mf-dash .db-remote { order: 20; }   /* remote control at the very bottom, as on the desktop */

  .mf-dash .db-c { border-radius: 18px; padding: 14px; gap: 10px; }

  /* who and where: number, status, meta; Profile / Service as round icon buttons in the corner */
  .mf-dash .db-hero { position: relative; padding: 14px; }
  .mf-dash .db-hero > .db-ch { flex-direction: column; gap: 4px; padding-right: 84px; }
  .mf-dash .db-hn { gap: 6px 8px; }
  .mf-dash .db-hn b { font-size: 22px; }
  .mf-dash .db-hn .m { font-size: 14px; flex-basis: 100%; order: 1; margin-top: -2px; }
  .mf-dash .db-hn .db-st, .mf-dash .db-hn .db-mod { order: 2; }
  .mf-dash .db-hn .db-mod { margin-left: 0; }            /* lines up with the status, not 6px to the right of it */
  .mf-dash .db-meta { gap: 4px 12px; font-size: 12.5px; }
  .mf-dash .db-acts { position: absolute; top: 12px; right: 12px; gap: 6px; }
  .mf-dash .db-acts .db-btn { font-size: 0; width: 38px; height: 38px; padding: 0; justify-content: center; gap: 0; }
  .mf-dash .db-acts .db-btn i { font-size: 17px; margin: 0; }

  /* the photo: a strip, not half the screen */
  .mf-dash .db-ph { min-height: 0; border-radius: 14px; }
  .mf-dash .db-ph img { width: 100%; height: 170px; max-height: none; border-radius: 14px; box-shadow: none; }
  .mf-dash .db-ph--empty { flex-direction: row; gap: 10px; height: 64px; min-height: 64px; font-size: 13px; }
  .mf-dash .db-ph--empty > i { font-size: 24px; }
  .mf-dash .db-ph--empty .db-btn { font-size: 12.5px; padding: 6px 12px; }

  .mf-dash .db-facts { grid-template-columns: 1fr 1fr; gap: 8px; }
  .mf-dash .db-facts div { padding: 8px 10px; border-radius: 12px; }
  .mf-dash .db-facts b { font-size: 14px; }

  /* engine tiles */
  .mf-dash .db-minis { gap: 10px; }
  .mf-dash .db-mini { border-radius: 18px; padding: 12px 13px; }
  .mf-dash .db-mv { font-size: 23px; }
  .mf-dash .db-mv.txt { font-size: 18px; }
  .mf-dash .db-dpf { gap: 4px 14px; }

  /* fuel and DEF side by side, their rings on one level */
  .mf-dash .db-ring { padding: 12px; }
  .mf-dash .db-ring > .db-ch { min-height: 44px; align-items: flex-start; gap: 6px; }
  .mf-dash .db-ring .db-sub { white-space: nowrap; }
  .mf-dash .db-mpg { padding: 3px 7px; border-radius: 9px; font-size: 9.5px; line-height: 1.15; gap: 3px; flex: none; }
  .mf-dash .db-mpg b { font-size: 14px; }
  .mf-dash .db-ringbox { width: 108px; height: 108px; margin: 0 auto; }
  .mf-dash .db-rv b { font-size: 24px; }
  .mf-dash .db-rv small { font-size: 12px; }
  .mf-dash .db-rv span { max-width: 74px; text-align: center; font-size: 10px; line-height: 1.15; }   /* "~1,298 mi range" stays inside the ring */
  .mf-dash .db-ring h2 { font-size: 13.5px; }

  .mf-dash .db-mapbox, .mf-dash .db-map .db-mapbox { height: 220px; min-height: 220px; }
  .mf-dash .db-rbtns { grid-template-columns: 1fr 1fr; }
  .mf-dash .db-rbtns button { height: 58px; }
}

/* ================================================================
   Fleet (inc/mf-fleet.php, js/mf-fleet.js)
   ================================================================ */
.fl-brl { display: none; }
@media (max-width: 640px) {
  .mf-fleet .mf-main { padding-left: 10px; padding-right: 10px; }
  /* readiness: a card per truck, its nine bricks in a 3 × 3 grid with their names */
  .mf-fleet .fl-legend { gap: 6px 10px; }
  .mf-fleet .fl-rwrap { overflow: visible; }
  .mf-fleet .fl-rt, .mf-fleet .fl-rt tbody { display: block; width: 100%; }
  .mf-fleet .fl-rt thead { display: none; }
  .mf-fleet .fl-rt tbody { display: flex; flex-direction: column; gap: 10px; }
  .mf-fleet .fl-rt tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 6px; padding: 12px; border: 1px solid var(--mf-border); border-radius: 14px; background: var(--mf-surface); }
  .mf-fleet .fl-rt td { display: block; padding: 0 !important; min-width: 0; }
  .mf-fleet .fl-rt td:first-child { grid-column: 1 / -1; }
  .mf-fleet .fl-rt td.fl-verdict { grid-column: 1 / -1; grid-row: 2; text-align: left; padding: 0 !important; font-size: 13px; }
  .mf-fleet .fl-truck { min-width: 0; }
  .mf-fleet .fl-tn { white-space: normal; }
  /* the column's icon sits inside its brick: icon + value, three to a row */
  .mf-fleet .fl-rt td:not(:first-child):not(.fl-verdict) { position: relative; }
  .mf-fleet .fl-brl { display: block; position: absolute; left: 8px; top: 50%; transform: translateY(-50%); font-size: 0; pointer-events: none; z-index: 1; opacity: .75; }
  .mf-fleet .fl-brl i { font-size: 12px; color: currentColor; }
  .mf-fleet .fl-br { min-width: 0; height: 30px; font-size: 12px; padding: 0 6px 0 24px; justify-content: flex-start; overflow: hidden; text-overflow: ellipsis; }
  .mf-fleet .fl-br > i { display: none; }
  .mf-fleet .fl-br.none { background: var(--mf-surface-2); }
  .mf-fleet .fl-g2, .mf-fleet .fl-g2b { grid-template-columns: minmax(0, 1fr); }
}

/* ================================================================
   Analytics (template-analytics.php, js/mf-analytics.js clipLong)
   ================================================================ */
.an-more { display: none; }
@media (max-width: 640px) {
  .mf-an .an-main { padding: 12px 10px calc(var(--mf-tabbar-h) + env(safe-area-inset-bottom) + 20px); }
  .mf-an #an-periods { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .mf-an #an-periods::-webkit-scrollbar { display: none; }
  .mf-an #an-periods .mf-tab { flex: none; }
  .mf-an .an-kpis { gap: 8px; }
  .mf-an tbody.is-clipped > tr:nth-child(n+5) { display: none !important; }
  .an-more { display: block; width: 100%; height: 42px; margin-top: 8px; border: 1px solid var(--mf-border); border-radius: 10px;
    background: var(--mf-surface); font: 600 14px var(--mf-font); color: var(--mf-accent-text); }
}

/* ================================================================
   Service, truck profile, settings, BOL, weight
   ================================================================ */
@media (max-width: 640px) {
  /* every app page: the old site's body padding is not for the app; the page colour runs to the bottom */
  body.mf-ui { padding: 0 !important; margin: 0 !important; overflow-x: clip; background: var(--mf-bg); }

  /* truck profile: one page that scrolls, nothing cut at the screen's height */
  .mf-truck .mf-app, .mf-truck .tk-main { height: auto !important; max-height: none !important; overflow: visible !important; }
  .mf-truck .tk-main { width: 100%; max-width: none; padding: 12px 12px calc(var(--mf-tabbar-h) + env(safe-area-inset-bottom) + 20px); }
  .mf-truck .tk-trips a > b { white-space: nowrap; flex: none; }   /* "$1,475" in one piece */

  /* Service: the five counters as a strip you swipe */
  .mf-sv .sv-kpis { display: flex !important; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0; padding: 0 0 2px; scrollbar-width: none; }
  .mf-sv .sv-kpis::-webkit-scrollbar { display: none; }
  .mf-sv .sv-kpi { flex: 0 0 auto; min-width: 140px; scroll-snap-align: start; }

  /* truck profile: a photo strip; with no photo just a small band */
  .mf-truck .tk-photo { height: 180px; }
  .mf-truck .tk-photo:not(:has(img)) { height: 72px; font-size: 30px; }

  /* weight: ruler numbers never break into two lines */
  .mf-weight .ruler-label { white-space: nowrap; font-size: 10px; }

  /* settings: the section tabs scroll sideways without a bar */
  .mf-profile [role="tablist"], .mf-profile .pf-tabs, .mf-profile .pf-nav { scrollbar-width: none; }
}

/* truck profile, tablet and phone: the photo stays inside its band (a grid item's 100% height
   meant the picture's own height, so it ran over the number, the model and the VIN) */
@media (max-width: 900px) {
  .mf-truck .tk-photo { overflow: hidden; }
  .mf-truck .tk-photo:has(img) { display: block; }
  .mf-truck .tk-photo img { width: 100%; height: 100%; object-fit: cover; }
}

/* ================================================================
   Room under the content, on every app page and every screen size:
   the last card never sits on the bottom edge (or under the tab bar)
   — there is always a bit more to scroll.
   ================================================================ */
:root { --mf-end-room: 88px; }
body.mf-ui:not(.mf-ops) .mf-main, body.mf-ui .pf-body { padding-bottom: var(--mf-end-room) !important; }
/* Operations on a desktop fits the screen; its lists scroll inside their panels */
.mf-ops .mf-panel__scroll { padding-bottom: 24px; }
@media (max-width: 640px) {
  :root { --mf-end-room: 72px; }
  body.mf-ui:not(.mf-x) .mf-main, body.mf-ui:not(.mf-x) .pf-body { padding-bottom: calc(var(--mf-tabbar-h) + env(safe-area-inset-bottom) + var(--mf-end-room)) !important; }
  body.mf-ui.mf-dash--driver:not(.mf-x) .mf-main { padding-bottom: calc(env(safe-area-inset-bottom) + var(--mf-end-room)) !important; }   /* the driver's pages have no tab bar */
  .mf-ops .mf-panel__scroll { padding-bottom: 0; }
  .mf-ops .mf-col-detail .ops-pane { padding-bottom: calc(env(safe-area-inset-bottom) + 24px); }
  .mf-more__sheet { padding-bottom: calc(var(--mf-tabbar-h) + env(safe-area-inset-bottom) + 16px); }
}
