/* ============================================================================
   FORMULA1 PAINTS ERP v2 — Cloudflare-dashboard light theme
   ========================================================================== */

:root {
  --orange: #f6821f;
  --orange-dark: #9a5c00;
  --orange-tint: #fdeedc;
  --bg: #f7f8fa;
  --band: #e4e8ee;
  --panel: #ffffff;
  --line: #e6e8ec;
  --text: #1c1f24;
  --muted: #6b7280;
  --green: #157f3d;
  --green-bg: #e2f5e9;
  --red: #c5221f;
  --red-bg: #fdeceb;
  --amber: #935f00;
  --amber-bg: #fdf3d8;
  --gray-bg: #eef0f3;
  --radius: 10px;
  --side-w: 248px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font: 14px/1.5 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.error { color: var(--red); }
a { color: var(--orange-dark); }

/* ============ LOGIN ============ */
#login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1000px 500px at 80% -10%, #fdf1e3 0%, transparent 60%),
    radial-gradient(800px 400px at -10% 110%, #fdf1e3 0%, transparent 55%),
    var(--bg);
  padding: 1rem;
}
.login-box {
  width: 400px; max-width: 100%;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 2rem; box-shadow: 0 10px 40px rgba(20,30,50,.08);
}
.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-brand h1 { font-size: 20px; margin-top: .6rem; }
.brand-dot {
  display: inline-block; width: 14px; height: 14px; border-radius: 4px;
  background: linear-gradient(135deg, #fbad41, var(--orange));
}
.form-error {
  background: var(--red-bg); color: var(--red);
  border: 1px solid #f6c7c5; border-radius: 8px;
  padding: .5rem .75rem; font-size: 13px; margin: .5rem 0;
}

/* ============ TOPBAR ============ */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: 56px; z-index: 60;
  background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: .9rem; padding: 0 1rem;
}
.topbar-brand { display: flex; align-items: center; gap: .5rem; font-size: 15px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; }
.user-chip { display: flex; align-items: center; gap: .5rem; font-weight: 600; }
.icon-btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 8px; width: 34px; height: 34px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--gray-bg); }

/* ============ SIDEBAR (Cloudflare light) ============ */
.shell { display: flex; padding-top: 56px; min-height: 100vh; }
.sidebar {
  width: var(--side-w); flex-shrink: 0;
  position: sticky; top: 56px; height: calc(100vh - 56px);
  overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;   /* foot pinned with margin-top:auto —
     justify-content:space-between + overflow pushed the LAST menu items out of
     reach on phones (cont-196) */
  transition: margin-left .18s ease;
}
.sidebar.collapsed { margin-left: calc(var(--side-w) * -1); }
.nav-group { padding: .35rem 0; }
.nav-group-title {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); padding: .8rem 1rem .35rem;
  display: flex; align-items: center; gap: .35rem; cursor: pointer; user-select: none;
}
.nav-group-title .chev { width: 12px; height: 12px; transition: transform .15s; }
.nav-group.collapsed .chev { transform: rotate(-90deg); }
.nav-group.collapsed .nav-item { display: none; }
.nav-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem 1rem .5rem 1.25rem; color: var(--text);
  text-decoration: none; font-size: 13.5px; border-left: 3px solid transparent;
  cursor: pointer;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .75; }
.nav-item:hover { background: #f3f4f6; }
.nav-item.active {
  background: var(--orange-tint); color: var(--orange-dark);
  border-left-color: var(--orange); font-weight: 600;
}
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto; background: var(--orange); color: #fff;
  border-radius: 999px; font-size: 11px; font-weight: 700;
  min-width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0 6px;
}
.sidebar-foot { padding: 1rem; border-top: 1px solid var(--line); margin-top: auto; }
.side-backdrop { display: none; }

/* ============ CONTENT ============ */
.content { flex: 1; padding: 1.5rem; min-width: 0; }
.page-head { display: flex; align-items: center; gap: .8rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head h2 { font-size: 20px; }
.head-actions { margin-left: auto; display: flex; gap: .5rem; }
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1.1rem;
}
.panel h3 { font-size: 15px; margin-bottom: .7rem; }
.denied-box {
  max-width: 480px; margin: 4rem auto; text-align: center;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 2.5rem 2rem;
}

/* ============ BUTTONS / CHIPS ============ */
.btn {
  display: inline-flex; align-items: center; gap: .35rem;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: .45rem .85rem; border-radius: 8px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--gray-bg); }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn.primary:hover { background: #e5761a; }
.btn.ghost { background: transparent; }
/* cont-138: an ACTIVE filter button (the Today pick) must stay visible — the
   plain .btn.ghost rule above has the same specificity as .btn.primary but
   comes LATER, so it used to win and paint the pressed Today button
   white-on-transparent (invisible button AND text). The third class here wins
   on specificity and restores the solid orange pressed state. */
.btn.ghost.primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn.ghost.primary:hover { background: #e5761a; }
.btn.danger { color: var(--red); border-color: #f2b8b6; }
.btn.danger:hover { background: var(--red-bg); }
.btn.small { padding: .25rem .6rem; font-size: 12.5px; border-radius: 7px; }
.btn.full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.chip {
  display: inline-block; background: var(--orange-tint); color: var(--orange-dark);
  border: 1px solid #f6d4ab; border-radius: 999px; padding: .2rem .7rem;
  font-size: 12.5px; font-weight: 700;
}
/* ============ CARDS ============ */
.cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: .8rem; margin-bottom: 1.1rem;
}
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .85rem 1rem; display: flex; flex-direction: column; gap: .25rem;
}
.card-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.card-value { font-size: 21px; font-weight: 700; }
.card.warn .card-value { color: var(--amber); }
.card.danger .card-value { color: var(--red); }

/* Report Summary — printed-report sheet (cont-177/177b): the screen mirrors
   the printed document — company band, From/To/Printed meta, uppercase
   sections, ruled lines with the amount right-aligned and the View button
   at the far right of every line and breakdown */
.rs-sheet { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.2rem .6rem; max-width: 820px; }
.rs-band { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
  padding-bottom: .7rem; border-bottom: 2px solid var(--line); margin-bottom: .55rem; }
.rs-company { font-weight: 800; font-size: 16px; }
.rs-company-sub { font-size: 12px; color: var(--muted); }
.rs-doctype { font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: 13px; padding-top: .25rem; }
.rs-meta { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; font-size: 12.5px; color: var(--muted);
  padding-bottom: .7rem; border-bottom: 1px solid var(--line); }
.rs-meta strong { color: var(--text); }
.rs-foot { margin-top: .6rem; padding-top: .55rem; border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--muted); }
.rs-section-title { text-transform: uppercase; letter-spacing: .08em; font-weight: 700;
  font-size: 11.5px; color: var(--muted); margin: .9rem 0 .15rem; }   /* cont-191: was used with no rule — headings fell back to plain body text */
.rs-line { display: flex; align-items: center; gap: .75rem; padding: .5rem 0;
  border-bottom: 1px dashed var(--line); }
.rs-line:last-child { border-bottom: none; }
.rs-line-label { flex: 1; font-weight: 600; }
.rs-line-amt { font-weight: 700; min-width: 110px; text-align: right; font-variant-numeric: tabular-nums; }
.rs-line-actions { flex: 0 0 auto; }
.rs-line-sub { padding: .35rem 0 .35rem 1.1rem; }
.rs-line-sub .rs-line-label { font-weight: 400; color: var(--muted); }
.rs-line-sub .rs-line-amt { font-weight: 600; }
@media print { .rs-line-actions { display: none !important; } }
.rs-card .card-value { font-size: 22px; }
.rs-card-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.rs-subs { margin-top: .35rem; display: flex; flex-direction: column; }
.rs-sub { display: flex; align-items: center; gap: .5rem; padding-top: .35rem;
  border-top: 1px dashed var(--line); font-size: 12.5px; color: var(--muted); }
.rs-sub span:first-child { flex: 1; }
.rs-sub .rs-amt { font-weight: 700; color: var(--text); }

/* Dashboard — live cockpit (cont-176) */
.dash-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 1rem; align-items: start; margin-top: 1rem; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }
.dash-col { display: flex; flex-direction: column; gap: 1rem; }
.dash-col .panel { margin-bottom: 0; }
.dash-queue-row { display: flex; align-items: center; gap: .6rem; padding: .45rem 0;
  border-bottom: 1px dashed var(--line); }
.dash-queue-row:last-child { border-bottom: none; }
.dash-queue-row .dq-label { flex: 1; }
.dash-queue-row .dq-count { font-weight: 700; min-width: 2.2rem; text-align: right; }
.dash-queue-row .dq-count.hot { color: #c0392b; font-weight: 800; }  /* cont-178: pending counts render red */
.live-chip { display: inline-flex; align-items: center; gap: .45rem; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #2e9e5b; display: inline-block; }
.live-chip.live-off .live-dot { background: var(--muted); }

/* ============ TABLES ============ */
table { width: 100%; border-collapse: collapse; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { padding: .55rem .7rem; text-align: left; border-bottom: 1px solid var(--line); font-size: 13.5px; vertical-align: middle; }
th { background: #fafbfc; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn { margin-left: .3rem; }
th.actions-col { width: 1%; }   /* cont-191: the marker th finally gets its rule — squeeze the actions column to content width */
.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
/* cont-193: wide tables scroll sideways INSIDE their wrapper (core.js
   wrapTables slides every data table into one of these) instead of
   stretching the page or getting clipped on phones. Harmless on desktop —
   it only scrolls when the table is genuinely wider than its panel. */
.tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ============ BADGES ============ */
.badge {
  display: inline-block; border-radius: 999px; padding: .15rem .6rem;
  font-size: 11.5px; font-weight: 700; text-transform: capitalize;
}
.badge.draft            { background: var(--gray-bg); color: var(--muted); }
.badge.pending_approval { background: var(--amber-bg); color: var(--amber); }
.badge.approved         { background: var(--green-bg); color: var(--green); }
.badge.rejected         { background: var(--red-bg); color: var(--red); }
.badge.active           { background: var(--green-bg); color: var(--green); }
.badge.inactive         { background: var(--red-bg); color: var(--red); }
.badge.deleted          { background: var(--red-bg); color: var(--red); }
/* cont-138: the derived "Delivered" bill state and the confirmed sales
   return read PLAIN — no chip background (owner request), unlike the
   pending/approved states which keep theirs */
.badge.confirmed        { background: transparent; color: var(--text); }
.badge.delivered        { background: transparent; color: var(--text); }

/* ============ cont-134: bills audit UI ============ */
/* cont-135: the RED second confirmation — Edit/Del on an APPROVED bill opens
   a warning-styled ask FIRST; the panel and the Yes button are red */
.danger-panel {
  border: 1px solid #f2b8b6; border-left: 4px solid var(--red);
  background: var(--red-bg); color: var(--red);
  border-radius: 8px; padding: 10px 14px; margin-bottom: 10px;
  font-size: 13.5px; line-height: 1.5;
}
.btn.danger-solid { background: var(--red); color: #fff; border-color: var(--red); }
.btn.danger-solid:hover { background: #a91c1a; }
/* the small "Modified after approved" note under a bill number + its hover
   tooltip (a styled panel, NOT the bare title attribute) */
.mod-tip {
  position: relative; display: inline-block; margin-left: 7px;
  font-size: 10.5px; font-weight: 600; color: var(--amber);
  cursor: help; border-bottom: 1px dotted var(--amber);
  white-space: nowrap;   /* cont-194: "Approved Modified" stays on ONE line — on phones it sits in a min-content column and used to break in two */
}
/* cont-136: the bills-list variant sits UNDER the bill number (a second
   line) — inline it made the number column unnecessarily wide */
.mod-tip.under { margin-left: 0; margin-top: 2px; }
/* cont-136: fixed-header popups (the stock-movements pattern) — the BOX
   never scrolls, only the body does, so the head (title + Close) stays put;
   the body carries its own rounded edge so the scrollbar never clips the
   popup's rounded corner */
.modal-scroll-body { max-height: 74vh; overflow: auto; border-radius: 10px; }
.mod-tip-box {
  display: none; position: absolute; left: 0; top: calc(100% + 6px); z-index: 60;
  width: max-content; max-width: 320px; padding: 9px 12px;
  background: #fffdfa; color: #333; border: 1px solid var(--line);
  border-left: 4px solid var(--amber); border-radius: 8px;
  box-shadow: 0 8px 22px rgba(0,0,0,.16); font-size: 12px; font-weight: 500;
  line-height: 1.45; text-align: left; cursor: default;
}
.mod-tip:hover .mod-tip-box, .mod-tip:focus-within .mod-tip-box { display: block; }
/* the merged row message for a voided (deleted) bill — number + date stay,
   the rest of the row is one cell telling who deleted it and why */
.void-msg {
  color: var(--red); font-size: 13px;
  /* cont-136: NO row background change for a deleted bill — the red message
     text alone marks the row (owner request) */
  background: transparent;
}
.void-panel {
  border: 1px solid var(--red-bg, #f5c6c2); border-left: 4px solid var(--red);
  background: var(--red-bg, #fdf0ef); color: var(--red);
  border-radius: 8px; padding: 10px 14px; margin-bottom: 10px;
  font-size: 13.5px;
}

/* ============ FORMS ============ */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: .6rem 0 .25rem; }
.sub-label { margin-top: 1rem; }
input, select, textarea {
  width: 100%; padding: .5rem .65rem; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; font-size: 13.5px; background: var(--panel); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #f8c48f; border-color: var(--orange); }
.filters { display: flex; gap: .5rem; margin-bottom: .9rem; flex-wrap: wrap; }
.filters input, .filters select { width: auto; min-width: 150px; flex: 0 1 auto; }
/* cont-194: queue + delivery buttons carry two labels — full text on
   desktop, the short View / Appr / Rej / Del / Confirm set on phones */
.bmini { display: none; }
.form-row { display: flex; gap: .8rem; }
.form-row > div { flex: 1; min-width: 0; }
.check-line { display: flex; align-items: center; gap: .5rem; font-size: 13.5px; color: var(--text); margin-top: .8rem; }
.check-line input { width: auto; }

/* item groups page: section heading row per group type (Finished / Raw Materials) */
.type-head td { background: var(--bg); border-top: 2px solid var(--line); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: .55rem .6rem; }
/* report subtotal row (My Receivable — per sales person) */
tr.alt-row td { background: var(--gray-bg); }
.check-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: .4rem; }
.check-list .check-line { margin: 0; padding: .35rem .5rem; border-radius: 6px; }
.check-list .check-line:hover { background: var(--gray-bg); }
.totals-bar {
  display: flex; justify-content: flex-end; gap: 1.5rem;
  padding: .6rem 0; margin-top: .8rem; font-size: 14px;
  border-top: 1px dashed var(--line);
}
/* ---- bill due strip: total due passed the credit limit (billing + approve) ---- */
#bm-due.over-limit {
  border: 1px solid var(--red); border-radius: var(--radius);
  background: var(--red-bg); padding: .6rem .8rem;
}
#bm-due.over-limit #bm-due-total { color: var(--red); }
#bm-due-warn { color: var(--red); border-color: var(--red); background: #fff; }
#bm-due.over-limit #bm-due-warn { background: var(--red); color: #fff; }

/* ---- bill VIEW modal credit strip — same "limit exceeds" message as the
   approve modal; separate ids because both modals live in the DOM ---- */
#bv-due {
  display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; align-items: center;
  margin-top: .8rem; padding: .55rem .8rem; font-size: 13.5px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--gray-bg);
}
#bv-due.over-limit {
  border: 1px solid var(--red); background: var(--red-bg);
}
#bv-due.over-limit #bv-due-total { color: var(--red); }
#bv-due-warn { color: var(--red); border-color: var(--red); background: #fff; }
#bv-due.over-limit #bv-due-warn { background: var(--red); color: #fff; }

/* queue row chip: this bill would cross the customer's credit limit */
.chip.over-chip { color: var(--red); border-color: var(--red); background: #fff; white-space: nowrap; }

/* cont-206: "Billed: price" — the customer's last billed rate for the picked
   item, small gray italic text DIRECTLY under the rate field. Absolutely
   positioned so its appearance never shifts the field itself; the field
   keeps the item's set price. The ROW always reserves 14px of bottom padding
   for the hint — showing/hiding it moves nothing, inputs stay aligned, and
   adding another item row leaves the hint its own space instead of it
   overlapping the row below. */
.line { padding-bottom: 14px; }
.line .rate-wrap { position: relative; }
.line .bl-billed {
  position: absolute; left: 0; top: 100%; margin-top: 1px;
  font-size: 10px; font-style: italic; line-height: 1.15;
  color: var(--muted); white-space: nowrap; pointer-events: none;
}

/* ---- sales return modal: entry modes + bill lookup ---- */
.ret-modes { display: flex; gap: 1.2rem; margin: .2rem 0 .8rem; }
.ret-modes label { display: flex; align-items: center; gap: .4rem; font-size: 13.5px; cursor: pointer; }
.ret-billrow { display: flex; align-items: center; gap: .5rem; margin: .3rem 0 .8rem; }
.ret-prefix { font-weight: 600; padding: .45rem .6rem; background: var(--gray-bg); border: 1px solid var(--line); border-radius: var(--radius); }
table.ret-items { width: 100%; margin-top: .5rem; }
table.ret-items td, table.ret-items th { padding: .35rem .5rem; }

/* ============ BILL / RETURN LINE ROWS ============ */
.line { display: grid; grid-template-columns: 2.2fr .8fr .9fr 1fr 32px; gap: .45rem; align-items: center; margin-bottom: .45rem; }
.line .amt { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.line .btn { justify-self: center; }
/* cont-134: transport + cost lines on the bill form — purpose | amount | ✕ */
.cost-line { display: grid; grid-template-columns: 1fr 150px 32px; gap: .45rem; align-items: center; margin-bottom: .45rem; }
.cost-line .cl-purpose[readonly] { color: #444; background: #f6f7f9; }
.prod-mat { display: grid; grid-template-columns: 2.2fr .9fr 32px; gap: .45rem; align-items: center; margin-bottom: .45rem; }

/* ============ MODALS ============ */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 20, 30, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 4vh 1rem; overflow-y: auto;
}
.modal-box {
  background: var(--panel); border-radius: 14px; width: 560px; max-width: 100%;
  padding: 1.4rem 1.5rem; box-shadow: 0 24px 70px rgba(10,15,25,.25);
  margin-bottom: 4vh;
}
.modal-box.small { width: 420px; }
.modal-box.wide { width: 860px; }
.modal-box h3 { margin-bottom: .4rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.2rem; }

/* ============ PERMISSION MATRIX ============ */
.perm-groups { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem 1.2rem; margin-top: .6rem; }
.perm-group { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; }
.perm-group h4 { font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .05em; margin-bottom: .4rem; }
.perm-group .check-line { margin: 0 0 .2rem; }

/* ============ PAGER / TOAST ============ */
.pager { display: flex; align-items: center; gap: .8rem; justify-content: flex-end; padding: .7rem 0; font-size: 13px; }
.toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  background: #1f2937; color: #fff; padding: .6rem 1.1rem; border-radius: 10px;
  font-size: 13.5px; z-index: 200; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  max-width: 90vw;
}
.toast.err { background: var(--red); }
.toast.warn { background: var(--amber); }
.report-head { padding: .8rem 0; }
.report-head h3 { margin-bottom: .2rem; }

/* ============ MOBILE ============ */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 56px; bottom: 0; height: auto; z-index: 70; margin-left: 0; box-shadow: 0 0 40px rgba(0,0,0,.15); padding-bottom: env(safe-area-inset-bottom, 0); }
  .sidebar.collapsed { margin-left: calc(var(--side-w) * -1); }
  .side-backdrop.show {
    display: block; position: fixed; inset: 56px 0 0 0; z-index: 65; background: rgba(15,20,30,.35);
  }
  .form-row { flex-direction: column; gap: 0; }
  .perm-groups { grid-template-columns: 1fr; }
  .line { grid-template-columns: 1.6fr .7fr .8fr .9fr 32px; }
  .content { padding: 1rem; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  /* cont-193: long modal forms (the bill modal) scroll under a footer that
     never scrolls away — Save/Cancel stay reachable on tablets and phones */
  .modal { padding: 3vh .7rem .7rem; }
  .modal-box { padding: 1.1rem 1rem; }
  .modal-actions {
    position: sticky; bottom: 0; z-index: 5; background: var(--panel);
    border-top: 1px solid var(--line); padding-top: .7rem; margin-top: 1rem;
    box-shadow: 0 -10px 18px -12px rgba(15,23,42,.28);
  }
}

/* ============ MOBILE — phones (cont-193) ============
   Marketing bills and reads reports from a phone. NOT a separate site and
   not mobile-first: the desktop layout is untouched, these rules only relax
   fixed widths below 640px, stack the bill line rows, stop iOS auto-zoom
   and grow the tap targets. */
@media (max-width: 640px) {
  .content { padding: .8rem; }
  .page-head h2 { font-size: 18px; }
  /* the head action row owns a full line; fixed-width inputs (the dashboard's
     style="width:360px" search) shrink to it instead of overflowing */
  .head-actions { width: 100%; margin-left: 0; flex-wrap: wrap; }
  .head-actions input, .head-actions select { width: 100% !important; flex: 1 1 160px; min-width: 0; }
  /* iOS zooms any focused input whose font is smaller than 16px — 16 everywhere */
  input, select, textarea, .combo-input { font-size: 16px; }
  /* tighter cells so more columns fit before the sideways scroll starts */
  th, td { padding: .45rem .5rem; font-size: 13px; }
  th { font-size: 11px; }
  /* comfortable tap targets */
  .btn { padding: .5rem .85rem; }
  .btn.small { padding: .45rem .7rem; }
  .nav-item { padding: .65rem 1rem .65rem 1.25rem; }
  /* filter rows: every control takes a comfortable width and wraps */
  .filters input, .filters select, .filters .combo { flex: 1 1 150px; min-width: 130px; }
  /* cont-220: wrapped pickers must size like every other field — the later
     desktop .filters .combo rule (flex:0 1 auto) otherwise lets the combo
     input's intrinsic width paint over the neighbouring field */
  .filters .combo.combo { flex: 1 1 150px; min-width: 150px; max-width: 100%; }
  .filters .combo.combo > .combo-input { width: 100%; max-width: 100%; min-width: 0; }
  /* the bill line stacks: the item picker owns row 1, qty · rate · amount · ✕
     share row 2 — no more 60px-wide selects on a 360px screen */
  .line { grid-template-columns: 1fr 1fr 1fr 32px; }
  .line > *:first-child { grid-column: 1 / -1; }
  .cost-line { grid-template-columns: 1fr 110px 32px; }
  .prod-mat { grid-template-columns: 1fr 1fr 32px; }
  /* the receive/production popups' fixed 130px qty column (page-scoped
     styles) — same stack: picker full row, qty + ✕ under it. The body
     prefix out-specifies the page-injected <style> blocks. */
  body #fr-modal .fr-line, body #mu-modal .mu-line,
  body #prod-modal .prod-line, body #sfr-modal .sfr-line { grid-template-columns: 1fr 110px 32px; }
  body #fr-modal .fr-line > *:first-child, body #mu-modal .mu-line > *:first-child,
  body #prod-modal .prod-line > *:first-child, body #sfr-modal .sfr-line > *:first-child { grid-column: 1 / -1; }
  body #fr-modal .fr-meta, body #mu-modal .mu-meta,
  body #prod-modal .prod-meta, body #sfr-modal .sfr-meta { grid-template-columns: 1fr; }
  .totals-bar { flex-wrap: wrap; gap: .5rem 1.2rem; }
  .combo-menu { max-width: min(92vw, 340px); }
  .cards { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
  .card-value { font-size: 19px; }
  /* slim topbar: the avatar carries the identity, the name text goes */
  #user-name { display: none; }
  /* toasts span the width instead of pinching in the middle */
  .toast { left: .6rem; right: .6rem; transform: none; max-width: none; text-align: center; }
}
/* ============================================================================
   cont-207 (cont-193 re-map): BILLS LIST on phones — each row becomes a
   virtual two-column layout; the DESKTOP table is untouched (this whole
   block is inside a max-width media query). Left column: line 1 = bill no +
   ", " + date (no header), line 2 = customer name, line 3 = ordered by.
   Right column: line 1 = net amount (semi-bold), line 2 = status — the
   status chip loses its background and renders as plain italic text in the
   same color it had as a chip. Line 4 = the row buttons (right aligned).
   Deleted-bill rows keep their message under the no/date line, LEFT aligned
   (the status cell's right-alignment must not leak onto the merged cell).
   Filters on phones read: search → status → date from → date to → buttons,
   with Date from / Date to placeholders (cont-209).
   ========================================================================== */
@media (max-width: 640px) {
  /* cont-193/194: filter order on phones — search, status, date from, date
     to, then the remaining buttons; the Date from / Date to placeholders are
     the required+placeholder overlay from cont-209 */
  #page-bills .filters > #bill-search { order: 1; }
  #page-bills .filters > #bill-status { order: 2; }
  #page-bills .filters > #bill-from { order: 3; }
  #page-bills .filters > #bill-to { order: 4; }
  #page-bills .filters > #bill-today { order: 5; }
  #page-bills .filters > #bill-reset { order: 6; }
  #page-bills table.bills-list { display: block; }
  #page-bills table.bills-list thead { display: none; }
  #page-bills table.bills-list tbody { display: block; }
  #page-bills table.bills-list tbody tr {
    display: grid;
    /* col1 is min-content so the "Approved Modified" tip (which sits under the
       bill no) cannot widen the column and push the comma off the number;
       col4 caps at 46vw so a long button row wraps instead of clipping the
       net amount / buttons off the right edge */
    grid-template-columns: min-content max-content minmax(0, 1fr) minmax(auto, 46vw);
    gap: 2px 0;
    padding: 10px 12px;
  }
  #page-bills table.bills-list tbody tr + tr { border-top: 1px solid var(--line); }
  #page-bills table.bills-list tbody tr td { border: 0; padding: 0; background: none; }
  /* LEFT · line 1: bill no + comma + date (the comma rides in front of the
     date — after the number there may be the "Approved Modified" tip).
     nowrap on the number: min-content sizing must not break it at the
     hyphen (FB- / 0142). */
  #page-bills table.bills-list tbody tr td:nth-child(1) { grid-area: 1 / 1; }
  #page-bills table.bills-list tbody tr td:nth-child(1) strong { white-space: nowrap; }
  #page-bills table.bills-list tbody tr td:nth-child(2) { grid-area: 1 / 2; }
  #page-bills table.bills-list tbody tr td:nth-child(2)::before { content: ', '; font-weight: 400; }
  /* LEFT · line 2: customer name (cont-193: swapped with ordered-by — the
     owner wants customer | status on one line, ordered-by below) */
  #page-bills table.bills-list tbody tr td:nth-child(4) {
    grid-area: 2 / 1 / 3 / 4; font-weight: 600;
  }
  /* RIGHT · line 1: the net amount */
  #page-bills table.bills-list tbody tr td:nth-child(5) {
    grid-area: 1 / 4; justify-self: end;
    font-weight: 600; white-space: nowrap;
  }
  #page-bills table.bills-list tbody tr td:nth-child(3) {
    grid-area: 2 / 4; justify-self: end; text-align: right;
    font-size: 12.5px;
  }
  #page-bills table.bills-list tbody tr .badge {
    background: transparent; padding: 0; font-weight: 400;
    font-style: italic; font-size: 12.5px;
  }
  /* line 3: ordered by (quiet) */
  #page-bills table.bills-list tbody tr td:nth-child(6) {
    grid-area: 3 / 1 / 4 / 4;
    font-size: 11px; color: var(--muted); font-style: italic;
  }
  #page-bills table.bills-list tbody tr td:nth-child(6)::before { content: 'Ordered by '; }
  /* line 4: the buttons, one row, right aligned */
  #page-bills table.bills-list tbody tr td:nth-child(7) {
    grid-area: 4 / 1 / 5 / -1; text-align: right;
    white-space: normal;
  }
  #page-bills table.bills-list tbody tr td:nth-child(7) .btn { margin: 2px 0 2px .3rem; }
  /* full-width informational rows (empty list message, deleted-bill reason —
     row 2, directly under the no/date line, so no blank row in between).
     cont-193: the message cell IS the status cell positionally, so the
     status mapping's justify-self/text-align leak onto it — stretch it back
     and keep the deletion message LEFT aligned (owner request) */
  #page-bills table.bills-list tbody tr td[colspan] {
    grid-area: 2 / 1 / 3 / -1 !important;
    justify-self: stretch; text-align: left;
  }
}
/* ============================================================================
   cont-209: CUSTOMER STATEMENT + MY CUSTOMER REPORT on phones — the same
   virtual two-column rows as the bills list (cont-207). LEFT: line 1 =
   date · type (the type chip loses its background, plain italic in its
   color), line 2 = description, line 3 = reference in quiet muted italics.
   RIGHT: line 1 debit, line 2 credit, line 3 balance — each value keeps its
   column alignment under a small muted Dr/Cr/Bal tag so the numbers read
   without the header row. Desktop is untouched.
   Also here: the from/to date filters get visible placeholders on phones —
   many mobile browsers render an empty <input type=date> completely blank,
   so the placeholder text is overlaid until a value is picked (required
   keeps :not(:valid) matching while empty; the inputs are not in a form, so
   required cannot block anything).
   ========================================================================== */
@media (max-width: 640px) {
  .filters input[type="date"] { position: relative; }
  .filters input[type="date"]:not(:valid)::before {
    content: attr(placeholder); position: absolute; left: 12px; top: 50%;
    transform: translateY(-50%); color: var(--muted); pointer-events: none;
  }
  /* browsers that DO draw the native mm/dd/yyyy ghost (desktop Chrome,
     Android) must not double it up with the overlay */
  .filters input[type="date"]:not(:valid)::-webkit-datetime-edit { color: transparent; }
  #page-statement table, #page-ledger table, #page-mycustomerreport table { display: block; }
  #page-statement table thead, #page-ledger table thead,
  #page-mycustomerreport table thead { display: none; }
  #page-statement table tbody, #page-ledger table tbody,
  #page-mycustomerreport table tbody { display: block; }
  #page-statement table tbody tr, #page-ledger table tbody tr,
  #page-mycustomerreport table tbody tr {
    display: grid;
    grid-template-columns: max-content max-content minmax(0, 1fr) minmax(auto, 46vw);
    gap: 2px 0;
    padding: 10px 12px;
  }
  #page-statement table tbody tr + tr, #page-ledger table tbody tr + tr,
  #page-mycustomerreport table tbody tr + tr { border-top: 1px solid var(--line); }
  #page-statement table tbody tr td, #page-ledger table tbody tr td,
  #page-mycustomerreport table tbody tr td { border: 0; padding: 0; background: none; }
  /* LEFT · line 1: date · type */
  #page-statement table tbody tr td:nth-child(1), #page-ledger table tbody tr td:nth-child(1),
  #page-mycustomerreport table tbody tr td:nth-child(1) { grid-area: 1 / 1; font-weight: 600; white-space: nowrap; }
  #page-statement table tbody tr td:nth-child(2), #page-ledger table tbody tr td:nth-child(2),
  #page-mycustomerreport table tbody tr td:nth-child(2) { grid-area: 1 / 2; font-size: 12.5px; }
  #page-statement table tbody tr td:nth-child(2)::before, #page-ledger table tbody tr td:nth-child(2)::before,
  #page-mycustomerreport table tbody tr td:nth-child(2)::before { content: ' ·  '; }
  /* the type chip renders as plain italic text in its color (bills-status style) */
  #page-statement table tbody tr .chip, #page-ledger table tbody tr .chip,
  #page-mycustomerreport table tbody tr .chip {
    background: transparent; border: 0; padding: 0;
    font-weight: 400; font-style: italic; font-size: 12.5px;
  }
  /* LEFT · line 2: description, line 3: reference */
  #page-statement table tbody tr td:nth-child(4), #page-ledger table tbody tr td:nth-child(4),
  #page-mycustomerreport table tbody tr td:nth-child(4) { grid-area: 2 / 1 / 3 / 4; font-weight: 600; }
  #page-statement table tbody tr td:nth-child(3), #page-ledger table tbody tr td:nth-child(3),
  #page-mycustomerreport table tbody tr td:nth-child(3) {
    grid-area: 3 / 1 / 4 / 4;
    font-size: 11px; color: var(--muted); font-style: italic;
  }
  #page-statement table tbody tr td:nth-child(3)::before, #page-ledger table tbody tr td:nth-child(3)::before,
  #page-mycustomerreport table tbody tr td:nth-child(3)::before { content: 'Ref: '; }
  /* RIGHT · debit / credit / balance, tagged so the dashes stay meaningful */
  #page-statement table tbody tr td:nth-child(5), #page-ledger table tbody tr td:nth-child(5),
  #page-mycustomerreport table tbody tr td:nth-child(5),
  #page-statement table tbody tr td:nth-child(6), #page-ledger table tbody tr td:nth-child(6),
  #page-mycustomerreport table tbody tr td:nth-child(6),
  #page-statement table tbody tr td:nth-child(7), #page-ledger table tbody tr td:nth-child(7),
  #page-mycustomerreport table tbody tr td:nth-child(7) { font-weight: 600; white-space: nowrap; }
  #page-statement table tbody tr td:nth-child(5), #page-ledger table tbody tr td:nth-child(5),
  #page-mycustomerreport table tbody tr td:nth-child(5) { grid-area: 1 / 4; justify-self: end; }
  #page-statement table tbody tr td:nth-child(6), #page-ledger table tbody tr td:nth-child(6),
  #page-mycustomerreport table tbody tr td:nth-child(6) { grid-area: 2 / 4; justify-self: end; }
  #page-statement table tbody tr td:nth-child(7), #page-ledger table tbody tr td:nth-child(7),
  #page-mycustomerreport table tbody tr td:nth-child(7) { grid-area: 3 / 4; justify-self: end; }
  #page-statement table tbody tr td:nth-child(5)::before, #page-ledger table tbody tr td:nth-child(5)::before,
  #page-mycustomerreport table tbody tr td:nth-child(5)::before { content: 'Dr '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-statement table tbody tr td:nth-child(6)::before, #page-ledger table tbody tr td:nth-child(6)::before,
  #page-mycustomerreport table tbody tr td:nth-child(6)::before { content: 'Cr '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-statement table tbody tr td:nth-child(7)::before, #page-ledger table tbody tr td:nth-child(7)::before,
  #page-mycustomerreport table tbody tr td:nth-child(7)::before { content: 'Bal '; color: var(--muted); font-weight: 400; font-size: 11px; }
  /* full-width informational rows, should any appear */
  #page-statement table tbody tr td[colspan], #page-ledger table tbody tr td[colspan],
  #page-mycustomerreport table tbody tr td[colspan] { grid-column: 1 / -1 !important; }
}
/* ============================================================================
   cont-210: QUEUE / RETURNS / DELIVERY / VOUCHERS on phones — the cont-207
   bills pattern applied to the remaining list tables (each list table is
   tagged m-list; desktop is untouched). Shared machinery below, then each
   page's column→cell map:
   · QUEUE      line 1 date (net right) · line 2 customer · line 3 ordered
                by · line 4 notes · buttons right under the net
   · RETURNS    line 1 "RTN-…, date" (total right) · line 2 customer ·
                line 3 status · line 4 against bill · line 5 received by
   · DELIVERY   line 1 "FB-…, date" (total right) · line 2 customer · line 3
                pending-delivery status
   · VOUCHERS   (discounts / expenses / payments / transfers) line 1
                "VCH-…, date" (amount right) · line 2 the main text
                (customer / category / from / to) · line 3 status · line 4+
                the quiet facts (type / paid from / received in / spent or
                collected by). Draft vouchers carry no number (a muted dash)
                — the comma is gated by td:has(strong) so drafts read just
                the date, and the dash itself is hidden.
   Deleted rows (void-msg) span the full width under the no/date line.
   ========================================================================== */
@media (max-width: 640px) {
  #page-queue table.m-list, #page-returns table.m-list, #page-delivery table.m-list,
  #page-discounts table.m-list, #page-expenses table.m-list, #page-payments table.m-list,
  #page-transfers table.m-list { display: block; }
  #page-queue table.m-list thead, #page-returns table.m-list thead,
  #page-delivery table.m-list thead, #page-discounts table.m-list thead,
  #page-expenses table.m-list thead, #page-payments table.m-list thead,
  #page-transfers table.m-list thead { display: none; }
  #page-queue table.m-list tbody, #page-returns table.m-list tbody,
  #page-delivery table.m-list tbody, #page-discounts table.m-list tbody,
  #page-expenses table.m-list tbody, #page-payments table.m-list tbody,
  #page-transfers table.m-list tbody { display: block; }
  #page-queue table.m-list tbody tr, #page-returns table.m-list tbody tr,
  #page-delivery table.m-list tbody tr, #page-discounts table.m-list tbody tr,
  #page-expenses table.m-list tbody tr, #page-payments table.m-list tbody tr,
  #page-transfers table.m-list tbody tr {
    display: grid;
    grid-template-columns: min-content max-content minmax(0, 1fr) minmax(auto, 46vw);
    gap: 2px 0;
    padding: 10px 12px;
  }
  #page-queue table.m-list tbody tr + tr, #page-returns table.m-list tbody tr + tr,
  #page-delivery table.m-list tbody tr + tr, #page-discounts table.m-list tbody tr + tr,
  #page-expenses table.m-list tbody tr + tr, #page-payments table.m-list tbody tr + tr,
  #page-transfers table.m-list tbody tr + tr { border-top: 1px solid var(--line); }
  #page-queue table.m-list tbody tr td, #page-returns table.m-list tbody tr td,
  #page-delivery table.m-list tbody tr td, #page-discounts table.m-list tbody tr td,
  #page-expenses table.m-list tbody tr td, #page-payments table.m-list tbody tr td,
  #page-transfers table.m-list tbody tr td { border: 0; padding: 0; background: none; }
  /* cont-194: per-page filter order on phones — search/type first, then the
     dates, then the remaining controls */
  #page-returns .filters > #ret-search { order: 1; }
  #page-returns .filters > #ret-status { order: 2; }
  #page-returns .filters > #ret-from { order: 3; }
  #page-returns .filters > #ret-to { order: 4; }
  #page-returns .filters > #ret-today { order: 5; }
  #page-returns .filters > #ret-reset { order: 6; }
  #page-delivery .filters > #dlv-from { order: 1; }
  #page-delivery .filters > #dlv-to { order: 2; }
  #page-delivery .filters > #dlv-search { order: 3; }
  #page-delivery .filters > #dlv-today { order: 4; }
  #page-delivery .filters > #dlv-reset { order: 5; }
  #page-payments .filters > #pay-search { order: 1; }
  #page-payments .filters > #pay-account { order: 2; }
  #page-payments .filters > #pay-from { order: 3; }
  #page-payments .filters > #pay-to { order: 4; }
  #page-payments .filters > #pay-status { order: 5; }
  #page-payments .filters > #pay-today { order: 6; }
  #page-payments .filters > #pay-reset { order: 7; }
  #page-discounts .filters > #dis-search { order: 1; }
  #page-discounts .filters > #dis-type { order: 2; }
  #page-discounts .filters > #dis-from { order: 3; }
  #page-discounts .filters > #dis-to { order: 4; }
  #page-discounts .filters > #dis-status { order: 5; }
  #page-discounts .filters > #dis-today { order: 6; }
  #page-discounts .filters > #dis-reset { order: 7; }
  #page-expenses .filters > #exp-search { order: 1; }
  #page-expenses .filters > #exp-cat { order: 2; }
  #page-expenses .filters > #exp-from { order: 3; }
  #page-expenses .filters > #exp-to { order: 4; }
  #page-expenses .filters > #exp-status { order: 5; }
  #page-expenses .filters > #exp-acc { order: 6; }
  #page-expenses .filters > #exp-today { order: 7; }
  #page-expenses .filters > #exp-reset { order: 8; }
  #page-expenses .filters > #exp-print { order: 9; }
  #page-transfers .filters > #tr-search { order: 1; }
  #page-transfers .filters > #tr-account-filter { order: 2; }
  #page-transfers .filters > #tr-from { order: 3; }
  #page-transfers .filters > #tr-to { order: 4; }
  #page-transfers .filters > #tr-status { order: 5; }
  #page-transfers .filters > #tr-today { order: 6; }
  #page-transfers .filters > #tr-reset { order: 7; }
  /* status chips/badges → plain italic text in their color (bills style) */
  #page-queue table.m-list .badge, #page-returns table.m-list .badge,
  #page-delivery table.m-list .badge, #page-discounts table.m-list .badge,
  #page-expenses table.m-list .badge, #page-payments table.m-list .badge,
  #page-transfers table.m-list .badge, #page-purchases table.m-list .badge,
  #page-localpurchase table.m-list .badge, #page-supplierpayments table.m-list .badge,
  #page-users table.m-list .badge {
    background: transparent; border: 0; padding: 0;
    font-weight: 400; font-style: italic; font-size: 12.5px;
  }
  /* the queue's "limit exceeds" credit chip rides under the net amount */
  #page-queue table.m-list .over-chip {
    background: transparent; border: 0; padding: 0;
    font-weight: 400; font-style: italic; font-size: 11px;
  }
  /* buttons wrap under the amount instead of stretching the row */
  #page-queue table.m-list td.actions, #page-returns table.m-list td.actions,
  #page-delivery table.m-list td.actions, #page-discounts table.m-list td.actions,
  #page-expenses table.m-list td.actions, #page-payments table.m-list td.actions,
  #page-transfers table.m-list td.actions {
    white-space: normal; max-width: 46vw; text-align: right;
  }
  #page-queue table.m-list td.actions .btn, #page-returns table.m-list td.actions .btn,
  #page-delivery table.m-list td.actions .btn, #page-discounts table.m-list td.actions .btn,
  #page-expenses table.m-list td.actions .btn, #page-payments table.m-list td.actions .btn,
  #page-transfers table.m-list td.actions .btn { margin: 1px 0 1px .3rem; }
  /* full-width informational (deleted) rows */
  #page-queue table.m-list td[colspan], #page-returns table.m-list td[colspan],
  #page-delivery table.m-list td[colspan], #page-discounts table.m-list td[colspan],
  #page-expenses table.m-list td[colspan], #page-payments table.m-list td[colspan],
  #page-transfers table.m-list td[colspan] { grid-column: 1 / -1 !important; }

  /* ---- APPROVAL QUEUE (cont-194 re-map): line 1 = customer | net (the
     "limit exceeds" chip stacks BELOW the amount), line 2 = date with time,
     line 3 = ordered by, line 4 = notes (full width, left, quiet), line 5 =
     the buttons in ONE line right-aligned with the short View / Appr / Rej /
     Del labels ---- */
  #page-queue table.m-list tbody tr td:nth-child(2) { grid-area: 1 / 1 / 2 / 4; font-weight: 600; }
  #page-queue table.m-list tbody tr td:nth-child(4) {
    grid-area: 1 / 4; justify-self: end;
    font-weight: 600; white-space: nowrap;
    /* the amount text node and the over-chip stack vertically, right aligned */
    display: flex; flex-direction: column; align-items: flex-end; gap: 1px;
  }
  #page-queue table.m-list tbody tr td:nth-child(1) { grid-area: 2 / 1 / 3 / 5; white-space: nowrap; }
  /* ordered by + notes: the same quiet grey italics as the bills cards */
  #page-queue table.m-list tbody tr td:nth-child(3),
  #page-queue table.m-list tbody tr td:nth-child(5) {
    font-size: 11px; color: var(--muted); font-style: italic;
  }
  #page-queue table.m-list tbody tr td:nth-child(3) { grid-area: 3 / 1 / 4 / 5; }
  #page-queue table.m-list tbody tr td:nth-child(3)::before { content: 'Ordered by '; }
  #page-queue table.m-list tbody tr td:nth-child(5) { grid-area: 4 / 1 / 5 / -1; text-align: left; }
  #page-queue table.m-list tbody tr td:nth-child(5)::before { content: 'Notes: '; }
  /* the buttons: ONE line, left to right, right-aligned — the shared block's
     46vw cap and wrapping are undone for the queue only */
  #page-queue table.m-list td.actions { white-space: nowrap; max-width: none; }
  #page-queue table.m-list tbody tr td:nth-child(6) { grid-area: 5 / 1 / 6 / -1; }
  #page-queue .blong { display: none; }
  #page-queue .bmini { display: inline; }
  /* filters on phones: search → bill types → date from → date to → reset
     (the Date from / Date to placeholders are the cont-209 overlay) */
  #page-queue .filters > #q-search { order: 1; }
  #page-queue .filters > #q-credit { order: 2; }
  #page-queue .filters > #q-from { order: 3; }
  #page-queue .filters > #q-to { order: 4; }
  #page-queue .filters > #q-reset { order: 5; }

  /* ---- SALES RETURNS (cont-194 re-map): line 1 = no, date | total;
     line 2 = customer | status; line 3 = "Received by X against bill no Y"
     (the against-bill no rides in a data attribute; without a bill the line
     reads just "Received by X") — quiet grey italics; line 4 = buttons ---- */
  #page-returns table.m-list tbody tr td:nth-child(1) { grid-area: 1 / 1; font-weight: 600; }
  #page-returns table.m-list tbody tr td:nth-child(1) strong { white-space: nowrap; }
  /* pending returns carry a muted dash instead of a number — hide it so the
     date reads clean; the comma only appears when a number exists */
  #page-returns table.m-list tbody tr td:nth-child(1):not(:has(strong)) { visibility: hidden; }
  #page-returns table.m-list tbody tr td:nth-child(1):has(strong) ~ td:nth-child(2)::before { content: ', '; }
  #page-returns table.m-list tbody tr td:nth-child(2) { grid-area: 1 / 2; white-space: nowrap; }
  #page-returns table.m-list tbody tr td:nth-child(5) { grid-area: 1 / 4; justify-self: end; font-weight: 600; white-space: nowrap; }
  #page-returns table.m-list tbody tr td:nth-child(3) { grid-area: 2 / 1 / 3 / 4; font-weight: 600; }
  #page-returns table.m-list tbody tr td:nth-child(7) { grid-area: 2 / 4; justify-self: end; font-size: 12.5px; }
  #page-returns table.m-list tbody tr td:nth-child(6) {
    grid-area: 3 / 1 / 4 / -1; text-align: left;
    font-size: 11px; color: var(--muted); font-style: italic;
  }
  #page-returns table.m-list tbody tr td:nth-child(6)::before { content: 'Received by '; }
  #page-returns table.m-list tbody tr td:nth-child(6)[data-bill]::after { content: ' against bill no ' attr(data-bill); }
  /* the Against Bill No column is redundant on phones — its number is already
     woven into the received-by line */
  #page-returns table.m-list tbody tr td:nth-child(4) { display: none; }
  #page-returns table.m-list tbody tr td:nth-child(8) {
    grid-area: 4 / 1 / 5 / -1; max-width: none; white-space: nowrap; text-align: right;
  }

  /* ---- DELIVERY (cont-194 re-map): line 1 = no, date | total;
     line 2 = customer | "pending delivery"; line 3 = buttons right-aligned
     with the short mobile labels (View / Confirm) ---- */
  #page-delivery table.m-list tbody tr td:nth-child(1) { grid-area: 1 / 1; }
  #page-delivery table.m-list tbody tr td:nth-child(1) strong { white-space: nowrap; }
  #page-delivery table.m-list tbody tr td:nth-child(2) { grid-area: 1 / 2; }
  #page-delivery table.m-list tbody tr td:nth-child(2)::before { content: ', '; font-weight: 400; }
  #page-delivery table.m-list tbody tr td:nth-child(5) { grid-area: 1 / 4; justify-self: end; font-weight: 600; white-space: nowrap; }
  #page-delivery table.m-list tbody tr td:nth-child(4) { grid-area: 2 / 1 / 3 / 4; font-weight: 600; }
  #page-delivery table.m-list tbody tr td:nth-child(3) { grid-area: 2 / 4; justify-self: end; font-size: 12.5px; }
  #page-delivery table.m-list tbody tr td:nth-child(6) {
    grid-area: 3 / 1 / 4 / -1; max-width: none; white-space: nowrap; text-align: right;
  }
  #page-delivery .blong { display: none; }
  #page-delivery .bmini { display: inline; }

  /* ---- VOUCHERS shared: no, date | amount | main text · buttons | status |
     quiet facts (discounts: type · expenses: paid from + spent by ·
     payments: received in + collected by · transfers: from → to) ---- */
  #page-discounts table.m-list tbody tr td:nth-child(1),
  #page-expenses table.m-list tbody tr td:nth-child(1),
  #page-payments table.m-list tbody tr td:nth-child(1),
  #page-transfers table.m-list tbody tr td:nth-child(1) { grid-area: 1 / 1; font-weight: 600; }
  #page-discounts table.m-list tbody tr td:nth-child(1) strong,
  #page-expenses table.m-list tbody tr td:nth-child(1) strong,
  #page-payments table.m-list tbody tr td:nth-child(1) strong,
  #page-transfers table.m-list tbody tr td:nth-child(1) strong { white-space: nowrap; }
  /* draft vouchers carry a muted dash instead of a number — hide it; the
     comma only appears when the voucher has a number */
  #page-discounts table.m-list tbody tr td:nth-child(1):not(:has(strong)),
  #page-expenses table.m-list tbody tr td:nth-child(1):not(:has(strong)),
  #page-payments table.m-list tbody tr td:nth-child(1):not(:has(strong)),
  #page-transfers table.m-list tbody tr td:nth-child(1):not(:has(strong)) { visibility: hidden; }
  #page-discounts table.m-list tbody tr td:nth-child(1):has(strong) ~ td:nth-child(2)::before,
  #page-expenses table.m-list tbody tr td:nth-child(1):has(strong) ~ td:nth-child(2)::before,
  #page-payments table.m-list tbody tr td:nth-child(1):has(strong) ~ td:nth-child(2)::before,
  #page-transfers table.m-list tbody tr td:nth-child(1):has(strong) ~ td:nth-child(2)::before { content: ', '; }
  #page-discounts table.m-list tbody tr td:nth-child(2),
  #page-expenses table.m-list tbody tr td:nth-child(2),
  #page-payments table.m-list tbody tr td:nth-child(2),
  #page-transfers table.m-list tbody tr td:nth-child(2) { grid-area: 1 / 2; white-space: nowrap; }
  #page-discounts table.m-list tbody tr td:nth-child(5),
  #page-expenses table.m-list tbody tr td:nth-child(4),
  #page-payments table.m-list tbody tr td:nth-child(5),
  #page-transfers table.m-list tbody tr td:nth-child(5) {
    grid-area: 1 / 4; justify-self: end; white-space: nowrap;
  }
  #page-discounts table.m-list tbody tr td:nth-child(7),
  #page-expenses table.m-list tbody tr td:nth-child(8),
  #page-payments table.m-list tbody tr td:nth-child(8),
  #page-transfers table.m-list tbody tr td:nth-child(7) { grid-area: 2 / 4; justify-self: end; }
  #page-discounts table.m-list tbody tr td:nth-child(3),
  #page-payments table.m-list tbody tr td:nth-child(3) { grid-area: 2 / 1 / 3 / 4; font-weight: 600; }
  #page-expenses table.m-list tbody tr td:nth-child(3) { grid-area: 2 / 1 / 3 / 4; font-weight: 600; }
  /* cont-195 TRANSFERS (journal contra) re-map: line 2 = "from account →
     to account" with NO labels (the to-account rides in a data attribute —
     the To column is redundant on phones) | status right, line 3 = buttons */
  #page-transfers table.m-list tbody tr td:nth-child(3):not(.void-msg) {
    grid-area: 2 / 1 / 3 / 4; font-weight: 600; text-align: left;
  }
  #page-transfers table.m-list tbody tr td:nth-child(3):not(.void-msg)[data-to]::after {
    content: ' → ' attr(data-to);
  }
  #page-transfers table.m-list tbody tr td:nth-child(4) { display: none; }
  #page-transfers table.m-list tbody tr td:nth-child(6) {
    grid-area: 2 / 4; justify-self: end; font-size: 12.5px; font-style: italic;
  }
  #page-transfers table.m-list tbody tr td:nth-child(7) {
    grid-area: 3 / 1 / 4 / -1; max-width: none; white-space: nowrap; text-align: right;
  }
  /* status gets its own line, then the quiet facts (transfers: line 4 —
     its To-account occupies line 3) */
  #page-discounts table.m-list tbody tr td:nth-child(6),
  #page-expenses table.m-list tbody tr td:nth-child(7),
  #page-payments table.m-list tbody tr td:nth-child(7) {
    grid-area: 3 / 1 / 4 / 4; font-size: 12.5px; font-style: italic;
  }

  #page-discounts table.m-list tbody tr td:nth-child(4),
  #page-expenses table.m-list tbody tr td:nth-child(5),
  #page-payments table.m-list tbody tr td:nth-child(4),
  #page-expenses table.m-list tbody tr td:nth-child(6),
  #page-payments table.m-list tbody tr td:nth-child(6) {
    font-size: 11px; color: var(--muted); font-style: italic;
  }
  /* cont-194 DISCOUNT VOUCHERS re-map: line 2 = customer | status, line 3 =
     the type (as before), line 4 = buttons; the amount goes semi-bold */
  #page-discounts table.m-list tbody tr td:nth-child(5) { font-weight: 600; }
  #page-discounts table.m-list tbody tr td:nth-child(6) {
    grid-area: 2 / 4; justify-self: end; font-size: 12.5px;
  }
  #page-discounts table.m-list tbody tr td:nth-child(4) { grid-area: 3 / 1 / 4 / -1; text-align: left; }
  #page-discounts table.m-list tbody tr td:nth-child(4)::before { content: 'Type: '; }
  #page-discounts table.m-list tbody tr td:nth-child(7) { grid-area: 4 / 1 / 5 / -1; }
  /* cont-195 EXPENSES re-map: line 2 = category | status, line 3 = "Spent
     by X, <paid-from>" full width quiet italics (the account rides in a
     data attribute — the Paid From column is redundant on phones), line 4 =
     buttons; the amount keeps its bold */
  #page-expenses table.m-list tbody tr td:nth-child(7) {
    grid-area: 2 / 4; justify-self: end; font-size: 12.5px;
  }
  #page-expenses table.m-list tbody tr td:nth-child(8) { grid-area: 4 / 1 / 5 / -1; }
  #page-expenses table.m-list tbody tr td:nth-child(5) { display: none; }
  #page-expenses table.m-list tbody tr td:nth-child(6) {
    grid-area: 3 / 1 / 4 / -1; text-align: left;
    font-size: 11px; color: var(--muted); font-style: italic;
  }
  #page-expenses table.m-list tbody tr td:nth-child(6)::before { content: 'Spent by '; }
  #page-expenses table.m-list tbody tr td:nth-child(6)[data-acc]::after { content: ', ' attr(data-acc); }
  /* cont-194 RECEIVE PAYMENTS re-map: line 2 = customer | status, line 3 =
     "Collected by X, <account>" full width quiet italics (the account name
     rides in a data attribute — the Received-In column is redundant on
     phones), line 4 = buttons; the amount goes semi-bold like the others */
  #page-payments table.m-list tbody tr td:nth-child(5) { font-weight: 600; }
  #page-payments table.m-list tbody tr td:nth-child(7) {
    grid-area: 2 / 4; justify-self: end; font-size: 12.5px;
  }
  #page-payments table.m-list tbody tr td:nth-child(8) { grid-area: 4 / 1 / 5 / -1; }
  #page-payments table.m-list tbody tr td:nth-child(4) { display: none; }
  #page-payments table.m-list tbody tr td:nth-child(6) {
    grid-area: 3 / 1 / 4 / -1; text-align: left;
    font-size: 11px; color: var(--muted); font-style: italic;
  }
  #page-payments table.m-list tbody tr td:nth-child(6)::before { content: 'Collected by '; }
  #page-payments table.m-list tbody tr td:nth-child(6)[data-acc]::after { content: ', ' attr(data-acc); }

  /* deleted-row messages span the width and keep their regular weight — the
     main-text placement rules above also land on the message cell */
  #page-returns table.m-list td.void-msg, #page-discounts table.m-list td.void-msg,
  #page-expenses table.m-list td.void-msg, #page-payments table.m-list td.void-msg,
  #page-transfers table.m-list td.void-msg, #page-purchases table.m-list td.void-msg,
  #page-localpurchase table.m-list td.void-msg, #page-supplierpayments table.m-list td.void-msg {
    font-weight: 400;
  }
  /* deleted/empty rows must ALWAYS span the full width — re-asserted here so
     the per-page placement maps above (equal specificity, later order) can
     never squeeze the message into one column */
  #page-queue table.m-list tbody tr td[colspan], #page-returns table.m-list tbody tr td[colspan],
  #page-delivery table.m-list tbody tr td[colspan], #page-discounts table.m-list tbody tr td[colspan],
  #page-expenses table.m-list tbody tr td[colspan], #page-payments table.m-list tbody tr td[colspan],
  #page-transfers table.m-list tbody tr td[colspan], #page-purchases table.m-list tbody tr td[colspan],
  #page-localpurchase table.m-list tbody tr td[colspan], #page-supplierpayments table.m-list tbody tr td[colspan] {
    grid-area: 2 / 1 / 3 / -1 !important;
  }
  /* cont-223: the four voucher pages' action buttons sit on ONE merged row
     AND look exactly like the bills page's buttons — natural width, the
     default .btn.small mobile padding, right-aligned (no flex stretch, no
     padding override); nowrap keeps the row single-line */
  #page-payments table.m-list tbody tr td.actions,
  #page-expenses table.m-list tbody tr td.actions,
  #page-discounts table.m-list tbody tr td.actions,
  #page-transfers table.m-list tbody tr td.actions {
    max-width: none; white-space: nowrap; text-align: right; justify-self: stretch;
  }
  #page-payments table.m-list tbody tr td.actions .btn,
  #page-expenses table.m-list tbody tr td.actions .btn,
  #page-discounts table.m-list tbody tr td.actions .btn,
  #page-transfers table.m-list tbody tr td.actions .btn { margin: 2px 0 2px .3rem; vertical-align: top; }
}
/* ============================================================================
   cont-211: DELETED BILLS / CUSTOMERS / ZONES / SALES PERSONS / CUSTOMER
   PREFERENCE on phones (card rows, m-list) — and a numeric-panel variant
   (n-list) for SALES REPORT, MY RECEIVABLE and the sales-persons report,
   where a row is mostly numbers: the name leads, the balance sits top-right,
   the remaining figures flow as tagged label+value cells in a 3-column grid
   (group / subtotal / grand-total rows share the same map). Desktop
   untouched. The DELETED BILLS reason spans the FULL row width (2/1/3/-1) —
   it must never squeeze into one column on a phone.
   ========================================================================== */
@media (max-width: 640px) {
  #page-deletedbills table.m-list, #page-customers table.m-list, #page-zones table.m-list,
  #page-salespersons table.m-list, #page-customerpreference table.m-list { display: block; }
  #page-deletedbills table.m-list thead, #page-customers table.m-list thead,
  #page-zones table.m-list thead, #page-salespersons table.m-list thead,
  #page-customerpreference table.m-list thead { display: none; }
  #page-deletedbills table.m-list tbody, #page-customers table.m-list tbody,
  #page-zones table.m-list tbody, #page-salespersons table.m-list tbody,
  #page-customerpreference table.m-list tbody { display: block; }
  #page-deletedbills table.m-list tbody tr, #page-customers table.m-list tbody tr,
  #page-zones table.m-list tbody tr, #page-salespersons table.m-list tbody tr,
  #page-customerpreference table.m-list tbody tr {
    display: grid;
    grid-template-columns: min-content max-content minmax(0, 1fr) minmax(auto, 46vw);
    gap: 2px 0;
    padding: 10px 12px;
  }
  #page-deletedbills table.m-list tbody tr + tr, #page-customers table.m-list tbody tr + tr,
  #page-zones table.m-list tbody tr + tr, #page-salespersons table.m-list tbody tr + tr,
  #page-customerpreference table.m-list tbody tr + tr { border-top: 1px solid var(--line); }
  #page-deletedbills table.m-list tbody tr td, #page-customers table.m-list tbody tr td,
  #page-zones table.m-list tbody tr td, #page-salespersons table.m-list tbody tr td,
  #page-customerpreference table.m-list tbody tr td { border: 0; padding: 0; background: none; }
  #page-customers table.m-list td.actions, #page-zones table.m-list td.actions,
  #page-salespersons table.m-list td.actions, #page-customerpreference table.m-list td.actions {
    white-space: normal; max-width: 46vw; text-align: right;
  }
  #page-customers table.m-list td.actions .btn, #page-zones table.m-list td.actions .btn,
  #page-salespersons table.m-list td.actions .btn, #page-customerpreference table.m-list td.actions .btn {
    margin: 1px 0 1px .3rem;
  }
  #page-deletedbills table.m-list td[colspan], #page-customers table.m-list td[colspan],
  #page-zones table.m-list td[colspan], #page-salespersons table.m-list td[colspan],
  #page-customerpreference table.m-list td[colspan] { grid-column: 1 / -1 !important; }

  /* ---- DELETED BILLS: no, date | Details · reason (FULL width) · type · by ---- */
  #page-deletedbills table.m-list tbody tr td:nth-child(1) { grid-area: 1 / 1; font-weight: 600; }
  #page-deletedbills table.m-list tbody tr td:nth-child(1) strong { white-space: nowrap; }
  #page-deletedbills table.m-list tbody tr td:nth-child(3) { grid-area: 1 / 2; white-space: nowrap; }
  #page-deletedbills table.m-list tbody tr td:nth-child(3)::before { content: ', '; font-weight: 400; }
  #page-deletedbills table.m-list tbody tr td:nth-child(6) { grid-area: 1 / 4; justify-self: end; white-space: normal; }
  /* the reason merges BOTH columns — one full-width line under the no/date
     (the td carries an inline max-width for the desktop column — beat it) */
  #page-deletedbills table.m-list tbody tr td:nth-child(4) {
    grid-area: 2 / 1 / 3 / -1; font-size: 13px; max-width: none !important;
  }
  #page-deletedbills table.m-list tbody tr td:nth-child(4)::before {
    content: 'Reason: '; color: var(--muted); font-size: 11px;
  }
  #page-deletedbills table.m-list tbody tr td:nth-child(2),
  #page-deletedbills table.m-list tbody tr td:nth-child(5) {
    font-size: 11px; color: var(--muted); font-style: italic;
  }
  #page-deletedbills table.m-list tbody tr td:nth-child(2) { grid-area: 3 / 1 / 4 / 4; }
  #page-deletedbills table.m-list tbody tr td:nth-child(2)::before { content: 'Type: '; }
  #page-deletedbills table.m-list tbody tr td:nth-child(5) { grid-area: 4 / 1 / 5 / 4; }
  #page-deletedbills table.m-list tbody tr td:nth-child(5)::before { content: 'By: '; }

  /* ---- CUSTOMERS (cont-195 re-map): line 1 = name, line 2 = "Op: x,
     Limit: y", line 3 = "Sales by: z, Assigned: …" quiet italics (the
     assigned names ride in a data attribute; the Zone column stays
     desktop-only), line 4 = buttons right ---- */
  #page-customers table.m-list tbody tr td:nth-child(1) { grid-area: 1 / 1 / 2 / 4; font-weight: 600; }
  #page-customers table.m-list tbody tr td:nth-child(4) { grid-area: 2 / 1; white-space: nowrap; }
  #page-customers table.m-list tbody tr td:nth-child(4)::before { content: 'Op: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-customers table.m-list tbody tr td:nth-child(4)::after { content: ', '; }
  #page-customers table.m-list tbody tr td:nth-child(5) { grid-area: 2 / 2; white-space: nowrap; }
  #page-customers table.m-list tbody tr td:nth-child(5)::before { content: 'Limit: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-customers table.m-list tbody tr td:nth-child(3) {
    grid-area: 3 / 1 / 4 / -1; text-align: left;
    font-size: 11px; color: var(--muted); font-style: italic;
  }
  #page-customers table.m-list tbody tr td:nth-child(3)::before { content: 'Sales by: '; }
  #page-customers table.m-list tbody tr td:nth-child(3)[data-assigned]::after { content: ', Assigned: ' attr(data-assigned); }
  #page-customers table.m-list tbody tr td:nth-child(2),
  #page-customers table.m-list tbody tr td:nth-child(6) { display: none; }
  #page-customers table.m-list tbody tr td:nth-child(7) {
    grid-area: 4 / 1 / 5 / -1; max-width: none; white-space: nowrap; text-align: right;
  }

  /* ---- ZONES (cont-195): line 1 = name | customers count, line 2 =
     "Coverage area: …" quiet italics, line 3 = buttons right ---- */
  #page-zones table.m-list tbody tr td:nth-child(1) { grid-area: 1 / 1 / 2 / 3; font-weight: 600; }
  #page-zones table.m-list tbody tr td:nth-child(3) { grid-area: 1 / 4; justify-self: end; font-weight: 600; white-space: nowrap; }
  #page-zones table.m-list tbody tr td:nth-child(3)::before { content: 'Customers: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-zones table.m-list tbody tr td:nth-child(2) {
    grid-area: 2 / 1 / 3 / -1; text-align: left;
    font-size: 11px; color: var(--muted); font-style: italic;
  }
  #page-zones table.m-list tbody tr td:nth-child(2)::before { content: 'Coverage area: '; }
  #page-zones table.m-list tbody tr td:nth-child(4) {
    grid-area: 3 / 1 / 4 / -1; max-width: none; white-space: nowrap; text-align: right;
  }

  /* ---- SALES PERSONS list (cont-195): line 1 = name | customers count,
     line 2 = "Phone: x, Email: y" quiet italics (the email rides in a data
     attribute — it has no desktop column), line 3 = buttons right ---- */
  #page-salespersons table.m-list tbody tr td:nth-child(1) { grid-area: 1 / 1 / 2 / 3; font-weight: 600; }
  #page-salespersons table.m-list tbody tr td:nth-child(3) { grid-area: 1 / 4; justify-self: end; font-weight: 600; white-space: nowrap; }
  #page-salespersons table.m-list tbody tr td:nth-child(3)::before { content: 'Customers: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-salespersons table.m-list tbody tr td:nth-child(2) {
    grid-area: 2 / 1 / 3 / -1; text-align: left;
    font-size: 11px; color: var(--muted); font-style: italic;
  }
  #page-salespersons table.m-list tbody tr td:nth-child(2)::before { content: 'Phone: '; }
  #page-salespersons table.m-list tbody tr td:nth-child(2)[data-email]::after { content: ', Email: ' attr(data-email); }
  #page-salespersons table.m-list tbody tr td:nth-child(4) {
    grid-area: 3 / 1 / 4 / -1; max-width: none; white-space: normal; text-align: right;
  }

  /* ---- CUSTOMER PREFERENCE: ONE column — item name (unit right) ·
     sold/returned line · buttons (owner request: with a long item name the
     side-by-side layout pushed the Sold/Returned buttons outside the card,
     so the buttons get their own full-width row) ---- */
  #page-customerpreference table.m-list tbody tr {
    grid-template-columns: minmax(0, 1fr) max-content;
    gap: 2px 10px;
  }
  #page-customerpreference table.m-list tbody tr td:nth-child(1) { grid-area: 1 / 1 / 2 / 3; font-weight: 600; }
  #page-customerpreference table.m-list tbody tr td:nth-child(1) strong { white-space: normal; }
  /* cont-195 re-map: the unit column is hidden on phones; the Returned
     figure rides in a data attribute so Sold + Returned share ONE line with
     the buttons right */
  #page-customerpreference table.m-list tbody tr td:nth-child(2),
  #page-customerpreference table.m-list tbody tr td:nth-child(4) { display: none; }
  #page-customerpreference table.m-list tbody tr td:nth-child(3) { grid-area: 2 / 1; font-weight: 600; font-size: 12.5px; text-align: left; }
  #page-customerpreference table.m-list tbody tr td:nth-child(3)::before { content: 'Sold: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-customerpreference table.m-list tbody tr td:nth-child(3)[data-ret]::after {
    content: ', Returned: ' attr(data-ret); font-weight: 400; font-size: 12.5px;
  }
  #page-customerpreference table.m-list tbody tr td:nth-child(3) strong[data-unit]::after {
    content: ' ' attr(data-unit); font-weight: 400; font-size: 11px;
  }
  #page-customerpreference table.m-list tbody tr td:nth-child(5) {
    grid-area: 2 / 2; justify-self: end; text-align: right; max-width: none; white-space: nowrap;
  }
  #page-customerpreference table.m-list tbody tr td:nth-child(5) .btn { margin: 1px 0 1px .3rem; }
  /* group header rows keep their banded look */
  #page-customerpreference table.m-list tbody tr.type-head td {
    background: #e4e8ee; border-top: 2px solid var(--line);
    font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); padding: .55rem .6rem .2rem;
  }

  /* ---- numeric-panel machinery (n-list): sales report, my receivable,
          sales-persons report — 3 equal columns of tagged figures ---- */
  #page-salesreport table.n-list, #page-myreceivable table.n-list,
  #page-salespersons table.n-list, #page-receivable table.n-list { display: block; }
  #page-salesreport table.n-list thead, #page-myreceivable table.n-list thead,
  #page-salespersons table.n-list thead, #page-receivable table.n-list thead { display: none; }
  #page-salesreport table.n-list tbody, #page-myreceivable table.n-list tbody,
  #page-salespersons table.n-list tbody, #page-receivable table.n-list tbody { display: block; }
  #page-salesreport table.n-list tbody tr, #page-myreceivable table.n-list tbody tr,
  #page-salespersons table.n-list tbody tr, #page-receivable table.n-list tbody tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2px 4px;
    padding: 10px 12px;
  }
  #page-salesreport table.n-list tbody tr + tr, #page-myreceivable table.n-list tbody tr + tr,
  #page-salespersons table.n-list tbody tr + tr, #page-receivable table.n-list tbody tr + tr { border-top: 1px solid var(--line); }
  #page-salesreport table.n-list tbody tr td, #page-myreceivable table.n-list tbody tr td,
  #page-salespersons table.n-list tbody tr td, #page-receivable table.n-list tbody tr td { border: 0; padding: 0; background: none; }
  #page-salesreport table.n-list tbody tr td[colspan],
  #page-myreceivable table.n-list tbody tr td[colspan],
  #page-salespersons table.n-list tbody tr td[colspan], #page-receivable table.n-list tbody tr td[colspan] { grid-column: 1 / -1 !important; }
  /* the figures themselves */
  #page-salesreport table.n-list tbody tr td:nth-child(n+3),
  #page-myreceivable table.n-list tbody tr td:nth-child(n+2),
  #page-salespersons table.n-list tbody tr td:nth-child(n+2), #page-receivable table.n-list tbody tr td:nth-child(n+2) {
    font-size: 12.5px; font-weight: 600;
  }
  #page-salesreport table.n-list tbody tr td:nth-child(n+3)::before,
  #page-myreceivable table.n-list tbody tr td:nth-child(n+2)::before,
  #page-salespersons table.n-list tbody tr td:nth-child(n+2)::before, #page-receivable table.n-list tbody tr td:nth-child(n+2)::before {
    color: var(--muted); font-weight: 400; font-size: 11px;
  }
  /* banded subtotal rows (My Receivable) keep their background */
  #page-myreceivable table.n-list tbody tr.alt-row td { background: var(--gray-bg); }

  /* ---- SALES REPORT: customer | balance · zone · bills/gross/disc ·
          net/ret/paid ---- */
  #page-salesreport table.n-list tbody tr td:nth-child(1) { grid-area: 1 / 1 / 2 / 3; font-weight: 600; }
  #page-salesreport table.n-list tbody tr td:nth-child(9) { grid-area: 1 / 3; justify-self: end; white-space: nowrap; }
  #page-salesreport table.n-list tbody tr td:nth-child(2) { grid-area: 2 / 1 / 3 / 4; font-size: 11px; color: var(--muted); font-style: italic; }
  #page-salesreport table.n-list tbody tr td:nth-child(2)::before { content: 'Zone: '; }
  #page-salesreport table.n-list tbody tr td:nth-child(3) { grid-area: 3 / 1; }
  #page-salesreport table.n-list tbody tr td:nth-child(3)::before { content: 'Bills: '; }
  #page-salesreport table.n-list tbody tr td:nth-child(4) { grid-area: 3 / 2; }
  #page-salesreport table.n-list tbody tr td:nth-child(4)::before { content: 'Gross: '; }
  #page-salesreport table.n-list tbody tr td:nth-child(5) { grid-area: 3 / 3; }
  #page-salesreport table.n-list tbody tr td:nth-child(5)::before { content: 'Disc: '; }
  #page-salesreport table.n-list tbody tr td:nth-child(6) { grid-area: 4 / 1; }
  #page-salesreport table.n-list tbody tr td:nth-child(6)::before { content: 'Net: '; }
  #page-salesreport table.n-list tbody tr td:nth-child(7) { grid-area: 4 / 2; }
  #page-salesreport table.n-list tbody tr td:nth-child(7)::before { content: 'Ret: '; }
  #page-salesreport table.n-list tbody tr td:nth-child(8) { grid-area: 4 / 3; }
  #page-salesreport table.n-list tbody tr td:nth-child(8)::before { content: 'Paid: '; }

  /* ---- MY RECEIVABLE: customer | balance · opening/bills/rcvd · disc/ret
     (the same map covers the per-person subtotals and the grand total) ---- */
  #page-myreceivable table.n-list tbody tr td:nth-child(1) { grid-area: 1 / 1 / 2 / 3; font-weight: 600; }
  #page-myreceivable table.n-list tbody tr td:nth-child(7) { grid-area: 1 / 3; justify-self: end; white-space: nowrap; }
  #page-myreceivable table.n-list tbody tr td:nth-child(2) { grid-area: 2 / 1; }
  #page-myreceivable table.n-list tbody tr td:nth-child(2)::before { content: 'Opening: '; }
  #page-myreceivable table.n-list tbody tr td:nth-child(3) { grid-area: 2 / 2; }
  #page-myreceivable table.n-list tbody tr td:nth-child(3)::before { content: 'Bills: '; }
  #page-myreceivable table.n-list tbody tr td:nth-child(4) { grid-area: 2 / 3; }
  #page-myreceivable table.n-list tbody tr td:nth-child(4)::before { content: 'Rcvd: '; }
  #page-myreceivable table.n-list tbody tr td:nth-child(5) { grid-area: 3 / 1; }
  #page-myreceivable table.n-list tbody tr td:nth-child(5)::before { content: 'Disc: '; }
  #page-myreceivable table.n-list tbody tr td:nth-child(6) { grid-area: 3 / 2; }
  #page-myreceivable table.n-list tbody tr td:nth-child(6)::before { content: 'Ret: '; }

  /* ---- RECEIVABLE: same shape as My Receivable — customer | balance ·
     opening/bills/rcvd · disc/ret (the grand-total row shares the map) ---- */
  #page-receivable table.n-list tbody tr td:nth-child(1) { grid-area: 1 / 1 / 2 / 3; font-weight: 600; }
  #page-receivable table.n-list tbody tr td:nth-child(7) { grid-area: 1 / 3; justify-self: end; white-space: nowrap; }
  #page-receivable table.n-list tbody tr td:nth-child(2) { grid-area: 2 / 1; }
  #page-receivable table.n-list tbody tr td:nth-child(2)::before { content: 'Opening: '; }
  #page-receivable table.n-list tbody tr td:nth-child(3) { grid-area: 2 / 2; }
  #page-receivable table.n-list tbody tr td:nth-child(3)::before { content: 'Bills: '; }
  #page-receivable table.n-list tbody tr td:nth-child(4) { grid-area: 2 / 3; }
  #page-receivable table.n-list tbody tr td:nth-child(4)::before { content: 'Rcvd: '; }
  #page-receivable table.n-list tbody tr td:nth-child(5) { grid-area: 3 / 1; }
  #page-receivable table.n-list tbody tr td:nth-child(5)::before { content: 'Disc: '; }
  #page-receivable table.n-list tbody tr td:nth-child(6) { grid-area: 3 / 2; }
  #page-receivable table.n-list tbody tr td:nth-child(6)::before { content: 'Ret: '; }
  /* sales-person group headers keep their banded look */
  #page-myreceivable table.n-list tbody tr.type-head td {
    background: #e4e8ee; border-top: 2px solid var(--line);
    font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); padding: .55rem .6rem .2rem;
  }

  /* ---- SALES PERSONS report: person | Details · customers/sales/rcvd ·
          ret/disc (grand total row shares the map) ---- */
  #page-salespersons table.n-list tbody tr td:nth-child(1) { grid-area: 1 / 1 / 2 / 3; font-weight: 600; }
  #page-salespersons table.n-list tbody tr td:nth-child(7) { grid-area: 1 / 3; justify-self: end; white-space: normal; }
  #page-salespersons table.n-list tbody tr td:nth-child(7) .btn { margin: 0 0 0 .3rem; }
  #page-salespersons table.n-list tbody tr td:nth-child(2) { grid-area: 2 / 1; }
  #page-salespersons table.n-list tbody tr td:nth-child(2)::before { content: 'Customers: '; }
  #page-salespersons table.n-list tbody tr td:nth-child(3) { grid-area: 2 / 2; }
  #page-salespersons table.n-list tbody tr td:nth-child(3)::before { content: 'Sales: '; }
  #page-salespersons table.n-list tbody tr td:nth-child(4) { grid-area: 2 / 3; }
  #page-salespersons table.n-list tbody tr td:nth-child(4)::before { content: 'Rcvd: '; }
  #page-salespersons table.n-list tbody tr td:nth-child(5) { grid-area: 3 / 1; }
  #page-salespersons table.n-list tbody tr td:nth-child(5)::before { content: 'Ret: '; }
  #page-salespersons table.n-list tbody tr td:nth-child(6) { grid-area: 3 / 2; }
  #page-salespersons table.n-list tbody tr td:nth-child(6)::before { content: 'Disc: '; }
  /* group headers and empty-state rows must ALWAYS span the full width —
     re-asserted after the per-page maps (equal specificity, later order) */
  #page-deletedbills table.m-list tbody tr td[colspan], #page-customers table.m-list tbody tr td[colspan],
  #page-zones table.m-list tbody tr td[colspan], #page-salespersons table.m-list tbody tr td[colspan],
  #page-customerpreference table.m-list tbody tr td[colspan], #page-salesreport table.n-list tbody tr td[colspan],
  #page-myreceivable table.n-list tbody tr td[colspan], #page-salespersons table.n-list tbody tr td[colspan] {
    grid-area: 1 / 1 / 2 / -1 !important;
  }
}
/* ============================================================================
   cont-212: the ZONES generated report (#zone-preview — "Customers in N
   zones", the table the Print button prints) on phones. Its columns are
   DYNAMIC (Contact / Balance toggles build 2–6 different shapes), so the
   map rides on what the cells ARE, not their position: the balance is the
   only td with class "num" (top-right, "Due: " tag); everything else is a
   plain td — # number, name (bold), then full-width quiet lines for the
   address, contact person and mobile when those columns are on. Zone
   headings (h4) and desktop are untouched. The A4 print itself is paper-
   sized by the browser and needs no phone layout.
   ========================================================================== */
@media (max-width: 640px) {
  #zone-preview table { display: block; }
  #zone-preview table thead { display: none; }
  #zone-preview table tbody { display: block; }
  #zone-preview table tbody tr {
    display: grid;
    /* the balance column is OPTIONAL (Balance toggle) — size it to its
       content so rows without it don't reserve a 46vw empty track */
    grid-template-columns: min-content max-content minmax(0, 1fr) minmax(0, max-content);
    gap: 2px 0;
    padding: 8px 12px;
  }
  #zone-preview table tbody tr + tr { border-top: 1px solid var(--line); }
  #zone-preview table tbody tr td { border: 0; padding: 0; background: none; }
  #zone-preview table tbody tr td:nth-child(1) { grid-area: 1 / 1; font-size: 11px; color: var(--muted); padding-right: 7px; }
  #zone-preview table tbody tr td:nth-child(1)::before { content: '#'; margin-right: 3px; }
  #zone-preview table tbody tr td:nth-child(2) { grid-area: 1 / 2 / 2 / 4; font-weight: 600; }
  /* the balance column — whatever position it lands at, it is the td.num */
  #zone-preview table tbody tr td.num { grid-area: 1 / 4; justify-self: end; font-weight: 600; white-space: nowrap; }
  #zone-preview table tbody tr td.num::before { content: 'Due: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #zone-preview table tbody tr td:nth-child(3):not(.num) { grid-area: 2 / 1 / 3 / 4; font-size: 11px; color: var(--muted); font-style: italic; }
  #zone-preview table tbody tr td:nth-child(3):not(.num)::before { content: 'Addr: '; }
  #zone-preview table tbody tr td:nth-child(4) { grid-area: 3 / 1 / 4 / 4; font-size: 11px; color: var(--muted); font-style: italic; }
  #zone-preview table tbody tr td:nth-child(4)::before { content: 'Contact: '; }
  #zone-preview table tbody tr td:nth-child(5):not(.num) { grid-area: 4 / 1 / 5 / 4; font-size: 11px; color: var(--muted); font-style: italic; }
  #zone-preview table tbody tr td:nth-child(5):not(.num)::before { content: 'Mobile: '; }
  #zone-preview table tbody tr td[colspan] { grid-column: 1 / -1 !important; }
}
/* the audit details render in FULL now (mobile request) — on wide screens
   clamp the cell to two lines so a long JSON blob doesn't blow up the row */
#page-logs table.m-list tbody tr td:nth-child(5) {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
/* ============================================================================
   cont-213: PURCHASES / SUPPLIERS / ACCOUNTS / ADMIN groups + the rest of
   CUSTOMER PREFERENCE on phones (card rows, m-list; desktop untouched):
   · PURCHASES + LOCAL PURCHASE — same pattern as the voucher registers:
     "PU-…, date" (total right) · supplier · status · "Mode: …"; deleted
     purchases keep their reason message full width (cont-210 re-assert)
   · SUPPLIERS — name (+ inactive chip) | due (per currency, wraps) ·
     "Country: …" quiet · buttons; the LOCAL/FOREIGN section bands stay
   · SUPPLIER PAYMENTS — "SP-…, date" (amount right) · supplier · buttons ·
     "Mode / BDT / Created by" quiet lines · status; deleted reason full width
   · ACCOUNTS — account (+ no / details) | balance · "Type: …" quiet ·
     Op / In / Out figures in a 3-cell line · buttons
   · ACCOUNT STATEMENT — the statement row shape with In / Out / Bal tags
   · MODIFIED BILLS — "FB-…, date" · reason FULL width · "Type / Modified /
     By" quiet lines · View button
   · AUDIT LOG — "time, user" (action chip right) · "Entity: …" · details
   · USERS & PERMISSIONS — "username, full name" (perms chip right) ·
     "Designation: …" · status · buttons
   · CUSTOMER PREFERENCE popups (Sold / Returned) — bill/no · date
     (quantity right) · customer quiet · rate right; the customer column is
     conditional, so quantity/rate are picked by td.num position
   ========================================================================== */
@media (max-width: 640px) {
  #page-purchases table.m-list, #page-localpurchase table.m-list, #page-suppliers table.m-list,
  #page-supplierpayments table.m-list, #page-accounts table.m-list, #page-logs table.m-list,
  #page-users table.m-list, #page-modifiedbills table.m-list { display: block; }
  #page-purchases table.m-list thead, #page-localpurchase table.m-list thead,
  #page-suppliers table.m-list thead, #page-supplierpayments table.m-list thead,
  #page-accounts table.m-list thead, #page-logs table.m-list thead,
  #page-users table.m-list thead, #page-modifiedbills table.m-list thead { display: none; }
  #page-purchases table.m-list tbody, #page-localpurchase table.m-list tbody,
  #page-suppliers table.m-list tbody, #page-supplierpayments table.m-list tbody,
  #page-accounts table.m-list tbody, #page-logs table.m-list tbody,
  #page-users table.m-list tbody, #page-modifiedbills table.m-list tbody { display: block; }
  #page-purchases table.m-list tbody tr, #page-localpurchase table.m-list tbody tr,
  #page-suppliers table.m-list tbody tr, #page-supplierpayments table.m-list tbody tr,
  #page-accounts table.m-list tbody tr, #page-logs table.m-list tbody tr,
  #page-users table.m-list tbody tr, #page-modifiedbills table.m-list tbody tr {
    display: grid;
    grid-template-columns: min-content max-content minmax(0, 1fr) minmax(auto, 46vw);
    gap: 2px 0;
    padding: 10px 12px;
  }
  #page-purchases table.m-list tbody tr + tr, #page-localpurchase table.m-list tbody tr + tr,
  #page-suppliers table.m-list tbody tr + tr, #page-supplierpayments table.m-list tbody tr + tr,
  #page-accounts table.m-list tbody tr + tr, #page-logs table.m-list tbody tr + tr,
  #page-users table.m-list tbody tr + tr, #page-modifiedbills table.m-list tbody tr + tr {
    border-top: 1px solid var(--line);
  }
  #page-purchases table.m-list tbody tr td, #page-localpurchase table.m-list tbody tr td,
  #page-suppliers table.m-list tbody tr td, #page-supplierpayments table.m-list tbody tr td,
  #page-accounts table.m-list tbody tr td, #page-logs table.m-list tbody tr td,
  #page-users table.m-list tbody tr td, #page-modifiedbills table.m-list tbody tr td {
    border: 0; padding: 0; background: none;
  }
  #page-purchases table.m-list td.actions, #page-localpurchase table.m-list td.actions,
  #page-suppliers table.m-list td.actions, #page-supplierpayments table.m-list td.actions,
  #page-accounts table.m-list td.actions, #page-users table.m-list td.actions {
    white-space: normal; max-width: 46vw; text-align: right;
  }
  /* cont-221: the four card actions stay on ONE row — equal buttons that
     shrink instead of wrapping (large system fonts wrapped "Del" alone) */
  #page-accounts table.m-list tbody tr td.actions { display: flex; flex-wrap: nowrap; max-width: none; }
  #page-accounts table.m-list tbody tr td.actions .btn {
    flex: 1 1 0; min-width: 0; margin: 0 0 0 .3rem;
    justify-content: center; text-align: center;
  }
  #page-purchases table.m-list td.actions .btn, #page-localpurchase table.m-list td.actions .btn,
  #page-suppliers table.m-list td.actions .btn, #page-supplierpayments table.m-list td.actions .btn,
  #page-accounts table.m-list td.actions .btn, #page-users table.m-list td.actions .btn {
    margin: 1px 0 1px .3rem;
  }
  #page-suppliers table.m-list tbody tr td[colspan],
  #page-accounts table.m-list tbody tr td[colspan], #page-logs table.m-list tbody tr td[colspan],
  #page-users table.m-list tbody tr td[colspan], #page-modifiedbills table.m-list tbody tr td[colspan] {
    grid-area: 1 / 1 / 2 / -1 !important;
  }
  /* the LOCAL / FOREIGN section bands keep their banded look */
  #page-suppliers table.m-list tbody tr.type-head td {
    background: #e4e8ee; border-top: 2px solid var(--line);
    font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); padding: .55rem .6rem .2rem;
  }

  /* ---- PURCHASES + LOCAL PURCHASE ---- */
  #page-purchases table.m-list tbody tr td:nth-child(1),
  #page-localpurchase table.m-list tbody tr td:nth-child(1) { grid-area: 1 / 1; font-weight: 600; }
  #page-purchases table.m-list tbody tr td:nth-child(1) strong,
  #page-localpurchase table.m-list tbody tr td:nth-child(1) strong { white-space: nowrap; }
  #page-purchases table.m-list tbody tr td:nth-child(2),
  #page-localpurchase table.m-list tbody tr td:nth-child(2) { grid-area: 1 / 2; white-space: nowrap; }
  /* the ", " after the number only when the number is stamped (a <strong>
     in the FIRST cell — the row total is bold too, so the row-wide :has
     would always match) */
  #page-purchases table.m-list tbody tr:has(td:nth-child(1) strong) td:nth-child(2)::before,
  #page-localpurchase table.m-list tbody tr:has(td:nth-child(1) strong) td:nth-child(2)::before { content: ', '; font-weight: 400; }
  /* draft rows: the muted "— stamped at confirm" text is LONG — let it flow
     across the first two columns instead of wrapping in the narrow first
     one, with the date following it */
  #page-purchases table.m-list tbody tr td:nth-child(1):not(:has(strong)),
  #page-localpurchase table.m-list tbody tr td:nth-child(1):not(:has(strong)) { grid-area: 1 / 1 / 2 / 3; white-space: nowrap; padding-right: 8px; }
  #page-purchases table.m-list tbody tr:not(:has(td:nth-child(1) strong)) td:nth-child(2),
  #page-localpurchase table.m-list tbody tr:not(:has(td:nth-child(1) strong)) td:nth-child(2) { grid-area: 1 / 3; }
  #page-purchases table.m-list tbody tr td:nth-child(6),
  #page-localpurchase table.m-list tbody tr td:nth-child(6) { grid-area: 1 / 4; justify-self: end; white-space: nowrap; }
  #page-purchases table.m-list tbody tr td:nth-child(3),
  #page-localpurchase table.m-list tbody tr td:nth-child(3) { grid-area: 2 / 1 / 3 / 4; font-weight: 600; }
  /* cont-195 re-map: line 2 = supplier | status, line 3 = mode, line 4 =
     buttons right */
  #page-purchases table.m-list tbody tr td:nth-child(4),
  #page-localpurchase table.m-list tbody tr td:nth-child(4) {
    grid-area: 2 / 4; justify-self: end; font-size: 12.5px;
  }
  #page-purchases table.m-list tbody tr td:nth-child(5),
  #page-localpurchase table.m-list tbody tr td:nth-child(5) {
    grid-area: 3 / 1 / 4 / -1; text-align: left;
    font-size: 11px; color: var(--muted); font-style: italic;
  }
  #page-purchases table.m-list tbody tr td:nth-child(5)::before,
  #page-localpurchase table.m-list tbody tr td:nth-child(5)::before { content: 'Mode: '; }
  #page-purchases table.m-list tbody tr td:nth-child(7),
  #page-localpurchase table.m-list tbody tr td:nth-child(7) {
    grid-area: 4 / 1 / 5 / -1; max-width: none; white-space: nowrap; text-align: right;
  }
  /* filter order on phones: search → type → dates → the rest */
  #page-purchases .filters > #pur-search { order: 1; }
  #page-purchases .filters > #pur-type-filter { order: 2; }
  #page-purchases .filters > #pur-from { order: 3; }
  #page-purchases .filters > #pur-to { order: 4; }
  #page-purchases .filters > #pur-supplier-filter { order: 5; }
  #page-purchases .filters > #pur-status { order: 6; }
  #page-purchases .filters > #pur-today { order: 7; }
  #page-purchases .filters > #pur-reset { order: 8; }
  #page-localpurchase .filters > #lp-search { order: 1; }
  #page-localpurchase .filters > #lp-type-filter { order: 2; }
  #page-localpurchase .filters > #lp-from { order: 3; }
  #page-localpurchase .filters > #lp-to { order: 4; }
  #page-localpurchase .filters > #lp-supplier-filter { order: 5; }
  #page-localpurchase .filters > #lp-status { order: 6; }
  #page-localpurchase .filters > #lp-today { order: 7; }
  #page-localpurchase .filters > #lp-reset { order: 8; }

  /* ---- SUPPLIERS: 2 columns — name with country BELOW it (left) | due
     (right); row 2 merges both columns for the buttons (owner request) ---- */
  #page-suppliers table.m-list tbody tr {
    grid-template-columns: minmax(0, 1fr) minmax(auto, 46vw);
    gap: 2px 10px;
  }
  #page-suppliers table.m-list tbody tr td:nth-child(1) { grid-area: 1 / 1 / 2 / 2; font-weight: 600; }
  /* a lengthy supplier name WRAPS (no nowrap) — nowrap made it paint over the
     due amount on the right */
  #page-suppliers table.m-list tbody tr td:nth-child(1) strong { white-space: normal; }
  #page-suppliers table.m-list tbody tr td:nth-child(3) { grid-area: 1 / 2 / 3 / 3; justify-self: end; font-weight: 600; text-align: right; }
  #page-suppliers table.m-list tbody tr td:nth-child(2) { grid-area: 2 / 1 / 3 / 2; font-size: 11px; color: var(--muted); font-style: italic; }
  #page-suppliers table.m-list tbody tr td:nth-child(2)::before { content: 'Country: '; }
  #page-suppliers table.m-list tbody tr td:nth-child(4) {
    grid-area: 3 / 1 / 4 / 3; text-align: left; max-width: none; white-space: normal;
  }
  #page-suppliers table.m-list tbody tr td:nth-child(4) .btn { margin: 2px 6px 2px 0; }

  /* ---- SUPPLIER PAYMENTS ---- */
  #page-supplierpayments table.m-list tbody tr td:nth-child(1) { grid-area: 1 / 1; font-weight: 600; }
  #page-supplierpayments table.m-list tbody tr td:nth-child(1) strong { white-space: nowrap; }
  #page-supplierpayments table.m-list tbody tr td:nth-child(2) { grid-area: 1 / 2; white-space: nowrap; }
  #page-supplierpayments table.m-list tbody tr td:nth-child(2)::before { content: ', '; font-weight: 400; }
  #page-supplierpayments table.m-list tbody tr:not(:has(strong)) td:nth-child(2)::before { content: none; }
  /* cont-195 re-map: line 1 no+date | amount SEMI-BOLD, line 2 supplier |
     status, line 3 "Mode: x, Equivalent: y" (the equivalent rides in a data
     attribute — it only shows for foreign currencies), line 4 created by,
     line 5 buttons right */
  #page-supplierpayments table.m-list tbody tr td:nth-child(4) {
    grid-area: 1 / 4; justify-self: end; white-space: nowrap; font-weight: 600;
  }
  #page-supplierpayments table.m-list tbody tr td:nth-child(3) { grid-area: 2 / 1 / 3 / 4; font-weight: 600; }
  #page-supplierpayments table.m-list tbody tr td:nth-child(8) { grid-area: 2 / 4; justify-self: end; font-size: 12.5px; }
  #page-supplierpayments table.m-list tbody tr td:nth-child(6) {
    grid-area: 3 / 1 / 4 / -1; text-align: left;
    font-size: 11px; color: var(--muted); font-style: italic;
  }
  #page-supplierpayments table.m-list tbody tr td:nth-child(6)::before { content: 'Mode: '; }
  #page-supplierpayments table.m-list tbody tr td:nth-child(6)[data-eq]::after { content: ', Equivalent: ' attr(data-eq); }
  #page-supplierpayments table.m-list tbody tr td:nth-child(5) { display: none; }
  #page-supplierpayments table.m-list tbody tr td:nth-child(7) {
    grid-area: 4 / 1 / 5 / -1; text-align: left;
    font-size: 11px; color: var(--muted); font-style: italic;
  }
  #page-supplierpayments table.m-list tbody tr td:nth-child(7)::before { content: 'Created by: '; }
  #page-supplierpayments table.m-list tbody tr td:nth-child(9) {
    grid-area: 5 / 1 / 6 / -1; max-width: none; white-space: nowrap; text-align: right;
  }

  /* ---- ACCOUNTS: one card — name (account no) · balance right · branch line
     when present · Type · Op · In · Out; the buttons sit in a 2-per-line grid
     UNDER the card (owner request: the old right-hand button stack read as a
     second card inside the card and squeezed the figures). Buttons are
     renamed on phones via data-short (Stat / Edit / Deac / Act / Del). ---- */
  #page-accounts table.m-list tbody tr {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 3px 10px;
  }
  #page-accounts table.m-list tbody tr td:nth-child(1) { grid-area: 1 / 1 / 3 / 2; font-weight: 600; }
  #page-accounts table.m-list tbody tr td:nth-child(1) strong { white-space: normal; }
  #page-accounts table.m-list tbody tr td:nth-child(6) { grid-area: 1 / 2 / 2 / 3; justify-self: end; white-space: nowrap; }
  /* cont-195 re-map: line 2 = the details/branch line (rendered inside the
     name cell) with the TYPE right, line 3 = "Op: x, In: y, Out: z" ONE
     line (In/Out ride in data attributes — the columns are hidden), line 4
     = buttons right (real labels again — they have their own row now) */
  #page-accounts table.m-list tbody tr td:nth-child(2) {
    grid-area: 2 / 2; justify-self: end; align-self: end; text-align: right;
    font-size: 11px; font-style: italic;
  }
  #page-accounts table.m-list tbody tr td:nth-child(3) { grid-area: 3 / 1 / 4 / 3; font-size: 12.5px; font-weight: 600; text-align: left; }
  #page-accounts table.m-list tbody tr td:nth-child(3)::before { content: 'Op: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-accounts table.m-list tbody tr td:nth-child(3)::after {
    content: ', In: ' attr(data-in) ', Out: ' attr(data-out);
    font-weight: 400; font-size: 12.5px;
  }
  #page-accounts table.m-list tbody tr td:nth-child(4),
  #page-accounts table.m-list tbody tr td:nth-child(5) { display: none; }
  #page-accounts table.m-list tbody tr td:nth-child(7) {
    grid-area: 4 / 1 / 5 / 3; text-align: right;
    white-space: normal; max-width: none;
  }
  #page-accounts table.m-list tbody tr td:nth-child(7) .btn { margin: 1px 0 1px .3rem; }

  /* ---- MODIFIED BILLS ---- */
  #page-modifiedbills table.m-list tbody tr td:nth-child(1) { grid-area: 1 / 1; font-weight: 600; }
  #page-modifiedbills table.m-list tbody tr td:nth-child(1) strong { white-space: nowrap; }
  #page-modifiedbills table.m-list tbody tr td:nth-child(3) { grid-area: 1 / 2; white-space: nowrap; }
  #page-modifiedbills table.m-list tbody tr td:nth-child(3)::before { content: ', '; font-weight: 400; }
  #page-modifiedbills table.m-list tbody tr td:nth-child(7) { grid-area: 1 / 4; justify-self: end; white-space: normal; }
  #page-modifiedbills table.m-list tbody tr td:nth-child(7) .btn { margin: 0 0 0 .3rem; }
  /* the reason merges BOTH columns — one full-width line (beat the inline
     340px desktop cap) */
  #page-modifiedbills table.m-list tbody tr td:nth-child(5) {
    grid-area: 2 / 1 / 3 / -1; font-size: 13px; max-width: none !important;
  }
  #page-modifiedbills table.m-list tbody tr td:nth-child(5)::before { content: 'Reason: '; color: var(--muted); font-size: 11px; }
  #page-modifiedbills table.m-list tbody tr td:nth-child(2),
  #page-modifiedbills table.m-list tbody tr td:nth-child(4),
  #page-modifiedbills table.m-list tbody tr td:nth-child(6) { font-size: 11px; color: var(--muted); font-style: italic; text-align: left; }
  #page-modifiedbills table.m-list tbody tr td:nth-child(2) { grid-area: 3 / 1 / 4 / 4; }
  #page-modifiedbills table.m-list tbody tr td:nth-child(2)::before { content: 'Type: '; }
  #page-modifiedbills table.m-list tbody tr td:nth-child(4) { grid-area: 4 / 1 / 5 / 4; }
  #page-modifiedbills table.m-list tbody tr td:nth-child(4)::before { content: 'Modified: '; }
  #page-modifiedbills table.m-list tbody tr td:nth-child(6) { grid-area: 5 / 1 / 6 / 4; }
  #page-modifiedbills table.m-list tbody tr td:nth-child(6)::before { content: 'By: '; }

  /* ---- AUDIT LOG: "date time, user" (action right) · Entity + FULL
     details on the next line (the JS no longer truncates the details) ---- */
  #page-logs table.m-list tbody tr {
    grid-template-columns: minmax(0, auto) minmax(0, 1fr) minmax(0, auto);
    gap: 3px 8px;
  }
  #page-logs table.m-list tbody tr td:nth-child(1) { grid-area: 1 / 1; font-weight: 600; white-space: nowrap; }
  #page-logs table.m-list tbody tr td:nth-child(2) { grid-area: 1 / 2; white-space: nowrap; }
  #page-logs table.m-list tbody tr td:nth-child(2)::before { content: ', '; font-weight: 400; }
  #page-logs table.m-list tbody tr td:nth-child(3) { grid-area: 1 / 3; justify-self: end; }
  #page-logs table.m-list tbody tr td:nth-child(3) .chip {
    background: transparent; border: 0; padding: 0;
    font-weight: 400; font-style: italic; font-size: 12.5px;
  }
  #page-logs table.m-list tbody tr td:nth-child(4) { grid-area: 2 / 1 / 3 / 2; font-size: 11px; color: var(--muted); font-style: italic; }
  #page-logs table.m-list tbody tr td:nth-child(4)::before { content: 'Entity: '; }
  #page-logs table.m-list tbody tr td:nth-child(5) {
    grid-area: 2 / 2 / 3 / 4; font-size: 11px; color: var(--muted);
    word-break: break-all; max-width: none;
    display: block; -webkit-line-clamp: unset; -webkit-box-orient: unset;
    overflow: visible;
  }

  /* ---- USERS & PERMISSIONS: "Username: …, Full Name" flows as ONE line
     (no virtual middle column) with the perms count right; line 2 =
     Designation (left) | Status (right); line 3 = the buttons in one row,
     right aligned (owner request) ---- */
  #page-users table.m-list tbody tr {
    grid-template-columns: max-content minmax(0, 1fr) auto;
    gap: 3px 0; /* no column gap — the comma prefix carries its own spacing */
  }
  #page-users table.m-list tbody tr td:nth-child(1) { grid-area: 1 / 1 / 2 / 2; font-weight: 600; }
  #page-users table.m-list tbody tr td:nth-child(1)::before { content: 'Username: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-users table.m-list tbody tr td:nth-child(2) { grid-area: 1 / 2 / 2 / 3; font-size: 12.5px; }
  #page-users table.m-list tbody tr td:nth-child(2)::before { content: ', '; font-weight: 400; }
  #page-users table.m-list tbody tr td:nth-child(5) { grid-area: 1 / 3 / 2 / 4; justify-self: end; }
  #page-users table.m-list tbody tr td:nth-child(5) .chip {
    background: transparent; border: 0; padding: 0;
    font-weight: 400; font-style: italic; font-size: 12.5px; color: var(--muted);
  }
  #page-users table.m-list tbody tr td:nth-child(3) { grid-area: 2 / 1 / 3 / 3; font-size: 11px; color: var(--muted); font-style: italic; }
  #page-users table.m-list tbody tr td:nth-child(3)::before { content: 'Designation: '; }
  #page-users table.m-list tbody tr td:nth-child(4) {
    grid-area: 2 / 3 / 3 / 4; justify-self: end; text-align: right;
    font-size: 12.5px; white-space: nowrap;
  }
  #page-users table.m-list tbody tr td:nth-child(4)::before { content: 'Status: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  /* the buttons: one row, right aligned */
  #page-users table.m-list tbody tr td:nth-child(6) {
    grid-area: 3 / 1 / 4 / 4; text-align: right;
    white-space: normal; max-width: none;
  }
  #page-users table.m-list tbody tr td:nth-child(6) .btn { margin: 2px 0 2px .3rem; }

  /* ---- ACCOUNT STATEMENT — statement rows with In / Out / Bal tags ---- */
  #page-account-statement table { display: block; }
  #page-account-statement table thead { display: none; }
  #page-account-statement table tbody { display: block; }
  #page-account-statement table tbody tr {
    display: grid;
    grid-template-columns: max-content max-content minmax(0, 1fr) minmax(auto, 46vw);
    gap: 2px 0;
    padding: 10px 12px;
  }
  #page-account-statement table tbody tr + tr { border-top: 1px solid var(--line); }
  #page-account-statement table tbody tr td { border: 0; padding: 0; background: none; }
  #page-account-statement table tbody tr td:nth-child(1) { grid-area: 1 / 1; font-weight: 600; white-space: nowrap; }
  #page-account-statement table tbody tr td:nth-child(2) { grid-area: 1 / 2; font-size: 12.5px; }
  #page-account-statement table tbody tr td:nth-child(2)::before { content: ' ·  '; }
  #page-account-statement table tbody tr .chip {
    background: transparent; border: 0; padding: 0;
    font-weight: 400; font-style: italic; font-size: 12.5px;
  }
  #page-account-statement table tbody tr td:nth-child(4) { grid-area: 2 / 1 / 3 / 4; font-weight: 600; }
  #page-account-statement table tbody tr td:nth-child(3) { grid-area: 3 / 1 / 4 / 4; font-size: 11px; color: var(--muted); font-style: italic; }
  #page-account-statement table tbody tr td:nth-child(3)::before { content: 'Ref: '; }
  #page-account-statement table tbody tr td:nth-child(5),
  #page-account-statement table tbody tr td:nth-child(6),
  #page-account-statement table tbody tr td:nth-child(7) { font-weight: 600; white-space: nowrap; }
  #page-account-statement table tbody tr td:nth-child(5) { grid-area: 1 / 4; justify-self: end; }
  #page-account-statement table tbody tr td:nth-child(6) { grid-area: 2 / 4; justify-self: end; }
  #page-account-statement table tbody tr td:nth-child(7) { grid-area: 3 / 4; justify-self: end; }
  #page-account-statement table tbody tr td:nth-child(5)::before { content: 'In '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-account-statement table tbody tr td:nth-child(6)::before { content: 'Out '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-account-statement table tbody tr td:nth-child(7)::before { content: 'Bal '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-account-statement table tbody tr td[colspan] { grid-column: 1 / -1 !important; }

  /* ---- CUSTOMER PREFERENCE popups (Sold / Returned; dynamic customer
     column — quantity is the .num that is NOT last, rate/qty-only rows end
     with their .num) ---- */
  #cpf-sold-modal table, #cpf-ret-modal table { display: block; }
  #cpf-sold-modal table thead, #cpf-ret-modal table thead { display: none; }
  #cpf-sold-modal table tbody, #cpf-ret-modal table tbody { display: block; }
  #cpf-sold-modal table tbody tr, #cpf-ret-modal table tbody tr {
    display: grid;
    grid-template-columns: min-content max-content minmax(0, 1fr) minmax(auto, 46vw);
    gap: 2px 0;
    padding: 8px 12px;
  }
  #cpf-sold-modal table tbody tr + tr, #cpf-ret-modal table tbody tr + tr { border-top: 1px solid var(--line); }
  #cpf-sold-modal table tbody tr td, #cpf-ret-modal table tbody tr td { border: 0; padding: 0; background: none; }
  #cpf-sold-modal table tbody tr td:nth-child(1), #cpf-ret-modal table tbody tr td:nth-child(1) { grid-area: 1 / 1; font-weight: 600; }
  #cpf-sold-modal table tbody tr td:nth-child(1) strong, #cpf-ret-modal table tbody tr td:nth-child(1) strong { white-space: nowrap; }
  #cpf-sold-modal table tbody tr td:nth-child(2), #cpf-ret-modal table tbody tr td:nth-child(2) { grid-area: 1 / 2; white-space: nowrap; }
  #cpf-sold-modal table tbody tr td:nth-child(2)::before, #cpf-ret-modal table tbody tr td:nth-child(2)::before { content: ', '; font-weight: 400; }
  #cpf-sold-modal table tbody tr td.num:not(:last-child) { grid-area: 1 / 4; justify-self: end; white-space: nowrap; }
  #cpf-sold-modal table tbody tr td.num:not(:last-child)::before { content: 'Qty: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #cpf-ret-modal table tbody tr td.num:last-child { grid-area: 1 / 4; justify-self: end; white-space: nowrap; }
  #cpf-ret-modal table tbody tr td.num:last-child::before { content: 'Qty: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #cpf-sold-modal table tbody tr td.num:last-child { grid-area: 2 / 4; justify-self: end; white-space: nowrap; font-size: 12.5px; }
  #cpf-sold-modal table tbody tr td.num:last-child::before { content: 'Rate: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #cpf-sold-modal table tbody tr td:nth-child(3):not(.num),
  #cpf-ret-modal table tbody tr td:nth-child(3):not(.num) { grid-area: 2 / 1 / 3 / 4; font-size: 11px; color: var(--muted); font-style: italic; }
  #cpf-sold-modal table tbody tr td:nth-child(3):not(.num)::before,
  #cpf-ret-modal table tbody tr td:nth-child(3):not(.num)::before { content: 'Customer: '; }
  #cpf-sold-modal table tbody tr td[colspan], #cpf-ret-modal table tbody tr td[colspan] { grid-area: 1 / 1 / 2 / -1 !important; }
}
/* ============================================================================
   cont-214: REPORTS — DAY BOOK on phones (card rows; Receivable joins the
   n-list pattern of My Receivable above, CSS-only):
   · "date, voucher" (amount right) · particulars · "Account: …" (empty on
     transfer rows, so the label is skipped there)
   · the group bands and the per-group subtotal lines keep their look — a
     subtotal puts its amount back on the same line, at the right
   ========================================================================== */
@media (max-width: 640px) {
  #db-result table { display: block; }
  #db-result table thead { display: none; }
  #db-result table tbody { display: block; }
  #db-result table tbody tr {
    display: grid;
    grid-template-columns: min-content max-content minmax(0, 1fr) minmax(0, max-content);
    gap: 2px 0;
    padding: 8px 12px;
  }
  #db-result table tbody tr + tr { border-top: 1px solid var(--line); }
  #db-result table tbody tr td { border: 0; padding: 0; background: none; }
  #db-result table tbody tr td:nth-child(1) { grid-area: 1 / 1; font-weight: 600; white-space: nowrap; }
  #db-result table tbody tr td:nth-child(2) { grid-area: 1 / 2; white-space: nowrap; }
  #db-result table tbody tr td:nth-child(2)::before { content: ', '; font-weight: 400; }
  #db-result table tbody tr td:nth-child(5) { grid-area: 1 / 4; justify-self: end; white-space: nowrap; font-weight: 600; }
  #db-result table tbody tr td:nth-child(3) { grid-area: 2 / 1 / 3 / 4; font-weight: 600; }
  #db-result table tbody tr td:nth-child(4) { grid-area: 3 / 1 / 4 / 4; font-size: 11px; color: var(--muted); font-style: italic; }
  #db-result table tbody tr td:nth-child(4):not(:empty)::before { content: 'Account: '; }
  /* group band rows ("RECEIPTS — 12 vouchers · total …") keep their band */
  #db-result table tbody tr.db-group td[colspan] {
    grid-area: 1 / 1 / 2 / -1 !important;
    background: #e4e8ee; border-top: 2px solid var(--line);
    font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); padding: .55rem .6rem .2rem;
  }
  /* cont-221: the band row must not let its one long line widen the
     max-content tracks past the viewport — single fluid track, text wraps */
  #db-result table tbody tr.db-group { grid-template-columns: minmax(0, 1fr); }
  #db-result table tbody tr.db-group td[colspan] { min-width: 0; overflow-wrap: anywhere; line-height: 1.5; }
  /* subtotal rows: label left, amount right — one line (no date comma) */
  #db-result table tbody tr.db-subtotal td[colspan] { grid-area: 1 / 1 / 2 / 4 !important; }
  #db-result table tbody tr.db-subtotal td:nth-child(2) { grid-area: 1 / 4; justify-self: end; white-space: nowrap; }
  #db-result table tbody tr.db-subtotal td:nth-child(2)::before { content: none; }
  /* empty-state row spans everything */
  #db-result table tbody tr td[colspan] { grid-area: 1 / 1 / 2 / -1 !important; }
}
/* ============================================================================
   cont-215: INVENTORY & PRODUCTION groups on phones — every main list becomes
   card rows (same virtual-column machinery as the rest of the app):
   · ITEMS / MATERIALS / CANS — name | stock · unit/price/ideal figures ·
     buttons full width
   · GROUPS / UNITS — name | count · buttons full width
   · BULK PRICING — editable grid stays tappable: item | unit | current price,
     the new-price input with its History button below; the group band keeps
     its inline group-price input + Apply
   · PRODUCTION / FINISHED RECEIVE / SEMI-FINISHED RECEIVE / MATERIALS
     UTILIZATION — "number, date" (status right) · items list · by-line ·
     buttons full width; deleted rows keep their reason line
   · SEMI STOCK / STOCK REPORT / RAW MATERIALS REPORT — name | closing ·
     the figures in labelled 3-column grids · buttons full width
   · movements/details popups: rows read as wrapped inline lines; wide label/
     value tables scroll instead of clipping
   ========================================================================== */
@media (max-width: 640px) {
  /* ---- shared machinery: the bare tables of the group ---- */
  #page-items > table, #page-groups > table, #page-units > table,
  #page-materials > table, #page-bulkpricing > table, #page-cans #can-list > table,
  #page-production > table, #page-finishedreceive > table,
  #page-semifinishreceive > table, #page-materialsutilization > table,
  #page-semifinishstock #sfs-groups > table, #page-stockreport #stk-groups > table,
  #page-materialsreport #rmr-groups > table,
  #gitems-modal table, #bp-hist-table, #cm-out table,
  #sf-mv-body table, #sm-body table, #rm-body table { display: block; }
  #page-items > table thead, #page-groups > table thead, #page-units > table thead,
  #page-materials > table thead, #page-bulkpricing > table thead, #page-cans #can-list > table thead,
  #page-production > table thead, #page-finishedreceive > table thead,
  #page-semifinishreceive > table thead, #page-materialsutilization > table thead,
  #page-semifinishstock #sfs-groups > table thead, #page-stockreport #stk-groups > table thead,
  #page-materialsreport #rmr-groups > table thead,
  #gitems-modal table thead, #bp-hist-table thead, #cm-out table thead,
  #sf-mv-body table thead, #sm-body table thead, #rm-body table thead { display: none; }
  #page-items > table tbody, #page-groups > table tbody, #page-units > table tbody,
  #page-materials > table tbody, #page-bulkpricing > table tbody, #page-cans #can-list > table tbody,
  #page-production > table tbody, #page-finishedreceive > table tbody,
  #page-semifinishreceive > table tbody, #page-materialsutilization > table tbody,
  #page-semifinishstock #sfs-groups > table tbody, #page-stockreport #stk-groups > table tbody,
  #page-materialsreport #rmr-groups > table tbody,
  #gitems-modal table tbody, #bp-hist-table tbody, #cm-out table tbody,
  #sf-mv-body table tbody, #sm-body table tbody, #rm-body table tbody { display: block; }
  #page-items > table tbody tr, #page-groups > table tbody tr, #page-units > table tbody tr,
  #page-materials > table tbody tr, #page-bulkpricing > table tbody tr, #page-cans #can-list > table tbody tr,
  #page-production > table tbody tr, #page-finishedreceive > table tbody tr,
  #page-semifinishreceive > table tbody tr, #page-materialsutilization > table tbody tr,
  #page-semifinishstock #sfs-groups > table tbody tr, #page-stockreport #stk-groups > table tbody tr,
  #page-materialsreport #rmr-groups > table tbody tr,
  #gitems-modal table tbody tr, #bp-hist-table tbody tr, #cm-out table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 10px;
    padding: 10px 12px;
  }
  #page-items > table tbody tr + tr, #page-groups > table tbody tr + tr, #page-units > table tbody tr + tr,
  #page-materials > table tbody tr + tr, #page-bulkpricing > table tbody tr + tr, #page-cans #can-list > table tbody tr + tr,
  #page-production > table tbody tr + tr, #page-finishedreceive > table tbody tr + tr,
  #page-semifinishreceive > table tbody tr + tr, #page-materialsutilization > table tbody tr + tr,
  #page-semifinishstock #sfs-groups > table tbody tr + tr, #page-stockreport #stk-groups > table tbody tr + tr,
  #page-materialsreport #rmr-groups > table tbody tr + tr,
  #gitems-modal table tbody tr + tr, #bp-hist-table tbody tr + tr, #cm-out table tbody tr + tr {
    border-top: 1px solid var(--line);
  }
  #page-items > table tbody tr td, #page-groups > table tbody tr td, #page-units > table tbody tr td,
  #page-materials > table tbody tr td, #page-bulkpricing > table tbody tr td, #page-cans #can-list > table tbody tr td,
  #page-production > table tbody tr td, #page-finishedreceive > table tbody tr td,
  #page-semifinishreceive > table tbody tr td, #page-materialsutilization > table tbody tr td,
  #page-semifinishstock #sfs-groups > table tbody tr td, #page-stockreport #stk-groups > table tbody tr td,
  #page-materialsreport #rmr-groups > table tbody tr td,
  #gitems-modal table tbody tr td, #bp-hist-table tbody tr td, #cm-out table tbody tr td {
    border: 0; padding: 0; background: none;
  }
  /* action cells: buttons wrap inside the card */
  #page-items td.actions, #page-groups td.actions, #page-units td.actions,
  #page-materials td.actions, #page-bulkpricing td.actions, #page-cans td.actions,
  #page-production > table td.actions, #page-finishedreceive > table td.actions,
  #page-semifinishreceive > table td.actions, #page-materialsutilization > table td.actions,
  #page-semifinishstock #sfs-groups td.actions, #page-stockreport #stk-groups td.actions,
  #page-materialsreport #rmr-groups td.actions { white-space: normal; max-width: none; }
  #page-items td.actions .btn, #page-groups td.actions .btn, #page-units td.actions .btn,
  #page-materials td.actions .btn, #page-cans td.actions .btn,
  #page-production > table td.actions .btn, #page-finishedreceive > table td.actions .btn,
  #page-semifinishreceive > table td.actions .btn, #page-materialsutilization > table td.actions .btn,
  #page-semifinishstock #sfs-groups td.actions .btn, #page-stockreport #stk-groups td.actions .btn,
  #page-materialsreport #rmr-groups td.actions .btn { margin: 2px 0 2px .3rem; }
  /* banded group rows keep their look */
  #page-items tr.type-head td, #page-materials tr.type-head td, #page-cans tr.type-head td,
  #page-groups tr.type-head td, #page-semifinishstock #sfs-groups tr.type-head td,
  #page-stockreport #stk-groups tr.type-head td, #page-materialsreport #rmr-groups tr.type-head td {
    background: #e4e8ee; border-top: 2px solid var(--line);
    font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); padding: .55rem .6rem .2rem;
  }
  /* figure prefixes + values (the labelled metric cells) */
  #page-items td.num, #page-materials td.num, #page-cans td.num,
  #page-semifinishstock #sfs-groups td.num, #page-stockreport #stk-groups td.num,
  #page-materialsreport #rmr-groups td.num { font-size: 12.5px; font-weight: 600; }
  #page-items td.num::before, #page-materials td.num::before, #page-cans td.num::before,
  #page-semifinishstock #sfs-groups td.num::before, #page-stockreport #stk-groups td.num::before,
  #page-materialsreport #rmr-groups td.num::before {
    color: var(--muted); font-weight: 400; font-size: 11px;
  }
  /* cont-209: the group's record lists (production, receives, utilizations) —
     the first cell is the record's identity (strong) and the action buttons
     ALWAYS sit on their own last line, right-aligned, like the other cards */
  #page-production > table tbody tr td:first-child,
  #page-finishedreceive > table tbody tr td:first-child,
  #page-semifinishreceive > table tbody tr td:first-child,
  #page-materialsutilization > table tbody tr td:first-child,
  #page-finishedutilization > table tbody tr td:first-child,
  #page-semiutilization > table tbody tr td:first-child { font-weight: 600; }
  #page-production > table tbody tr td.actions,
  #page-finishedreceive > table tbody tr td.actions,
  #page-semifinishreceive > table tbody tr td.actions,
  #page-materialsutilization > table tbody tr td.actions,
  #page-finishedutilization > table tbody tr td.actions,
  #page-semiutilization > table tbody tr td.actions { grid-column: 1 / -1; text-align: right; }

  /* band rows and empty states span the whole card (bulk pricing handles its
     own — its band carries inputs, not a colspan) */
  #page-items td[colspan], #page-groups td[colspan], #page-units td[colspan],
  #page-materials td[colspan], #page-cans td[colspan],
  #page-semifinishstock #sfs-groups td[colspan], #page-stockreport #stk-groups td[colspan],
  #page-materialsreport #rmr-groups td[colspan] { grid-area: 1 / 1 / 2 / -1 !important; }

  /* ---- ITEMS (cont-209 re-map): line 1 = name | Stock right (semi-bold),
     line 2 = "Unit: u, Price: p, Ideal: i" full width (price/ideal ride in
     data attributes — those columns are hidden), line 3 = buttons right ---- */
  #page-items > table tbody tr { grid-template-columns: minmax(0, 1fr) auto; }
  #page-items td:nth-child(1) { grid-area: 1 / 1 / 2 / 2; font-weight: 600; }
  #page-items td:nth-child(1) strong { white-space: normal; }
  #page-items td:nth-child(4) { grid-area: 1 / 2 / 2 / 3; justify-self: end; text-align: right; font-size: 12.5px; }
  #page-items td:nth-child(4)::before { content: 'Stock: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-items td:nth-child(2) { grid-area: 2 / 1 / 3 / 3; font-size: 12.5px; }
  #page-items td:nth-child(2)::before { content: 'Unit: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-items td:nth-child(2)[data-price]::after {
    content: ', Price: ' attr(data-price) ', Ideal: ' attr(data-ideal);
    font-weight: 400; font-size: 12.5px;
  }
  #page-items td:nth-child(3), #page-items td:nth-child(5) { display: none; }
  #page-items td:nth-child(6) { grid-area: 3 / 1 / 4 / 3; text-align: right; }

  /* ---- GROUPS: name | Assigned · buttons ---- */
  #page-groups td:nth-child(1) { grid-area: 1 / 1 / 2 / 2; font-weight: 600; }
  #page-groups td:nth-child(2) { grid-area: 1 / 2 / 2 / 3; justify-self: end; font-size: 12.5px; font-weight: 600; }
  #page-groups td:nth-child(2)::before { content: 'Assigned: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-groups td:nth-child(3) { grid-area: 2 / 1 / 3 / 3; text-align: right; }

  /* ---- RAW MATERIALS (cont-209): line 1 = name | Stock w/ unit right,
     line 2 = Known as + Ideal, line 3 = buttons right ---- */
  #page-materials > table tbody tr { grid-template-columns: minmax(0, 1fr) auto; }
  #page-materials td:nth-child(1) { grid-area: 1 / 1 / 2 / 2; font-weight: 600; }
  #page-materials td:nth-child(1) strong { white-space: normal; }
  #page-materials td:nth-child(5) { grid-area: 1 / 2 / 2 / 3; justify-self: end; text-align: right; font-size: 12.5px; }
  #page-materials td:nth-child(5)::before { content: 'Stock: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-materials td:nth-child(5)[data-unit]::after { content: ' ' attr(data-unit); font-weight: 400; font-size: 11px; }
  #page-materials td:nth-child(5) div { display: none; }   /* the low-stock sub-line */
  #page-materials td:nth-child(2) { grid-area: 2 / 1 / 3 / 3; font-size: 12.5px; font-style: italic; color: var(--muted); overflow-wrap: anywhere; }
  #page-materials td:nth-child(2)::before { content: 'Known as: '; font-style: normal; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-materials td:nth-child(2)::after {
    content: ', Ideal: ' attr(data-ideal);   /* cont-210: one line left to right, like the customers card */
    font-style: normal; font-weight: 400; font-size: 12.5px;
  }
  #page-materials td:nth-child(3), #page-materials td:nth-child(4) { display: none; }
  #page-materials td:nth-child(6) { grid-area: 3 / 1 / 4 / 3; text-align: right; }

  /* ---- RAW MATERIALS REPORT (cont-209): line 1 = name | stock right,
     line 2 = "Opening: q, Purch: q, Prod: q, Used: q, Value: a" (rides on
     data attributes — the figure columns are hidden), line 3 = buttons ---- */
  #page-materialsreport #rmr-groups > table tbody tr { grid-template-columns: minmax(0, 1fr) auto; }
  #page-materialsreport #rmr-groups td:nth-child(1) { grid-area: 1 / 1 / 2 / 2; font-weight: 600; }
  #page-materialsreport .u-quiet { display: none; }
  #page-materialsreport #rmr-groups td:nth-child(6) { grid-area: 1 / 2 / 2 / 3; justify-self: end; text-align: right; font-size: 12.5px; }
  #page-materialsreport #rmr-groups td:nth-child(6)::before { content: 'Stock: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-materialsreport #rmr-groups td:nth-child(2) { grid-area: 2 / 1 / 3 / 3; font-size: 12.5px; }
  #page-materialsreport #rmr-groups td:nth-child(2)::before { content: 'Opening: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-materialsreport #rmr-groups td:nth-child(2)[data-purch]::after {
    content: ', Purch: ' attr(data-purch) ', Prod: ' attr(data-prod) ', Used: ' attr(data-used) ', Value: ' attr(data-value);
    font-weight: 400; font-size: 12.5px;
  }
  #page-materialsreport #rmr-groups td:nth-child(3), #page-materialsreport #rmr-groups td:nth-child(4),
  #page-materialsreport #rmr-groups td:nth-child(5), #page-materialsreport #rmr-groups td:nth-child(7) { display: none; }
  #page-materialsreport #rmr-groups td:nth-child(8) { grid-area: 3 / 1 / 4 / 3; text-align: right; }

  /* ---- STOCK REPORT (cont-209): line 1 = name | closing stock right,
     line 2 = the period's movements + value (data attributes), line 3 =
     Graph / View movements right ---- */
  #page-stockreport #stk-groups > table tbody tr { grid-template-columns: minmax(0, 1fr) auto; }
  #page-stockreport #stk-groups td:nth-child(1) { grid-area: 1 / 1 / 2 / 2; font-weight: 600; }
  #page-stockreport .u-quiet { display: none; }
  #page-stockreport #stk-groups td:nth-child(8) { grid-area: 1 / 2 / 2 / 3; justify-self: end; text-align: right; font-size: 12.5px; }
  #page-stockreport #stk-groups td:nth-child(8)::before { content: 'Stock: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-stockreport #stk-groups td:nth-child(2) { grid-area: 2 / 1 / 3 / 3; font-size: 12.5px; }
  #page-stockreport #stk-groups td:nth-child(2)::before { content: 'Opening: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-stockreport #stk-groups td:nth-child(2)[data-produced]::after {
    content: ', Produced: ' attr(data-produced) ', Purchased: ' attr(data-purchased) ', Sold: ' attr(data-sold) ', Returned: ' attr(data-returned) ', Adjusted: ' attr(data-adjusted) ', Value: ' attr(data-value);
    font-weight: 400; font-size: 12.5px;
  }
  #page-stockreport #stk-groups td:nth-child(3), #page-stockreport #stk-groups td:nth-child(4), #page-stockreport #stk-groups td:nth-child(5),
  #page-stockreport #stk-groups td:nth-child(6), #page-stockreport #stk-groups td:nth-child(7), #page-stockreport #stk-groups td:nth-child(9) { display: none; }
  #page-stockreport #stk-groups td:nth-child(10) { grid-area: 3 / 1 / 4 / 3; text-align: right; }

  /* ---- SEMI FINISH STOCK (cont-209): line 1 = name | stock right, line 2 =
     "Opening: q, Prod: q, Recv: q, Used: q" (data attributes), line 3 =
     Graph / View movements right ---- */
  #page-semifinishstock #sfs-groups > table tbody tr { grid-template-columns: minmax(0, 1fr) auto; }
  #page-semifinishstock #sfs-groups td:nth-child(1) { grid-area: 1 / 1 / 2 / 2; font-weight: 600; }
  #page-semifinishstock .u-quiet { display: none; }
  #page-semifinishstock #sfs-groups td:nth-child(6) { grid-area: 1 / 2 / 2 / 3; justify-self: end; text-align: right; font-size: 12.5px; }
  #page-semifinishstock #sfs-groups td:nth-child(6)::before { content: 'Stock: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-semifinishstock #sfs-groups td:nth-child(2) { grid-area: 2 / 1 / 3 / 3; font-size: 12.5px; }
  #page-semifinishstock #sfs-groups td:nth-child(2)::before { content: 'Opening: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-semifinishstock #sfs-groups td:nth-child(2)[data-prod]::after {
    content: ', Prod: ' attr(data-prod) ', Recv: ' attr(data-recv) ', Used: ' attr(data-used);
    font-weight: 400; font-size: 12.5px;
  }
  #page-semifinishstock #sfs-groups td:nth-child(3), #page-semifinishstock #sfs-groups td:nth-child(4),
  #page-semifinishstock #sfs-groups td:nth-child(5) { display: none; }
  #page-semifinishstock #sfs-groups td:nth-child(7) { grid-area: 3 / 1 / 4 / 3; text-align: right; }

  /* ---- CANS & CARTONS (cont-209): line 1 = name | In stock right, line 2 =
     "Unit: u, Opening: n, Ideal: n", line 3 = buttons right ---- */
  #page-cans #can-list > table tbody tr { grid-template-columns: minmax(0, 1fr) auto; }
  #page-cans #can-list > table tbody tr td:nth-child(1) { grid-area: 1 / 1 / 2 / 2; font-weight: 600; }
  #page-cans #can-list > table tbody tr td:nth-child(1) strong { white-space: normal; }
  #page-cans #can-list > table tbody tr td:nth-child(4) { grid-area: 1 / 2 / 2 / 3; justify-self: end; text-align: right; font-size: 12.5px; }
  #page-cans #can-list > table tbody tr td:nth-child(4)::before { content: 'In stock: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-cans #can-list > table tbody tr td:nth-child(4) div { display: none; }
  #page-cans #can-list > table tbody tr td:nth-child(2) { grid-area: 2 / 1 / 3 / 3; font-size: 12.5px; }
  #page-cans #can-list > table tbody tr td:nth-child(2)::before { content: 'Unit: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-cans #can-list > table tbody tr td:nth-child(2)[data-open]::after {
    content: ', Opening: ' attr(data-open) ', Ideal: ' attr(data-ideal);
    font-weight: 400; font-size: 12.5px;
  }
  #page-cans #can-list > table tbody tr td:nth-child(3),
  #page-cans #can-list > table tbody tr td:nth-child(5) { display: none; }
  #page-cans #can-list > table tbody tr td:nth-child(6) { grid-area: 3 / 1 / 4 / 3; text-align: right; }

  /* ---- UNITS: name | In use · buttons ---- */
  #page-units td:nth-child(1) { grid-area: 1 / 1 / 2 / 2; font-weight: 600; }
  #page-units td:nth-child(2) { grid-area: 1 / 2 / 2 / 3; justify-self: end; font-size: 12.5px; font-weight: 600; }
  #page-units td:nth-child(2)::before { content: 'In use: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-units td:nth-child(3) { grid-area: 2 / 1 / 3 / 3; }

  /* ---- MATERIALS: name | Stock · Known as · Unit/Ideal · buttons ---- */
  #page-materials > table tbody tr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #page-materials td:nth-child(1) { grid-area: 1 / 1 / 2 / 2; font-weight: 600; }
  #page-materials td:nth-child(1) strong { white-space: normal; }
  #page-materials td:nth-child(5) { grid-area: 1 / 2 / 2 / 3; justify-self: end; text-align: right; }
  #page-materials td:nth-child(5)::before { content: 'Stock: '; }
  #page-materials td:nth-child(2) { grid-area: 2 / 1 / 3 / 3; font-size: 11px; color: var(--muted); font-style: italic; }
  #page-materials td:nth-child(2)::before { content: 'Known as: '; }
  #page-materials td:nth-child(3) { grid-area: 3 / 1 / 4 / 2; font-weight: 400; font-style: italic; color: var(--muted); }
  #page-materials td:nth-child(3)::before { content: 'Unit: '; }
  #page-materials td:nth-child(4) { grid-area: 3 / 2 / 4 / 3; justify-self: end; }
  #page-materials td:nth-child(4)::before { content: 'Ideal: '; }
  #page-materials td:nth-child(6) { grid-area: 4 / 1 / 5 / 3; }

  /* ---- BULK PRICING: item | unit | current price; new-price input +
     History below; the GROUP band keeps its input + Apply ---- */
  #page-bulkpricing > table tbody tr { grid-template-columns: minmax(0, 1fr) auto auto; }
  #page-bulkpricing td:nth-child(1) { grid-area: 1 / 1 / 2 / 2; font-weight: 600; }
  #page-bulkpricing td:nth-child(1) strong { white-space: normal; }
  #page-bulkpricing td:nth-child(2) { grid-area: 1 / 2 / 2 / 3; font-size: 11px; color: var(--muted); font-style: italic; }
  #page-bulkpricing td:nth-child(3) { grid-area: 1 / 3 / 2 / 4; justify-self: end; }
  #page-bulkpricing td:nth-child(3)::before { content: 'Current: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-bulkpricing td:nth-child(4) { grid-area: 2 / 1 / 3 / 3; }
  #page-bulkpricing td:nth-child(5) { grid-area: 2 / 3 / 3 / 4; justify-self: end; }
  /* the band row: same slots, but no metric prefixes; empty rows full width */
  #page-bulkpricing tr.type-head td::before { content: none !important; }
  #page-bulkpricing tr.type-head td:nth-child(1) { font-weight: 600; }
  #page-bulkpricing tr.type-head td:nth-child(2) { justify-self: end; }
  #page-bulkpricing tr.type-head td:nth-child(3) { justify-self: end; }
  #page-bulkpricing tr:not(.type-head) td[colspan] { grid-area: 1 / 1 / 2 / -1 !important; }

  /* ---- CANS & CARTONS: name | In stock · Unit/Ideal · Opening · buttons
     (the map works with AND without the Actions column) ---- */
  #page-cans > table tbody tr, #page-cans #can-list > table tbody tr {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #page-cans #can-list td:nth-child(1) { grid-area: 1 / 1 / 2 / 2; font-weight: 600; }
  #page-cans #can-list td:nth-child(1) strong { white-space: normal; }
  #page-cans #can-list td:nth-child(4) { grid-area: 1 / 2 / 2 / 3; justify-self: end; text-align: right; }
  #page-cans #can-list td:nth-child(4)::before { content: 'In stock: '; }
  #page-cans #can-list td:nth-child(2) { grid-area: 2 / 1 / 3 / 2; font-weight: 400; font-style: italic; color: var(--muted); }
  #page-cans #can-list td:nth-child(2)::before { content: 'Unit: '; }
  #page-cans #can-list td:nth-child(5) { grid-area: 2 / 2 / 3 / 3; justify-self: end; }
  #page-cans #can-list td:nth-child(5)::before { content: 'Ideal: '; }
  #page-cans #can-list td:nth-child(3) { grid-area: 3 / 1 / 4 / 3; }
  #page-cans #can-list td:nth-child(3)::before { content: 'Opening: '; }
  #page-cans #can-list td:nth-child(6) { grid-area: 4 / 1 / 5 / 3; }

  /* ---- PRODUCTION / FINISHED / SEMI-FINISHED RECEIVE / MATERIALS
     UTILIZATION: "number, date" (status right) · items · by · buttons ---- */
  #page-production > table tbody tr,
  #page-finishedreceive > table tbody tr,
  #page-semifinishreceive > table tbody tr,
  #page-materialsutilization > table tbody tr {
    grid-template-columns: min-content max-content minmax(0, 1fr) auto;
    gap: 2px 0; /* no column gap — the comma prefix carries its own spacing */
  }
  #page-production > table td:nth-child(1), #page-finishedreceive > table td:nth-child(1),
  #page-semifinishreceive > table td:nth-child(1), #page-materialsutilization > table td:nth-child(1) {
    grid-area: 1 / 1 / 2 / 2; font-weight: 600;
  }
  #page-production > table td:nth-child(1) strong, #page-finishedreceive > table td:nth-child(1) strong,
  #page-semifinishreceive > table td:nth-child(1) strong, #page-materialsutilization > table td:nth-child(1) strong {
    white-space: nowrap;
  }
  #page-production > table td:nth-child(2), #page-finishedreceive > table td:nth-child(2),
  #page-semifinishreceive > table td:nth-child(2), #page-materialsutilization > table td:nth-child(2) {
    grid-area: 1 / 2 / 2 / 3; white-space: nowrap;
  }
  #page-production > table td:nth-child(2)::before, #page-finishedreceive > table td:nth-child(2)::before,
  #page-semifinishreceive > table td:nth-child(2)::before, #page-materialsutilization > table td:nth-child(2)::before {
    content: ', '; font-weight: 400;
  }
  #page-production > table td:nth-child(3), #page-finishedreceive > table td:nth-child(3),
  #page-semifinishreceive > table td:nth-child(3), #page-materialsutilization > table td:nth-child(3) {
    grid-area: 1 / 4 / 2 / 5; justify-self: end; text-align: right;
    font-size: 12.5px;
  }
  #page-production > table td:nth-child(3) .chip, #page-finishedreceive > table td:nth-child(3) .chip,
  #page-semifinishreceive > table td:nth-child(3) .chip, #page-materialsutilization > table td:nth-child(3) .chip {
    background: transparent; border: 0; padding: 0;
    font-weight: 400; font-style: italic;
  }
  #page-production > table td:nth-child(4), #page-finishedreceive > table td:nth-child(4),
  #page-semifinishreceive > table td:nth-child(4), #page-materialsutilization > table td:nth-child(4) {
    grid-area: 2 / 1 / 3 / 5; font-weight: 600;
  }
  #page-production > table td:nth-child(5), #page-finishedreceive > table td:nth-child(5),
  #page-semifinishreceive > table td:nth-child(5), #page-materialsutilization > table td:nth-child(5) {
    grid-area: 3 / 1 / 4 / 5; font-size: 11px; color: var(--muted); font-style: italic;
  }
  #page-production > table td:nth-child(5)::before { content: 'Produced by '; }
  #page-finishedreceive > table td:nth-child(5)::before,
  #page-semifinishreceive > table td:nth-child(5)::before { content: 'Delivered by '; }
  #page-materialsutilization > table td:nth-child(5)::before { content: 'Received by '; }
  #page-production > table td:nth-child(6), #page-finishedreceive > table td:nth-child(6),
  #page-semifinishreceive > table td:nth-child(6), #page-materialsutilization > table td:nth-child(6) {
    grid-area: 4 / 1 / 5 / 5; text-align: right;
  }
  /* deleted rows: the reason line spans the card, BELOW the number/date line
     (tr + class beats the generic td[colspan] rule below it) */
  #page-production > table tbody tr td.void-msg, #page-finishedreceive > table tbody tr td.void-msg,
  #page-semifinishreceive > table tbody tr td.void-msg, #page-materialsutilization > table tbody tr td.void-msg {
    grid-area: 2 / 1 / 3 / -1 !important;
  }
  /* empty-state rows */
  #page-production > table td[colspan], #page-finishedreceive > table td[colspan],
  #page-semifinishreceive > table td[colspan], #page-materialsutilization > table td[colspan] {
    grid-area: 1 / 1 / 2 / -1 !important;
  }

  /* cont-209: the old 3-column cards for SEMI STOCK / STOCK REPORT / RAW
     MATERIALS REPORT were replaced by the cont-209 one-line-figure cards
     mapped with the ITEMS block above (semi stock keeps its own map below) */

  /* ---- the small modal tables: name | value cards ---- */
  #gitems-modal table tbody tr td:nth-child(1) { grid-area: 1 / 1 / 2 / 2; font-weight: 600; }
  #gitems-modal table tbody tr td:nth-child(2) { grid-area: 1 / 2 / 2 / 3; justify-self: end; font-weight: 600; }
  #gitems-modal table tbody tr td[colspan] { grid-area: 1 / 1 / 2 / -1 !important; }
  #bp-hist-table tbody tr td:nth-child(1) { grid-area: 1 / 1 / 2 / 2; font-weight: 600; }
  #bp-hist-table tbody tr td:nth-child(3) { grid-area: 1 / 2 / 2 / 3; justify-self: end; font-weight: 600; }
  #bp-hist-table tbody tr td:nth-child(2) { grid-area: 2 / 1 / 3 / 3; font-size: 11px; color: var(--muted); font-style: italic; }
  #bp-hist-table tbody tr td[colspan] { grid-area: 1 / 1 / 2 / -1 !important; }
  /* can movements: date | qty · stock after · reason */
  #cm-out table tbody tr { grid-template-columns: minmax(0, 1fr) auto; }
  #cm-out table tbody tr td:nth-child(1) { grid-area: 1 / 1 / 2 / 2; font-weight: 600; }
  #cm-out table tbody tr td:nth-child(2) { grid-area: 1 / 2 / 2 / 3; justify-self: end; font-weight: 600; }
  #cm-out table tbody tr td:nth-child(3) { grid-area: 2 / 1 / 3 / 2; font-size: 12.5px; }
  #cm-out table tbody tr td:nth-child(3)::before { content: 'Stock after: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #cm-out table tbody tr td:nth-child(4) { grid-area: 3 / 1 / 4 / 3; font-size: 11px; color: var(--muted); font-style: italic; }

  /* ---- movements popups ( Produced/Received/Consumed/... sections ):
     each row reads as one wrapped inline line ---- */
  #sf-mv-body table tbody tr, #sm-body table tbody tr, #rm-body table tbody tr {
    display: block; padding: 8px 12px; border-top: 1px solid var(--line);
  }
  #sf-mv-body table tbody tr + tr, #sm-body table tbody tr + tr,
  #rm-body table tbody tr + tr { border-top: 1px solid var(--line); }
  #sf-mv-body td, #sm-body td, #rm-body td {
    display: inline; border: 0; padding: 0 8px 0 0; background: none;
  }
  #sf-mv-body td.num, #sm-body td.num, #rm-body td.num { font-weight: 600; }

  /* wide label/value tables inside details modals scroll, never clip */
  #prod-view-modal .modal-box, #fr-view-modal .modal-box, #sfr-view-modal .modal-box,
  #mu-view-modal .modal-box, #sfs-mv-modal .modal-box, #stk-mv-modal .modal-box,
  #rmr-mv-modal .modal-box, #can-move-modal .modal-box, #gitems-modal .modal-box,
  #bp-hist-modal .modal-box { overflow-x: auto; }
}
/* ============================================================================
   cont-186: FINISHED UTILIZATION + SEMI UTILIZATION on phones — the exact
   batch-voucher card layout of production / finished receive / materials
   utilization (cont-215): "number, date" with the status right · items list ·
   received-by line · buttons full width right; deleted vouchers keep their
   reason line. Desktop untouched.
   ========================================================================== */
@media (max-width: 640px) {
  #page-finishedutilization > table,
  #page-semiutilization > table { display: block; }
  #page-finishedutilization > table thead,
  #page-semiutilization > table thead { display: none; }
  #page-finishedutilization > table tbody,
  #page-semiutilization > table tbody { display: block; }
  #page-finishedutilization > table tbody tr,
  #page-semiutilization > table tbody tr {
    display: grid;
    grid-template-columns: min-content max-content minmax(0, 1fr) auto;
    gap: 2px 0; /* no column gap — the comma prefix carries its own spacing */
    padding: 10px 12px;
  }
  #page-finishedutilization > table tbody tr + tr,
  #page-semiutilization > table tbody tr + tr { border-top: 1px solid var(--line); }
  #page-finishedutilization > table tbody tr td,
  #page-semiutilization > table tbody tr td { border: 0; padding: 0; background: none; }
  /* line 1: number + comma + date (status right) */
  #page-finishedutilization > table td:nth-child(1), #page-semiutilization > table td:nth-child(1) {
    grid-area: 1 / 1 / 2 / 2; font-weight: 600;
  }
  #page-finishedutilization > table td:nth-child(1) strong, #page-semiutilization > table td:nth-child(1) strong { white-space: nowrap; }
  #page-finishedutilization > table td:nth-child(2), #page-semiutilization > table td:nth-child(2) {
    grid-area: 1 / 2 / 2 / 3; white-space: nowrap;
  }
  #page-finishedutilization > table td:nth-child(2)::before, #page-semiutilization > table td:nth-child(2)::before {
    content: ', '; font-weight: 400;
  }
  #page-finishedutilization > table td:nth-child(3), #page-semiutilization > table td:nth-child(3) {
    grid-area: 1 / 4 / 2 / 5; justify-self: end; text-align: right; font-size: 12.5px;
  }
  #page-finishedutilization > table td:nth-child(3) .chip, #page-semiutilization > table td:nth-child(3) .chip {
    background: transparent; border: 0; padding: 0;
    font-weight: 400; font-style: italic;
  }
  /* line 2: the items list */
  #page-finishedutilization > table td:nth-child(4), #page-semiutilization > table td:nth-child(4) {
    grid-area: 2 / 1 / 3 / 5; font-weight: 600;
  }
  /* line 3: received by (quiet) */
  #page-finishedutilization > table td:nth-child(5), #page-semiutilization > table td:nth-child(5) {
    grid-area: 3 / 1 / 4 / 5; font-size: 11px; color: var(--muted); font-style: italic;
  }
  #page-finishedutilization > table td:nth-child(5)::before, #page-semiutilization > table td:nth-child(5)::before {
    content: 'Received by ';
  }
  /* line 4: the buttons, right aligned */
  #page-finishedutilization > table td:nth-child(6), #page-semiutilization > table td:nth-child(6) {
    grid-area: 4 / 1 / 5 / 5; text-align: right;
  }
  #page-finishedutilization > table td.actions .btn, #page-semiutilization > table td.actions .btn {
    white-space: normal; max-width: none; margin: 2px 0 2px .3rem;
  }
  /* deleted vouchers: the reason line spans the card, below the number/date */
  #page-finishedutilization > table tbody tr td.void-msg, #page-semiutilization > table tbody tr td.void-msg {
    grid-area: 2 / 1 / 3 / -1 !important;
  }
  /* empty-state rows */
  #page-finishedutilization > table td[colspan], #page-semiutilization > table td[colspan] {
    grid-area: 1 / 1 / 2 / -1 !important;
  }
  /* the details modal's label/value tables scroll, never clip */
  #fu-view-modal .modal-box, #su-view-modal .modal-box { overflow-x: auto; }
}
/* ============================================================================
   A4 PRINT ENGINE — #print-area is filled by app.js, then window.print()
   ========================================================================== */
.print-only { display: none; }

@media print {
  body { background: #fff; }
  body > *:not(#print-area) { display: none !important; }
  .print-only {
    display: block !important; position: static;
    width: 190mm; margin: 0 auto; color: #111; font-size: 12.5px;
  }
  /* cont-135: the cont-134 print forcing (0.5cm/0.9cm margins meant to push
     the printer's own header/footer off the sheet) did NOT work on the
     owner's setup — REMOVED; the engine is back to the standard A4 margins */
  @page { size: A4; margin: 12mm 10mm; }
}

.p-band {
  /* cont-198: back to the cont-196 geometry — the logo box + name+address
     block exactly as before (the box height follows the name+address block,
     no taller). The doc title + status/period chips OVERLAY the band from the
     right: position:absolute takes them out of the flow, so they can never
     squeeze the name+address column — the address keeps its single line (the
     original cont-197 goal, without the taller stacked band the owner found
     messy). The chip sits under the title like the old right zone did. */
  position: relative;
  display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: 3px solid var(--orange); padding-bottom: 10px; margin-bottom: 14px;
  /* the name+address block's exact height: 21px name + 3px gap + 11.5px sub at
     the app's 1.5 line-height (if the header fonts ever change, update this
     one variable) */
  --plogo-h: calc(21px * 1.5 + 11.5px * 1.5 + 3px);
  /* cont-195: decent breathing room between the logo and its border */
  --plogo-pad: 5px;
}
.p-brand { display: flex; align-items: stretch; gap: 10px; }
.p-doc-float { position: absolute; top: 0; right: 0; text-align: right; }
.p-logo-box {
  flex: 0 0 auto; position: relative; overflow: hidden;
  height: var(--plogo-h);
  /* border-box width = padded image area (at the logo's own ratio) + 2×pad + borders */
  width: calc((var(--plogo-h) - 3px - 2 * var(--plogo-pad)) * 272 / 169 + 2 * var(--plogo-pad) + 3px);
  border: 1.5px solid #d9dde3; border-radius: 8px; background: #fff;
}
.p-logo-box img {
  position: absolute; inset: var(--plogo-pad);
  width: calc(100% - 2 * var(--plogo-pad)); height: calc(100% - 2 * var(--plogo-pad));
  object-fit: contain;
}
.p-company { font-size: 21px; font-weight: 800; letter-spacing: .2px; }
.p-company-sub { color: #444; font-size: 11.5px; margin-top: 3px; }
.p-doc-type {
  font-size: 15px; font-weight: 800; letter-spacing: .25em; text-transform: uppercase;
  text-align: right;
}
.p-chip {
  display: inline-block; margin-top: 5px; padding: 2px 10px;
  border: 1.5px solid var(--green); color: var(--green); border-radius: 999px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em;
}
.p-meta { display: flex; gap: 26px; margin-bottom: 12px; }
.p-meta-item { font-size: 12px; }
.p-meta-item span { display: block; color: #666; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; }
.p-meta-item strong { font-size: 13px; }
.p-billto {
  border: 1px solid #e2e5ea; border-radius: 8px; padding: 10px 12px;
  margin-bottom: 14px; background: #fafbfc;
}
.p-billto-label { font-size: 10px; font-weight: 700; color: #888; letter-spacing: .12em; margin-bottom: 3px; }
.p-billto-name { font-size: 15px; font-weight: 700; }
.p-billto-line { font-size: 12px; color: #444; }
.p-duo { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.p-duo .p-billto { flex: 1; margin-bottom: 0; }
.p-dues { border: 1.5px solid #d9dde3; border-radius: 10px; padding: 10px 14px; min-width: 225px; background: #fafbfc; }
.p-dues h4 { margin: 0 0 6px; font-size: 10px; font-weight: 700; letter-spacing: .12em; color: #888; text-transform: uppercase; }
.p-due-row { display: flex; justify-content: space-between; gap: 20px; font-size: 12px; padding: 3px 0; }
.p-due-row.total { border-top: 1px solid #c9ced6; margin-top: 5px; padding-top: 6px; font-weight: 800; font-size: 13.5px; }
.p-group { margin-bottom: 12px; }
.p-group-title { font-size: 13px; font-weight: 800; margin: 8px 0 4px; }
.p-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.p-table th {
  background: #f2f3f5; border: 1px solid #d9dde3; padding: 6px 8px;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; text-align: left;
}
.p-table td { border: 1px solid #e2e5ea; padding: 6px 8px; font-size: 12px; }
.p-center { text-align: center; }
.p-right { text-align: right; }
.p-words { font-size: 12px; padding: 6px 0; border-top: 1px dashed #cfd4db; }
.p-totals { margin-left: auto; width: 240px; font-size: 12.5px; }
.p-totals p { display: flex; justify-content: space-between; padding: 3px 0; }
.p-totals .p-net {
  border-top: 2px solid #111; margin-top: 4px; padding-top: 6px;
  font-weight: 800; font-size: 14px;
}
.p-notes { font-size: 11.5px; color: #444; margin-top: 8px; }
.p-sign { display: flex; justify-content: space-between; margin-top: 42px; }
.p-sign-box { width: 200px; text-align: center; font-size: 11px; color: #555; }
.p-sign-line { border-bottom: 1px solid #999; height: 26px; margin-bottom: 5px; }
.p-foot {
  margin-top: 22px; padding-top: 8px; border-top: 1px solid #e2e5ea;
  text-align: center; color: #777; font-size: 10.5px;
}
/* multi-page report pagination (cont-53): fixed-height page divs; every
   printed page ends with "Page x of y" bottom-right (print only).
   cont-67: break-after carries BOTH the modern property and the legacy
   page-break alias — some engines (older Safari, Android WebView) only
   honor the legacy one, and a missed break collapses every sheet onto one
   printed page. overflow is visible: if a sheet's content ever exceeds
   258mm it must spill visibly, never be silently swallowed (that once hid
   print rows and page numbers). */
.p-page {
  position: relative; height: 258mm; overflow: visible;
  break-after: page; page-break-after: always;
}
.p-page-last { height: auto; break-after: auto; page-break-after: auto; }
.p-pageno { position: absolute; bottom: 0; right: 0; font-size: 10.5px; color: #777; }
/* cont-201: the #build-tag stamp is gone (owner's call) — its rule removed */

.p-cont { font-size: 11px; color: #555; margin-bottom: 10px; }
.p-fixed { table-layout: fixed; }
.p-fixed td, .p-fixed th { padding-left: 4px; padding-right: 4px; }
.p-fixed td { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
/* statement/report print blocks */
.p-title { font-size: 17px; font-weight: 800; margin-bottom: 2px; }
.p-sub { color: #555; font-size: 11.5px; margin-bottom: 12px; }
.p-summary { display: flex; gap: 18px; margin: 10px 0; font-size: 12.5px; }
.p-summary div { border: 1px solid #e2e5ea; border-radius: 8px; padding: 8px 12px; background: #fafbfc; }
.p-summary span { display: block; color: #666; font-size: 10px; text-transform: uppercase; letter-spacing: .07em; }
.p-summary strong { font-size: 14px; }

/* ================= PERMISSION MATRIX (pages/users.js) ================= */
.perm-toolbar{display:flex;gap:.6rem;align-items:center;margin-bottom:.6rem}
.perm-search{flex:1}
.perm-groups{max-height:52vh;overflow:auto;border:1px solid var(--line,#e5e7eb);border-radius:8px;padding:.35rem .75rem}
.perm-group{padding:.35rem 0}
.perm-group + .perm-group{border-top:1px dashed var(--line,#e5e7eb)}
.perm-group-head{display:flex;align-items:center;gap:.5rem;padding:.35rem 0}
.perm-group-head h4{margin:0;font-size:.8rem;text-transform:uppercase;letter-spacing:.04em}
.perm-mini{margin-left:auto;display:flex;gap:.25rem}
.btn.mini{padding:.1rem .45rem;font-size:.72rem;line-height:1.4}
.perm-row{display:flex;align-items:center;gap:.6rem;padding:.3rem .25rem;border-radius:6px;cursor:pointer}
.perm-row:hover{background:rgba(127,127,127,.07)}
.perm-row input[type=checkbox]{width:16px;height:16px;flex:none}
.perm-label{flex:1;display:flex;flex-direction:column;line-height:1.25}
.perm-desc{font-size:.75rem;color:#6b7280}
.perm-code{flex:none;font-size:.72rem;color:#9ca3af;background:rgba(127,127,127,.08);padding:.1rem .4rem;border-radius:4px}

/* ---------- searchable dropdowns (cont-152) ----------
   The wrapper keeps the original <select> (hidden — it stays the source of
   truth for options/value/rate data-* attributes); the input on top does the
   in-page type-to-filter, the menu lists the matches. */
.combo { position: relative; width: 100%; }
/* filter bars: the combo host takes over the sizing the old <select> had */
.filters .combo { width: auto; min-width: 150px; flex: 0 1 auto; }
.combo > select { display: none !important; }
.combo-input { width: 100%; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }
.combo-input:focus { outline: none; border-color: #93b4f8; box-shadow: 0 0 0 2px rgba(37, 99, 235, .13); }
.combo-input:disabled { background: var(--bg); color: var(--muted); }
.combo-menu { display: none; position: absolute; top: 100%; left: 0; right: 0; min-width: 260px; max-height: 240px; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(20, 30, 60, .16); z-index: 90; }
.combo-menu.open { display: block; }
/* cont-153: full names always visible — rows wrap, no ellipsis */
.combo-menu .cm-row { padding: .45rem .6rem; cursor: pointer; font-size: 13px; line-height: 1.35; word-break: break-word; }
.combo-menu .cm-row.active, .combo-menu .cm-row:hover { background: #eef4ff; }
.combo-menu .cm-none { padding: .45rem .6rem; color: var(--muted); font-size: 13px; }

/* ==========================================================================
   SHELL UX — user hover menu, sidebar footer brand, hover-reveal, login,
   About popup (cont-179 … cont-182)
   ========================================================================== */

/* ---- topbar right: avatar + name, hover menu (cont-179) ---- */
.user-chip { position: relative; display: flex; align-items: center; gap: .5rem; cursor: pointer; outline: none; }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #fbad41, var(--orange)); color: #fff;
  font-size: 12px; font-weight: 800; letter-spacing: .02em;
}
.user-menu {
  display: none; position: absolute; top: calc(100% + 10px); right: 0; z-index: 80;
  min-width: 220px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 18px 50px rgba(15,23,42,.18); padding: .45rem;
}
.user-chip:hover .user-menu, .user-chip:focus-within .user-menu { display: block; }
.user-menu-head { display: flex; flex-direction: column; gap: .1rem; padding: .55rem .7rem; border-bottom: 1px solid var(--line); margin-bottom: .35rem; }
.user-menu-head strong { font-size: 13.5px; }
.user-menu-item {
  display: flex; align-items: center; gap: .55rem; width: 100%;
  background: none; border: 0; font: inherit; font-size: 13.5px; color: var(--text);
  padding: .55rem .65rem; border-radius: 8px; cursor: pointer; text-align: left;
}
.user-menu-item:hover { background: var(--gray-bg); }
.user-menu-item.danger { color: #c0392b; }
.user-menu-item svg { opacity: .8; }

/* ---- sidebar footer = the software brand (name + version + About) ---- */
.side-brand { display: flex; align-items: center; gap: .45rem; margin-bottom: .3rem; flex-wrap: wrap; }
.side-brand-name { font-weight: 800; font-size: 14px; letter-spacing: -.01em; }
.ver-tag { font-size: 11.5px; font-weight: 700; color: var(--orange-dark); letter-spacing: .04em; }  /* cont-181: plain v1, no background */
.about-link {
  display: inline-flex; align-items: center; gap: .3rem; cursor: pointer;
  color: var(--muted); text-decoration: none; font-size: 12px; border-radius: 6px;
}
.about-link:hover { color: var(--orange-dark); text-decoration: underline; }

/* ---- hover-reveal overlay (desktop): a PURE overlay (cont-183) --------------
   The hidden sidebar is taken OUT of the page flow entirely — fixed and
   translated off-canvas — instead of the old in-flow negative margin (whose
   .18s transition re-flowed the page: on mouse-out the menu re-entered the
   flex row at full width and the content visibly squeezed left). Now showing
   or hiding the menu only ever SLIDES the same fixed box over the page; the
   content can never shift.                                                  */
#side-hotzone { position: fixed; left: 0; top: 56px; bottom: 0; width: 14px; z-index: 65; display: none; }
body.side-hidden #side-hotzone { display: block; }
@media (min-width: 901px) {
  body.side-hidden .sidebar {
    position: fixed; left: 0; top: 56px; bottom: 0; z-index: 70;
    margin-left: 0;                                    /* neutralize the old negative-margin hide */
    transform: translateX(calc(var(--side-w) * -1));   /* fully off-canvas — zero layout impact */
    box-shadow: none; transition: transform .18s ease; /* slide animation only, never layout */
  }
  body.side-hidden .sidebar.hover-reveal {
    transform: translateX(0);                          /* slides back OVER the page */
    box-shadow: 0 12px 44px rgba(15,23,42,.22);
  }
}
@media (max-width: 900px) {
  #side-hotzone { display: none !important; }   /* mobile keeps the backdrop flow */
  .sidebar.hover-reveal { position: fixed; }
}

/* ---- login card — logo slot on top, even vertical rhythm ---- */
.login-box { transition: box-shadow .25s ease, transform .25s ease; }
.login-box:hover { box-shadow: 0 18px 60px rgba(20,30,50,.13); transform: translateY(-2px); }
#login-logo { display: block; margin: 0 auto .5rem; max-height: 76px; max-width: 220px; object-fit: contain; }
#login-logo.hidden { display: none; }
.login-brand h1 { font-size: 21px; letter-spacing: -.01em; margin-top: .3rem; }
.login-brand .muted { margin-top: .25rem; font-size: 13px; }
#login-form label:first-child { margin-top: 0; }        /* first label hugs the brand block */
#login-form input { margin-bottom: .15rem; }
#login-form .form-error { margin: .7rem 0 0; }
#login-form .btn { margin-top: 1.15rem; }               /* clear separation before Sign in */
#login-form > .muted.center.small { margin-top: .9rem; }

/* ---- About popup — centered composition, no logo mark, no shadow (cont-182) ---- */
.about-card { position: relative; max-width: 440px; padding: 0 0 1.5rem; overflow: hidden; border-radius: 16px; box-shadow: none; }
.about-x {
  position: absolute; top: 12px; right: 12px; z-index: 2; border: 0; background: rgba(255,255,255,.75);
  font-size: 14px; color: var(--muted); cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.about-x:hover { background: var(--gray-bg); color: var(--text); }
.about-hero {
  padding: 1.5rem 1.6rem 1.05rem; text-align: center; border-bottom: 1px solid var(--line);
  background:
    radial-gradient(440px 150px at 50% -50px, var(--orange-tint) 0%, transparent 72%),
    var(--panel);
}
.about-hero h2 { font-size: 20px; font-weight: 800; letter-spacing: -.01em; margin: 0; }
.about-body { padding: 1.15rem 1.7rem 0; text-align: center; }
.about-cap { font-size: 12.5px; color: var(--muted); margin: 0 0 .2rem; }   /* written as-is, no uppercase */
.about-co { font-size: 17px; font-weight: 800; margin: 0 0 .2rem; }
.about-line { font-size: 13.5px; margin: .15rem 0; }
.about-rule { border: 0; border-top: 1px solid var(--line); margin: .95rem auto; width: 60%; }
.about-dev { color: var(--orange-dark); font-weight: 700; text-decoration: none; border-bottom: 1.5px solid transparent; }
.about-dev:hover { border-bottom-color: var(--orange); }
.about-note {
  margin-top: .95rem; font-size: 12.5px; color: var(--muted); line-height: 1.55; text-align: left;
  background: var(--gray-bg); border: 1px solid var(--line); border-radius: 10px; padding: .65rem .8rem;
}

/* permission search dropdown (cont-187) */
.ps2-dd {
  position: absolute; left: 0; right: 0; top: calc(100% + 3px); z-index: 30;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
  max-height: 240px; overflow: auto; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.ps2-opt { padding: 7px 10px; cursor: pointer; display: flex; gap: 8px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.ps2-opt:hover { background: rgba(127,127,127,.15); }

/* ============================================================================
   cont-213: the GENERATED SUPPLIER STATEMENT on phones — the raw 7-column
   ledger table (Date · Type · Reference · Description · Debit · Credit ·
   Due) gets the bills card treatment: line 1 date + type + reference | due
   right, line 2 description (quiet, skipped when empty), line 3 the debit
   and/or credit figures (the credit rides in a data attribute). The four
   stat cards above the table are the responsive .cards grid already.
   Desktop untouched.
   ========================================================================== */
@media (max-width: 640px) {
  #sup-stmt-result table { display: block; }
  #sup-stmt-result table thead { display: none; }
  #sup-stmt-result table tbody { display: block; }
  #sup-stmt-result table tbody tr {
    display: grid;
    grid-template-columns: min-content max-content minmax(0, 1fr) minmax(auto, 46vw);
    gap: 2px 6px;
    padding: 10px 12px;
  }
  #sup-stmt-result table tbody tr + tr { border-top: 1px solid var(--line); }
  #sup-stmt-result table tbody tr td { border: 0; padding: 0; background: none; text-align: left; }
  #sup-stmt-result table tbody tr td:nth-child(1) { grid-area: 1 / 1; white-space: nowrap; }
  #sup-stmt-result table tbody tr td:nth-child(2) { grid-area: 1 / 2; }
  #sup-stmt-result table tbody tr td:nth-child(2) .chip {
    background: transparent; border: 0; padding: 0; font-weight: 400; font-size: 11px;
  }
  #sup-stmt-result table tbody tr td:nth-child(3) {
    grid-area: 1 / 3; font-size: 11px; color: var(--muted); font-style: italic;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  #sup-stmt-result table tbody tr td:nth-child(7) { grid-area: 1 / 4; justify-self: end; white-space: nowrap; }
  #sup-stmt-result table tbody tr td:nth-child(4) {
    grid-area: 2 / 1 / 3 / -1; text-align: left;
    font-size: 11px; color: var(--muted); font-style: italic;
  }
  #sup-stmt-result table tbody tr td:nth-child(4):empty { display: none; }
  #sup-stmt-result table tbody tr td:nth-child(5) { grid-area: 3 / 1 / 4 / -1; text-align: left; font-size: 12.5px; }
  /* the desktop "—" dash span is hidden here; the Debit/Credit labels are
     gated on it with :has so a credit-only row reads "Credit: x" */
  #sup-stmt-result table tbody tr td:nth-child(5) .dmuted { display: none; }
  #sup-stmt-result table tbody tr td:nth-child(5):not(:has(.dmuted))::before {
    content: 'Debit: '; color: var(--muted); font-weight: 400; font-size: 11px;
  }
  #sup-stmt-result table tbody tr td:nth-child(5):not(:has(.dmuted))[data-cr]::after {
    content: ', Credit: ' attr(data-cr); color: var(--muted); font-weight: 400; font-size: 11px;
  }
  #sup-stmt-result table tbody tr td:nth-child(5):has(.dmuted)[data-cr]::after {
    content: 'Credit: ' attr(data-cr); color: var(--muted); font-weight: 400; font-size: 11px;
  }
  #sup-stmt-result table tbody tr td:nth-child(5):has(.dmuted):not([data-cr]) { display: none; }
  #sup-stmt-result table tbody tr td:nth-child(6) { display: none; }
}

/* ============================================================================
   cont-219: ITEMS / ITEM GROUPS / UNITS / RAW MATERIALS cards rebuilt as FLEX
   lines, to the user's line-by-line spec (v1.90). The grid machinery in
   cont-215 already described the right shape, but grid-track sizing on a tr
   inside table context shrank the card to ~half width on the user's browser.
   Flex has no track sizing: every card is a full-width flex column —
   · ITEMS   line 1 name … Stock right (semi-bold) · line 2 "Unit: u, Price:
     p, Ideal: i" comma-separated full width · line 3 buttons one row right
   · GROUPS  line 1 name … Assigned right · line 2 buttons one row right
   · UNITS   line 1 name … In use right · line 2 buttons one row right
   · MATERIALS line 1 name … "Stock: 1200 kg" right · line 2 "Known as: k,
     Ideal: i" full width · line 3 buttons one row right
   This block sits LAST in the cascade so it wins the ties with cont-215;
   the old grid-area rules for these four pages become no-ops under flex.
   ========================================================================== */
@media (max-width: 640px) {
  #page-items > table tbody tr, #page-groups > table tbody tr,
  #page-units > table tbody tr, #page-materials > table tbody tr {
    display: flex; flex-wrap: wrap; width: 100%; min-width: 100%; max-width: 100%;
    box-sizing: border-box; align-items: baseline; gap: 3px 0; padding: 10px 12px;
  }
  /* line 1: name takes the rest, the metric hugs the right edge */
  #page-items > table tbody tr td:nth-child(1),
  #page-groups > table tbody tr td:nth-child(1),
  #page-units > table tbody tr td:nth-child(1),
  #page-materials > table tbody tr td:nth-child(1) {
    order: 1; flex: 1 1 auto; min-width: 0; font-weight: 600;
  }
  #page-items > table tbody tr td:nth-child(1) strong,
  #page-materials > table tbody tr td:nth-child(1) strong { white-space: normal; }
  #page-items > table tbody tr td:nth-child(4),
  #page-groups > table tbody tr td:nth-child(2),
  #page-units > table tbody tr td:nth-child(2),
  #page-materials > table tbody tr td:nth-child(5) {
    order: 2; flex: 0 0 auto; text-align: right; font-size: 12.5px; font-weight: 600;
  }
  #page-groups > table tbody tr td:nth-child(2)::before { content: 'Assigned: '; }
  #page-units > table tbody tr td:nth-child(2)::before { content: 'In use: '; }
  /* line 2: the comma-separated figures, full width */
  #page-items > table tbody tr td:nth-child(2),
  #page-materials > table tbody tr td:nth-child(2) {
    order: 3; flex: 1 1 100%; min-width: 0; font-size: 12.5px;
  }
  /* line 3: the buttons — one row, right aligned */
  #page-items > table tbody tr td:nth-child(6),
  #page-groups > table tbody tr td:nth-child(3),
  #page-units > table tbody tr td:nth-child(3),
  #page-materials > table tbody tr td:nth-child(6) {
    order: 4; flex: 1 1 100%; min-width: 0;
    display: flex; flex-wrap: nowrap; justify-content: flex-end; gap: 6px;
  }
  #page-items > table tbody tr td:nth-child(6) .btn,
  #page-groups > table tbody tr td:nth-child(3) .btn,
  #page-units > table tbody tr td:nth-child(3) .btn,
  #page-materials > table tbody tr td:nth-child(6) .btn { margin: 2px 0; flex-shrink: 1; }
  /* hidden raw columns (values ride the line-2 data attributes) */
  #page-items > table tbody tr td:nth-child(3),
  #page-items > table tbody tr td:nth-child(5),
  #page-materials > table tbody tr td:nth-child(3),
  #page-materials > table tbody tr td:nth-child(4) { display: none; }
  /* band + empty rows stay full width */
  #page-items > table tbody tr td[colspan], #page-groups > table tbody tr td[colspan],
  #page-units > table tbody tr td[colspan], #page-materials > table tbody tr td[colspan] {
    flex: 1 1 100%; order: 0;
  }
  /* materials: stock with its unit; the low-stock sub-line stays hidden */
  #page-materials > table tbody tr td:nth-child(5)[data-unit]::after { content: ' ' attr(data-unit); font-weight: 400; font-size: 11px; }
  #page-materials > table tbody tr td:nth-child(5) div { display: none; }
  /* units/groups counts keep the muted label style */
  #page-groups > table tbody tr td:nth-child(2)::before,
  #page-units > table tbody tr td:nth-child(2)::before {
    color: var(--muted); font-weight: 400; font-size: 11px;
  }
}

/* ==== cont-212: user-request mobile refinements + audit-log tidy-up ====
   Group bands read as GROUPS (one tinted band look on every groupwise page),
   the report pages' figure line aligns left, bulk pricing gets a group
   filter + a tighter card, cans & cartons collapse to name+stock / buttons,
   deleted & modified bills lose the panel card + the count line, and the
   View movements / View modifications buttons carry their short mobile
   labels. The identical rules live in styles.css, cards.css and the inline
   copy inside index.html — keep all three in step. ==== */

/* ---- desktop: audit log tidiness (both modes) — the details cell renders
   "key value · key value" (pages/logs.js) and clamps to ONE line; the full
   JSON sits in the cell's title tooltip ---- */
#page-logs table.m-list th, #page-logs table.m-list td { vertical-align: top; }
#page-logs table.m-list th:nth-child(1), #page-logs table.m-list td:nth-child(1) { white-space: nowrap; }
#page-logs table.m-list th:nth-child(2), #page-logs table.m-list td:nth-child(2) { white-space: nowrap; }
#page-logs table.m-list th:nth-child(3), #page-logs table.m-list td:nth-child(3) { white-space: nowrap; }
#page-logs table.m-list .log-details {
  max-width: 52ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#page-logs table.m-list .log-details b { font-weight: 600; color: var(--muted); }
#page-logs table.m-list .log-sep { color: var(--muted); }

@media (max-width: 640px) {


  /* ---- RAW MATERIALS REPORT / STOCK REPORT / SEMI FINISH STOCK: the
     "Opening: …, Purch: …" line reads from the LEFT — td.num's desktop
     right-align made every wrapped tail dangle to the right edge ---- */
  #page-materialsreport #rmr-groups td:nth-child(2),
  #page-stockreport #stk-groups td:nth-child(2),
  #page-semifinishstock #sfs-groups td:nth-child(2) { text-align: left; }

  /* the mobile button labels: View movements → Movements,
     View modifications → View (the cont-194 two-label pattern) */
  #page-materialsreport .blong, #page-stockreport .blong,
  #page-semifinishstock .blong, #page-cans .blong,
  #page-modifiedbills .blong { display: none; }
  #page-materialsreport .bmini, #page-stockreport .bmini,
  #page-semifinishstock .bmini, #page-cans .bmini,
  #page-modifiedbills .bmini { display: inline; }

  /* ---- BULK PRICING card: line 1 = name + grey-italic [unit],
     line 2 = Current: amount · Price set: input · History right.
     The GROUP band keeps its price input + Apply, tinted. ---- */
  #page-bulkpricing > table tbody tr { grid-template-columns: auto minmax(0, 1fr) auto; gap: 3px 8px; }
  #page-bulkpricing td:nth-child(1) { grid-area: 1 / 1 / 2 / 4; font-weight: 600; }
  #page-bulkpricing td:nth-child(1) strong { white-space: normal; }
  #page-bulkpricing > table tbody tr:not(.type-head) td:nth-child(1)[data-unit]::after {
    content: ' [' attr(data-unit) ']'; font-style: italic;
    color: var(--muted); font-weight: 400; font-size: 11px;
  }
  #page-bulkpricing td:nth-child(2) { display: none; }
  #page-bulkpricing td:nth-child(3) { grid-area: 2 / 1 / 3 / 2; justify-self: start; font-size: 12.5px; }
  #page-bulkpricing td:nth-child(3)::before { content: 'Current: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  /* the price field flexes inside its cell — the 'Price set:' label and the
     input share the cell on ONE line and shrink instead of colliding with
     the Current amount or the History button */
  #page-bulkpricing td:nth-child(4) {
    grid-area: 2 / 2 / 3 / 3; display: flex; align-items: center;
    justify-content: flex-end; gap: 4px; white-space: nowrap;
  }
  #page-bulkpricing td:nth-child(4)::before { content: 'Price set: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-bulkpricing td:nth-child(4) input { flex: 1 1 0; min-width: 64px; max-width: 120px; }
  #page-bulkpricing td:nth-child(4) input::placeholder { font-size: 11px; }
  #page-bulkpricing td:nth-child(5) { grid-area: 2 / 3 / 3 / 4; justify-self: end; }
  /* the group band: name line 1 · its input + Apply right on line 2 */
  #page-bulkpricing tr.type-head td:nth-child(1) { grid-area: 1 / 1 / 2 / 4; }
  #page-bulkpricing tr.type-head td:nth-child(2) { display: block; grid-area: 2 / 2 / 3 / 3; justify-self: end; }
  #page-bulkpricing tr.type-head td:nth-child(3) { grid-area: 2 / 3 / 3 / 4; justify-self: end; }

  /* ---- CANS & CARTONS card: line 1 = name | Stock: qtn right, line 2 =
     the full app's buttons (Movements · Adjust · Rename · Ideal · Del).
     The selectors carry the cont-209 block's full chain so this later block
     wins it (a shorter chain loses on specificity). ---- */
  #page-cans #can-list > table tbody tr { grid-template-columns: minmax(0, 1fr) auto; }
  #page-cans #can-list > table tbody tr td:nth-child(1) { grid-area: 1 / 1 / 2 / 2; font-weight: 600; }
  #page-cans #can-list > table tbody tr td:nth-child(4) { grid-area: 1 / 2 / 2 / 3; justify-self: end; text-align: right; font-size: 12.5px; }
  #page-cans #can-list > table tbody tr td:nth-child(4)::before { content: 'Stock: '; color: var(--muted); font-weight: 400; font-size: 11px; }
  #page-cans #can-list > table tbody tr td:nth-child(2),
  #page-cans #can-list > table tbody tr td:nth-child(3),
  #page-cans #can-list > table tbody tr td:nth-child(5) { display: none; }
  #page-cans #can-list > table tbody tr td:nth-child(6) { grid-area: 2 / 1 / 3 / 3; text-align: right; }

  /* ---- DELETED BILLS: no panel card around the list, no "N deleted bills"
     count line; line 3 carries Type and By together ---- */
  #page-deletedbills .panel { background: none; border: 0; padding: 0; margin: 0; }
  #page-deletedbills .filters #dbill-count { display: none; }
  #page-deletedbills table.m-list tbody tr td:nth-child(2) { grid-area: 3 / 1 / 4 / 3; }
  #page-deletedbills table.m-list tbody tr td:nth-child(5) { grid-area: 3 / 3 / 4 / 5; justify-self: start; white-space: nowrap; }

  /* ---- MODIFIED BILLS: same card strip + count removal; line 3 =
     "Type: … Modified: …" (By lives in the popup on phones) ---- */
  #page-modifiedbills .panel { background: none; border: 0; padding: 0; margin: 0; }
  #page-modifiedbills .filters #mdb-count { display: none; }
  #page-modifiedbills table.m-list tbody tr td:nth-child(2) { grid-area: 3 / 1 / 4 / 3; }
  #page-modifiedbills table.m-list tbody tr td:nth-child(4) { grid-area: 3 / 3 / 4 / 5; justify-self: start; white-space: nowrap; }
  #page-modifiedbills table.m-list tbody tr td:nth-child(6) { display: none; }

  /* ---- AUDIT LOG: the details keep their FULL text (cont-185) but wrap as
     words (no more mid-token break-all walls) ---- */
  #page-logs table.m-list tbody tr td:nth-child(5) { word-break: break-word; }
  #page-logs table.m-list .log-details { max-width: none; white-space: normal; overflow: visible; }
}

/* ==== cont-214: ACCOUNTS mobile card re-map — the Total Receive / Total
   Cash Out columns left the table (Account · Type · Opening · Balance ·
   buttons), so balance re-slots to td 4, the buttons to td 5, the old
   td4/td5 display:none is undone and the In/Out tail is dropped ==== */
@media (max-width: 640px) {
  #page-accounts table.m-list tbody tr td:nth-child(4) {
    display: block; grid-area: 1 / 2 / 2 / 3; justify-self: end; white-space: nowrap;
  }
  #page-accounts table.m-list tbody tr td:nth-child(5) {
    display: block; grid-area: 4 / 1 / 5 / 3; text-align: right;
  }
  #page-accounts table.m-list tbody tr td:nth-child(3)::before { content: 'Opening: '; }
  #page-accounts table.m-list tbody tr td:nth-child(3)::after { content: none !important; }
}

/* ==== cont-216: BULK PRICING group bands keep the grey banded look on
   phones — the page sat out of the banded-grey lists, so the generic card
   rule (background:none) flattened the band to transparent at phone
   widths; desktop was never affected ==== */
@media (max-width: 640px) {
  #page-bulkpricing tr.type-head td { background: #e4e8ee; border-top: 2px solid var(--line); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: .55rem .6rem .2rem; }
}

/* ==== cont-217: phone fine-tuning from the owner's walkthrough —
   one line of right-aligned row buttons (expenses + accounts), short
   labels via data-short (Stat / Edit / Deac / Act / Del, phones only),
   the expenses + journal-contra search fields on their own full line,
   and the mobile group bands in a clearly visible grey (--band) ==== */
@media (max-width: 640px) {
  /* one line of buttons, right-aligned — the shrink-to-fit cell wrapped
     Delete onto a 2nd line (expenses) and stacked 4 accounts buttons */
  #page-expenses table.m-list tbody tr td:nth-child(8),
  #page-accounts table.m-list tbody tr td:nth-child(7) {
    display: flex; flex-wrap: nowrap; justify-content: flex-end;
    align-items: center; white-space: nowrap; text-align: right;
  }
  #page-expenses table.m-list tbody tr td:nth-child(8) .btn,
  #page-accounts table.m-list tbody tr td:nth-child(7) .btn { margin: 1px 0 1px .3rem; }
  /* short labels on phones (data-short sits on the buttons themselves) */
  .btn[data-short] { font-size: 0; }
  .btn[data-short]::after { content: attr(data-short); font-size: 13.5px; font-weight: 600; }
  .btn.small[data-short]::after { font-size: 12.5px; }
  /* search + the type filter share ONE line (owner request) — the search
     grows to fill, the type field keeps ~40%; the rest of the filters wrap
     below, so nothing overlaps */
  #page-expenses .filters > #exp-search,
  #page-transfers .filters > #tr-search { flex: 1 1 55%; min-width: 0; }
  #page-expenses .filters > #exp-cat,
  #page-transfers .filters > #tr-account-filter { flex: 0 1 40%; }
}

/* ==== cont-221: daybook band rows wrap their full text; accounts card
   actions stay on one merged row ==== */
html.mob #db-result table tbody tr.db-group{grid-template-columns: minmax(0, 1fr);}
html.mob #db-result table tbody tr.db-group td[colspan]{min-width: 0; overflow-wrap: anywhere; line-height: 1.5;}
html.mob #page-accounts table.m-list tbody tr td.actions{display: flex; flex-wrap: nowrap; max-width: none;}
html.mob #page-accounts table.m-list tbody tr td.actions .btn{flex: 1 1 0; min-width: 0; margin: 0 0 0 .3rem; justify-content: center; text-align: center;}
