/* =====================================================================
   mobile.css — dedicated responsive layer for the app
   ---------------------------------------------------------------------
   Loaded LAST on every page (injected right before </head>) so its
   small-screen overrides win on equal specificity without !important.

   This file holds the GLOBAL mobile baseline that fixes the cross-cutting
   breakages found in the 2026-06-13 mobile audit:
     - the shared .page-header bar never wrapped on small screens
     - the base .form-grid stayed hard 2-column with no breakpoint
     - many wide data tables sat in overflow:hidden wrappers (or no
       wrapper at all) and overflowed / clipped on phones
   Plus a few page-specific fixes (kanban board, copilot tabs).

   Page-by-page bespoke tuning beyond this baseline is tracked separately;
   see the audit notes. Keep page-specific rules at the bottom, commented
   with the page name.
   ---------------------------------------------------------------------
   GLOBAL INJECTION: as of the 2026 mobile pass this file is injected before
   </head> on EVERY rendered page by the res.render wrapper in server.js, so it
   always loads LAST and its overrides win without !important. (A per-view
   <link> may also exist on some pages — harmless duplicate.)

   BREAKPOINT CONVENTION — put new responsive rules on these lines:
     <=1024px  tablet  — multi-column grids drop to 2-up
     <=768px   MOBILE  — off-canvas drawer nav, single-column grids, scrollable
                         tabs/toolbars, table scroll wrappers   (primary line)
     <=480px   phone   — tighter .view padding, stacked toolbars, bigger taps
   ===================================================================== */

/* ---------------------------------------------------------------------
   A. Mobile nav — off-canvas drawer (replaces the desktop rail on phones)
   The topbar hamburger (#nav-toggle in x-topbar) toggles body.nav-open; the
   sidebar then slides in over the content with a dismiss scrim. Base bits live
   here (not app.css) to keep the app.css↔examples drift gate clean.
   --------------------------------------------------------------------- */
.nav-toggle {
  display: none;            /* shown only on mobile, and only when a sidebar exists */
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;               /* edit-panels.css gives every <button> 12px 24px — that squeezed the icon to 0 wide on the tray/review/fixing pages */
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: var(--topbar-fg);  /* it sits on the topbar — follow the bar's ink, not the page's */
  border-radius: var(--r-8, 9px);
  cursor: pointer;
}
.nav-toggle:hover { background: var(--topbar-hover); color: var(--topbar-fg); }
.nav-toggle svg,.nav-toggle i[data-lucide] { width: 22px; height: 22px; }
.nav-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-slow) var(--ease);
  z-index: 39;              /* under .sidebar (40) + .topbar (50), over content */
}
@media (max-width: 768px) {
  body.has-rail .nav-toggle { display: inline-flex; }
  .sidebar {
    width: 248px;
    transform: translateX(-100%);
    transition: transform var(--dur-slow) var(--ease-in-out);
  }
  /* Show labels + badges + group headers in the open drawer (override the
     desktop hover-collapse so the expanded rail is fully readable). */
  .sidebar .navlink span,
  .sidebar .navlink .badge,
  .sidebar .nav-group { opacity: 1; }
  /* the drawer opens under the top bar, which keeps the logo on a phone — the head
     stays only for Edit sidebar's icon (the pin is for wide windows only) */
  .sidebar .rail-head { display: none; }
  .sidebar .rail-head:has(.rail-edit) { display: flex; height: 40px; }
  .sidebar .rail-head .rail-logo { display: none; }
  .sidebar .rail-head:not(:has(.rail-edit)) ~ .nav { padding-top: 6px; }
  body.nav-open .sidebar { transform: translateX(0); box-shadow: var(--elev-4, 0 12px 40px rgba(0, 0, 0, 0.3)); }
  /* The drawer IS the open rail: a folded group is folded from the moment it opens.
     app.css folds one only under :hover, which a drawer opened by the ☰ hasn't got until
     you touch it, so its entries showed and then jumped shut (2026-10-24,
     rail-fold.browser.test.js). */
  .sidebar:not(.is-editing) .nav-sec.is-closed .nav-items:not(:focus-within) { display: none; }
  body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  /* On <html>, not <body>: app.css keeps html{overflow-y:scroll}, so a body
     overflow would clip the page to one screen and jump it to the top. The
     scrollbar this removes is paid back by x-topbar's drawer script
     (--scroll-lock-gap, see .topbar in app.css). */
  html.nav-open { overflow: hidden; }
  .main { margin-left: 0; }
  body > .app-footer { margin-left: 0; }
  .view { padding: 20px 16px 50px; }
}

/* ---------------------------------------------------------------------
   B. Overflow containment — the PAGE itself never scrolls sideways on a phone.
   Root cause of "content too wide": flex/grid children default to min-width:auto,
   so wide content (tables, long SKUs/URLs, fixed-px boxes) grows their track past
   the viewport. Cap everything to the screen and let containers shrink. Intended
   inner scrollers (table wrappers, tab strips) keep their own overflow-x and
   scroll WITHIN their box — not the page.
   --------------------------------------------------------------------- */
@media (max-width: 768px) {
  /* Backstop: the page never scrolls sideways. clip (not hidden) so it doesn't
     break position:sticky; off-canvas drawer sits off-screen left, unaffected. */
  html { overflow-x: clip; }
  /* Cards + their contents stay within the viewport; long unbreakable strings wrap. */
  .card, .pad, .kpi { max-width: 100%; overflow-wrap: anywhere; }
  /* ...which lets a flex item shrink below its longest word — so a card head's
     actions wrap onto their own line instead of squeezing the title to one
     letter per line (the Mail-in card on a purchase). */
  .card-head { flex-wrap: wrap; }
  /* …and the title's own words stay whole: a note beside it (<h3>… Contact <span
     class="cap">…</span></h3>) squeezed it to "Conta / ct" (Console → Prospects,
     2026-10-29). break-word still breaks a word too long for a line of its own; it
     only stops the title shrinking below its words. */
  .card-head h3 { overflow-wrap: break-word; }
  /* The icon keeps its size, and a note beside the title gives up its room first (down to
     its longest word) — the title no longer shrinks to fit it ("Look / around on / eBay"
     beside a shrunken icon). */
  .card-head h3 > svg, .card-head h3 > i[data-lucide] { flex: none; }
  .card-head h3 > .cap { flex-shrink: 99; }
  /* Inside a box, text sits 12px in — the tray editor's panels' inset (edit-tray.css,
     `.panel` at ≤860px). Cards held it 20px in, so CRM's pages read with a wider
     edge than the tray page (owner, 2026-10-10). src/ui/phone-layout-consistency.browser.test.js */
  .card-head { padding: 12px; }
  .pad { padding: 14px 12px; }
  /* …and a group of buttons in it wraps too: three buttons in one row ran off
     the card (Scanner → Open Orders' "Change Location", 2026-10-09). */
  .card-head > :not(h1, h2, h3, h4):has(> .btn) { flex-wrap: wrap; min-width: 0; max-width: 100%; }
  /* Let grid/flex layouts AND their direct children shrink to fit instead of
     growing a track to their content (the min-width:auto default is the culprit). */
  .grid, .field-grid, .split, .kpis, .tiles, .toolbar, .actions-row,
  .grid > *, .field-grid > *, .split > *,
  .kpis > *, .tiles > *, .toolbar > *, .actions-row > * {
    min-width: 0;
  }
  /* Media + preformatted blocks never exceed their container. */
  img, svg, video, canvas { max-width: 100%; }
  pre { max-width: 100%; overflow-x: auto; }
  /* A <fieldset> defaults to min-width:min-content, so it grows to its widest
     child instead of shrinking with its panel — every editor panel (tray /
     review / fixing) wraps its fields in one, and a three-column preview grid
     inside it dragged the whole panel past the card's edge (2026-09-26). */
  fieldset { min-width: 0; }
}

/* ---------------------------------------------------------------------
   0. Universal safety — media never forces the page wider than the screen
   --------------------------------------------------------------------- */
@media (max-width: 768px) {
  img,
  video,
  canvas {
    max-width: 100%;
    height: auto;
  }
}

/* ---------------------------------------------------------------------
   1. Shared page header (.page-header) — let it wrap instead of overflow
   Affects: findings, finding-detail, finding-form, search-agent,
   search-request-form, and every other page using the shared header.
   --------------------------------------------------------------------- */
@media (max-width: 768px) {
  .page-header {
    flex-wrap: wrap;
    row-gap: 8px;
  }
  .page-header h1 {
    white-space: normal;
    word-break: break-word;
  }
  .header-controls,
  .header-left,
  .header-right {
    flex-wrap: wrap;
  }
}

/* ---------------------------------------------------------------------
   2. Two-column form grids collapse to one column on phones
   Affects: crm-lead-new (.lp-grid), crm-repair-new (.rp-grid). (The tray /
   review / fixing panels' .field-grid collapses in edit-panels.css, and every
   other .field-grid in section 7 below.)
   --------------------------------------------------------------------- */
@media (max-width: 768px) {
  .lp-grid,
  .rp-grid {
    grid-template-columns: 1fr;
  }
  /* The photo grid (app.css "PHOTO GRID"): three photos across, whatever the width. */
  .photo-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
}

/* ---------------------------------------------------------------------
   3. Wide data tables — make their wrappers scroll horizontally instead
   of clipping (overflow:hidden) or blowing out the page.
   These wrapper classes are used across reports, admin, copilot, etc.
   --------------------------------------------------------------------- */
@media (max-width: 768px) {
  .table-wrap,
  .table-container,
  .data-table-wrap,
  .audit-table-wrap,
  .tech-table-wrap,
  .employee-table-wrap,
  .sa-table-wrap,
  .inv-table-wrap,
  .admin-table-wrap,
  .tr-table-wrap,
  #table-wrap,
  #queue-wrap,
  #reportContainer {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ---------------------------------------------------------------------
   4. Bare data tables with NO scroll wrapper — make the table itself a
   horizontal scroller so columns keep their width and stay readable.
   Affects the CRM + commission tables that aren't wrapped in a div.
   --------------------------------------------------------------------- */
@media (max-width: 768px) {
  table.crm-table:not(.mcards),
  table.cu-table:not(.mcards),
  table.rp-table:not(.mcards),
  table.pr-table:not(.mcards),
  table.cr-table:not(.mcards),
  table.repairs-table:not(.mcards) {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
}

/* ---------------------------------------------------------------------
   4b. Card layout for the WIDEST tables — instead of a horizontal scroll,
   stack each row into a labelled card on phones. Opt-in: add class "mcards"
   to the <table> and a data-label="Column" to each <td> (the label is shown
   above the value via ::before; cells with no data-label render unlabelled).
   Applied to: crm-source-report, crm-pipeline-report, crm-customers,
   crm-repairs, crm-audit, repairs, reports-consignments.
   --------------------------------------------------------------------- */
@media (max-width: 768px) {
  table.mcards,
  table.mcards tbody {
    display: block;
    width: 100%;
  }
  table.mcards thead {
    display: none;
  }
  table.mcards tr {
    display: block;
    margin: 0 0 10px;
    padding: 4px 12px;
    border: 1.25px solid var(--border);
    border-radius: var(--r-8, 8px);
    background: var(--surface);
  }
  /* The card rules here and below set `display` on every row and cell, which
     beats the browser's own [hidden]{display:none} — a row a page hid (an
     empty-state row, a toggled-off line) showed up as a card. Re-assert it. */
  table.mcards tr[hidden],
  table.mcards td[hidden] {
    display: none !important;
  }
  table.mcards td {
    display: block;
    width: auto;
    padding: 7px 0;
    border: none;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  table.mcards td.wrap-cell.wide,
  table.mcards td.wrap-cell.mid {
    min-width: 0;
  }
  table.mcards td:last-child {
    border-bottom: none;
  }
  /* A card is ONE line per field: the label on the left, the value beside it
     (it wraps if long). Stacking the label ABOVE every value made a seven-column
     row a seven-row card — the Tray Manager list was one card per screen. */
  table.mcards td[data-label]:not([data-label=""]):not([data-empty]) {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 6px 0;
  }
  table.mcards td[data-label]:not([data-label=""]) > * { min-width: 0; }
  table.mcards td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 92px;
    padding-top: 2px;
    font-size: calc(var(--tsr) * var(--n-11, 11.2));
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    line-height: 1.3;
  }
  /* The FIRST cell is the row's identity (a name, an order number, a SKU) and
     becomes the card's title line — no label, full width. */
  table.mcards td:first-child[data-label] {
    display: block;
    padding: 8px 0 6px;
    font-weight: 600;
  }
  table.mcards td:first-child[data-label]::before { display: none; }
  table.mcards td[data-label=""]::before {
    display: none;
  }
  table.mcards td:empty,
  table.mcards td[data-empty],
  table.mcards td[data-label][data-empty] {
    display: none;
  }
  /* A numeric column right-aligns its cell; the label in front of the value
     must not inherit that and drift to the right of its own box. */
  table.mcards td[data-label]::before { text-align: left; }
  /* Same reason as the .cell-ellip reset below: a .col-cap ceiling is about the
     column BESIDE this one, and a stacked card has no column beside it — left
     in force it would squeeze the card's row to the cap's width. */
  table.mcards td.col-cap,
  table.mcards td.col-cap-sm {
    max-width: none;
  }
  /* A .cell-ellip cell exists to stop text bleeding into the NEXT column — but
     a stacked card has no next column, and the full card width is available, so
     let the value wrap out in full here instead of ellipsising it. */
  table.mcards .cell-ellip {
    display: inline;
    max-width: none;
    overflow: visible;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

/* ---------------------------------------------------------------------
   5. Long unbreakable strings (URLs, JSON dumps) shouldn't push cards wide
   --------------------------------------------------------------------- */
@media (max-width: 768px) {
  .details-grid a,
  .details-grid p,
  .au-detail {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}

/* ---------------------------------------------------------------------
   6. New design-system ("circle-3") components — mobile baseline.
   The 2026-06 audit covered legacy vocab; these cover the examples vocab
   (.tabs/.toolbar/.field-grid) the shell migration introduced.
   --------------------------------------------------------------------- */
@media (max-width: 768px) {
  /* Horizontal tab strips scroll sideways instead of wrapping/overflowing.
     app.css now does this at every width (inventory has 9 section tabs); this
     only adds the iOS momentum-scroll flag on touch. */
  .tabs { -webkit-overflow-scrolling: touch; }
  /* ── Control bars on a phone are a GRID, not a wrapped row (2026-09-26) ──
     Wrapped, every control kept its own width, so rows ended at different
     lengths and buttons landed wherever the wrap left them. Now every .toolbar
     (filter bars, create forms, action rows — 85 views) is two equal columns:
     a search box or a from–to date range takes the full width, every other
     control fills its cell edge to edge, a nested zone (.tb-filters / .tb-tail /
     .tb-actions) is the same grid inside its full-width cell, the spacer goes,
     and a bar's closing primary button fills its row. The folded filter bars
     (.has-sheet) keep their own flex layout, tuned above; a bar inside a
     .page-head keeps the 3-column head grid. */
  .toolbar:not(.has-sheet), .inv-toolbar {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; align-items: stretch;
  }
  .toolbar:not(.has-sheet) > .tb-input,
  .toolbar:not(.has-sheet) > .chip.range:has(input[type="date"]),
  .toolbar:not(.has-sheet) > .tb-filters, .toolbar:not(.has-sheet) > .tb-tail,
  .toolbar:not(.has-sheet) > .tb-actions, .toolbar:not(.has-sheet) > .inv-toolbar-more,
  .toolbar:not(.has-sheet) > h1, .toolbar:not(.has-sheet) > h2, .toolbar:not(.has-sheet) > h3,
  .toolbar:not(.has-sheet) > .field-grid, .toolbar:not(.has-sheet) > .pager,
  .toolbar:not(.has-sheet) > .flash, .toolbar:not(.has-sheet) > .message { grid-column: 1 / -1; }
  .toolbar:not(.has-sheet) > .spacer { display: none; }
  /* …and a search box fills that row edge to edge, like Orders/Products: app.css
     caps .tb-input at 340px for a desktop bar, which left it ~26px short on every
     plain filter bar (Trays, Review, Purchasing, the Reports hub…, owner 2026-10-06).
     A search kept in a stacked .field (Settings → Roles) takes the row too.
     src/ui/phone-search-sort.browser.test.js */
  .toolbar:not(.has-sheet) > .tb-input, .toolbar:not(.has-sheet) .tb-filters > .tb-input { width: 100%; min-width: 0; max-width: none; }
  .toolbar:not(.has-sheet) > .field:has(input[type="search"]) { grid-column: 1 / -1; }
  /* The ONE field of an "add" row (Settings → Categories / panels / options / matrix:
     `.tb-field.grow`) takes the row too, so its button sits under it at full width. */
  .toolbar:not(.has-sheet) > .tb-field.grow { grid-column: 1 / -1; width: 100%; max-width: none; }
  /* A bar nested in a bar (a <form class="toolbar"> inside a .toolbar, the CRM
     lists) is the same grid at full width, not one half-width cell of the outer. */
  .toolbar:not(.has-sheet) > .toolbar, .toolbar:not(.has-sheet) > form { grid-column: 1 / -1; }
  /* A GROUP of buttons (a segmented choice rendered into a span — the scanner's
     label windows) is one full-width wrapping row of equal chips, never an inline
     run whose lines overlap inside a half cell. */
  .toolbar:not(.has-sheet) > span:has(> .btn), .toolbar:not(.has-sheet) > div:has(> .btn):not(.tb-actions):not(.tb-filters):not(.tb-tail):not(.toolbar) {
    grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px;
  }
  .toolbar:not(.has-sheet) > span:has(> .btn) > .btn, .toolbar:not(.has-sheet) > div:has(> .btn):not(.tb-actions):not(.tb-filters):not(.tb-tail):not(.toolbar) > .btn { flex: 1 1 auto; justify-content: center; box-sizing: border-box; }
  /* …but a .tb-bulk (actions on ticked rows) is such a span, hidden until a row is
     ticked, and the rule above out-ranked app.css's [hidden] — the bar showed with
     nothing ticked. src/ui/tb-bulk.browser.test.js */
  .toolbar:not(.has-sheet) > .tb-bulk[hidden] { display: none; }
  /* A chip carries a caption AND a control (a select, or min–max inputs): at
     half width the control is squeezed to nothing, so every chip spans the row. */
  .toolbar:not(.has-sheet) > .chip { grid-column: 1 / -1; }
  .toolbar:not(.has-sheet) > .btn, .toolbar:not(.has-sheet) > .chip, .toolbar:not(.has-sheet) > select,
  .toolbar:not(.has-sheet) > .input, .toolbar:not(.has-sheet) > .inv-dropdown, .toolbar:not(.has-sheet) > .field,
  .toolbar:not(.has-sheet) > label, .toolbar:not(.has-sheet) > .tb-field { width: 100%; min-width: 0; max-width: none; margin: 0; box-sizing: border-box; }
  /* A button's text wraps inside its cell rather than running past the edge
     (`.btn` is nowrap by default; a long label at half width overflowed). */
  .toolbar:not(.has-sheet) > .btn, .toolbar:not(.has-sheet) .tb-actions > .btn, .toolbar:not(.has-sheet) .tb-filters > .btn,
  .page-head > .actions > .btn:not(.icon) { white-space: normal; height: auto; min-height: 36px; padding-top: 6px; padding-bottom: 6px; line-height: 1.2; text-align: center; }
  .toolbar:not(.has-sheet) > .btn { justify-content: center; }
  .toolbar:not(.has-sheet) > .btn.primary:last-child { grid-column: 1 / -1; }
  .toolbar:not(.has-sheet) .inv-dropdown > .inv-dropdown-toggle { width: 100%; justify-content: space-between; }
  .toolbar:not(.has-sheet) .chip > select, .toolbar:not(.has-sheet) .chip > input:not([type=checkbox]):not([type=radio]) { flex: 1 1 0; min-width: 0; width: auto; }
  .toolbar:not(.has-sheet) > .tb-filters, .toolbar:not(.has-sheet) > .tb-actions, .toolbar:not(.has-sheet) > .tb-tail,
  .toolbar:not(.has-sheet) > .inv-toolbar-more {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0;
  }
  .toolbar:not(.has-sheet) .tb-filters > .tb-input, .toolbar:not(.has-sheet) .tb-tail > .inv-toolbar-more,
  .toolbar:not(.has-sheet) .tb-tail > .tb-actions, .toolbar:not(.has-sheet) .tb-tail > .spacer { grid-column: 1 / -1; }
  .toolbar:not(.has-sheet) .tb-actions > .btn, .toolbar:not(.has-sheet) .tb-filters > .btn,
  .toolbar:not(.has-sheet) .tb-filters > select, .toolbar:not(.has-sheet) .tb-filters > .input,
  .toolbar:not(.has-sheet) .tb-filters > .chip, .toolbar:not(.has-sheet) .tb-filters > .inv-dropdown { width: 100%; min-width: 0; justify-content: center; box-sizing: border-box; }
  .toolbar:not(.has-sheet) .tb-actions > .btn.primary:only-child { grid-column: 1 / -1; }
  /* …and the same chip rule one level down: a chip inside a .tb-split filter zone
     (eBay offers) spans the zone, or "Listed at least [ ] days" gets no input. */
  .toolbar:not(.has-sheet) .tb-filters > .chip { grid-column: 1 / -1; }
  /* A from–to DATE chip: its caption (a `.chip-cap` span) sits on a line above
     the two pickers instead of wrapping mid-word between them. */
  .toolbar .chip.range:has(input[type="date"]) { flex-wrap: wrap; height: auto; min-height: 36px; padding: 5px 12px 7px; row-gap: 2px; }
  .toolbar .chip.range:has(input[type="date"]) > .chip-cap { flex: 1 1 100%; font-size: calc(var(--tsr) * 12); color: var(--text-muted); line-height: 1.4; }
  .toolbar .chip.range:has(input[type="date"]) > input[type="date"] { flex: 1 1 0; min-width: 0; }
  /* The form grid collapses to one column. */
  .field-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .view { padding: 16px 12px 44px; }

  .toolbar > .tb-input { flex: 1 1 100%; }
  /* In the Filters pane, a condition's field picker takes a line of its own so
     the value box and its × still fit beside each other. */
  .inv-cond-row { flex-wrap: wrap; }
  .inv-cond-row > [data-cond-field] { flex: 1 1 100%; }
}

/* ---------------------------------------------------------------------
   7. PHONE PASS (2026-09-26) — the cross-cutting gaps behind "using this app
   from a phone is a pain". Global rules only; page tuning stays below.
   --------------------------------------------------------------------- */

/* 7a. Topbar search on a phone. Beside the hamburger, the brand and the action
   icons there is no room for the inline search box, so on ≤768px — the SAME line
   as the hamburger; it used to vanish at 920px with nothing in its place — it is
   replaced by a .search-toggle icon in the action cluster that opens the SAME
   .search box as a full-width strip under the topbar (body.search-open, set by
   x-topbar's script). Same input, same typeahead, same Enter → /search: nothing
   is duplicated, so the two can never drift apart. */
.search-toggle { display: none; }
@media (max-width: 768px) {
  .topbar { gap: 10px; padding-left: 12px; padding-right: calc(12px + var(--scroll-lock-gap, 0px)); }
  .topbar .search { display: none; }
  .topbar .search-toggle { display: grid; }
  /* the rail is a drawer here: the tile sits after the hamburger, not over a rail */
  body.has-rail .brand .logo-lockup { margin-left: 0; }
  body.search-open .topbar .search-toggle { background: var(--topbar-hover); color: var(--topbar-fg); }
  body.search-open .topbar .search {
    display: block;
    position: fixed; top: var(--topbar-h); left: 0; right: 0;
    max-width: none; margin: 0; padding: 8px 12px;
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    z-index: 48;   /* over the nav drawer (40) and the search scrim (45), under the topbar (50) */
  }
  /* The strip's 12px padding shifts the icon / clear anchors that sit inside the box. */
  body.search-open .search .si { left: 24px; }
  body.search-open .search .search-clear { right: 20px; }
  body.search-open .search .search-results {
    left: 12px; right: 12px; width: auto; transform: none; top: 100%;
    max-height: calc(var(--vh) - var(--topbar-h) - 66px);   /* topbar + strip 54 + 12 clearance */
  }
}
@media (max-width: 480px) {
  /* "Who's online" is a glance feature; on a phone its 44px are the difference
     between the action cluster fitting the topbar and the avatar falling off it. */
  .topbar .presence { display: none; }
  /* Two-up KPI tiles (app.css) get ~165px each: tighter padding, a slightly
     smaller display number, and the label may wrap. */
  .kpi { padding: 14px 14px 10px; }
  .kpi .val { font-size: calc(var(--tsr) * var(--n-24, 26)); }
  .kpi .lbl { flex-wrap: wrap; row-gap: 2px; }
}
/* The "sellevry" wordmark needs ~100px of the bar beside the hamburger and the
   tile: with an admin's icon cluster (Who's online shows above 480px) it pushed
   the avatar off any screen under ~495px. The tile alone there — 559px, not the
   480 line, because the cluster is widest just above it (520 until the top bar
   got its Back, 2026-10-09: with it the cluster + wordmark need 556px). */
@media (max-width: 559px) {
  .topbar .brand .logo-word { display: none; }
}
/* Narrower than a standard iPhone (a mini / SE at 375px, most Androids at 360):
   with the top bar's Back the bar's controls need 396px at their usual spacing,
   so the avatar and its menu ran off the right edge (owner, 2026-10-10: the menu
   "gets cut off"). Closer together there — every button keeps its 38px target.
   Tested by src/ui/page-head-topbar.browser.test.js. */
@media (max-width: 389px) {
  .topbar { gap: 6px; }
  .topbar .tb-actions { gap: 2px; }
}

/* 7f. Narrow tables (1–3 columns are not carded) wrap their cells on a phone.
   app.css keeps every body cell on one line (`tbody td{white-space:nowrap}`),
   which is right on a desktop and wrong at 390px: a three-column report (a
   week, a value, a range) or the AI tool catalog ran past the edge and had to
   be dragged sideways inside its .tablewrap. A cell may wrap here, and a long
   single token (a tool name, a URL) breaks rather than widening the column. */
@media (max-width: 768px) {
  /* break-word, not anywhere: `anywhere` lets the auto layout squeeze a column to
     one character and split "2026-06-29" and "NEEDS" mid-word; `break-word` sizes
     each column to its longest WORD first and only breaks a word that still
     cannot fit. Numbers never wrap. */
  table:not(.mcards) th, table:not(.mcards) td { white-space: normal; overflow-wrap: break-word; padding-left: 10px; padding-right: 10px; }
  /* A single long token — a tool or field name in <code>, a SKU, a link — may
     break anywhere (it has no words to keep whole), and a status pill wraps
     instead of holding its column open. */
  table:not(.mcards) td code, table:not(.mcards) td .mono, table:not(.mcards) td .num, table:not(.mcards) td a { overflow-wrap: anywhere; }
  table:not(.mcards) td .pill { white-space: normal; height: auto; min-height: 22px; padding-top: 2px; padding-bottom: 2px; line-height: 1.2; }
}

/* 7i. A dropdown is never wider than its box on a phone (2026-10-23, the mobile
   smoke): a select is as wide as its longest option, and a long field name in Settings →
   Title templates / Content templates made the whole page scroll sideways. It shows
   the chosen option cut short instead; the list it opens still shows every option in
   full. Tested by src/ui/phone-no-sideways.browser.test.js. */
@media (max-width: 768px) {
  select { max-width: 100%; }
}

/* 7g. Modals on a phone follow the VISUAL viewport (2026-09-27). The backdrop
   is fixed to the layout viewport, which the on-screen keyboard does not
   shrink on iOS — so a modal centred in it (the tray's item notes) had its
   compose box under the keys with no way to scroll to it. --vvh/--vvt mirror
   window.visualViewport (mobile-chrome.js); the box starts at the top, is
   never taller than what is on screen, and its body scrolls. */
@media (max-width: 768px) {
  .x-modal-backdrop { align-items: flex-start; padding: 10px; top: var(--vvt, 0px); bottom: auto; height: var(--vvh, var(--vh)); }
  .x-modal { width: 100%; max-height: calc(var(--vvh, var(--vh)) - 20px); }
  .x-modal.is-tall { height: auto; }
  .x-modal-backdrop.is-full { align-items: center; }
  .notes-feed { height: min(300px, 32vh); }
  /* The avatar menu's My account dialog (partials/user-avatar) the same way
     (2026-10-10, owner: it "shifts too far up and out of the screen"): as tall as
     what is visible, title and tabs on top, the panel scrolling below them — the
     desktop's fixed 58%-of-the-screen panel ran under the keyboard.
     Tested by src/ui/user-settings-phone.browser.test.js. */
  .account-modal-overlay { align-items: flex-start; padding: 10px; top: var(--vvt, 0px); bottom: auto; height: var(--vvh, var(--vh)); box-sizing: border-box; }
  .account-modal.account-settings { width: 100%; max-width: none; height: 100%; flex-direction: column; box-sizing: border-box; }
  .account-modal.account-settings:not([hidden]) { display: flex; }
  .account-settings .account-panels { flex: 1 1 auto; height: auto; min-height: 0; grid-template-rows: minmax(0, 1fr); }
}

/* 7h. Item change log (/items/:sku/history) on a phone. The "at this point"
   cluster was a fixed 440px grid, which zoomed the whole page out, and the
   record head's chip + Restore button ran off the card. */
@media (max-width: 768px) {
  .hist-timeline { flex-direction: column; align-items: stretch; gap: 12px; margin-top: 12px; }
  .hist-at { flex: 1 1 auto; width: 100%; max-width: 100%; min-width: 0; }
  .hist-at > .btn.primary { justify-self: stretch; justify-content: center; }
  .hist-record .card-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .hist-record .card-head > .actions { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
  .hist-record .card-head > .actions > .chip { flex: 1 1 100%; min-width: 0; max-width: 100%; white-space: nowrap; }
  .hist-record .card-head > .actions > .chip > select { flex: 1 1 0; min-width: 0; width: auto; text-overflow: ellipsis; }
  .hist-record .card-head > .actions > .btn { flex: 1 1 100%; justify-content: center; white-space: normal; height: auto; min-height: 36px; padding: 6px 12px; }
  .hist-cols { columns: 1; }
  .hist-row { flex-wrap: wrap; gap: 4px 10px; padding-left: 10px; }
  .hist-label { flex: 1 1 100%; }
  .hist-value { flex: 1 1 auto; min-width: 0; }
  .hist-act { margin-left: auto; }
  .hist-by { white-space: normal; }
  .hist-item-meta { gap: 6px 10px; }
}

/* 7b. Sorting a carded table. Carding hides <thead>, and the header is where
   every sort control lives — so every carded table lost its sorting on a phone.
   mobile-tables.js gives each carded table ONE control outside the header (a
   "Sort by" select + a direction button) that clicks the header's own <th>, so
   the table's existing sort code does the work. Visible only while carded. */
.mtbl-sort { display: none; }
@media (max-width: 768px) {
  /* A right-aligned "Sort [column]" chip and a bordered ghost icon button — the
     filter-bar primitives, not a full-width select: that one read as a stray
     form field and touched the card's edges (2026-09-27). The control sits in
     the card's padding, outside the .tablewrap scroll box. */
  .mtbl-sort { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin: 0 0 10px; }
  .mtbl-sort > .chip { flex: 0 1 auto; min-width: 0; max-width: calc(100% - 44px); height: 36px; }
  .mtbl-sort > .chip > select { min-width: 0; max-width: 100%; text-overflow: ellipsis; }
  .mtbl-sort > .mtbl-dir { flex: 0 0 36px; width: 36px; height: 36px; padding: 0; border: 1px solid var(--border); background: var(--surface); }
  .mtbl-sort > .mtbl-dir svg, .mtbl-sort > .mtbl-dir i[data-lucide] { width: 16px; height: 16px; }
  /* Inside the list's box, top-right, 12px in — whichever element draws the box:
     the card around a borderless strip (Trays), or a wrapper that draws its own
     border (a standalone .tablewrap, Inventory's .inv-table-wrap — the bar touched
     its border on Products/Orders, owner 2026-10-06). */
  .card > .mtbl-sort,
  .tablewrap > .mtbl-sort, .inv-table-wrap > .mtbl-sort { margin: 12px 12px 4px; }
  .card.pad > .mtbl-sort { margin: 0 0 10px; }
}

/* 7k. A row drop-down on a phone (app.css "ROW DROP-DOWN", /js/row-drill.js). A carded
   row's band would be a card of its own; instead the open card and its band read as ONE
   card (the band hangs off the card's foot while it is there, opening or folding), and
   the chevron sits in the card's first line, at its right. The boxes stack (the band's
   own width, app.css). */
@media (max-width: 768px) {
  table.mcards tr.row-link.drill-row { position: relative; }
  table.mcards td.drill-cell { position: absolute; top: 10px; right: 12px; padding: 0; border: 0; }
  table.mcards tr.row-link.drill-row > td:first-child { padding-right: 28px; }
  table.mcards tr.row-link.drill-row.open { background: var(--accent-soft); }
  table.mcards tr.row-link.drill-row.open > td { background: none; }
  table.mcards tr.row-link.drill-row:has(+ tr.drill-detail) { margin-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom-color: var(--border-light); }
  table.mcards tr.row-link.drill-row + tr.drill-detail { padding: 0 12px; border-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
  table.mcards tr.row-link.drill-row + tr.drill-detail > td { padding: 0; border: 0; }
  table.mcards .drill-boxes { padding: 10px 0 12px; }
}

/* 7d. (The phone filter sheet that lived here is gone: every list's filters sit in
   ONE Filters pane — the list kit — which opens as a sheet on a phone; see
   "LIST KIT on a phone" below.) */

/* 7c. Touch. Two things a pointer never needed:
   - iOS Safari zooms the page into any field whose text is under 16px the moment
     it is focused, and the page stays zoomed afterwards. Fields get 16px on a
     touch device — nothing else changes size.
   - A finger needs ~36px of target; the compact controls were sized for a
     pointer (.btn 34, .input 32, .btn.sm 30, .btn.xs 22, .info-btn 15, the CoPilot row buttons 26).
   `pointer:coarse` is the PRIMARY input being a finger — a phone or a tablet,
   not a touchscreen laptop driven by its trackpad. */
@media (pointer: coarse) {
  .input,
  .field input:not([type=checkbox]):not([type=radio]):not([type=file]),
  .field select, .field textarea,
  .toolbar:has(.field>.field-label) .field .input.sm,
  .tb-input input, .chip > select, .chip > input:not([type=checkbox]):not([type=radio]),
  .search input, .input.sm, textarea { font-size: max(16px, calc(var(--tsr) * 16)); }
  /* …and EVERY field you type in, whatever a page sheet set (2026-10-08, owner:
     "when we click the input box the page becomes super wide and large like we
     zoomed in"): app.css `.composer-input{font-size:14px}` (the CoPilot and
     inbox message box) beat the bare `textarea` above, so tapping it zoomed the
     page. :root body raises this over any class rule. Tested by
     src/ui/copilot-phone.browser.test.js. */
  :root body :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]):not([type=button]):not([type=submit]):not([type=reset]):not([type=image]):not([type=hidden]), select, textarea, [contenteditable="true"], [contenteditable="plaintext-only"]) { font-size: max(16px, calc(var(--tsr) * 16)); }
  .btn, .input, .tb-input input, .chip, .subnav a, .btn.sm, .input.sm, .inv-btn-sm, .pager .pager-link, .sw-act, .sw-actions .sw-btn { min-height: 36px; }
  .btn.xs { min-height: 30px; }
  .btn.icon.xs { width: 30px; }
  .field textarea[data-autogrown], textarea.input[data-autogrown] { --ag-row-h: 36px; }   /* one grown row = the 36px .input beside it */
  .composer-send { width: 36px; height: 36px; }   /* the composer's input reserves 44px for it */
  .act-menu-item { min-height: 40px; }            /* action-menu rows: a finger-sized target */
  .mention-opt { min-height: 40px; }              /* the @ picker's people (app.css "MENTION PICKER") */
  .tag-field { padding: 5px 6px; } .tag-item { height: 32px; padding-left: 10px; } .tag-x { width: 28px; height: 28px; }   /* app.css TAG FIELD: a finger can hit the × */
  .tag-field > input:not([type=checkbox]):not([type=radio]):not([type=file]) { height: 32px; }
  .x-modal__close { padding: 9px; }
  .search .search-clear { width: 32px; height: 32px; }
  .info-btn { width: 20px; height: 20px; line-height: 20px; }
  .segmented > label > span { height: 34px; }       /* Buy It Now / Auction and the like */
  .tabs a, .tabs > button:not(.btn) { padding-top: 12px; padding-bottom: 12px; }
  /* Apple's minimums on an iPhone / iPad (the Apple design review, 2026-10-23): text
     11pt, a control 28×28pt (44 by default). Each of these was under: the visual size
     stays, the box a finger can hit grows. Tested by src/ui/phone-sizes.browser.test.js. */
  .pill.xs, .avatar-sm, .chat-meta, .ib-msg .meta { font-size: calc(var(--tsr) * 11); }
  .seg > button { min-height: 36px; }                 /* the list kit's quick filter, as .btn / .chip */
  .segmented.sm > label > span { height: 34px; }    /* the avatar menu's Appearance: System · Light · Dark (24px) */
  button.nav-group { height: 32px; line-height: 32px; margin-top: 4px; }   /* the drawer's group headers (22px), as tall as its entries */
  .filter-chip { height: 36px; padding-right: 2px; }
  .filter-chip :is(button, a) { width: 32px; height: 32px; }   /* a chip's × (20×20) */
  .filter-clear { min-height: 36px; padding: 0 10px; }       /* "Clear all" (55×15) */
  .toast .toast-close { position: relative; }
  .toast .toast-close::before { content: ""; position: absolute; inset: -12px; }   /* a toast's × (20×20): a 44px hit area */
  .tile-remove::before { content: ""; position: absolute; inset: -13px; border-radius: 50%; }   /* a dashboard tile's × in Edit mode (22×22) */
}

/* 7e. Column resize (/js/col-resize.js, app.css "COLUMN RESIZE").
   - A carded table has no columns, so the widths someone set on a wider screen
     must not apply to it: they are INLINE styles on the table (hence
     !important, same as the carded-cell width reset above), and a 900px-wide
     "card" would scroll the page sideways. Its cells wrap in full again, no "…".
   - A finger has no hover to reveal the grip and needs a wider target, so on
     touch the grip is 16px and its line always shows. */
@media (max-width: 768px) {
  table.mcards.col-sized {
    table-layout: auto !important;
    width: 100% !important;
    min-width: 0 !important;
  }
  table.mcards.col-sized > tbody > tr > td { overflow: visible; }
}
/* A carded table has no columns to move, pin or hide: its layout tools and its
   pins go (app.css "TABLE KIT"). */
@media (max-width: 768px) {
  /* the bar grid's span:has(> .btn) cell rule must not bring the tools back */
  .tk-tools, .tk-pin, .toolbar:not(.has-sheet) > span.tk-tools { display: none; }
}
@media (pointer: coarse) {
  .col-resizer { width: 16px; }
  .col-resizer::after { right: 5px; background: color-mix(in srgb, var(--th-fg) 30%, transparent); }
}

/* 7h. Touch feel (2026-10-08, owner: "check if there are other mobile ui look
   and feel things missing"). What still gave a finger a web page, not an app:
   - every tap flashed the browser's grey/blue box over what was tapped;
   - two quick taps on a button (a + / − stepper, Next) zoomed the page in;
   - a long press on a button, a tab or a menu entry selected its words, or
     opened the link pop-up;
   - a tapped row or menu entry gave no sign the tap landed.
   The stuck hover colour after a tap is /js/touch-hover.js. Typing fields keep
   their own selection: an iPhone cannot type into a field whose parent says
   user-select:none, so only controls with no field inside are listed.
   Tested by src/ui/touch-feel.browser.test.js. */
@media (pointer: coarse) {
  html { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
  :is(button, .btn, .navlink, .tabs a, .tabs > button:not(.btn), .pager-link, summary, .scanner-tile, .act-menu-item, .user-menu-item, .sw-tab, .pill) {
    -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  }
  :is(.navlink, .tabs a, .tabs > button:not(.btn), tr.row-link, a.ib-conv, .act-menu-item, .user-menu-item, .ib-opt, .check-item, .mention-opt, .scanner-tile, .sw-tab):active { opacity: .65; }
  .sw-tab { min-height: 32px; padding-inline: 14px; }   /* the CoPilot panel's Today / Chat switch */
  .sidebar.is-editing .nav-grip { width: 32px; height: 32px; margin: 0 -8px 0 -6px; }   /* Edit sidebar: a grip a thumb can hold */
  .sw-head-act { min-height: 32px; min-width: 36px; }   /* …the History · New chat capsule beside it, as tall */
  body .sw-panel-head .sw-close { width: 38px; height: 38px; }   /* body: copilot-widget.css loads after this sheet */
}

/* =====================================================================
   PAGE-SPECIFIC FIXES
   ===================================================================== */

/* --- inventory: the nested sub-rail (.inv-sidebar) becomes a horizontal
   scrollable tab strip with labels once it stacks above the content (≤860px),
   instead of the cramped icon-only wrap it had. Top-level nav is the drawer. */
@media (max-width: 860px) {
  .inv-sidebar nav {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 4px;
  }
  .inv-sidebar .inv-nav-link {
    flex: 0 0 auto;
    white-space: nowrap;
  }
  .inv-sidebar .inv-nav-link span:not(.crm-inbox-badge) { display: inline; }
}

/* --- review / fixing: their phone layout (the Preview / Check screens, the
   section cards, the decision bar at the bottom of the screen) lives with the
   desktop layout in the pages' own sheet, review-fixing.css (2026-10-09). */

/* --- inventory + product detail (2026-09-26 phone pass) -------------------
   .inv-field-row is a hard two-column form row with no breakpoint (7× on the
   inventory page, 14× on the product page). (The product page's Save is the
   app.css DOCK BAR since 2026-10-11 — its phone shape is below.) */
@media (max-width: 768px) {
  .inv-field-row { grid-template-columns: 1fr; }
}

/* --- DOCK BAR on a phone (app.css): the screen's bottom edge, side to side
   (out over the page's 16px / 12px gutter), above the home indicator. */
@media (max-width: 768px) {
  .dock-bar {
    bottom: 0; margin: 12px -16px 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    gap: 8px; border-radius: var(--r-16, 14px) var(--r-16, 14px) 0 0; border-left: 0; border-right: 0; border-bottom: 0;
  }
}
@media (max-width: 480px) {
  .dock-bar { margin-left: -12px; margin-right: -12px; }
}

/* --- Compact ROW lists (table.m-rows, opt-in) ------------------------------
   A list whose rows are scanned, not read field by field (orders, customers,
   consignments, the tray manager) is a compact row on a phone rather than a
   label:value card: the identity on the first line with the one thing that
   matters most at its right, then a run of the row's facts, then its actions.
   The view marks the table `m-rows` and gives each cell a role:
     .m-title   the row's identity (name, number)          — line 1, left
     .m-lead    the headline value or status               — line 1, right
     .m-fact    a fact; .m-cap prefixes its column name    — the run below
                (a bare number like "3" needs "Orders 3"); .m-wide takes a row
     .m-actions the row's buttons                          — end of the run, right
   Empty cells (mobile-tables.js data-empty) drop out. (2026-09-27) */
@media (max-width: 768px) {
  table.mcards.m-rows tbody tr {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
    margin: 0; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--border-light); border-radius: 0;
    background: var(--surface); box-shadow: none;
  }
  table.mcards.m-rows tbody tr:last-child { border-bottom: 0; }
  table.mcards.m-rows td { display: block; padding: 0; border: 0; font-weight: 400; white-space: normal; text-align: left; }
  table.mcards.m-rows td::before { display: none; }
  table.mcards.m-rows td[data-empty] { display: none; }
  table.mcards.m-rows td.m-title { flex: 1 1 55%; min-width: 0; order: 1; font-weight: 600; font-size: calc(var(--tsr) * 15); line-height: 1.25; }
  table.mcards.m-rows td.m-title .cellflex { align-items: center; gap: 10px; }
  table.mcards.m-rows td.m-lead { flex: 0 1 auto; order: 2; margin-left: auto; text-align: right; }
  table.mcards.m-rows td.m-lead > div { justify-content: flex-end; flex-wrap: wrap; flex-direction: row !important; gap: 4px !important; }
  table.mcards.m-rows td.m-fact { flex: 0 1 auto; order: 3; min-width: 0; font-size: calc(var(--tsr) * var(--n-12, 12.5)); color: var(--text-muted); }
  table.mcards.m-rows td.m-fact.m-strong { color: var(--text); font-weight: 600; }
  table.mcards.m-rows td.m-fact.m-wide { flex: 1 1 100%; }
  table.mcards.m-rows td.m-cap::before { display: inline; flex: 0 0 auto; padding: 0; content: attr(data-label) " "; font-size: inherit; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--text-faint); margin: 0; }
  table.mcards.m-rows td.m-cap { gap: 4px; }
  table.mcards.m-rows td.m-actions { flex: 0 0 auto; order: 4; margin-left: auto; }
  table.mcards.m-rows td.m-actions .btn { width: 36px; height: 36px; min-height: 0; padding: 0; }
  table.mcards.m-rows td.m-actions .btn svg, table.mcards.m-rows td.m-actions .btn i[data-lucide] { width: 18px; height: 18px; }
}

/* --- tray / review / fixing: the item header (edit-panels.css .tray-item-header,
   shared by all three editor pages) was ONE non-wrapping row — 75px thumbnail,
   SKU, qty, name, stage, then up to eight icon buttons — and ran off the right
   edge of a phone (2026-09-26). It is now [thumb · SKU · qty · stage] / [name],
   then the action buttons on a row of their own; eight 36px icons fit a 358px
   row. ≤860px = the tray's accordion line (its workspace starts at 861px). */
@media (max-width: 860px) {
  /* The list container centred itself at 98% with a 1rem inner gutter on top of
     the page's own — on a 375px screen that is 30px of nothing. */
  #tray-list-container, #review-container { max-width: none; margin: .5rem 0 0; padding: 0; }
  .tray-item-header { flex-wrap: wrap; gap: .5rem .6rem; padding: .7rem .75rem; }
  .tray-item-header .tray-item-title { flex: 1 1 100%; flex-wrap: wrap; gap: .35rem .5rem; min-width: 0; }
  .tray-item-title .header-thumbnail { width: 44px; height: 44px; }
  .tray-item-title .sku-display { font-size: calc(var(--tsr) * var(--n-12, 12.48)); }
  .tray-item-title .name-display { flex: 1 1 100%; order: 9; font-size: calc(var(--tsr) * var(--n-15, 15.2)); line-height: 1.25; overflow-wrap: anywhere; white-space: normal; }
  .tray-item-header .tray-item-title .stage-label { margin-left: auto; }
  .tray-item-title .reviewed-label, .tray-item-title .open-task-pill { order: 8; }
  .tray-item-header .header-actions { flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
  .tray-item-header .header-actions .btn.icon.sm { width: 36px; height: 36px; }
  .tray-item-header .tray-item-arrow { margin-left: auto; }
}

/* --- CoPilot panel: its top offset is 4px below the topbar — on a
   phone the panel is full-width, so the 4px slit showed the page through it. */
@media (max-width: 768px) {
  /* copilot-widget.css is loaded LAZILY (appended to <body> on first open), so
     it lands after this sheet in the cascade — equal specificity would lose. */
  html:root { --sw-top-offset: var(--topbar-h); }
  /* The panel follows the VISUAL viewport (mobile-chrome.js sets --vvh/--vvt from
     window.visualViewport): when the keyboard opens for the chat composer the
     panel shrinks with the screen instead of keeping the composer under the keys. */
  /* While the keyboard is up the phone scrolls the visible area down (--vvt) but
     the top bar stays put, scrolling out of sight with the page — so "60px
     below the visible top" left a band of page between the bar and the panel,
     and the panel's top sat too low (owner, 2026-10-08: "a bit too far down as
     the corners are cut off"). The panel starts under the bar while it is in
     view, at the visible top once it isn't, and always ends at the keyboard. */
  body .sw-panel { top: max(var(--topbar-h), var(--vvt, 0px)); height: calc(var(--vvt, 0px) + var(--vvh, var(--vh)) - max(var(--topbar-h), var(--vvt, 0px))); }
  /* A two-line message box on a phone (130px on a computer): with the keyboard
     up, every line it takes is a line of conversation you can't see. */
  body .sw-panel .composer-input { min-height: 76px; height: 76px; max-height: 30vh; }
  /* …and with no slit, its top edge meets the topbar: a top line + rounded
     corner there would double the topbar's own border. The left line stays. */
  body .sw-panel { border-top: 0; border-top-left-radius: 0; }
}

/* --- carded tables: drop any hard-coded column width/min-width so each cell
   fills the card instead of forcing it wider than the phone. Inventory locks
   several columns to 300–400px, which overflow even once stacked. --- */
@media (max-width: 768px) {
  table.mcards td,
  table.mcards th {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
  }
}

/* --- scanner: content must clear the off-canvas drawer (not keep the desktop rail's
   rail margin), and the forced one-row KPI strip becomes a 2-up grid so it fits
   a phone instead of squeezing 5 tiles across. --- */
@media (max-width: 768px) {
  body[data-page="scanner"].has-rail .scanner-container { margin-left: 0; }
  /* the app's page margin, as .view's (scanner-extras.css) */
  body[data-page="scanner"] .scanner-container { padding-left: 16px; padding-right: 16px; }
  body[data-page="scanner"] .kpis {
    grid-auto-flow: row;
    grid-template-columns: repeat(2, 1fr);
  }
  /* The scan-card 2-col layout + its control grid have desktop inline styles
     that don't collapse on their own — stack them on a phone. */
  body[data-page="scanner"] .grid.cols-2,
  body[data-page="scanner"] .scan-control { grid-template-columns: 1fr; }
  /* The quick-action tiles on a phone: three EQUAL tiles a row, all one height,
     the icon above a centred label that may take a second line (2026-10-08,
     owner: "the tiles of the scanner in mobile view are distorted and have a
     different size depending on the text on them"). They were icon-beside-label
     flex tiles: a long label was cut ("Transpor", "Consignm") or wrapped and made
     its tile taller than the rest. Tested by src/ui/scanner-tiles-phone.browser.test.js. */
  body[data-page="scanner"] .scanner-tile-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 8px; }
  body[data-page="scanner"] .scanner-tile-grid.cols-3 > .scanner-tile {
    flex-direction: column; justify-content: center; text-align: center;
    gap: 6px; padding: 12px 6px; min-width: 0;
  }
  body[data-page="scanner"] .scanner-tile-grid.cols-3 .scanner-tile-label { font-size: calc(var(--tsr) * var(--n-12, 12.5)); line-height: 1.25; min-width: 0; overflow-wrap: break-word; hyphens: auto; }
}
/* …and on a phone, the phone's page margin (after the ≤768px rule above, so it wins) */
@media (max-width: 480px) {
  body[data-page="scanner"] .scanner-container { padding-left: 12px; padding-right: 12px; }
}

/* --- inventory + product/channel detail: elements that keep hard px widths and
   overflow a phone (filters, filter dropdowns, app-card grid, bulk-preview
   columns, channel rule rows, the product hero/key-facts). --- */
@media (max-width: 768px) {
  /* Filter inputs shrink to the (wrapped) row instead of forcing 180px each. */
  .inv-toolbar input,
  .inv-toolbar select { min-width: 0; }
  /* A full-width placeholder row ("No orders match — orders are ingested when
     channel webhooks fire.") is one nowrap line: for the moment before the rows
     arrive it widened the page, and a phone browser stays zoomed out after that. */
  td.inv-placeholder, table.mcards td[colspan] { white-space: normal; overflow-wrap: anywhere; }
  /* Filter dropdown popovers anchor to the right + cap to the viewport so they
     never spill off the right edge. */
  .inv-dropdown-panel { min-width: 0; max-width: calc(100vw - 24px); left: auto; right: 0; }
  /* Bulk price-change preview: drop the pinned 300/150/130px columns even when
     the table isn't carded. */
  .inv-table .bulk-col-name,
  .inv-table .bulk-col-cat,
  .inv-table .bulk-col-cond { width: auto !important; min-width: 0 !important; max-width: none !important; }
  /* Channel pricing/inventory rule rows stack label + controls. */
  .inv-pd-rule-row { flex-direction: column; align-items: stretch; }
  .inv-pd-rule-label { min-width: 0; width: 100%; }
  /* Product detail: hero + key-facts go single/2-up. Zero-minimum columns: a
     bare 1fr grew to the photo strip's full length (product-page.css ≤900px). */
  .pr-hero { grid-template-columns: minmax(0, 1fr); }
  .pr-keyfacts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .inv-toolbar input,
  .inv-toolbar select { width: 100%; }
  /* the key facts stay small tiles, two across (the mock's phone board); a long
     value wraps inside its tile (product-page.css ≤900px) */
  .pr-keyfacts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* --- copilot: the tab strip and case/run tables ---------------------- */
@media (max-width: 768px) {
  .sa-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* --- kanban: board was clipped (parents overflow-x:hidden + 240px cols).
   Let the board scroll horizontally instead of hiding off-screen columns.
   SCOPED to the kanban page: an unscoped `html` here undid the global
   html{overflow-x:clip} backstop (section B) on EVERY page, so any overflowing
   element let the whole page scroll sideways on a phone (fixed 2026-09-26). */
@media (max-width: 768px) {
  body.kanban-page,
  body.kanban-page .container {
    overflow-x: auto;
  }
  body.kanban-page .kanban-board {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ── My Work → Calendar ──────────────────────────────────────────────────────
   Phones: the month grid keeps its seven columns but shows each entry as a
   coloured bar without text (tap the day for the week), the list view's time
   moves above the title, and the week view scrolls sideways. */
@media (max-width: 768px){
  /* The page head is TWO rows on a phone: the title block, then the actions on
     their own line, left-aligned and one size down. Sharing the title's line
     squeezed a two-word title into two lines beside a cluster of 38px buttons. */
  .page-head{flex-direction:column;align-items:stretch;gap:10px;margin-bottom:12px}
  .page-head h1{font-size:calc(var(--tsr) * var(--n-20, 22));line-height:1.2}
  .page-head > .actions{margin-top:0;min-height:0;flex-wrap:wrap;gap:8px;justify-content:flex-start}
  .page-head > .actions > .btn:not(.icon):not(.ghost){flex:1 1 calc(50% - 4px);justify-content:center}
  .page-head > .actions > .btn.ghost:not(.icon){flex:0 0 auto}
  /* Icon-only actions (pin, schedule, export) get a visible edge on a phone —
     borderless 34px ghosts read as stray glyphs beside the Back button. */
  .page-head > .actions > .btn.icon,.page-head > .actions > .act-menu > summary.btn.icon{flex:0 0 34px;border:1px solid var(--border);background:var(--surface)}
  /* A search box in the head (the dashboard's quick find) takes the whole row,
     so it and the primary button beside it end at the same edge. */
  .page-head > .actions > .tb-input{flex:1 1 100%;width:100%;max-width:none}
  /* …which means the cluster spans the head: its desktop align-self:flex-start
     shrank it to its content, 12px short of the cards below (the dashboard). */
  .page-head > .actions:has(> .tb-input){align-self:stretch}
  .page-head > div:first-child:not(.actions){flex:0 0 auto}
  .page-head .btn{height:34px;padding:0 12px;font-size:calc(var(--tsr) * 13)}
  .page-head .btn.icon{width:34px;padding:0}
  .page-head .btn.sm{height:34px}
  /* …but a cluster of ICONS ONLY (clock, pin, export, print, history — every child an
     icon button) stays on the TITLE's line (owner, 2026-10-22: a row for three icons
     is wasted room). The title block's children join the head's grid, so only the <h1>
     shares its line with the icons and the line under it (a subtitle, the status pills)
     keeps the full width. Only a plain head: a title block that starts with its <h1>,
     then the cluster, nothing else. A cluster with a worded button keeps the thumb row
     above. Tested by src/ui/phone-icon-head.browser.test.js. */
  .page-head:has(> div:first-child:not(.actions) > h1:first-child):has(> .actions:nth-child(2):last-child > .btn.icon:not([hidden])):not(:has(> .actions > :not(.btn.icon, details.act-menu, [hidden]))):not(:has(> .actions > details.act-menu > summary:not(.btn.icon))){display:grid;grid-template-columns:minmax(0,1fr) auto;column-gap:10px;row-gap:0;align-items:center}
  .page-head:has(> div:first-child:not(.actions) > h1:first-child):has(> .actions:nth-child(2):last-child > .btn.icon:not([hidden])):not(:has(> .actions > :not(.btn.icon, details.act-menu, [hidden]))):not(:has(> .actions > details.act-menu > summary:not(.btn.icon))) > div:first-child{display:contents}
  .page-head:has(> div:first-child:not(.actions) > h1:first-child):has(> .actions:nth-child(2):last-child > .btn.icon:not([hidden])):not(:has(> .actions > :not(.btn.icon, details.act-menu, [hidden]))):not(:has(> .actions > details.act-menu > summary:not(.btn.icon))) > div:first-child > :not(h1){grid-column:1 / -1}
  .page-head:has(> div:first-child:not(.actions) > h1:first-child):has(> .actions:nth-child(2):last-child > .btn.icon:not([hidden])):not(:has(> .actions > :not(.btn.icon, details.act-menu, [hidden]))):not(:has(> .actions > details.act-menu > summary:not(.btn.icon))) > div:first-child > h1{grid-column:1;grid-row:1;min-width:0}
  .page-head:has(> div:first-child:not(.actions) > h1:first-child):has(> .actions:nth-child(2):last-child > .btn.icon:not([hidden])):not(:has(> .actions > :not(.btn.icon, details.act-menu, [hidden]))):not(:has(> .actions > details.act-menu > summary:not(.btn.icon))) > .actions{grid-column:2;grid-row:1;flex-wrap:nowrap;align-self:center}
  /* A head that carries a control bar (tray, review, fixing): a 3-column grid —
     every select on a row of its own, the buttons sharing one row, equal widths. */
  .page-head > .toolbar{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;width:100%;margin:0}
  .page-head > .toolbar > select{grid-column:1 / -1;width:100%;height:36px}
  .page-head > .toolbar > .btn,.page-head > .toolbar > #saveBtn{justify-content:center;width:100%;min-width:0;height:36px}
  .page-head > .toolbar > #saveStatus,.page-head > .toolbar > .spacer{grid-column:1 / -1}
  /* A subtitle line laid out as an inline display:flex row (tray / review /
     fixing heads) squeezes its spans into columns on a phone — let it wrap. */
  .page-head > div:first-child .t-mut{flex-wrap:wrap}
  /* The tray's overview photo beside its title is an avatar on a phone, not a hero. */
  .page-head .tray-overview-image{width:56px;height:56px;max-width:56px;max-height:56px;object-fit:cover;border-radius:var(--r-12, 10px);flex:0 0 auto}
  .cal-cell{min-height:78px;padding:4px 3px}
  .cal-chip{height:8px;padding:0;border-radius:var(--r-4, 4px)}
  .cal-chip svg,.cal-chip i[data-lucide],.cal-chip-time,.cal-chip-title{display:none}
  .cal-more{font-size:calc(var(--tsr) * var(--n-11, 10.5));padding:0 2px}
  .cal-row{grid-template-columns:30px minmax(0,1fr) auto;row-gap:2px}
  .cal-row-time{grid-column:2 / 4;grid-row:1}
  .cal-row-icon{grid-row:1 / 3}
  .cal-facts{grid-template-columns:1fr;gap:2px}
  .cal-facts dd{margin-bottom:8px}
  .cal-title{min-width:0;font-size:calc(var(--tsr) * 15)}
  /* The calendar's .tb-actions is a date stepper (‹ Today ›), not a filter bar's
     Reset / Apply: one row, the arrows staying 34px icons, Today taking the rest.
     §6's two-column grid stacked it into three rows. (calendar-toolbar-phone.browser.test.js) */
  .toolbar.cal-toolbar:not(.has-sheet) > .tb-actions{display:flex;grid-column:1 / -1;gap:8px}
  .toolbar.cal-toolbar:not(.has-sheet) > .tb-actions > .btn{flex:1 1 auto;width:auto}
  .toolbar.cal-toolbar:not(.has-sheet) > .tb-actions > .btn.icon{flex:0 0 34px;width:34px}
}

/* ── Channel settings (inventory-channel): toggle rows ──────────────────────
   `.inv-toggle-row` is a fixed 200px | 50px | 1fr grid (inventory.css). On a
   phone that leaves the description a few pixels wide, running down the page one
   syllable per line and past the card edge. Here: name + switch on one line, the
   description on its own line below. Test: src/ui/toggle-row-phone.browser.test.js */
@media (max-width:768px){
  .inv-toggle-row{grid-template-columns:minmax(0,1fr) auto;row-gap:4px}
  .inv-toggle-row > .inv-muted{grid-column:1 / -1}
  /* .inv-value-row (same file): the name on its own line, the sentence and its note below. */
  .inv-pd-card .inv-value-row{grid-template-columns:minmax(0,1fr)}
  .inv-value-row > .inv-muted{grid-column:1}
  .inv-value-row:has(> textarea) > span:first-child{padding-top:0}
}

/* ── Inventory → eBay offers (inventory-ebay-offers): the row's Send offer ────
   The m-rows pattern sizes an actions-cell button as a 36px icon square; this
   one keeps its words ("Send offer" is not self-evident), so it takes its width. */
@media (max-width:768px){
  table.mcards.m-rows td.m-actions .btn.eo-send{width:auto;padding:0 12px;gap:6px}
}

/* ── A conversation page (.chat-window — Support tickets, in the app and the console)
   is ONE screen at every width (phone 2026-10-10, owner: "only the chat panel should
   scroll, not the whole page"; computer 2026-10-12, owner: "the card chat-window must
   be fixed"): the title keeps its place, the reply box sits at the bottom, only the
   messages scroll (they open at the newest, /js/chat-window.js). The height follows
   what the phone shows above the keyboard (--vvt / --vvh, as the CoPilot panel; on a
   computer they are unset and --vh stands in). <html> holds the lock — an iPhone
   ignores a body lock. Not in a media query: a computer needs it too.
   src/ui/chat-one-screen.browser.test.js */
html.chat-page { overflow: hidden; }
body.chat-page .main { height: calc(var(--vvt, 0px) + var(--vvh, var(--vh)) - var(--topbar-h)); min-height: 0; display: flex; flex-direction: column; }
body.chat-page .main > .view { flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; overflow: hidden; padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px) * var(--no-kb, 1)); }
body.chat-page .chat-window { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; margin-bottom: 0; }
body.chat-page .chat-window > .chat-thread { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
body.chat-page .chat-window > .chat-compose { flex: 0 0 auto; }


/* ── Scanner → Order Picklist (order-detail): an item to pick (2026-10-09, owner:
   "open orders and order picklist are not mobile optimized with text and images
   overflowing"). On a computer: two 192px photos | the details | Scan. On a phone
   that row ran ~200px off the screen and squeezed the title to a letter per line,
   so it stacks: the photos as two squares side by side, the details at full
   width, then a full-width Scan button. src/ui/scanner-orders-phone.browser.test.js */
@media (max-width: 768px) {
  body[data-page="scanner"] .pick-item { flex-wrap: wrap; align-items: stretch; gap: 10px; }
  body[data-page="scanner"] .pick-item-photos { flex: 1 1 100%; max-width: 360px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body[data-page="scanner"] .pick-item-photos img { width: 100%; height: auto; aspect-ratio: 1; }
  body[data-page="scanner"] .pick-item-info { flex: 1 1 100%; min-width: 0; overflow-wrap: anywhere; }
  body[data-page="scanner"] .pick-item-bin { max-width: 100%; line-height: 1.4; }
  body[data-page="scanner"] .pick-item .item-shipwith-badge { flex-wrap: wrap; }
  body[data-page="scanner"] .pick-item-act { flex: 1 1 100%; width: auto; }
  body[data-page="scanner"] .pick-item-act .scan-item-btn { width: 100%; min-height: 44px; }
}

/* ── Scanner → Picklist (picklist-print), ON THE SCREEN of a phone: the six
   fixed columns (photo, SKU, title, bin, ship with, qty) left the title a few
   pixels, a letter per line (owner, 2026-10-09). Each item becomes a block —
   the photo on the left; SKU and qty, the title, the bin, ship-with beside it.
   Paper keeps the table (screen only). */
@media screen and (max-width: 600px) {
  table.pdoc-table.items, table.pdoc-table.items tbody { display: block; width: 100%; }
  table.pdoc-table.items colgroup, table.pdoc-table.items thead { display: none; }
  table.pdoc-table.items tbody tr {
    display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; column-gap: 12px; row-gap: 3px;
    grid-template-areas: "img sku qty" "img title title" "img bin bin" "img ship ship";
    padding: 10px 0; border-bottom: 1px solid var(--border);
  }
  table.pdoc-table.items tbody td { display: block; padding: 0; border: 0; min-width: 0; overflow-wrap: anywhere; white-space: normal; }
  table.pdoc-table.items tbody td:nth-child(1) { grid-area: img; }
  table.pdoc-table.items tbody td:nth-child(2) { grid-area: sku; }
  table.pdoc-table.items tbody td:nth-child(3) { grid-area: title; }
  table.pdoc-table.items tbody td:nth-child(4) { grid-area: bin; }
  table.pdoc-table.items tbody td:nth-child(5) { grid-area: ship; }
  table.pdoc-table.items tbody td:nth-child(6) { grid-area: qty; }
  table.pdoc-table.items tbody td[colspan] { grid-column: 1 / -1; grid-row: auto; }
  table.pdoc-table.items tbody tr:has(> td[colspan]) { display: block; }
  table.pdoc-table.items td[data-label]::before { content: attr(data-label) " "; font-weight: 400; color: var(--text-muted); }
  table.pdoc-table.items td.qty { text-align: right; }
  table.pdoc-table.items tbody td:nth-child(5):has(> .t-mut:only-child) { display: none; }   /* nothing to ship with: no lone dash */
}

/* ── CRM → Occasions (crm-occasions): the row's Mark done ────────────────────
   The m-rows pattern sizes an actions-cell button as a 36px icon square; this
   one keeps its words (a bare check mark doesn't say what it does), so it takes
   its width — same exception as eBay offers' Send offer. */
@media (max-width:768px){
  table.mcards.m-rows td.m-actions .btn.occ-done-btn{width:auto;padding:0 12px;gap:6px}
}

/* Chat thread (app.css "CHAT THREAD": CRM inbox, support tickets): on a phone a
   bubble takes most of the row — 72% of a 390px screen left ~250px of text. The
   room beside it still shows which side wrote it. */
@media (max-width: 768px) {
  .chat-msg, .ib-msg { width: 86%; }
  .chat-thread, .ib-thread { padding: .75rem 1rem; }
}

/* --- no blur behind dialogs on a phone (2026-10-08, owner: "sometimes the page
   feels laggy or choppy"). A backdrop blur re-blurs the whole page under it on
   every frame something moves — costly on a phone, invisible at 2px anyway. --- */
@media (max-width: 768px), (pointer: coarse) {
  .modal, .x-modal-backdrop, .app-modal-backdrop, .modal-backdrop, .upload-loading-overlay { backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* --- SAFE AREA (the installed app, viewport-fit=cover — src/ui/app-install-head.js).
   The page may use the whole screen; these keep what matters off the rounded
   corners, the home-indicator strip and, held sideways, the notch. In portrait the
   side insets are 0, so only the bottom changes there. --- */
/* CoPilot: its message box sat flush with the bottom, its lower corners cut by the
   screen's (owner, 2026-10-08). The strip's height below it — none while the
   keyboard is up (--no-kb, mobile-chrome.js), the keyboard covers the strip. */
@media (max-width: 768px) {
  body .sw-panel { padding-bottom: calc(env(safe-area-inset-bottom, 0px) * var(--no-kb, 1)); }
  /* The page behind a phone-wide CoPilot panel does not scroll (2026-10-08, owner:
     "when CoPilot is open on mobile with my keyboard up and I scroll, it is very
     chunky and stutters"). It did: every scroll step with the keyboard up moved the
     visible area, re-placed the panel and restyled the page. Only the panel's own
     lists scroll, and they never hand a scroll on to the page. Same lock as the
     menu drawer (§A). */
  html.copilot-panel-open { overflow: hidden; }
  body .sw-panel .sw-chat-thread, body .sw-panel .sw-pane { overscroll-behavior: contain; }
}
html.app-standalone .topbar { padding-left: calc(12px + env(safe-area-inset-left, 0px)); padding-right: calc(12px + env(safe-area-inset-right, 0px) + var(--scroll-lock-gap, 0px)); }
@media (min-width: 769px) {
  html.app-standalone .topbar { padding-left: calc(22px + env(safe-area-inset-left, 0px)); padding-right: calc(22px + env(safe-area-inset-right, 0px) + var(--scroll-lock-gap, 0px)); }
  html.app-standalone .sidebar { left: env(safe-area-inset-left, 0px); }
  html.app-standalone body.has-rail .main,
  html.app-standalone body > .app-footer { margin-left: calc(var(--rail-w) + var(--rail-inset) + var(--rail-gap) + env(safe-area-inset-left, 0px)); }
}
/* the notch on the right of a phone held sideways (0 everywhere else) */
html.app-standalone .main { margin-right: env(safe-area-inset-right, 0px); }

/* Info-help editor's link fields (/js/field-info-editor.js): on a phone, Cancel
   and Save link share a row at equal width; Remove link goes on the row below. */
@media (max-width: 480px) {
  .info-editor-link-actions .spacer { display: none; }
  .info-editor-link-actions [data-link-cancel],
  .info-editor-link-actions [data-link-apply] { flex: 1 1 0; justify-content: center; }
  .info-editor-link-actions [data-link-remove] { order: 1; }
}

/* ── Settings → Twilio → Numbers: the Phones card's "Add a person… / Add a shared
   phone" row (views/admin-phone.ejs). Two controls that don't fit beside each
   other at phone width: each takes a row, so the select is never pushed off
   the left edge (2026-10-14). ─────────────────────────────────────────── */
@media (max-width: 768px) {
  #phoneAdd { flex-wrap: wrap; }
  #phoneAdd > select.input, #phoneAdd > .btn { flex: 1 1 100%; min-width: 0; max-width: none; }
}

/* ── Settings → Twilio → Call flows (views/admin-phone-flows.ejs): the map needs a
   computer's screen (owner, 2026-10-26: "it does not need to work on a phone"),
   so a phone gets a note in its place. The flow picker and New flow stay. ── */
@media (max-width: 768px) {
  .card.pf-card { display: none; }
  .card.pf-phone-note { display: block; }
}

/* ── CRM customer page (views/crm-customer.ejs, 2026-10-15) ───────────────
   One column in the mock-up's order: the profile, the numbers, Needs attention,
   Coming up, the record tabs, then Contact, Ships to and Marketing — what you
   came to do is not below four cards of details. The two columns' wrappers step
   aside (display:contents) so their cards can be ordered as one list. */
@media (max-width: 768px) {
  .cust-layout { display: flex; flex-direction: column; align-items: stretch; }   /* the desktop grid's align-items:start shrank every box to its content */
  .cust-side-top, .cust-side, .cust-main { display: contents; }
  .cust-profile { order: 1; }
  .cust-kpis { order: 2; }
  .cust-moment { order: 3; }   /* the right moment, right after the numbers (it is what to do next) */
  .cust-attn { order: 3; }
  .cust-coming { order: 4; }
  .cust-records { order: 5; }
  .cust-contact { order: 6; }
  .cust-ships { order: 7; }
  .cust-mkt { order: 8; }
  .cust-compose-head > .t-mut { margin-left: 0; flex-basis: 100%; }
  .cust-compose-write { flex-wrap: wrap; }
  .cust-compose-input { flex-basis: 100%; }
  .cust-compose-actions { margin-left: auto; }
  .cust-when, .cust-when-empty { padding-left: 12px; padding-right: 12px; }
  .cust-feed-row, .cust-feed > li:not(.cust-feed-row) { padding-left: 12px; padding-right: 12px; }
  /* Conversations: the search under the list's title, the catch-up's boxes one per row,
     Ask's button under its box, an opened thread a little shorter. */
  .cust-conv-list > .card-head { flex-wrap: wrap; }
  .cust-conv-search { flex-basis: 100%; max-width: none; }
  #convTable td.conv-main { width: auto; max-width: none; }   /* the card's title line: it wraps */
  #convTable .conv-title, #convTable .conv-main .cell-2 > small { white-space: normal; }
  .cust-brief-boxes { grid-template-columns: minmax(0, 1fr); }
  .cust-ask-form { flex-wrap: wrap; }
  .cust-ask-form .btn { flex: 1 1 100%; }
  .conv-band { padding-left: 0; padding-right: 0; }
  .conv-thread { max-height: 360px; }
}

/* ── Inventory → Bulk operations (views/inventory.ejs #tab-bulk-ops, 2026-10-15) ──
   These rows are FORMS that write (price change, field change, the spreadsheet
   upload), so on a phone each field takes a row of its own — its caption above it
   ("Forms stack"). As a two-up grid the 180px desktop dropdown ran past its cell
   (Overall condition stuck out of the card), the SKU box's long caption wrapped
   down beside Category and the file picker was cut off ("Datei auswählen | Kei").
   The dropdown, the SKU box and the file picker fill whatever cell they are in,
   in every .inv-toolbar. src/ui/inventory-phone-forms.browser.test.js */
@media (max-width: 768px) {
  #tab-bulk-ops .inv-toolbar { grid-template-columns: minmax(0, 1fr); }
  .inv-toolbar > label { min-width: 0; }
  .inv-toolbar > label > * { min-width: 0; max-width: 100%; box-sizing: border-box; }
  .inv-toolbar .inv-dropdown,
  .inv-toolbar .inv-dropdown > .inv-dropdown-toggle { width: 100%; min-width: 0; max-width: none; }
  #tab-bulk-ops #bulk-category-toggle { width: 100%; min-width: 0; max-width: none; }   /* its desktop 234px pin is an id rule */
  .inv-toolbar input[type="file"] { width: 100%; }
}

/* ── Inventory → Listing Schedule (public/js/inventory.js, 2026-10-15) ──────
   The desktop table pins SKU at 11rem and Actions at 21rem (fixed layout): on a
   phone that is 512px in a 327px card — the Item column got 0px, Actions ran off
   the card, and the "Nothing eligible to list right now." row (a colspan cell
   that is also :last-child, so right-aligned and nowrap) showed as "Noth". On a
   phone each item is two lines — SKU + item, then its buttons — and the headers
   go (the lines say what they are). The planned-date rows keep date ← → List all.
   src/ui/inventory-phone-forms.browser.test.js */
@media (max-width: 768px) {
  .inv-sched-card .inv-sched-table,
  .inv-sched-card .inv-sched-table tbody { display: block; width: 100%; table-layout: auto; }
  .inv-sched-card .inv-sched-table thead { display: none; }
  .inv-sched-card .inv-sched-table tbody tr { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: .6rem; align-items: center; }
  .inv-sched-card .inv-sched-table tbody tr.inv-sched-date { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
  .inv-sched-card .inv-sched-table tbody tr td:is(:first-child, :nth-child(2), :last-child) { display: block; width: auto; height: auto; min-width: 0; }   /* :is() out-ranks the desktop 11rem / 21rem column widths */
  .inv-sched-card .inv-sched-table tbody tr:not(.inv-sched-date) td:first-child { max-width: 11rem; }
  .inv-sched-card .inv-sched-table tbody tr:not(.inv-sched-date) td:last-child { grid-column: 1 / -1; text-align: left; white-space: normal; }
  .inv-sched-card .inv-sched-table tbody tr:not(.inv-sched-date) td:last-child:not([colspan]) { padding-top: 0; }
  .inv-sched-card .inv-sched-table tbody tr:not(.inv-sched-date) td[colspan] { grid-column: 1 / -1; max-width: none; white-space: normal; text-align: center; }
  .inv-sched-card .inv-sched-table tbody tr.inv-sched-date td { flex: 0 1 auto; }
}

/* ── Settings → Roles & access → a role (views/partials/role-head.ejs, every tab) ──
   The head's Copy · Compare with… · Delete role are text buttons sharing rows at
   equal width. The actions cluster is shrink-wrapped (desktop align-self:
   flex-start), so with only Copy and Compare with… (no Delete — people have the
   role) each got 50% of a cluster sized to their own text, and "Compare with…"
   broke onto two lines. The cluster takes the head's width here, as it does
   whenever its buttons wrap. src/roles/role-head.browser.test.js */
@media (max-width: 768px) {
  .page-head[data-role-head] > .actions { align-self: stretch; }
}

/* ── Settings → Roles & access (views/admin-roles.ejs) ──
   History · Compare · Why can't someone …? · New role: at half width "Why can't
   someone …?" broke onto two lines and ended in "…?". It shares the first row
   with the History icon (the whole rest of the row); Compare and New role share
   the second, New role still last. */
@media (max-width: 768px) {
  .page-head[data-roles-head] > .actions { align-self: stretch; }
  .page-head[data-roles-head] > .actions > a[href^="/settings/roles/compare"],
  .page-head[data-roles-head] > .actions > [data-new-role] { order: 1; }
}

/* ── Inventory → Offers (inventory-ebay-offers, inventory-buyer-offers): the store
   line's words wrap again on a phone. The head row: the pills, then the search,
   then Export, Refresh and Filters on ONE row (the two icons their own size, not
   two half-row cells), then "Offer at" + Send / Decline across the last. ─── */
@media (max-width: 768px) {
  .eo-channel-line { flex-wrap: wrap; }
  .eo-channel-line > .eo-line-text { white-space: normal; overflow: visible; flex-basis: 100%; }
  #eo-filters, #bo-filters { grid-template-columns: 36px 36px minmax(0, 1fr); }
  #eo-filters > .btn.icon, #bo-filters > .btn.icon { width: 36px; padding: 0; }
  #eo-filters > .tb-actions, #bo-filters > .tb-actions { grid-column: 1 / -1; display: flex; gap: 8px; }
  #eo-filters > .tb-actions > .chip { flex: 1 1 auto; }
  #eo-filters > .tb-actions > .btn, #bo-filters > .tb-actions > .btn { flex: 1 1 auto; justify-content: center; }
  .bo-msg { max-width: 100%; white-space: normal; }
  .bo-facts { grid-template-columns: auto 1fr; }
}

/* ── Console → Security → Console users (console/users): the row's New link ──
   The m-rows pattern sizes an actions-cell button as a 36px icon square; this
   one keeps its words (a bare refresh icon doesn't say it emails a new link), so
   it takes its width — same exception as eBay offers' Send offer. */
@media (max-width:768px){
  table.mcards.m-rows td.m-actions .btn.cu-new-link{width:auto;padding:0 12px;gap:6px}
}

/* ---- LIST KIT on a phone (app.css "LIST KIT"; the new layout, step 5). The
   status pills take their own row and scroll sideways inside it; the Filters
   popover opens as a sheet under the top bar; the quick look fills the screen
   (over the top bar, under every dialog). ---- */
@media (max-width: 768px) {
  .toolbar:not(.has-sheet) > .seg { grid-column: 1 / -1; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
  .seg::-webkit-scrollbar { display: none; }
  .seg > button { flex: none; }
  /* …like a tab strip: the edge with more pills behind it fades (/js/mobile-chrome.js sets
     the classes, and opens the strip on the pill in force) — a pill cut off at the edge
     read as a clipped word ("Complet", the Apple design review, 2026-10-23). Scrolling,
     not wrapping: a wrapped quick filter took two or three rows above the list. */
  .seg.tabs-more-right { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 44px), transparent); }
  .seg.tabs-more-left:not(.tabs-more-right) { -webkit-mask-image: linear-gradient(to right, transparent, #000 36px); mask-image: linear-gradient(to right, transparent, #000 36px); }
  .seg.tabs-more-left.tabs-more-right { -webkit-mask-image: linear-gradient(to right, transparent, #000 36px, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(to right, transparent, #000 36px, #000 calc(100% - 44px), transparent); }
  /* The Filters button takes a cell like any control, never a row of its own (the
     bar's rule for a span holding a button gave it one, leaving the Export icon
     alone on the row above — Customers, 2026-10-22). */
  .toolbar.list-head > span.filter-pop-wrap { grid-column: auto; display: flex; }
  .toolbar.list-head > span.filter-pop-wrap > .fbtn { flex: 1 1 auto; justify-content: center; }
  /* A report's clock · pin · Export at the end of its head row (app.css .tb-icons): the
     cell beside Filters, the icons at its right end at their own size — never a row of
     equal stretched buttons (the bar's rule for a span of buttons). In a card head too,
     they keep the edge the page head's icons get on a phone. */
  .toolbar:not(.has-sheet) > .tb-icons, .toolbar:not(.has-sheet) > span.tb-icons:has(> .btn) {
    grid-column: -2 / -1; display: flex; flex-wrap: nowrap; justify-content: flex-end; gap: 8px; }
  .toolbar:not(.has-sheet) > .tb-icons:empty { display: none; }
  /* …and in a head row with no Filters button (a look-up report: its search box alone;
     Consignor Payouts: pills + search; a report with its own pills only) the icons share the
     line of the control before them instead of a row of their own: the bar's second column
     shrinks to the icons, the search (or the pills) takes the rest. */
  .toolbar.list-head:not(.has-sheet):has(> .tb-icons:not(:empty)):not(:has(> .filter-pop-wrap)) { grid-template-columns: minmax(0, 1fr) auto; }
  .toolbar.list-head:not(.has-sheet):has(> .tb-icons:not(:empty)):not(:has(> .filter-pop-wrap)) > .tb-input,
  .toolbar.list-head:not(.has-sheet):has(> .tb-icons:not(:empty)):not(:has(> .filter-pop-wrap, > .tb-input)) > .seg { grid-column: 1 / 2; }
  .tb-icons > .btn.icon, .toolbar:not(.has-sheet) > span.tb-icons:has(> .btn) > .btn.icon {
    flex: 0 0 auto; border: 1px solid var(--border); background: var(--surface); }
  /* A view-tab row that ends with the page's actions (app.css "TAB ROW"): the strip takes
     the line, with its rule under it, and the actions sit on the next line at the right —
     beside the strip they squeezed it to a sliver that scrolled. */
  .tab-row:has(> .tb-icons) { flex-wrap: wrap; row-gap: 10px; box-shadow: none; }
  .tab-row:has(> .tb-icons) > .tabs { flex: 1 1 100%; box-shadow: inset 0 calc(-1 * var(--tabs-line-w)) 0 var(--tabs-line); }
  .tab-row:has(> .tb-icons) > .act-menu > summary.btn.icon { border: 1px solid var(--border); background: var(--surface); }
  /* …and the list's "New …" after it fills the other half (Step 13, 2026-10-22: Filters sat
     alone in a half cell on 25 pages): a bar's closing primary spans its row everywhere else
     (§6), and a span holding buttons does too — here the ••• and the primary share the cell. */
  .toolbar.list-head > span.filter-pop-wrap + .btn:last-child { grid-column: auto; }
  .toolbar.list-head:not(.has-sheet) > span.filter-pop-wrap + span.list-new { grid-column: auto; flex-wrap: nowrap; }
  .toolbar.list-head > span.list-new > .btn:not(.icon) { flex: 1 1 auto; min-width: 0; justify-content: center; }
  .toolbar.list-head > span.list-new > :is(.act-menu, .btn.icon) { flex: none; }
  .filter-pop { position: fixed; left: 12px; right: 12px; top: calc(var(--topbar-h) + 12px); width: auto;
    max-height: calc(var(--vh) - var(--topbar-h) - 24px); overflow-y: auto; overscroll-behavior: contain; }
  .filter-pop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-pop-cols { grid-template-columns: minmax(0, 1fr); }
  .side-panel { top: 0; right: 0; bottom: 0; left: 0; width: auto; max-width: none; border: 0; border-radius: 0; z-index: 70;
    padding-bottom: env(safe-area-inset-bottom, 0px); }
  .ql-tots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── Fixing Queue (reports-task-items) and Skipped Items (skipped-items): the row's
   labelled buttons. The m-rows pattern sizes an actions-cell button as a 36px icon
   square; Fix, Mark Received and Reverse Skip keep their words, so they take their width. */
@media (max-width:768px){
  table.mcards.m-rows td.m-actions .btn:is(.fq-fix, .receive-btn, .reverse-btn){width:auto;padding:0 12px;gap:6px}
}

/* ── Lone-button rows (2026-10-22, step 13): a card's action moved into the card's head
   or onto its row; on a phone it must not become a lone row again.
   Settings → Notifications & Messages → a message: "Send me a test" sits left of the On
   switch; when the two leave the sentence less than ~220px, they go under it, at the right.
   Marketing → Automations: Turn on / off beside the On / Off pill — the title wraps
   instead of pushing the button onto a row of its own.
   Tested by src/ui/card-head-actions.browser.test.js. */
@media (max-width:768px){
  .msg-row.is-flat{flex-wrap:wrap;row-gap:10px}
  .msg-row.is-flat > .msg-row-main{flex:1 1 220px}
  .msg-row.is-flat > .msg-ctl{margin-left:auto}
  .card.mka-card > .card-head{flex-wrap:nowrap;gap:8px}
  .card.mka-card > .card-head > h3{flex:1 1 auto;min-width:0}
  .card.mka-card > .card-head > .spacer{display:none}
  .card.mka-card > .card-head > :not(h3){flex:none}
}

/* ── Customer Data Hygiene (reports-crm-hygiene): a card's View · Export links were
   29×19 and 39×19 with 10px between them (the Apple design review, 2026-10-23: a finger
   needs 28×28pt). On a touch screen each link takes a 36px-tall box, the look unchanged,
   and the two sit far enough apart that the boxes never meet.
   Tested by src/ui/phone-sizes.browser.test.js. */
@media (pointer: coarse) {
  .hy-act { gap: 18px 20px; flex-wrap: wrap; }
  .hy-act a { position: relative; }
  .hy-act a::before { content: ""; position: absolute; inset: -9px -8px; }
}

/* 7j. LARGER TEXT ON A PHONE (the Apple design review; owner, 2026-10-23: "phones first").
   An iPhone set to a larger text size (Settings → Display & Text Size → Larger Text) left
   the app's text as small as before. /js/boot.js reads the phone's preferred body size
   before the first paint (the -apple-system-body font: 17px at the default) into --ts on
   <html>, held to 15–23px; on a touch phone every text size here and in the phone rules
   above is `calc(var(--tsr) * N)` with --tsr = --ts / 17 — exactly N px at the default
   size, larger as the phone asks. Everywhere else --tsr is 1px. The root font size stays
   16px (the app's rem values assume it); the fixed top bar keeps its sizes. A rule that
   sets a phone text size uses --tsr. Tested by src/ui/larger-text.browser.test.js and
   src/ui/larger-text.client.test.js. */
:root { --tsr: 1px; }
@media (max-width: 768px) and (pointer: coarse) {
  :root { --tsr: calc(var(--ts, 17px) / 17); --fs-body: calc(var(--tsr) * 13); }
  .btn { font-size: calc(var(--tsr) * 13); }
  .btn.sm, .btn.xs { font-size: calc(var(--tsr) * var(--n-12, 12.5)); }
  .chip { font-size: calc(var(--tsr) * 13); }
  .pill { font-size: calc(var(--tsr) * var(--n-12, 11.5)); }
  .tabs a, .tabs > button:not(.btn) { font-size: calc(var(--tsr) * 13); }
  .tabs a .pill, .tabs > button:not(.btn) .pill { font-size: calc(var(--tsr) * 11); }
  .seg > button { font-size: calc(var(--tsr) * 13); }
  .seg .n { font-size: calc(var(--tsr) * var(--n-12, 11.5)); }
  .kpi .lbl, .kpi .delta { font-size: calc(var(--tsr) * 12); }
  .card-head h3 { font-size: calc(var(--tsr) * 14); }
  .kv { font-size: calc(var(--tsr) * 13); }
  .cell-2 > small { font-size: calc(var(--tsr) * 12); }
  .field > label, .field .field-label { font-size: calc(var(--tsr) * 12); }
  .side-panel-title h3 { font-size: calc(var(--tsr) * var(--n-17, 18)); }
}

/* ── Settings → Notifications & Messages → a topic: a message whose days sit beside its
   switch (partials/message-row inlineDays) puts the two under its sentence, at the right. */
@media (max-width:768px){
  .msg-row:has(> .msg-ctl > .msg-row-days){flex-wrap:wrap;row-gap:10px}
  .msg-row:has(> .msg-ctl > .msg-row-days) > .msg-row-main{flex:1 1 100%}
  .msg-row:has(> .msg-ctl > .msg-row-days) > .msg-ctl{margin-left:auto}
}

/* Settings → Mailboxes → Connect a mailbox: the step's main action takes a row of its own (a
   sign-in button is too wide to share one), Back and Cancel share the row under it. */
@media (max-width:480px){
  #mbxModal .x-modal__foot{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}
  #mbxModal .x-modal__foot>.btn{justify-content:center}
  #mbxModal .x-modal__foot>.foot-start{margin-right:0}
  #mbxModal .x-modal__foot>.main-act{grid-column:1/-1;grid-row:1}
  #mbxModal .x-modal__foot>.foot-start[hidden]+.btn{grid-column:1/-1}
}

/* A group of fields that can't change (App.fieldsAsText, app.css "FIELD AS TEXT"): one column of rows on a phone. */
@media (max-width: 768px) {
  .field-grid.is-text-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Reports → Revert Changes (views/reports-revert-changes.ejs): a field is two lines — what it
   is (with its box) and its revert note, then before → after; a head row wraps its words. */
@media (max-width: 768px) {
  .rv-table thead, .rv-table colgroup { display: none; }
  .rv-table, .rv-table tbody { display: block; width: 100%; }
  .rv-table tr.rv-head { display: block; }
  .rv-table tr.rv-head[hidden], .rv-table tr.rv-field[hidden] { display: none; }
  .rv-table tr.rv-head > td { display: block; border-top: 1px solid var(--border); padding-left: 12px; padding-right: 12px; }
  .rv-head-in, .rv-meta { flex-wrap: wrap; gap: 6px 10px; white-space: normal; }
  .rv-count { display: none; }
  .rv-lead .cell-2 { flex-direction: column; align-items: flex-start; }
  .rv-lead .cell-2 small { flex-wrap: wrap; white-space: normal; }
  .rv-lead .cell-2 > :first-child { white-space: normal; }
  .rv-c1.lv-1 { padding-left: 14px; }
  .rv-c1.lv-2 { padding-left: 28px; }
  .rv-head-note, .rv-head-note.lv-2 { margin-left: 28px; }
  .rv-table tr.rv-field { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "field state" "before after"; border-top: 1px solid var(--border-light); padding: 6px 12px 8px 0; }
  .rv-table tr.rv-field > td { display: block; border: 0; padding: 2px 0; background: none; min-width: 0; }
  .rv-table tr.rv-field.is-picked { background: var(--accent-soft); }
  .rv-table tr.rv-field.is-picked > td { background: transparent; }
  .rv-table tr.rv-field > td:nth-child(1) { grid-area: field; padding-left: 12px; }
  .rv-table tr.rv-field > td:nth-child(2) { grid-area: before; color: var(--text-muted); padding-left: 54px; }
  .rv-table tr.rv-field:has(.lv-2) > td:nth-child(2) { padding-left: 68px; }
  .rv-table tr.rv-field > td:nth-child(2) .rv-val { text-decoration: line-through; text-decoration-thickness: 1px; }
  .rv-table tr.rv-field > td:nth-child(3) { grid-area: after; }
  .rv-table tr.rv-field > td:nth-child(4) { display: none; }
  .rv-table tr.rv-field > td:nth-child(5) { grid-area: state; text-align: right; }
  .rv-table tr.rv-more { display: block; }
  .rv-table tr.rv-more > td { display: block; border: 0; }
  .rv-table tr.rv-more .rv-c1 { padding-left: 28px; }
  .rv-card-head { flex-wrap: wrap; }
  .rv-card-title > .rv-window, .rv-card-hint { display: none; }
  .rv-group > button { padding: 0 8px; }
  .rv-plan-row { grid-template-columns: minmax(0, 1fr) 16px minmax(0, 1fr); }
  .rv-plan-f, .rv-plan-x { grid-column: 1 / -1; }
  .rv-plan-note { margin-left: 0; }
  .rv-text-cols { grid-template-columns: 1fr; }
}

/* Consignment record (views/consignment-record.ejs): an item's two note boxes, one under the other —
   side by side they were two narrow boxes on a phone. */
@media (max-width: 768px) {
  .cn-edit-box .field-grid.cols-2 { grid-template-columns: minmax(0, 1fr); }
}
