/* MSA UI polish — 20261206a  (MSA Programming, 6 Dec 2026)
   CSS only. No data, handler, number or financial-label changes. Scoped by route (body[data-msa-path]).
   Loaded last so it wins over earlier add-ons; each block says which audit item it fixes. */

/* ---------- 9. Fonts: Poppins with a real sans-serif fallback (was: `*{font-family:poppins!important}` with no generic fallback,
   so whenever the font file is late or fails the browser painted Times-style serif). font-display:swap + local() first. ---------- */
@font-face {
  font-family: poppins; font-style: normal; font-weight: 400; font-display: swap;
  src: local("Poppins"), local("Poppins Regular"), local("Poppins-Regular"),
       url(/assets/poppins-cpxAROuN.woff2) format("woff2"), url(/assets/poppins-DFPSF5un.woff) format("woff");
}
*, *::before, *::after {
  font-family: poppins, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif !important;
}
code, pre, kbd, samp { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important; }

/* ---------- 5. Inventory + Cash Flow: remove the small boxes around every cell (same rules as the supplier tabs, s2) ---------- */
body:is([data-msa-path="/inventory"], [data-msa-path="/cash-flow"]) #root main :is(
  [class*="MUIDataTableBodyCell"], [class*="MUIDataTableHeadCell"], [class*="MUIDataTableBodyRow"],
  [class*="MUIDataTableToolbar-left"], [class*="MUIDataTableToolbar-titleRoot"], [class*="MUIDataTableToolbar-titleText"],
  [class*="MUIDataTableFilterList"], td.MuiTableCell-root, th.MuiTableCell-root,
  [class*="MUIDataTable-root"] h6) {
  border: none !important; border-width: 0 !important; box-shadow: none !important; background-image: none !important;
}
body:is([data-msa-path="/inventory"], [data-msa-path="/cash-flow"]) #root main :is([class*="MUIDataTableBodyCell"], td.MuiTableCell-root) {
  background: transparent !important; background-color: transparent !important;
}
body:is([data-msa-path="/inventory"], [data-msa-path="/cash-flow"]) #root main [class*="MUIDataTableToolbar-root"] {
  border: none !important; box-shadow: none !important; background: transparent !important; min-height: 44px !important; height: auto !important; max-height: none !important; overflow: visible !important;
  display: flex !important; flex-wrap: wrap !important; align-items: center !important; justify-content: space-between !important; gap: 8px !important; padding: 0 0 8px !important;
}
body:is([data-msa-path="/inventory"], [data-msa-path="/cash-flow"]) #root main [class*="MUIDataTableToolbar-titleText"] {
  font-size: 16px !important; font-weight: 700 !important; color: #1f2937 !important; padding: 0 !important; margin: 0 !important;
}
/* read-only values inside table cells (Inventory item name / counts) lose their input-like frame; toolbar search keeps its frame */
body:is([data-msa-path="/inventory"], [data-msa-path="/cash-flow"]) #root main .MuiTableBody-root :is(input:not([type="checkbox"]):not([type="radio"]), textarea, .MuiOutlinedInput-root, .MuiInputBase-root) {
  border: none !important; background: transparent !important; box-shadow: none !important; padding-left: 0 !important; padding-right: 0 !important;
}
body:is([data-msa-path="/inventory"], [data-msa-path="/cash-flow"]) #root main .MuiTableBody-root :is(.MuiOutlinedInput-notchedOutline, fieldset) { border: none !important; }
body:is([data-msa-path="/inventory"], [data-msa-path="/cash-flow"]) #root main .MuiTableBody-root :is(.MuiBox-root, [class*="MuiPaper-root"]):not([class*="MuiTableContainer"]) {
  border-left-width: 0 !important; border-right-width: 0 !important; border-top-width: 0 !important; box-shadow: none !important;
}
/* header cells: plain coloured header like Suppliers */
body:is([data-msa-path="/inventory"], [data-msa-path="/cash-flow"]) #root main thead th.MuiTableCell-root {
  background: #dce3ec !important; color: #1f2937 !important; font-weight: 700 !important; border-bottom: 1px solid #c5d0dc !important;
}
body:is([data-msa-path="/inventory"], [data-msa-path="/cash-flow"]) #root main thead th.MuiTableCell-root * { background: transparent !important; }
/* keep one outline on the table shell */
body:is([data-msa-path="/inventory"], [data-msa-path="/cash-flow"]) #root main [class*="MUIDataTable-paper"],
body:is([data-msa-path="/inventory"], [data-msa-path="/cash-flow"]) #root main .MuiTableContainer-root { border: 1px solid #dbe3ec !important; border-radius: 8px; }

/* ---------- 6. Users / Customers / Suppliers / Truck owners (desktop): no mid-word breaks, no white bar ---------- */
/* cause 1: `[data-msa-record-row] > * {overflow-wrap:anywhere}` made every column's min-width ~1 letter -> table squeezed words.
   cause 2: <th class="flex ..."> / <td class="flex ..."> (display:flex on a table cell) creates an anonymous cell = the white bar. */
@media (min-width: 1025px) {
  html body:is([data-msa-path="/users"], [data-msa-path="/customers"], [data-msa-path="/suppliers"], [data-msa-path="/employees"]) #root main table :is(td, th) {
    overflow-wrap: normal !important; word-break: normal !important; hyphens: manual !important;
  }
  html body:is([data-msa-path="/users"], [data-msa-path="/customers"], [data-msa-path="/suppliers"], [data-msa-path="/employees"]) #root main table thead th,
  html body:is([data-msa-path="/users"], [data-msa-path="/customers"], [data-msa-path="/suppliers"], [data-msa-path="/employees"]) #root main table tbody tr > td {
    display: table-cell !important; vertical-align: middle;
  }
  html body:is([data-msa-path="/users"], [data-msa-path="/customers"], [data-msa-path="/suppliers"], [data-msa-path="/employees"]) #root main table thead th > span { white-space: nowrap; }
  /* words never break mid-word (overflow-wrap:normal above); narrow cells keep their one-line values, long text wraps between words */
  html body:is([data-msa-path="/users"], [data-msa-path="/customers"], [data-msa-path="/suppliers"], [data-msa-path="/employees"]) #root main table tbody tr > td:is(:first-child, [class*="space-y"]) { white-space: nowrap !important; }
  html body:is([data-msa-path="/users"], [data-msa-path="/customers"], [data-msa-path="/suppliers"], [data-msa-path="/employees"]) #root main table tbody tr > td:nth-child(2) { min-width: 11rem; }
  html body:is([data-msa-path="/users"], [data-msa-path="/customers"], [data-msa-path="/suppliers"], [data-msa-path="/employees"]) #root main table :is(thead th, tbody td) { padding-left: 8px !important; padding-right: 8px !important; }
  /* badges and buttons: one line */
  html body:is([data-msa-path="/users"], [data-msa-path="/customers"], [data-msa-path="/suppliers"], [data-msa-path="/employees"]) #root main table tbody :is(button, [data-msa-user-action], [data-msa-status-pill], .MuiButton-root, .MuiChip-root) {
    white-space: nowrap !important; overflow-wrap: normal !important; word-break: normal !important;
  }
  /* Actions: one tidy row, no wasted 17rem */
  html body:is([data-msa-path="/users"], [data-msa-path="/customers"], [data-msa-path="/suppliers"], [data-msa-path="/employees"]) #root main table :is(thead th:last-child, tbody tr > td:last-child) {
    min-width: 0 !important; width: 1% !important; white-space: nowrap !important; padding-right: 12px;
  }
  html body:is([data-msa-path="/users"], [data-msa-path="/customers"], [data-msa-path="/suppliers"], [data-msa-path="/employees"]) #root main table tbody tr > td:last-child > * {
    display: inline-flex !important; vertical-align: middle; margin: 2px 6px 2px 0 !important; white-space: nowrap !important;
  }
  /* status cell: pill + button stacked but never squeezed */
  html body:is([data-msa-path="/users"], [data-msa-path="/customers"], [data-msa-path="/suppliers"], [data-msa-path="/employees"]) #root main table tbody tr > td[class*="space-y"] > * { display: block; width: max-content; max-width: none; }
  html body:is([data-msa-path="/users"], [data-msa-path="/customers"], [data-msa-path="/suppliers"], [data-msa-path="/employees"]) #root main table tbody tr > td[class*="space-y"] > * + * { margin-top: 6px; }
}

/* ---------- 7. Profile card: fit the screen, wrap the name ---------- */
body[data-msa-path="/profile"] #root main .w-\[650px\] { width: 100% !important; max-width: 650px !important; box-sizing: border-box !important; min-width: 0 !important; }
body[data-msa-path="/profile"] #root main section, body[data-msa-path="/profile"] #root main section > div { min-width: 0 !important; max-width: 100% !important; box-sizing: border-box; }
body[data-msa-path="/profile"] #root main h3 { white-space: normal !important; overflow: visible !important; text-overflow: clip !important; overflow-wrap: anywhere; line-height: 1.2 !important; font-size: clamp(1.35rem, 6.2vw, 2.25rem) !important; }
body[data-msa-path="/profile"] #root main .text-center > div { overflow-wrap: anywhere; min-width: 0; max-width: 100%; flex-wrap: wrap; }
@media (max-width: 700px) {
  body[data-msa-path="/profile"] #root main { overflow-x: hidden !important; }
  body[data-msa-path="/profile"] #root main .py-2.px-4 { padding-left: 12px !important; padding-right: 12px !important; width: 100% !important; max-width: 100% !important; box-sizing: border-box; }
  body[data-msa-path="/profile"] #root main .w-\[650px\] { margin-top: 5rem !important; }
}

/* ---------- 8. Fleet Map: layout, font, buttons, loading state (content/tracking untouched) ---------- */
#msa-fleet-board { font-family: poppins, ui-sans-serif, system-ui, sans-serif !important; color: #1f2937 !important; box-sizing: border-box; }
#msa-fleet-board h2 { font-size: 20px !important; font-weight: 700 !important; line-height: 1.25 !important; margin: 0 !important; }
#msa-fleet-board > div:first-child { align-items: center; row-gap: 10px !important; }
#msa-fleet-board > div:first-child > div { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
#msa-fleet-board button[data-act] {
  display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 6px 12px !important; border: 1px solid #c5d0dc !important;
  border-radius: 8px !important; background: #fff !important; color: #243b53 !important; font-weight: 600; font-size: 13px; line-height: 1.2; cursor: pointer; white-space: nowrap;
}
#msa-fleet-board button[data-act]:hover { background: #eef3f9 !important; }
#msa-fleet-board button[data-act="follow"][aria-pressed="true"], #msa-fleet-board button[data-act="follow"].active { background: #e8f1fb !important; border-color: #3b82f6 !important; color: #1d4ed8 !important; }
#msa-fleet-board button[data-act="close"] { border-color: #f1b3a4 !important; color: #b42318 !important; }
#msa-fleet-board [data-live] { margin: 8px 0 !important; padding: 6px 10px; border-radius: 8px; background: #f1f5f9; color: #334155; font-size: 13px; }
#msa-fleet-board [data-q], #msa-fleet-board [data-motion] { height: 38px; padding: 6px 10px !important; border: 1px solid #c5d0dc; border-radius: 8px; background: #fff; font-size: 14px; box-sizing: border-box; }
#msa-fleet-board [data-q] { flex: 1 1 220px; min-width: 0 !important; }
#msa-fleet-board label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
#msa-fleet-board [data-filter-count] { color: #334155; font-size: 13px; }
#msa-fleet-board [data-list] > button[data-truck] { border-radius: 10px !important; box-shadow: 0 1px 2px rgba(15,23,42,.06); font-size: 13px; line-height: 1.45; cursor: pointer; }
#msa-fleet-board [data-detail], #msa-fleet-board [data-note-host] { border-radius: 10px; border: 1px solid #e2e8f0; font-size: 13px; }
#msa-fleet-board [data-note-host]:empty { display: none; }
#msa-fleet-board [data-map] { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid #cbd5e1; min-height: 240px; }
/* clear loading state: shown until the first map tile is on screen (set by msa-ui-polish js) */
#msa-fleet-board [data-map][data-msa-map-state="loading"]::after {
  content: "Loading map…"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 800;
  background: rgba(241,245,249,.85); color: #334155; font-weight: 600; font-size: 14px; pointer-events: none;
}
#msa-fleet-board [data-map][data-msa-map-state="slow"]::after {
  content: "Map is still loading — truck list is available on the left"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 16px; z-index: 800;
  background: rgba(254,243,199,.9); color: #92400e; font-weight: 600; font-size: 14px; pointer-events: none;
}
/* msa-fleet.js adds the sidebar width as left padding although <main> is already shifted by the sidebar -> 272px blank gap */
@media (min-width: 600px) { #msa-fleet-board { padding-left: 16px !important; } }
@media (max-width: 900px) {
  #msa-fleet-board { padding-left: 12px !important; padding-right: 12px !important; padding-top: 16px !important; }
  #msa-fleet-board [data-layout] { grid-template-columns: minmax(0, 1fr) !important; }
  #msa-fleet-board [data-layout] > div:last-child { order: -1; }
  #msa-fleet-board [data-map] { height: 320px !important; }
  #msa-fleet-board button[data-act] { flex: 1 1 auto; }
}

/* ---------- 10. Supplier Details ---------- */
/* 10a. Balance Transfers (OUT/IN) lists: Actions column was too narrow for three labelled buttons (cut to "V…");
   rows had their own scrollbars inside the list scrollbar (double scrollbars). Give Actions room, let them wrap, no inner scroll. */
@media (min-width: 1025px) {
  body[data-msa-path^="/users/suppliers/"] #root main [class*="_balanceTable_"] { grid-template-columns: minmax(40px, .35fr) minmax(130px, 1.3fr) minmax(110px, 1fr) minmax(250px, 1.35fr) !important; }
}
body[data-msa-path^="/users/suppliers/"] #root main [data-msa-record-row][class*="_balanceTable_"],
body[data-msa-path^="/users/suppliers/"] #root main [data-msa-record-heading][class*="_balanceTable_"] { overflow: visible !important; }
body[data-msa-path^="/users/suppliers/"] #root main [data-msa-record-list] { overflow-x: hidden !important; }
body[data-msa-path^="/users/suppliers/"] #root main [data-msa-record-cell="actions"] { flex-wrap: wrap !important; justify-content: center !important; gap: 6px !important; padding-left: 0 !important; min-width: 0 !important; }
body[data-msa-path^="/users/suppliers/"] #root main [data-msa-record-cell="actions"] > div { display: inline-flex; }
body[data-msa-path^="/users/suppliers/"] #root main [data-msa-record-cell="actions"] button { min-width: 0 !important; min-height: 32px !important; }
/* 10a'. Action buttons said "View" for Edit and Delete too (one CSS label for every icon button). Use each button's own aria-label. */
body[data-msa-path^="/users/suppliers/"] #root main [data-msa-user-action="view"][aria-label^="Edit"]::after { content: "Edit"; }
body[data-msa-path^="/users/suppliers/"] #root main [data-msa-user-action="view"][aria-label^="Delete"]::after { content: "Delete"; }
body[data-msa-path^="/users/suppliers/"] #root main [data-msa-user-action="view"][aria-label^="Delete"] {
  color: #b42318 !important; background: #fdecec !important; border-color: #f5b5ae !important;
}
body[data-msa-path^="/users/suppliers/"] #root main [data-msa-user-action="view"][aria-label^="Edit"] {
  color: #92400e !important; background: #fff6e8 !important; border-color: #f3c98b !important;
}
/* 10b. Summary cards (TIGO Supplier Balance etc.): fixed 140px cards in a 4-up flex row clipped long TZS amounts / pushed the last card out. */
body[data-msa-path^="/users/suppliers/"] #root main .MuiGrid-item.MuiGrid-grid-sm-true:has([class*="h-[140px]"]) {
  flex: 1 1 210px !important; min-width: min(210px, 100%) !important; max-width: 100% !important; box-sizing: border-box;
}
body[data-msa-path^="/users/suppliers/"] #root main [class*="h-[140px]"] { min-width: 0; box-sizing: border-box; }
body[data-msa-path^="/users/suppliers/"] #root main [class*="h-[140px]"] :is(h4, h5, h6, p, span) { overflow-wrap: anywhere; }
/* received-invoice amounts: keep "TZS 3,295,630.00" on one line */
body[data-msa-path^="/users/suppliers/"] #root main td, body[data-msa-path^="/users/suppliers/"] #root main [data-msa-record-cell] { overflow-wrap: break-word; }
/* one scrollbar: tab panels and cards do not scroll on their own */
body[data-msa-path^="/users/suppliers/"] #root main .MuiBox-root[role="tabpanel"], body[data-msa-path^="/users/suppliers/"] #root main [role="tabpanel"] > .MuiBox-root { overflow-x: visible; }

/* ---------- 11. Stacking / spacing (mobile + desktop) ---------- */
/* Tabs (N) pill: position set by msa-ui-polish js (right after the real title text; second header row on phones) */
#msa-workspace-toggle.msa-polish-pos { left: var(--msa-tabs-left, 150px) !important; top: var(--msa-tabs-top, 8px) !important; z-index: 1202 !important; }
body[data-msa-path="/maintenance"] #msa-workspace-toggle.msa-polish-pos { z-index: 1302 !important; }
/* floating shortcut buttons sit below the header/drawer layer and leave scroll room so they never hide the last rows */
#msa-sul-btn { z-index: 1100 !important; }
#msa-hr-open { z-index: 1100 !important; }
body:not([data-msa-owner="1"]) #root main { padding-bottom: max(88px, calc(72px + env(safe-area-inset-bottom))) !important; }
@media (max-width: 700px) {
  #msa-sul-btn { bottom: calc(8px + env(safe-area-inset-bottom)) !important; left: 8px !important; right: auto !important; min-height: 36px !important; padding: 6px 12px !important; font-size: 12px !important; opacity: .96; }
  #msa-hr-open { right: 8px !important; bottom: calc(8px + env(safe-area-inset-bottom)) !important; }
  /* Inventory (and any page with a tabs + actions header): tabs row got max-width calc(100% - 500px) = 0 on phones, so the action buttons sat where ORDERS should be */
  #root main div[style*="calc(100% - 500px)"] { max-width: 100% !important; flex: 1 1 100% !important; }
  #root main div.flex.flex-row.justify-between[style*="flex-wrap: nowrap"]:has(> div[style*="calc(100% - 500px)"]),
  #root main div.flex.flex-row.justify-between:has(> div[style*="calc(100% - 500px)"]) { flex-wrap: wrap !important; height: auto !important; row-gap: 8px !important; }
  #root main div.flex[style*="min-width: 480px"] { width: 100% !important; min-width: 0 !important; max-width: 100% !important; flex: 1 1 100% !important; flex-wrap: wrap !important; justify-content: flex-start !important; gap: 8px !important; padding: 0 8px 8px !important; box-sizing: border-box; }
  #root main div.flex[style*="min-width: 480px"] > div { flex: 1 1 130px; min-width: 0; }
  #root main div.flex[style*="min-width: 480px"] [class*="w-[160px]"] { width: 100% !important; min-width: 0; height: 64px !important; }
}

/* ---------- 12a. Trucks cards (desktop): toggle + text overlapped inside a 356px card ---------- */
@media (min-width: 1025px) {
body[data-msa-path="/trucks"] #root main [data-msa-fleet-compact] [data-msa-fleet-layout] { gap: 12px !important; flex-wrap: nowrap; }
body[data-msa-path="/trucks"] #root main [data-msa-fleet-compact] [data-msa-fleet-image] { width: 96px !important; flex: 0 0 96px; }
body[data-msa-path="/trucks"] #root main [data-msa-fleet-compact] [data-msa-fleet-info] { width: auto !important; flex: 1 1 0; min-width: 0; }
body[data-msa-path="/trucks"] #root main [data-msa-fleet-compact] [data-msa-fleet-info] > .flex.flex-row.justify-between { flex-wrap: wrap; gap: 6px; }
body[data-msa-path="/trucks"] #root main [data-msa-fleet-compact] [data-msa-fleet-info] .text-right { text-align: left; max-width: 100%; }
body[data-msa-path="/trucks"] #root main [data-msa-fleet-compact] [data-msa-fleet-info] .text-right button { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
body[data-msa-path="/trucks"] #root main [data-msa-fleet-compact] .truncate { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
body[data-msa-path="/trucks"] #root main [data-msa-fleet-compact] [data-msa-fleet-info] .py-1 > .flex { flex-wrap: wrap; gap: 6px; }
body[data-msa-path="/trucks"] #root main [data-msa-fleet-compact] [data-msa-fleet-info] .py-1 .w-\[110px\] { flex: 0 0 110px; }
}

/* ---------- 12b. Maintenance overlay: header sits above the overlay and its title is not covered (pill moved by js) ---------- */
body[data-msa-path="/maintenance"] header.MuiAppBar-root { z-index: 1301 !important; }
#msa-maint { z-index: 1300; }

/* ---------- 12c. Sidebar: only the active route is highlighted (js sets data-msa-nav-active on exactly one item) ---------- */
.MuiDrawer-paper li.MuiListItem-root { background-color: transparent !important; }
.MuiDrawer-paper li.MuiListItem-root[data-msa-nav-active="1"] { background-color: #43A515 !important; }

/* ===== 5b. Cash Flow: tab content sits in a fixed h-40 (160px) box, so cards overflow and the "Maelezo" details block hides behind them ===== */
body[data-msa-path="/cash-flow"] #root main .MuiGrid-container > .MuiGrid-item > .h-40 { height: auto !important; min-height: 10rem; }

/* ===== 10b. Supplier Details (mobile): the vertical sub-tabs (Sent / Received balances) take a 75px empty strip and push the list right; lay them out as a row ===== */
@media (max-width: 700px) {
  body[data-msa-path^="/users/suppliers/"] #root main .MuiBox-root:has(> .MuiTabs-vertical) { flex-direction: column !important; }
  body[data-msa-path^="/users/suppliers/"] #root main .MuiTabs-vertical { width: 100% !important; min-width: 0 !important; height: auto !important; border-right: 0 !important; border-bottom: 1px solid #e5e7eb; }
  body[data-msa-path^="/users/suppliers/"] #root main .MuiTabs-vertical .MuiTabs-scroller { overflow-x: auto !important; overflow-y: hidden !important; }
  body[data-msa-path^="/users/suppliers/"] #root main .MuiTabs-vertical .MuiTabs-flexContainerVertical { flex-direction: row !important; }
  body[data-msa-path^="/users/suppliers/"] #root main .MuiTabs-vertical .MuiTabs-indicator { display: none; }
  body[data-msa-path^="/users/suppliers/"] #root main .MuiTabs-vertical { flex-direction: row !important; }
  body[data-msa-path^="/users/suppliers/"] #root main .MuiTabs-vertical > .MuiTabScrollButton-root { display: none !important; }
  body[data-msa-path^="/users/suppliers/"] #root main .MuiTabs-vertical > .MuiTabs-scroller { height: auto !important; width: 100% !important; flex: 1 1 auto; }
  body[data-msa-path^="/users/suppliers/"] #root main .MuiTabs-vertical .MuiTab-root { max-width: none; min-width: 0; white-space: nowrap; }
  body[data-msa-path^="/users/suppliers/"] #root main .MuiBox-root:has(> .MuiTabs-vertical) > div.w-\[100\%\] { width: 100% !important; min-width: 0 !important; }
}


/* =====================================================================================
   ROUND 2 (b): re-audit 18:20 fixes. Everything above is unchanged from "a".
   ===================================================================================== */

/* ---- R2-a. Trucks (<=1300px): the Add Truck / Add Trailer buttons (w-[30%] box, justify-end) overflowed to the left over the TRUCKS / TRAILERS tabs inside a fixed 160px box ---- */
@media (max-width: 1300px) {
  body[data-msa-path="/trucks"] #root main .h-40:has(> .flex.flex-row.justify-between > .w-\[30\%\] .border-dashed) { height: auto !important; min-height: 0 !important; }
  body[data-msa-path="/trucks"] #root main div.flex.flex-row.justify-between:has(> .w-\[30\%\] .border-dashed) { flex-wrap: wrap !important; height: auto !important; row-gap: 8px; align-items: center; }
  body[data-msa-path="/trucks"] #root main div.flex.flex-row.justify-between:has(> .w-\[30\%\] .border-dashed) > :first-child { flex: 1 1 100%; min-width: 0; max-width: 100%; }
  body[data-msa-path="/trucks"] #root main div.flex.flex-row.justify-between:has(> .w-\[30\%\] .border-dashed) > .w-\[30\%\]:has(.border-dashed) { width: 100% !important; flex: 1 1 100%; justify-content: flex-start !important; flex-wrap: wrap; gap: 10px !important; padding: 0 8px 8px; box-sizing: border-box; }
  body[data-msa-path="/trucks"] #root main div.flex.flex-row.justify-between:has(> .w-\[30\%\] .border-dashed) .MuiTabs-root { min-height: 48px !important; height: auto !important; }
  body[data-msa-path="/trucks"] #root main div.flex.flex-row.justify-between:has(> .w-\[30\%\] .border-dashed) .MuiTab-root { height: 48px !important; min-height: 48px !important; }
}

/* ---- R2-b. Cash Flow header row: tabs (584px) + five action buttons (709px) in one nowrap row overflowed the card; buttons now wrap onto their own line ---- */
body[data-msa-path="/cash-flow"] #root main div.flex.flex-row.justify-between:has(> div.flex.flex-row.gap-5.justify-end) { flex-wrap: wrap !important; height: auto !important; row-gap: 8px; align-items: center; }
body[data-msa-path="/cash-flow"] #root main div.flex.flex-row.justify-between:has(> div.flex.flex-row.gap-5.justify-end) > :first-child { flex: 1 1 520px; min-width: 0; max-width: 100%; }
body[data-msa-path="/cash-flow"] #root main div.flex.flex-row.justify-between:has(> div.flex.flex-row.gap-5.justify-end) > div.flex.flex-row.gap-5.justify-end { flex: 0 1 auto; flex-wrap: wrap; gap: 8px !important; margin-left: auto; padding: 0 8px 4px; max-width: 100%; }

/* ---- R2-c. Wide tables scroll inside their card (the page itself must not). The js marks the scroller with data-msa-hscroll; the edge that still has more content fades, and the scrollbar is visible ---- */
[data-msa-hscroll] { max-width: 100% !important; scrollbar-width: thin; scrollbar-color: #94a3b8 #e2e8f0; overscroll-behavior-x: contain; }
[data-msa-hscroll]::-webkit-scrollbar { height: 10px; }
[data-msa-hscroll]::-webkit-scrollbar-track { background: #e2e8f0; border-radius: 6px; }
[data-msa-hscroll]::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 6px; }
[data-msa-hscroll="start"]  { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 44px), rgba(0,0,0,.12)); mask-image: linear-gradient(90deg, #000 calc(100% - 44px), rgba(0,0,0,.12)); }
[data-msa-hscroll="middle"] { -webkit-mask-image: linear-gradient(90deg, rgba(0,0,0,.12), #000 44px, #000 calc(100% - 44px), rgba(0,0,0,.12)); mask-image: linear-gradient(90deg, rgba(0,0,0,.12), #000 44px, #000 calc(100% - 44px), rgba(0,0,0,.12)); }
[data-msa-hscroll="end"]    { -webkit-mask-image: linear-gradient(90deg, rgba(0,0,0,.12), #000 44px); mask-image: linear-gradient(90deg, rgba(0,0,0,.12), #000 44px); }
/* the scroller inside a card never lets the card (or page) grow wider than the viewport */
body[data-msa-path="/revenue"] #root main section, body[data-msa-path^="/users/suppliers/"] #root main section { max-width: 100%; box-sizing: border-box; min-width: 0; }

/* ---- R2-d. Customers / Suppliers / Truck Owners summary chips (inside a divider): wrap instead of running off the right edge ---- */
@media (max-width: 900px) {
  #root main .MuiDivider-root.MuiDivider-withChildren:has(.MuiChip-root) { display: block !important; border: 0 !important; white-space: normal !important; }
  #root main .MuiDivider-root.MuiDivider-withChildren:has(.MuiChip-root)::before, #root main .MuiDivider-root.MuiDivider-withChildren:has(.MuiChip-root)::after { display: none !important; }
  #root main .MuiDivider-root.MuiDivider-withChildren:has(.MuiChip-root) > .MuiDivider-wrapper { display: flex !important; flex-wrap: wrap; gap: 8px; padding: 0 !important; white-space: normal; }
  #root main .MuiDivider-root.MuiDivider-withChildren:has(.MuiChip-root) .MuiChip-root { height: auto !important; min-height: 32px; max-width: 100%; }
  #root main .MuiDivider-root.MuiDivider-withChildren:has(.MuiChip-root) .MuiChip-label { white-space: normal !important; overflow: visible !important; text-overflow: clip !important; overflow-wrap: anywhere; padding-top: 6px; padding-bottom: 6px; }
}

/* ---- R2-e. Floating buttons: hidden while scrolling down (class set by js), page keeps bottom room ---- */
#msa-sul-btn, #msa-supplier-transfer, #msa-hr-open { transition: opacity .18s ease, transform .18s ease; }
body.msa-fab-hidden #msa-sul-btn, body.msa-fab-hidden #msa-supplier-transfer, body.msa-fab-hidden #msa-hr-open { opacity: 0 !important; transform: translateY(16px); pointer-events: none !important; }
#msa-supplier-transfer { z-index: 1100 !important; }
body[data-msa-path^="/users/suppliers/"] #root main { padding-bottom: 150px !important; }
@media (max-width: 700px) {
  #msa-supplier-transfer { right: 8px !important; bottom: calc(52px + env(safe-area-inset-bottom)) !important; }
}

/* ---- R2-f. Personal Expenses (and every MUIDataTable on phones/tablets): sticky 212px Actions column covered Amount..Description; toolbar icons collided with the search box ---- */
@media (max-width: 900px) {
  #root main table :is(th, td):last-child { right: auto !important; }
  #root main [class*="MUIDataTableToolbar-root"] { flex-wrap: wrap !important; height: auto !important; min-height: 48px; row-gap: 2px; }
  #root main [class*="MUIDataTableToolbar-left"] { flex: 1 1 100% !important; min-width: 0 !important; }
  #root main [class*="MUIDataTableToolbar-actions"] { flex: 1 1 100% !important; display: flex !important; justify-content: flex-end; }
}

/* ---- R2-g. Reports: card is a fixed-height column, so a 3-line title ran into the MANAGE button ---- */
body[data-msa-path="/reports"] #root main .MuiGrid-container > .MuiGrid-item > .MuiBox-root { height: auto !important; min-height: 120px; gap: 10px; justify-content: space-between; padding-bottom: 14px; box-sizing: border-box; }
body[data-msa-path="/reports"] #root main .MuiGrid-container > .MuiGrid-item > .MuiBox-root > p { margin: 0; }

/* ---- R2-h. Any tabs + actions header row (Trucks, Inventory STOCKS/ORDERS, ...) on phones/tablets: the actions box (w-[30%], inline min-width 480px) wraps under the tabs instead of covering them, whatever inline style the page gives it ---- */
@media (max-width: 900px) {
  #root main div.flex.flex-row.justify-between:has(> .w-\[30\%\] .border-dashed) { flex-wrap: wrap !important; height: auto !important; row-gap: 8px; }
  #root main div.flex.flex-row.justify-between:has(> .w-\[30\%\] .border-dashed) > :first-child { flex: 1 1 100% !important; min-width: 0 !important; max-width: 100% !important; }
  #root main div.flex.flex-row.justify-between > .w-\[30\%\].flex:has(.border-dashed) { width: 100% !important; min-width: 0 !important; max-width: 100% !important; flex: 1 1 100% !important; flex-wrap: wrap !important; justify-content: flex-start !important; gap: 8px !important; box-sizing: border-box; }
}
@media (max-width: 700px) {
  #msa-supplier-transfer { height: 40px !important; min-height: 40px !important; width: auto !important; padding: 0 14px !important; font-size: 13px !important; border-radius: 20px !important; }
}

#msa-workspace-toggle.msa-pill-away { opacity: 0 !important; pointer-events: none !important; }

@media (max-width: 700px) {
  body[data-msa-path="/cash-flow"] #root main div.flex.flex-row.justify-between:has(> div.flex.flex-row.gap-5.justify-end) > div.flex.flex-row.gap-5.justify-end { margin: 0 auto; justify-content: center; }
}

@media (max-width: 900px) {
  #root main div.flex[style*="min-width: 480px"] > div:empty { display: none; }
}

/* =====================================================================================
   ROUND 3 (c): stop remaining overlaps only. Colours, fonts and placement stay the same.
   ===================================================================================== */

/* ---- R3-1. Mobile: room at the bottom of the page so the floating buttons (HR, Supplier users, Transfer balance) never cover the last content when you stand still ---- */
@media (max-width: 700px) {
  body:not([data-msa-owner="1"]) #root main {
    padding-bottom: max(152px, calc(140px + env(safe-area-inset-bottom))) !important;
  }
  body[data-msa-path^="/users/suppliers/"] #root main {
    padding-bottom: max(200px, calc(188px + env(safe-area-inset-bottom))) !important;
  }
  /* the site footer sits after main and was sliding under the buttons */
  body:not([data-msa-owner="1"]) #root main + * {
    padding-bottom: max(88px, calc(76px + env(safe-area-inset-bottom))) !important;
  }
}

/* ---- R3-2. Mobile Reports: cards shrink to their title width; make every card the same full width ---- */
@media (max-width: 900px) {
  body[data-msa-path="/reports"] #root main .MuiGrid-container > .MuiGrid-item {
    flex: 1 1 100% !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box;
  }
  body[data-msa-path="/reports"] #root main .MuiGrid-container > .MuiGrid-item > .MuiBox-root {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }
}

/* ---- R3-3. Desktop Driver Requests: the in-page "Driver Requests" heading (and Refresh) sat under the fixed header because the usual toolbar spacer is hidden on this page. Push the page block down only; do not change the header title (another job). ---- */
@media (min-width: 701px) {
  body[data-msa-path="/driver-requests"] #msa-drq {
    padding-top: 72px !important;
  }
}
