/* ==========================================================================
   AKM Docs — new editor (editor.html). Beta, runs beside the current editor.
   Nothing here is loaded by index.html, so the current editor cannot be
   affected by any rule in this file.

   Design (owner-approved "v4", 2026-09-23): plain white paper, hairlines,
   rounded shapes. Colour only on the wordmark, title, letterhead rule, table
   header, document number and G. Total. Totals: plain labels, boxed values.

   Three layouts from one DOM:
     - desktop screen: the A4 sheet with the control dock on the right,
       PRINT / WhatsApp floating bottom-right (as in the current editor)
     - phone screen:   fluid sheet, item rows as stacked cards, dock on top,
       PRINT / WhatsApp in a bar fixed to the bottom
     - print:          strict A4, letterhead + footer on every page
   ========================================================================== */

/* Montserrat, self-hosted (Assets/fonts, SIL OFL, Latin subset). The same
   files are embedded in the jsPDF (pdf-editor.js), so the screen, the printed
   page and the WhatsApp PDF all use the same letters. */
@font-face { font-family: 'Montserrat'; font-weight: 500; font-display: swap; src: url('Assets/fonts/montserrat-500.ttf') format('truetype'); }
@font-face { font-family: 'Montserrat'; font-weight: 600; font-display: swap; src: url('Assets/fonts/montserrat-600.ttf') format('truetype'); }
@font-face { font-family: 'Montserrat'; font-weight: 700; font-display: swap; src: url('Assets/fonts/montserrat-700.ttf') format('truetype'); }
@font-face { font-family: 'Montserrat'; font-weight: 800; font-display: swap; src: url('Assets/fonts/montserrat-800.ttf') format('truetype'); }
@font-face { font-family: 'Montserrat'; font-weight: 900; font-display: swap; src: url('Assets/fonts/montserrat-900.ttf') format('truetype'); }

:root {
  --inv: #4a90e2; --inv-deep: #2560a8;
  --qt: #1fa67a;  --qt-deep: #137251;
  --dn: #e64c4c;  --dn-deep: #b42d2d;
  --rc: #b45309;  --rc-deep: #8a3f06;
  --accent: var(--inv); --deep: var(--inv-deep);
  --minus: #c2410c;
  --rent: #d97706;

  --bench: #e7ebf0; --bench-ink: #1c2530; --bench-muted: #5b6776;
  --panel: #ffffff; --panel-line: #d9e0e8; --well: #f2f5f8; --knob: #ffffff;
  --paper: #ffffff; --ink: #121a24; --text: #333d49; --muted: #6f7a86; --hair: #e3e7ec; --hair-2: #eef1f4;

  --ui: 'Montserrat', 'Segoe UI', Arial, sans-serif;
  --doc: Arial, Helvetica, sans-serif;
  --r: 10px;
  --actions-h: 64px;
}
.doc-invoice   { --accent: var(--inv); --deep: var(--inv-deep); }
.doc-quotation { --accent: var(--qt);  --deep: var(--qt-deep); }
.doc-delivery  { --accent: var(--dn);  --deep: var(--dn-deep); }
.doc-receipt   { --accent: var(--rc);  --deep: var(--rc-deep); }

[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bench); color: var(--bench-ink); font-family: var(--ui); -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font-family: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Sign-in screen ── */
.gate { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bench); z-index: 50; padding: 16px; }
.gate-card { background: var(--panel); border: 1px solid var(--panel-line); border-radius: 16px; padding: 32px 28px; text-align: center; max-width: 380px; width: 100%; display: grid; gap: 12px; }
.gate-card img { width: 150px; margin: 0 auto; }
.gate-card h1 { margin: 0; font-size: 20px; font-weight: 800; }
.gate-card p { margin: 0; color: var(--bench-muted); font-size: 13px; line-height: 1.5; }

/* ── Page frame ── */
.studio { max-width: 1260px; margin: 0 auto; padding-inline: 16px; padding-block: 12px 32px;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.topbar { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.topbar h1 { margin: 0; font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.beta { font-size: 10px; font-weight: 800; letter-spacing: .12em; color: #fff; background: var(--bench-ink); padding: 3px 7px; border-radius: 999px; }
.topbar .spacer { flex: 1; }
.linkbtn { font: 700 12.5px var(--ui); color: var(--bench-ink); background: var(--panel); border: 1px solid var(--panel-line); border-radius: 999px; padding: 7px 12px; text-decoration: none; cursor: pointer; }
.linkbtn:hover { border-color: var(--accent); }
.status { font-size: 12px; color: var(--bench-muted); }
.status.saving { color: var(--deep); font-weight: 700; }

/* ── Control dock ── */
.dock { display: grid; gap: 14px; align-content: start; min-width: 0; }
.dock .card, .grid2 > *, .field, .field input, .field select { min-width: 0; }
.card { background: var(--panel); border: 1px solid var(--panel-line); border-radius: 14px; padding: 14px; display: grid; gap: 12px; }
.card h2 { margin: 0; font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--bench-muted); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--well); padding: 5px; border-radius: 12px; }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 9px 8px; cursor: pointer; text-align: left; display: grid; gap: 2px; color: var(--bench-muted); min-height: 44px; }
.seg button b { font-size: 13.5px; font-weight: 700; display: flex; align-items: center; gap: 7px; color: inherit; }
.seg button small { font-size: 11px; font-weight: 500; }
.seg button .dot { width: 9px; height: 9px; border-radius: 50%; opacity: .45; flex: none; }
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--bench-ink); box-shadow: 0 1px 2px rgba(0,0,0,.1), 0 3px 10px rgba(0,0,0,.06); }
.seg button[aria-pressed="true"] .dot { opacity: 1; }
.btn { font: 700 13px var(--ui); border: 0; border-radius: 10px; padding: 10px 14px; cursor: pointer; background: var(--accent); color: #fff; min-height: 42px; }
.btn.ghost { background: var(--well); color: var(--bench-ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1 1 auto; }
.tip { font-size: 12px; line-height: 1.5; color: var(--bench-muted); margin: 0; }
.tip code { font-family: var(--doc); font-weight: 700; padding: 1px 6px; border-radius: 6px; background: var(--well); color: var(--bench-ink); }
.field { display: grid; gap: 6px; }
.field label, .field .lbl { font-size: 12px; font-weight: 700; }
.field label .opt { font-weight: 500; color: var(--bench-muted); }
.field input:disabled { opacity: .6; }
.field input, .field textarea, .field select { font: 500 14px/1.45 var(--ui); color: var(--bench-ink); background: var(--well); border: 1px solid transparent; border-radius: 10px; padding: 9px 11px; width: 100%; min-height: 42px; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); outline: none; }
.field textarea { min-height: 64px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; min-width: 0; }
.toggles { display: grid; gap: 4px; }
.tg { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: start; padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.tg:hover { background: var(--well); }
.tg span { font-size: 12.5px; line-height: 1.4; }
.tg.off span { color: var(--bench-muted); text-decoration: line-through; }
.tg .tag { font-style: normal; font-size: 9.5px; font-weight: 800; letter-spacing: .08em; color: #b45309; margin-right: 4px; }
.tg input { appearance: none; -webkit-appearance: none; width: 36px; height: 22px; border-radius: 22px; background: #b9c2cd; position: relative; cursor: pointer; margin: 0; flex: none; }
.tg input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--knob); transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.tg input:checked { background: var(--accent); }
.tg input:checked::after { transform: translateX(14px); background: #fff; }

/* ── Document tabs on top of the paper ──
   ONE row for the editor and the extras page (doc-tabs.js):
   Invoice · Quotation · Delivery · Receipt · [+] · Letter · Data sheet · Warranty · Packing list
   "+" hides / shows the last four in this same row (.x-open). On the extras
   page (.x-here) the open document's tab stays shown while the others hide. */
.doc-tabs { width: 210mm; max-width: 100%; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 3px; }
.doc-tabs button, .doc-tabs a { font: 700 13.5px var(--ui); color: var(--bench-muted); background: #dde3ea; border: 0; border-top: 3px solid transparent;
  border-radius: 10px 10px 0 0; padding: 9px 12px 10px; cursor: pointer; min-height: 42px; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }
.doc-tabs button:hover, .doc-tabs a:hover { color: var(--bench-ink); background: #e9edf2; }
.doc-tabs button[aria-pressed="true"] { background: var(--paper); color: var(--deep); border-top-color: var(--accent); box-shadow: 0 -4px 12px rgba(20,30,45,.06); }
.sheet-col .sheet { border-top-left-radius: 0; }
.more-tab { font: 800 18px/1 var(--ui) !important; color: var(--deep) !important; background: transparent !important; border: 1.5px dashed #9fb0c3 !important;
  border-bottom: 0 !important; border-radius: 10px 10px 0 0; padding: 9px 12px 10px !important; min-width: 40px; flex: none; }
.more-tab[aria-expanded="true"] { border-style: solid !important; }
.doc-tabs .x-group { display: contents; }
.doc-tabs:not(.x-open) .x-group > :not([aria-pressed="true"]) { display: none; }
.x-break { display: none; }
/* Open, the six extra tabs take their own line under the four sales tabs —
   on a computer too: eleven tabs do not fit one A4-wide row. */
.doc-tabs.x-open .x-break, .doc-tabs.x-here .x-break { display: block; flex-basis: 100%; height: 0; }

/* ── The sheet (screen) ── */
.sheet-col { min-width: 0; }
.sheet { background: var(--paper); color: var(--text); width: 210mm; max-width: 100%; min-height: 297mm; margin: 0 auto;
  padding: 8mm 10mm 6mm; display: flex; flex-direction: column; gap: 5mm; font-family: var(--doc); border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 18px 40px rgba(20,30,45,.14); }
.sheet.half { min-height: 148mm; }   /* half of A4: the slip can be cut off the sheet */
.sheet input, .sheet textarea, .sheet select { font-family: var(--doc); }
.plain { border: 0; background: transparent; padding: 0; color: inherit; font: inherit; width: 100%; min-width: 0; border-radius: 4px; }
.plain:hover { background: rgba(120,140,160,.08); }
.plain::placeholder { color: #a9b2bd; }
/* "Add." (address and / or email) wraps to a second line instead of running
   out of the box — on screen and in print, as the PDF does. */
textarea.plain.grow { resize: none; overflow: hidden; line-height: 1.35; field-sizing: content; min-height: 1.35em; max-height: 2.7em; display: block; }

.lh { display: flex; justify-content: space-between; align-items: flex-start; gap: 6mm; padding-bottom: 4mm; border-bottom: 2px solid var(--accent); }
.wordmark { font-family: var(--ui); font-weight: 900; font-size: 26px; letter-spacing: .04em; color: var(--accent); line-height: 1; }
.legal { font-size: 11.5px; color: var(--muted); margin-top: 1.6mm; line-height: 1.45; }
.lh-right { display: grid; justify-items: end; gap: 2mm; }
.lh-right img { height: 12mm; width: auto; }
.doc-title { margin: 0; font-family: var(--ui); font-weight: 800; font-size: 17px; letter-spacing: .1em; color: var(--deep); text-transform: uppercase; display: flex; align-items: center; gap: 2.5mm; text-align: right; }
.tag-rental { font: 800 9px var(--ui); letter-spacing: .14em; padding: 1mm 2.4mm; border-radius: 999px; border: 1.5px solid var(--rent); color: #92400e; }

.eyebrow { font: 800 8.5px var(--ui); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.to { display: grid; grid-template-columns: 1fr auto; gap: 6mm; align-items: start; }
.cust { display: grid; gap: .6mm; min-width: 0; }
.cust-head { display: flex; align-items: center; gap: 8px; }
.pick { font: 700 11px var(--ui); color: var(--deep); background: transparent; border: 1px solid var(--hair); border-radius: 999px; padding: 3px 9px; cursor: pointer; }
.pick:hover { border-color: var(--accent); }
.cust .name { font-weight: 700; font-size: 14px; color: var(--ink); }
.cust .line { font-size: 12px; color: var(--muted); display: grid; grid-template-columns: 11mm 1fr; align-items: baseline; }
.cust .line span { font-size: 11px; }
.rental-note { border-left: 2px solid var(--rent); padding: .5mm 0 .5mm 3mm; display: grid; gap: .6mm; min-width: 60mm; max-width: 80mm; }
.rental-note .name { font-weight: 700; font-size: 12.5px; color: var(--ink); }
.rental-note .lines { font-size: 11px; color: var(--muted); line-height: 1.45; }
/* The length of the hire leads (owner, 2026-10-14) — customers misread Qty x Rate/Day without it. */
.rental-note .big { font: 800 20px/1.1 var(--ui); color: var(--rent-ink, #92400e); letter-spacing: .01em; }
.rental-note .big.missing { font-size: 13px; color: var(--minus, #b91c1c); }
.items td.per, .items th.per { width: 16mm; }
.items td.per { font-weight: 800; color: var(--ink); }
.r-big input { font-size: 18px; font-weight: 800; }
.r-dates { margin-top: 10px; }
.r-dates summary { cursor: pointer; font-size: 12.5px; color: var(--muted); padding: 4px 0; }
.r-dates[open] summary { margin-bottom: 8px; }

.metabar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--hair); border-radius: var(--r); }
.metabar > div { padding: 2.4mm 3.5mm; display: grid; gap: .8mm; min-width: 0; }
.metabar > div + div { border-left: 1px solid var(--hair); }
.metabar .v { font-size: 13px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.metabar .v.no { font-weight: 800; color: var(--deep); }
.metabar select.v { appearance: none; -webkit-appearance: none; cursor: pointer; }
.date-btn { text-align: left; cursor: pointer; }
.date-input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }

/* Items */
.items-wrap { border: 1px solid var(--hair); border-radius: var(--r); overflow: hidden; }
.items { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.items th { background: var(--accent); color: #fff; font: 700 10.5px var(--ui); letter-spacing: .08em; text-transform: uppercase; padding: 2.6mm 2.5mm; text-align: left; }
.items th.n, .items td.n { text-align: right; }
.items th.c, .items td.c { text-align: center; }
.items td { padding: 2.2mm 2.5mm; border-top: 1px solid var(--hair-2); vertical-align: middle; font-size: 13px; color: var(--text); }
.items td.sno { width: 8mm; color: var(--muted); font-size: 12px; }
.items td.qty { width: 15mm; }
.items td.qty2 { width: 24mm; }
.items td.price { width: 27mm; }
.items td.amt { width: 29mm; font-weight: 700; color: var(--ink); }
.items td.x { width: 7mm; padding-left: 0; padding-right: 1.5mm; }
.items th.xh { width: 7mm; padding: 0; }
.model { display: block; font: 700 10.5px var(--doc); letter-spacing: .04em; color: var(--deep); text-transform: uppercase; padding-bottom: .5mm; }
/* An empty model shows as a faint "Model (optional)" line on screen, so it can
   be found on a phone too; it never prints (see @media print). */
.model:placeholder-shown { opacity: .55; }
.model::placeholder { font-weight: 600; letter-spacing: .02em; text-transform: none; }
.desc { display: block; font: 13px/1.35 var(--doc); resize: none; overflow: hidden; field-sizing: content; min-height: 1.35em; }
.num { text-align: inherit; font-variant-numeric: tabular-nums; }
.chip { display: inline-block; font: 800 11.5px var(--ui); padding: .7mm 2.2mm; border-radius: 999px; border: 1.5px solid var(--accent); color: var(--deep); cursor: text; }
.chip.neg { border-color: var(--minus); color: var(--minus); }
tr.pct td.price .num { position: absolute; opacity: 0; pointer-events: none; width: 1px; }
tr.pct td.price { position: relative; }
tr.pct td.price:focus-within .num { position: static; opacity: 1; pointer-events: auto; width: 100%; }
tr.pct td.price:focus-within .chip { display: none; }
tr.pct td.qty .num { visibility: hidden; }
td.amt.neg { color: var(--minus); }
.why { display: block; font-size: 10.5px; color: var(--muted); margin-top: .6mm; }
.rm { border: 0; background: transparent; color: #c0c8d2; cursor: pointer; font-size: 18px; line-height: 1; width: 26px; height: 26px; border-radius: 50%; }
.rm:hover { color: var(--minus); background: #fdeee6; }
.items tfoot td { border-top: 1px solid var(--hair); font-weight: 700; color: var(--ink); }
.items tfoot .lbl { font: 800 10.5px var(--ui); letter-spacing: .08em; text-transform: uppercase; color: var(--deep); text-align: right; }
.add { align-self: stretch; font: 700 12.5px var(--ui); color: var(--deep); background: transparent; border: 1px dashed var(--accent); border-radius: 999px; padding: 2mm 4mm; cursor: pointer; min-height: 38px; }

/* Totals: ONE rounded box — Subtotal and VAT on hairlines, G. Total filled
   across the foot of the same box. */
.sum { display: grid; grid-template-columns: 1fr 64mm; gap: 8mm; align-items: start; }
.words { font-size: 12px; line-height: 1.5; color: var(--text); padding-top: 1mm; }
.words i { color: var(--ink); }
.totals { border: 1px solid var(--hair); border-radius: 12px; overflow: hidden; font-variant-numeric: tabular-nums; }
.totals .r { display: flex; justify-content: space-between; align-items: baseline; gap: 4mm; padding: 2.3mm 4mm; font-size: 13px; }
.totals .r + .r { border-top: 1px solid var(--hair); }
.totals .r span { color: var(--text); }
.totals .r b { font-weight: 700; color: var(--ink); }
.totals .grand { background: var(--accent); border-top-color: var(--accent) !important; padding: 3mm 4mm; align-items: center; }
.totals .grand span { font: 800 11px var(--ui); letter-spacing: .1em; text-transform: uppercase; color: #fff; }
.totals .grand b { font: 800 17px var(--ui); color: #fff; }

/* Closing */
.closing { flex: 1 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto 1fr; column-gap: 8mm; row-gap: 4mm; }
.terms { grid-column: 1; grid-row: 1; font-size: 10.5px; line-height: 1.5; color: var(--text); display: grid; gap: 1.2mm; align-content: start; }
.terms ol { margin: 0; padding-left: 4mm; }
.terms .custom { border-left: 2px solid var(--accent); padding-left: 2.5mm; color: var(--ink); white-space: pre-wrap; }
.terms .custom:empty { display: none; }
.terms .link { color: var(--muted); }
.terms .link b { color: var(--deep); }
.bank { grid-column: 1; grid-row: 2; align-self: end; justify-self: start; border: 1px solid var(--hair); border-radius: var(--r); padding: 3mm 4mm; font-size: 11px; line-height: 1.55; color: var(--text); max-width: 100mm; }
.bank b { color: var(--ink); }
.receiver { grid-column: 1; grid-row: 2; align-self: end; justify-self: start; text-align: center; font-size: 11px; color: var(--muted); }
.receiver .box { width: 62mm; height: 20mm; border: 1.5px dashed #b5bec9; border-radius: var(--r); margin-bottom: 1.5mm; }
.stamp { grid-column: 2; grid-row: 1 / 3; align-self: end; text-align: center; font-size: 11px; color: var(--muted); }
.stamp img { height: 29mm; width: auto; display: block; margin: 0 auto 1mm; }
.foot { border-top: 1px solid var(--hair); padding-top: 2.6mm; display: flex; justify-content: space-between; gap: 4mm; align-items: baseline; font-size: 10.5px; color: var(--muted); }
.foot b { color: var(--deep); font-family: var(--ui); font-weight: 800; white-space: nowrap; }

/* Receipt: who paid and what for on the left; one rounded box on the right
   carries the amount and how it was paid, exactly as it prints. The method and
   cheque details are chosen in the dock's Payment card. */
.rc-grid { display: grid; grid-template-columns: 1fr 72mm; gap: 7mm; align-items: stretch; }
.rc-left { display: grid; gap: 3.2mm; align-content: start; }
.rc-line { display: grid; gap: 1mm; border-bottom: 1px solid var(--hair); padding-bottom: 2.6mm; }
.rc-line:last-child { border-bottom: 0; padding-bottom: 0; }
.rc-line .v { font-size: 13px; color: var(--ink); }
.rc-line .v.name { font-weight: 700; font-size: 14px; }
.rc-line .line { font-size: 12px; color: var(--muted); display: grid; grid-template-columns: 11mm 1fr; align-items: baseline; }
.rc-line .line span { font-size: 11px; }
.amount-box { border: 1px solid var(--hair); border-radius: 12px; overflow: hidden; display: grid; grid-template-rows: 1fr auto; }
.amt-top { padding: 4mm 4.5mm 3.5mm; display: grid; gap: 1.5mm; align-content: center; text-align: right; border-bottom: 2px solid var(--accent); }
.amount-box .big { display: flex; justify-content: flex-end; align-items: baseline; gap: 2mm; font: 800 26px var(--ui); color: var(--deep); font-variant-numeric: tabular-nums; }
.amount-box .big small { font-size: 12px; font-weight: 800; }
.amount-box input { font: inherit; color: inherit; text-align: right; width: 100%; min-width: 0; }
/* The field hugs its number so "AED" sits right beside it (Chrome/Edge). */
@supports (field-sizing: content) { .amount-box input { field-sizing: content; width: auto; min-width: 3ch; max-width: 100%; } }
.paid { padding: 2.6mm 4.5mm 3mm; display: grid; grid-template-columns: auto 1fr; column-gap: 3mm; row-gap: .6mm; align-items: baseline; text-align: right; }
.paid b { font: 800 12px var(--ui); letter-spacing: .08em; text-transform: uppercase; color: var(--deep); }
.paid .cq-out { grid-column: 1 / -1; font-size: 11.5px; line-height: 1.45; color: var(--text); white-space: pre-line; }
.paid .cq-out:empty { display: none; }
.rc-foot { display: flex; justify-content: space-between; align-items: flex-end; flex: 1 0 auto; gap: 6mm; }
.rc-foot .thanks { font-size: 12px; font-style: italic; color: var(--muted); }
.rc-foot .stamp img { height: 22mm; }

/* Dock: payment method, paper size, checks */
.methods { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.method { font: 700 12.5px var(--ui); border-radius: 999px; border: 1.5px solid var(--panel-line); padding: 8px 4px; color: var(--bench-muted); background: transparent; cursor: pointer; min-height: 38px; }
.method[aria-pressed="true"] { border-color: var(--accent); color: var(--deep); background: var(--panel); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.paper { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--bench-muted); }
.paper span { margin-right: auto; }
.paper button { font: 700 12px var(--ui); border: 1px solid var(--panel-line); background: transparent; color: var(--bench-muted); border-radius: 999px; padding: 5px 12px; cursor: pointer; min-height: 32px; }
.paper button[aria-pressed="true"] { border-color: var(--bench-ink); color: var(--bench-ink); }
.checks ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.checks li { display: grid; grid-template-columns: 20px 1fr; gap: 8px; align-items: start; font-size: 12.5px; line-height: 1.4; }
.checks li::before { content: ''; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font: 800 11px/18px var(--ui); text-align: center; }
.checks li.ok::before { content: '✓'; background: #e7f6ee; color: #137251; }
.checks li.warn::before { content: '!'; background: #fff4e0; color: #9a5b00; }
.checks li.error::before { content: '×'; background: #fdecea; color: #b42318; }
.checks li.error { color: #8f1d14; font-weight: 600; }
.checks li.todo::before { content: '•'; background: var(--well); color: var(--bench-muted); }
.checks li button { all: unset; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.checks.has-error { border-color: #f1b8b2; }
/* A row the checks point at (screen only). */
.items tbody tr.bad td { background: #fff6f5; }
.items tbody tr.bad td.sno { box-shadow: inset 3px 0 0 #d92d20; color: #b42318; font-weight: 700; }

/* ── Action buttons: PRINT + WhatsApp (never removed) ── */
.actions { position: fixed; right: 20px; bottom: 20px; z-index: 30; display: grid; gap: 10px; width: 130px; }
.actions button { height: 46px; border-radius: 10px; font: 800 14px var(--ui); letter-spacing: .02em; cursor: pointer; border: 0; box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.actions .wa { background: #25d366; color: #fff; }
.actions .print { background: var(--panel); color: var(--bench-ink); border: 1px solid var(--panel-line); }
.actions button:disabled { opacity: .6; cursor: progress; }

/* Customer picker */
.picker-back { position: fixed; inset: 0; background: rgba(10,15,20,.45); z-index: 40; display: grid; place-items: center; padding: 16px; }
.picker { background: var(--panel); color: var(--bench-ink); border-radius: 16px; width: min(520px, 100%); max-height: min(640px, 90vh); display: grid; grid-template-rows: auto auto 1fr; overflow: hidden; }
.picker header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 6px; }
.picker header h2 { margin: 0; font-size: 15px; }
.picker .search { padding: 6px 16px 10px; }
.picker .search input { width: 100%; font: 500 15px var(--ui); padding: 10px 12px; border-radius: 10px; border: 1px solid var(--panel-line); background: var(--well); color: var(--bench-ink); }
.picker ul { list-style: none; margin: 0; padding: 0 8px 10px; overflow: auto; }
.picker li button { width: 100%; text-align: left; border: 0; background: transparent; padding: 10px; border-radius: 10px; cursor: pointer; display: grid; gap: 2px; color: inherit; }
.picker li button:hover, .picker li button:focus-visible { background: var(--well); }
.picker li b { font-size: 14px; }
.open-kind { font: 800 9.5px var(--ui); letter-spacing: .1em; text-transform: uppercase; color: var(--deep); }
.picker li small { font-size: 12px; color: var(--bench-muted); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 60; background: var(--bench-ink); color: var(--bench); padding: 11px 16px; border-radius: 12px; font-size: 13.5px; font-weight: 600; max-width: min(520px, calc(100% - 32px)); box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.err { background: #b42318; color: #fff; }

/* ── Desktop: dock on the right, PRINT / WhatsApp pinned under it ──
   The buttons sit in the dock's column, below its cards, so they can never
   cover a field or a figure on the sheet or in the dock. */
@media screen and (min-width: 1180px) {
  .studio { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
  .dock { position: sticky; top: 12px; max-height: calc(100vh - 140px);   /* clears the topbar above and PRINT / WhatsApp below */ overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }
  .actions { right: calc(16px + max(0px, (100vw - 1260px) / 2)); bottom: 12px; width: 320px; grid-template-columns: 1fr 1fr; }
  .studio .dock { order: 2; }
}
/* ── Narrower screens: PRINT / WhatsApp in a bar along the bottom ── */
@media screen and (max-width: 1179px) {
  .studio { padding-bottom: calc(var(--actions-h) + 24px + env(safe-area-inset-bottom, 0px)); }
  .actions { left: 0; right: 0; bottom: 0; width: auto; grid-template-columns: minmax(0, 200px) minmax(0, 200px); justify-content: end; gap: 10px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); background: var(--panel); border-top: 1px solid var(--panel-line); box-shadow: 0 -4px 16px rgba(0,0,0,.08); }
  .actions button { box-shadow: none; }
  .toast { bottom: calc(var(--actions-h) + 20px + env(safe-area-inset-bottom, 0px)); }
}

/* ── Phone / narrow: fluid sheet, card rows, bottom action bar ──
   `screen` matters: an A4 print page is 794px wide, so without it this whole
   block applied to the printed sheet too. */
@media screen and (max-width: 820px) {
  .studio { padding-inline: 12px; padding-bottom: calc(var(--actions-h) + 24px + env(safe-area-inset-bottom, 0px)); gap: 12px; }
  /* Phone order: top bar, the document tabs + the document, then the
     checks, the Document card (Retail/Rental, Convert, paper), rental
     period, payment and notes — the same order as the extras page, so the
     tabs never jump when moving between the two. */
  .dock { display: contents; }
  .topbar { order: -3; }
  /* Phone top bar: the title on its own line, then the buttons as one even
     row (short labels) — they used to wrap raggedly under the title. */
  .topbar { gap: 8px; }
  .topbar h1 { flex: 1 1 auto; font-size: 17px; }
  .topbar .spacer { flex-basis: 100%; height: 0; }
  .topbar .linkbtn { flex: 1 1 0; min-width: 0; text-align: center; font-size: 13.5px; padding: 10px 6px; min-height: 42px; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }
  .topbar .wide { display: none; }
  #pct-tip { display: none; }   /* the % tip is a desktop hint; on a phone it pushed the paper down */
  .sheet-col { order: 0; }
  #checks-card { order: 1; }
  #doc-card { order: 2; }
  .dock .card:not(#doc-card):not(#checks-card) { order: 3; }
  .dock details.card > summary { list-style: none; cursor: pointer; }
  .sheet { width: 100%; min-height: 0; padding: 16px 14px; gap: 14px; border-radius: 12px; }
  /* Phone: Invoice · Quotation · Delivery · Receipt · + fill one row; the
     four + shows go on a second row under them, on the paper. */
  .doc-tabs { gap: 3px; }
  .doc-tabs button, .doc-tabs a { flex: 1 1 0; padding: 9px 2px 10px; font-size: 13px; min-width: 0; }
  .doc-tabs .more-tab { flex: none; min-width: 40px; padding: 9px 10px 10px !important; }
  .doc-tabs .x-group > * { flex: 1 1 30%; padding: 9px 4px 10px; font-size: 12.5px; }   /* six extras: two rows of three */
  .sheet-col .sheet { border-top-left-radius: 0; border-top-right-radius: 0; }
  .sheet.half { min-height: 0; }
  .wordmark { font-size: 21px; }
  .legal { font-size: 11px; }
  .lh-right img { height: 34px; }
  .doc-title { font-size: 14px; white-space: nowrap; flex-wrap: wrap; justify-content: flex-end; row-gap: 1.5mm; }
  .wordmark { white-space: nowrap; }
  .to { grid-template-columns: 1fr; gap: 10px; }
  .rental-note { max-width: none; }
  .metabar { grid-auto-flow: row; grid-template-columns: 1fr 1fr; }
  .metabar > div:nth-child(odd) { border-left: 0; }
  .metabar > div:nth-child(n+3) { border-top: 1px solid var(--hair); }
  .metabar .v, .plain { font-size: 16px; } /* 16px stops iOS zooming into a field */

  /* Items become cards. The words lead: model, then a large description,
     full width. Underneath, one slim line: Qty and Price as small inline
     boxes, the amount on the right. */
  .items thead { display: none; }
  .items, .items tbody, .items tr, .items td { display: block; width: auto !important; }
  .items tbody tr { display: grid; grid-template-columns: 20px 86px 116px minmax(0, 1fr) 26px; grid-template-areas:
      "sno desc desc desc x"
      "sno qty  price amt amt"; column-gap: 8px; row-gap: 8px; padding: 12px 10px 12px 8px; border-top: 1px solid var(--hair-2); }
  .items tbody tr:first-child { border-top: 0; }
  .items td { border: 0; padding: 0; }
  .items td.sno { grid-area: sno; padding-top: 3px; font-size: 12px; }
  .items td.item { grid-area: desc; min-width: 0; }
  .items td.qty, .items td.qty2:nth-of-type(3) { grid-area: qty; }
  .items td.price, .items td.qty2:nth-of-type(4) { grid-area: price; }
  .items td.amt { grid-area: amt; align-self: center; }
  .items td.x { grid-area: x; align-self: start; }
  .items tbody tr.rent { grid-template-areas:
      "sno desc desc desc x"
      "sno qty  price amt amt"
      "sno per  per   .   ."; }
  .items td.per { grid-area: per; display: flex; align-items: center; gap: 6px; background: var(--well); border-radius: 9px; padding: 0 9px; min-height: 32px; font-size: 16px; justify-self: start; }
  .model { font-size: 16px; letter-spacing: .03em; padding-bottom: 2px; }   /* 16px: iOS zooms into any smaller field */
  .desc { font-size: 17px; line-height: 1.35; color: var(--ink); }
  .items td.qty, .items td.qty2, .items td.price { display: flex; align-items: center; gap: 6px; background: var(--well); border-radius: 9px; padding: 0 9px; min-height: 36px; text-align: left; }
  .items td[data-label]::before { content: attr(data-label); flex: none; font: 800 8.5px var(--ui); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
  .items td .num { text-align: left; font-size: 16px; font-weight: 600; min-width: 0; }
  .items td.amt { text-align: right; font-size: 16px; }
  tr.pct td.qty { visibility: hidden; }
  .why { font-size: 11.5px; }
  .items tfoot, .items tfoot tr { display: block; }
  .items tfoot tr { display: flex; justify-content: space-between; gap: 10px; padding: 10px; }
  .items tfoot td { border: 0; padding: 0; }
  .items tfoot td:empty { display: none; }

  .sum { grid-template-columns: 1fr; gap: 12px; }
  .sum .words { order: 2; }
  .closing { grid-template-columns: 1fr; grid-template-rows: none; row-gap: 14px; }
  .terms, .bank, .receiver, .stamp { grid-column: 1; grid-row: auto; justify-self: stretch; }
  .bank { max-width: none; }
  .stamp { justify-self: end; }
  .stamp img { height: 80px; }
  .receiver .box { width: 100%; }
  .foot { flex-direction: column; gap: 4px; }
  .foot span { font-size: 10px; }
  .rc-grid { grid-template-columns: 1fr; }

  .actions { grid-template-columns: 1fr 1fr; padding-inline: 12px; }
}


@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ==========================================================================
   PRINT — strict A4, whatever the screen was. Same technique as the current
   editor's print sheet (styles.css, CONSOLIDATED PRINT STYLES): one @page with
   zero margin (keeps Chrome's own header/footer off), letterhead and footer
   position:fixed so they repeat on every page, and the sheet's padding cloned
   onto every page so content clears them.
   ========================================================================== */
@media print {
  @page { size: A4 portrait; margin: 0; }
  html, body { background: #fff !important; width: 210mm; }
  .studio { display: block; max-width: none; padding: 0; margin: 0; }
  .rental-note .big.missing,
  .topbar, .dock, .actions, .add, .rm, .pick, .toast, .picker-back, .gate, #akm-nav-root, .no-print, th.xh, td.x { display: none !important; }
  .sheet { width: 210mm !important; max-width: none; min-height: 296mm; margin: 0; border-radius: 0; box-shadow: none;
    padding: 44mm 10mm 20mm !important; gap: 4.5mm; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
  .sheet .lh { position: fixed; top: 8mm; left: 10mm; right: 10mm; background: #fff; }
  .sheet .foot { position: fixed; bottom: 5mm; left: 10mm; right: 10mm; background: #fff; }
  /* The receipt is a single half-A4 slip: nothing to repeat. */
  .sheet.half { min-height: 148mm; padding: 8mm 10mm 6mm !important; }
  .sheet.half .lh, .sheet.half .foot { position: static; }
  /* US Letter (the Paper switch in the dock; editor.js swaps the @page size). */
  html.paper-letter, html.paper-letter body { width: 215.9mm; }
  html.paper-letter .sheet { width: 215.9mm !important; }
  html.paper-letter .sheet:not(.half) { min-height: 278mm; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  .plain:hover { background: transparent; }
  *:focus, *:focus-visible { outline: none !important; }   /* a focused field must not print its ring */
  .plain::placeholder { color: transparent; }
  .model:placeholder-shown { display: none; }
  .cust .line.empty { display: none; }
  .items thead { display: table-header-group; }
  .items tr { break-inside: avoid; }
  .items tfoot { display: table-row-group; break-inside: avoid; }
  .items tfoot:empty { display: none; }
  /* The frame is cloned onto every page the table spans, so each page's part
     of the table is its own closed, rounded box (no open edges at a break). */
  .items-wrap { overflow: visible; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
  .items th:first-child { border-top-left-radius: calc(var(--r) - 1px); }
  .items th:nth-last-child(2) { border-top-right-radius: calc(var(--r) - 1px); }
  /* close the hairline seams a PDF viewer shows between filled header cells */
  .items th:not(:nth-last-child(-n+2)) { box-shadow: 1px 0 0 var(--accent); }
  .items td { padding-top: 1.7mm; padding-bottom: 1.7mm; }
  /* Totals may start a new page only as a whole; they never split. */
  .sum { break-inside: avoid; }
  .closing { break-inside: avoid; }
  tr.pct td.price .num { display: none; }
  /* A blank row never prints; a description's on-screen height (set by
     script for the screen width) is re-measured for the page. */
  .items tbody tr.blank { display: none; }
  .desc { height: auto !important; field-sizing: content; }
  .metabar select.v { appearance: none; -webkit-appearance: none; }
}

/* "Tap WhatsApp to send again" — the dashboard's WhatsApp button lands here (2026-10-14). */
@keyframes wa-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, .55); } 50% { box-shadow: 0 0 0 10px rgba(37, 211, 102, 0); } }
.actions .wa.pulse { animation: wa-pulse 1s ease-in-out 6; }
