/* CoffeeGX v2 · print.css — printable documents and the print pipeline.
 *
 * PIPELINE (core/print.js)
 *   1. Put the document markup in <div id="print-root"> — a direct child of <body>.
 *   2. Add ONE class to <html>: printing-slip58 | printing-slip80 | printing-a4 | printing-a6 |
 *      printing-label60x40 | printing-label100x60 | printing-labelsA4. It picks the @page size
 *      (named pages below) and the document width. print.js may add a longer @page for a roll.
 *   3. window.print(); on `afterprint` remove the class and empty #print-root.
 *   While #print-root has content, print media shows only it. With no job, Ctrl+P prints the page as
 *   it is, minus .no-print. #print-root is never visible on screen.
 *
 * DOCUMENTS (set lang and dir on the .doc: a document follows its country template, not the UI;
 * a missing dir is derived from lang). core/compliance.js renders slips, invoices, price lists and
 * tents with these classes; its DOC_CSS adds a few extras.
 *   .doc.doc-slip                 thermal slip, receipt, kitchen ticket or Z report; 80 mm by default,
 *                                 .doc-slip--58 for 58 mm rolls, .doc-slip--ticket for kitchen/bar tickets
 *   .doc.doc-a4                   invoice, proforma, credit note, statement, Z report (A4)
 *   .doc.doc-pricelist            A4 entrance price list (.doc-pricelist--compact: 3 columns, smaller)
 *   .doc.doc-tent                 A6 table tent: two .tent-face sections fold across the middle (the
 *                                 first, top half prints upside down); .doc-tent--single: one face
 *   .doc.doc-labels               bag labels: .doc-labels--60x40 | --100x60 (one label per page on a
 *                                 label printer) or --a4 holding .doc-sheet--60x40 | --100x60 | --70x37
 *                                 sheets (3×7, 2×4, 3×8 labels per A4 page; chunk the labels per sheet)
 *   [data-watermark="…"] on .doc, .doc-label, .doc-sheet or .tent-face prints a large diagonal word
 *   (the translated "Preview", "Void" or "Copy").
 *
 * SHARED PARTS (any document)
 *   .doc-head > .doc-logo, .doc-brand, .doc-meta, .doc-note, .doc-title (+ .doc-alt: a second-language
 *                        gloss on its own line; .doc-gloss: inline), .doc-stamp (VOID / COPY box)
 *                        On A4 the head has two columns: .doc-from (seller: logo, brand, meta lines)
 *                        and .doc-id (title + .doc-fields with number and dates), at the inline end.
 *   .doc-fields          <dl> of label/value pairs (date, number, table, staff…); a pair may sit in a <div>
 *   .doc-parties > .doc-party > .doc-party-label, .doc-party-name, p    (A4 seller/buyer blocks)
 *   .doc-lines           line table; td.num/th.num are end-aligned tabular; .doc-qty; .doc-mods
 *   .doc-summary         A4: tax table, .doc-legal and .doc-notes (.doc-section-title + .doc-note) beside
 *                        .doc-totals
 *   .doc-totals          <dl> of totals; .doc-grand on the grand-total dt and dd
 *   .doc-tax             tax breakdown table (rate, net, tax, gross)
 *   .doc-pay             <dl> of payments and change; .doc-sub on an indented pair (tendered, change)
 *   .doc-section-title, .doc-words ("Yalnız: …"), .doc-legal (<dl>: legal no., ETTN; an empty dd draws a
 *   fill-in line), .doc-note, .doc-strong, .doc-qr (<figure> with the QR <svg> + figcaption), .doc-foot
 *   (footer) with .doc-statement (legal texts), .doc-badge ("Made with CoffeeGX"), .doc-rule (<hr>)
 *   Slips separate their top-level sections with dashed rules automatically.
 *   Price list: .pricelist-cols > .pricelist-cat > .pricelist-cat-title + .pricelist-items >
 *     .pricelist-item > .pricelist-name (+ .pricelist-meta), .pricelist-dots, .pricelist-price;
 *     .pricelist-tax and .pricelist-date in .doc-foot. Tents reuse these inside .tent-face; a single face
 *     groups them in .tent-menu (.tent-menu--cols: two columns, from compliance.js).
 *   Labels: .doc-label > .label-brand, .label-name, .label-food, .label-notes, .label-facts
 *     (<dl> of <div><dt/><dd/></div>), .label-qr, .label-foot. No label text below 6.5pt (≈1.25 mm
 *     x-height; Türk Gıda Kodeksi asks for 1.2 mm on bags).
 *
 * PREVIEW: wrap any document in .doc-preview to show it on screen as paper, scaled down to fit.
 */

/* ------------------------------------------------------------------ the document base */

.doc {
  --doc-ink: var(--paper-ink);
  --doc-muted: var(--paper-muted);
  --doc-line: var(--paper-line);
  position: relative;
  box-sizing: border-box;
  background: var(--paper);
  color: var(--doc-ink);
  font-family: var(--font-doc);
  font-weight: 400;
  letter-spacing: 0;
  text-align: start;
  font-synthesis: none;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
/* A document's direction follows its own language, not the UI's: a Turkish slip printed from an Arabic
   UI stays left-to-right, an Arabic invoice from an English UI right-to-left. Templates should still set
   dir on the .doc; this catches the ones that forget. */
.doc:not(:lang(ar)) { direction: ltr; }
.doc:lang(ar) { direction: rtl; }
/* Tracking breaks Arabic joining (PRD §7.2): never in an Arabic document or run. */
.doc:lang(ar), .doc :lang(ar), :lang(ar)[data-watermark]::after { letter-spacing: 0 !important; }

/* Zero specificity: they only undo browser defaults (h1 2em bold, list indents…), so every class rule
   here and in compliance.js's DOC_CSS wins over them. base.css keeps its element styles out of .doc. */
:where(.doc) :where(h1, h2, h3, h4, p, dl, dt, dd, figure, figcaption, table, ul, ol, li) { font: inherit; letter-spacing: inherit; }
:where(.doc) :where(ul, ol) { margin: 0; padding: 0; list-style: none; }
:where(.doc) :where(th) { font-weight: 600; }
:where(.doc) :where(img, svg) { max-inline-size: 100%; }
:where(.doc) :where(a) { color: inherit; text-decoration-line: none; }
:where(.doc) :where(.mono) { font-size: 0.92em; }

.doc-alt { display: block; font-size: 0.82em; font-weight: 400; letter-spacing: 0; }
/* A gloss in the other script keeps its own order at its edges ("Invoice no." keeps its period at the
   end under an Arabic label) while it lines up with its parent like any other line: invisible
   left-to-right / right-to-left marks around it, no change of direction. */
:is(.doc-alt, .doc-gloss):not(:lang(ar))::before, :is(.doc-alt, .doc-gloss):not(:lang(ar))::after { content: "\200E"; }
:is(.doc-alt, .doc-gloss):lang(ar)::before, :is(.doc-alt, .doc-gloss):lang(ar)::after { content: "\200F"; }
.doc-rule { border: 0; border-block-start: 1px solid var(--doc-line); }
/* base.css styles h2 for the UI (18px); inside a document the title keeps the document size. */
.doc-section-title { margin-block-end: 1mm; font-size: 1em; font-weight: 600; line-height: 1.3; }
.doc-note { white-space: pre-line; }
.doc-words { color: var(--doc-muted); font-size: 0.92em; }
.doc-strong { font-weight: 600; }
.doc-statement { font-weight: 600; }

/* Label/value lists. compliance.js wraps each pair in a <div>; display: contents keeps the grid. */
:is(.doc-fields, .doc-totals, .doc-pay, .doc-legal) > div { display: contents; }
.doc-fields { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.6mm 3mm; }
.doc-fields dt { color: var(--doc-muted); }
.doc-fields dd { text-align: end; overflow-wrap: anywhere; }

.doc-lines { inline-size: 100%; border-collapse: separate; border-spacing: 0; }
.doc-lines :is(th, td) { padding: 0; vertical-align: top; text-align: start; }
.doc-lines :is(th, td).num { text-align: end; white-space: nowrap; }
.doc-lines :is(th, td) + :is(th, td) { padding-inline-start: 2.5mm; }
.doc-lines tr { break-inside: avoid; }
.doc-lines thead { display: table-header-group; }
.doc-qty { inline-size: 1%; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-mods { display: block; font-size: 0.86em; color: var(--doc-muted); }

/* No column gap: a rule on the grand-total row runs unbroken across label and amount. */
.doc-totals, .doc-pay { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.5mm 0; align-items: baseline; }
.doc-totals dd, .doc-pay dd { padding-inline-start: 4mm; text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-totals .doc-grand { font-weight: 600; }
.doc-sub { padding-inline-start: 3mm; font-size: 0.92em; }
:is(.doc-totals, .doc-pay) dd.doc-sub { padding-inline-start: 4mm; }

.doc-tax { inline-size: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.86em; }
.doc-tax :is(th, td) { padding: 0.4mm 0; text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-tax :is(th, td):first-child { text-align: start; white-space: normal; }
.doc-tax th { font-weight: 600; }
.doc-tax :is(th, td) + :is(th, td) { padding-inline-start: 2mm; }

.doc-legal { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1.5mm 4mm; align-items: end; }
.doc-legal dt { color: var(--doc-muted); }
.doc-legal dd { overflow-wrap: anywhere; }
.doc-legal dd:empty { block-size: 4.5mm; border-block-end: 1px solid var(--doc-ink); max-inline-size: 80mm; }

.doc-qr { display: grid; justify-items: center; gap: 1mm; text-align: center; }
.doc-qr svg { display: block; inline-size: var(--qr-size, 30mm); block-size: var(--qr-size, 30mm); color: var(--paper-ink); }
.doc-qr figcaption { font-size: 0.86em; }

.doc-foot { font-size: 0.86em; }
.doc-foot > * + * { margin-block-start: 1mm; }
.doc-badge { display: flex; align-items: center; justify-content: center; gap: 1mm; font-size: 0.8em; }
.doc-badge svg { inline-size: 1.2em; block-size: 1.2em; }
/* Free price lists and tents carry a 7pt "Made with CoffeeGX" line (PRD §7.10). */
:is(.doc-pricelist, .doc-tent) .doc-badge { font-size: 7pt; }

/* VOID / REFUNDED / COPY box (compliance.js); 600, never 700. */
.doc-stamp {
  justify-self: center;
  inline-size: max-content;
  max-inline-size: 100%;
  margin: 1mm auto 0;
  padding: 0.6mm 3mm;
  border: 1.5px solid currentColor;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-align: center;
}
.doc-slip .doc-stamp { font-weight: 600; }

/* Watermark: data-watermark holds the translated word ("Preview", "Önizleme", "İptal"…). */
:is(.doc, .doc-label, .doc-sheet, .tent-face)[data-watermark] { position: relative; }
:is(.doc, .doc-label, .doc-sheet, .tent-face)[data-watermark]::after {
  content: attr(data-watermark);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--paper-watermark);
  font: 600 var(--wm-size, 64pt)/1 var(--font-doc);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  transform: rotate(-24deg);
  pointer-events: none;
}
.doc-slip[data-watermark] { --wm-size: 28pt; }
.doc-label[data-watermark] { --wm-size: 14pt; }
:is(.doc-tent, .tent-face)[data-watermark] { --wm-size: 30pt; }

/* ------------------------------------------------------------------ slip (58/80 mm thermal) */

/* 72 mm printed on 80 mm rolls, 48 mm on 58 mm rolls. Pure black, weight 500 and dashed rules:
   a 203 dpi head drops grey and loses 400-weight hairlines. */
.doc-slip {
  --doc-muted: var(--paper-ink);
  --doc-line: var(--paper-ink);
  inline-size: 80mm;
  padding: 3mm 4mm 7mm;
  font-size: 9pt;
  line-height: 1.35;
  font-weight: 500;
}
.doc-slip--58 { inline-size: 58mm; padding-inline: 5mm; font-size: 8pt; }
.doc-slip > * + :not(.doc-badge, .doc-rule) { margin-block-start: 2.2mm; padding-block-start: 2.2mm; border-block-start: 1px dashed var(--doc-line); }
.doc-slip > .doc-rule { block-size: 0; border-block-start: 1px dashed var(--doc-line); }
.doc-slip > .doc-rule + * { border-block-start: 0; }
.doc-slip .doc-head { display: grid; justify-items: center; gap: 0.6mm; text-align: center; }
.doc-slip .doc-logo { max-block-size: 14mm; max-inline-size: 40mm; margin-block-end: 1mm; object-fit: contain; filter: grayscale(1) contrast(1.4); }
.doc-slip .doc-brand { font-size: 1.35em; font-weight: 600; line-height: 1.2; }
.doc-slip :is(.doc-meta, .doc-head .doc-note) { font-size: 0.86em; }
.doc-slip .doc-title { margin-block-start: 1.6mm; font-size: 1.12em; font-weight: 600; letter-spacing: 0.06em; }
.doc-slip .doc-title .doc-alt { letter-spacing: 0; }
.doc-slip .doc-lines td { padding-block: 0.5mm; }
.doc-slip .doc-lines thead th { padding-block-end: 0.8mm; font-size: 0.86em; }
.doc-slip .doc-qty { padding-inline-end: 0.5mm; }
.doc-slip .doc-mods { font-weight: 400; }
.doc-slip .doc-totals .doc-grand { margin-block-start: 0.8mm; font-size: 1.2em; line-height: 1.3; }
.doc-slip .doc-totals dd.doc-grand { font-size: 1.5em; line-height: 1.2; }
.doc-slip .doc-qr { --qr-size: 30mm; }
.doc-slip--58 .doc-qr { --qr-size: 26mm; }
.doc-slip .doc-foot { text-align: center; font-weight: 400; }
.doc-slip .doc-foot .doc-note { font-weight: 500; }
.doc-slip .doc-badge { margin-block-start: 2.2mm; font-weight: 400; }

/* Kitchen/bar ticket: no prices, big table number, items readable at arm's length. */
.doc-slip--ticket { font-size: 11pt; }
.doc-slip--ticket .doc-title { font-size: 1.9em; letter-spacing: 0; }
.doc-slip--ticket .doc-lines td { padding-block: 1mm; font-weight: 600; }
.doc-slip--ticket .doc-mods { font-weight: 500; }

/* ------------------------------------------------------------------ A4 document (invoice, proforma) */

.doc-a4 {
  display: flex;
  flex-direction: column;
  gap: 7mm;
  inline-size: 210mm;
  min-block-size: 297mm;
  padding: 16mm 16mm 14mm;
  font-size: 9.5pt;
  line-height: 1.45;
}
.doc-a4 .doc-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6mm 10mm; align-items: start; }
.doc-a4 .doc-from { display: grid; gap: 0.8mm; align-content: start; }
.doc-a4 .doc-logo { max-block-size: 16mm; max-inline-size: 50mm; margin-block-end: 2mm; object-fit: contain; }
.doc-a4 .doc-brand { font-size: 12.5pt; font-weight: 600; line-height: 1.3; }
.doc-a4 .doc-meta { color: var(--doc-muted); font-size: 8.5pt; }
.doc-a4 .doc-id { display: grid; justify-items: end; gap: 3mm; text-align: end; }
.doc-a4 .doc-title { font: 600 18pt/1.15 var(--font-display); letter-spacing: -0.02em; }
.doc-a4 .doc-title:lang(ar) { font-family: var(--font-doc); line-height: 1.4; }
.doc-a4 .doc-title .doc-alt { margin-block-start: 1mm; color: var(--doc-muted); font: 500 9pt/1.3 var(--font-doc); letter-spacing: 0; }
.doc-a4 .doc-id .doc-fields { gap: 0.8mm 5mm; text-align: start; }

.doc-parties {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(60mm, 1fr));
  gap: 5mm 12mm;
  padding-block: 5mm;
  border-block: 1px solid var(--doc-line);
}
.doc-party { display: grid; gap: 0.6mm; align-content: start; }
.doc-party-label { margin-block-end: 1mm; color: var(--doc-muted); font: 500 7.5pt/1.3 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; }
.doc-party-label:lang(ar) { font-family: var(--font-doc); font-weight: 600; text-transform: none; }
.doc-party-name { font-size: 10.5pt; font-weight: 600; }
.doc-party p:not(.doc-party-label, .doc-party-name) { color: var(--doc-muted); }

.doc-a4 .doc-lines thead th { padding-block-end: 2mm; border-block-end: 1px solid var(--doc-ink); color: var(--doc-muted); font-size: 8pt; font-weight: 500; vertical-align: bottom; }
.doc-a4 .doc-lines td { padding-block: 2.2mm; border-block-end: 1px solid var(--doc-line); }
.doc-a4 .doc-lines td:first-child { font-weight: 500; }

.doc-summary { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(86mm, 1fr); gap: 6mm 12mm; align-items: start; }
.doc-summary > :only-child { grid-column: 2; }
.doc-summary > div { display: grid; gap: 3mm; align-content: start; }
.doc-a4 .doc-totals { row-gap: 1.2mm; }
.doc-a4 .doc-totals .doc-grand { margin-block-start: 1.5mm; padding-block-start: 2.5mm; font-size: 11pt; }
.doc-a4 .doc-totals dd.doc-grand { font-size: 14pt; }
/* One rule across label and amount (their boxes sit at different heights: baseline alignment). */
.doc-totals { position: relative; }
.doc-a4 .doc-totals dt.doc-grand::before { content: ""; position: absolute; inset-inline: 0; margin-block-start: -2.5mm; border-block-start: 1px solid var(--doc-ink); }
.doc-a4 .doc-tax { font-size: 8pt; }
.doc-a4 .doc-tax th { padding-block-end: 1mm; border-block-end: 1px solid var(--doc-line); color: var(--doc-muted); font-weight: 500; }
.doc-a4 .doc-notes { display: grid; gap: 0.5mm; }
.doc-a4 .doc-notes .doc-note { color: var(--doc-muted); }

.doc-a4 .doc-foot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1mm 8mm;
  align-items: end;
  margin-block-start: auto;
  padding-block-start: 4mm;
  border-block-start: 1px solid var(--doc-line);
  color: var(--doc-muted);
  font-size: 7.5pt;
}
.doc-a4 .doc-foot > * { grid-column: 1; }
.doc-a4 .doc-foot > * + * { margin-block-start: 0; }
.doc-a4 .doc-foot .doc-qr { --qr-size: 26mm; grid-column: 2; grid-row: 1 / span 4; align-self: end; color: var(--doc-ink); }
.doc-a4 .doc-statement { font-weight: 500; }
.doc-a4 .doc-badge { justify-content: flex-start; }
.doc-a4[data-watermark] { --wm-size: 72pt; }

/* ------------------------------------------------------------------ A4 price list (entrance poster) */

.doc-pricelist {
  display: flex;
  flex-direction: column;
  gap: 9mm;
  inline-size: 210mm;
  min-block-size: 297mm;
  padding: 18mm 18mm 14mm;
  font-size: 12pt;
  line-height: 1.3;
}
.doc-pricelist .doc-head { display: grid; justify-items: center; gap: 2.5mm; text-align: center; }
.doc-pricelist .doc-logo { max-block-size: 22mm; max-inline-size: 60mm; object-fit: contain; }
.doc-pricelist .doc-brand { font: 600 30pt/1.1 var(--font-display); letter-spacing: -0.03em; }
.doc-pricelist .doc-brand:lang(ar) { font-family: var(--font-doc); line-height: 1.4; }
.doc-pricelist .doc-title { font: 500 10pt/1.3 var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; }
.doc-pricelist .doc-title:lang(ar) { font-family: var(--font-doc); font-weight: 600; text-transform: none; }
.pricelist-cols { flex: 1 0 auto; columns: 2 72mm; column-gap: 16mm; }
.pricelist-cat { break-inside: avoid; margin-block-end: 8mm; }
.pricelist-cat-title {
  margin-block-end: 2.5mm;
  padding-block-end: 2mm;
  border-block-end: 1.5px solid var(--doc-ink);
  font-size: 11pt;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  break-after: avoid;
}
.pricelist-cat-title:lang(ar) { text-transform: none; }
.pricelist-items { margin: 0; padding: 0; list-style: none; }
.pricelist-item { display: flex; align-items: baseline; gap: 2mm; padding-block: 1.6mm; break-inside: avoid; }
.pricelist-name { min-inline-size: 0; font-size: 13pt; font-weight: 500; }
.pricelist-meta { display: block; margin-block-start: 0.4mm; color: var(--doc-muted); font-size: 8.5pt; font-weight: 400; }
.pricelist-dots { flex: 1 1 4mm; min-inline-size: 4mm; align-self: baseline; border-block-end: 1.2px dotted var(--doc-muted); translate: 0 -0.25em; }
.pricelist-price { font-size: 14pt; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-pricelist .doc-foot { display: grid; justify-items: center; gap: 1mm; padding-block-start: 5mm; border-block-start: 1px solid var(--doc-line); text-align: center; font-size: 10pt; }
.doc-pricelist .doc-foot > * + * { margin-block-start: 0; }
.pricelist-tax { font-weight: 600; }
.pricelist-date { color: var(--doc-muted); }
.doc-pricelist--compact { gap: 6mm; padding: 14mm 14mm 12mm; font-size: 10pt; }
.doc-pricelist--compact .doc-brand { font-size: 24pt; }
.doc-pricelist--compact .pricelist-cols { columns: 3 52mm; column-gap: 10mm; }
.doc-pricelist--compact .pricelist-cat { margin-block-end: 6mm; }
.doc-pricelist--compact .pricelist-name { font-size: 10.5pt; }
.doc-pricelist--compact .pricelist-price { font-size: 11pt; }
.doc-pricelist--compact .pricelist-item { padding-block: 1mm; }

/* ------------------------------------------------------------------ A6 table tent */

/* An A6 card (105×148 mm) folded across the middle: two 105×74 mm faces, the first (top half) upside
   down so both sides read upright once folded. The faint dashed line is the fold guide.
   .doc-tent--single is one face for an acrylic stand. */
.doc-tent {
  display: grid;
  grid-template-rows: 1fr 1fr;
  inline-size: 105mm;
  block-size: 148mm;
  overflow: hidden;
  font-size: 10pt;
  line-height: 1.3;
}
.doc-tent::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  inset-block-start: 50%;
  border-block-start: 0.25mm dashed var(--paper-line);
}
.tent-face { display: flex; flex-direction: column; gap: 2.5mm; min-block-size: 0; padding: 7mm 8mm 6mm; overflow: hidden; text-align: center; }
.doc-tent:not(.doc-tent--single) > .tent-face:first-child:not(:only-child) { transform: rotate(180deg); }
.doc-tent .doc-head { display: grid; justify-items: center; gap: 1mm; }
.doc-tent .doc-logo { max-block-size: 12mm; max-inline-size: 40mm; object-fit: contain; }
.doc-tent .doc-brand { font: 600 16pt/1.15 var(--font-doc); letter-spacing: -0.01em; }
.doc-tent .doc-brand:lang(ar) { font-family: var(--font-doc); line-height: 1.4; }
.doc-tent .doc-title { font: 500 7.5pt/1.3 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; }
.doc-tent .doc-title:lang(ar) { font-family: var(--font-doc); font-weight: 600; text-transform: none; }
.doc-tent .pricelist-items { flex: 1 1 auto; min-block-size: 0; text-align: start; }
.doc-tent .pricelist-item { padding-block: 0.8mm; }
.doc-tent .pricelist-name { font-size: 10.5pt; }
.doc-tent .pricelist-price { font-size: 11pt; }
.doc-tent .doc-qr { --qr-size: 26mm; flex: 1 1 auto; align-content: center; }
.doc-tent .doc-foot { display: grid; gap: 0.4mm; font-size: 7pt; }
.doc-tent .doc-foot > * + * { margin-block-start: 0; }
/* Single face: a denser one-column menu; a long one grows onto a second card instead of clipping. */
.doc-tent--single { grid-template-rows: auto; block-size: auto; min-block-size: 148mm; overflow: visible; }
.doc-tent--single::before { display: none; }
.doc-tent--single .tent-face { gap: 2.5mm; padding: 6mm 8mm 5mm; overflow: visible; }
.doc-tent--single .tent-menu { min-block-size: auto; text-align: start; }
.doc-tent--single .doc-brand { font-size: 14pt; }
.doc-tent--single .pricelist-cat { margin-block-end: 2mm; }
.doc-tent--single .pricelist-cat-title { margin-block-end: 1mm; padding-block-end: 0.8mm; border-block-end-width: 1px; font-size: 7.5pt; }
.doc-tent--single .pricelist-item { padding-block: 0.2mm; }
.doc-tent--single .pricelist-name { font-size: 9pt; }
.doc-tent--single .pricelist-price { font-size: 9.5pt; }
.doc-tent--single .pricelist-meta { margin-block-start: 0; font-size: 6.5pt; line-height: 1.1; }
.doc-tent--single .tent-menu--cols { columns: 2 40mm; column-gap: 5mm; }
.doc-tent--single .tent-menu--cols :is(.pricelist-name, .pricelist-price) { font-size: 8.5pt; }

/* ------------------------------------------------------------------ labels */

.doc.doc-labels { display: flex; flex-wrap: wrap; gap: 4mm; background: none; }
.doc-labels--60x40 { --label-w: 60mm; --label-h: 40mm; }
.doc-labels--100x60 { --label-w: 100mm; --label-h: 60mm; }
.doc-label {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto 1fr auto;
  column-gap: 2.5mm;
  inline-size: var(--label-w, 60mm);
  block-size: var(--label-h, 40mm);
  padding: 2.4mm 3mm;
  overflow: hidden;
  background: var(--paper);
  color: var(--paper-ink);
  font-size: 7pt;
  line-height: 1.22;
  font-weight: 500;
  break-inside: avoid;
}
.doc-label > :not(.label-qr) { grid-column: 1; min-inline-size: 0; }
.label-brand { font: 500 6.5pt/1.25 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; }
.label-brand:lang(ar) { font-family: var(--font-doc); font-weight: 600; text-transform: none; }
.label-name { margin-block-start: 0.5mm; font: 600 11pt/1.1 var(--font-doc); letter-spacing: -0.01em; overflow-wrap: anywhere; }
.label-name:lang(ar) { line-height: 1.35; }
.label-food { font-size: 6.5pt; }
.label-notes { margin-block-start: 0.6mm; font-size: 7pt; font-weight: 400; }
/* Facts stack label over value; codes and dates keep plain digits (tnum widens the hyphen in R-0412). */
.label-facts { display: grid; grid-template-columns: repeat(var(--facts-cols, 2), minmax(0, max-content)); gap: 0.6mm 3.5mm; align-content: end; margin-block-start: 1mm; }
.label-facts > div { display: grid; min-inline-size: 0; }
.label-facts dt { font-size: 6.5pt; font-weight: 400; line-height: 1.15; }
.label-facts dd { font-size: 7.5pt; font-weight: 600; line-height: 1.2; white-space: nowrap; }
.label-foot { align-self: end; margin-block-start: 0.8mm; font-size: 6.5pt; font-weight: 400; line-height: 1.2; }
.label-qr { grid-column: 2; grid-row: 1 / -1; align-self: center; inline-size: var(--label-qr, 19mm); }
.label-qr svg { display: block; inline-size: 100%; block-size: auto; aspect-ratio: 1; color: var(--paper-ink); }
.label-qr figcaption { margin-block-start: 0.3mm; font-size: 6.5pt; text-align: center; }

.doc-labels--100x60 .doc-label, .doc-sheet--100x60 .doc-label { --label-qr: 28mm; padding: 4mm 4.5mm; column-gap: 4mm; font-size: 8pt; }
.doc-labels--100x60 .label-name, .doc-sheet--100x60 .label-name { font-size: 16pt; }
.doc-labels--100x60 .label-brand, .doc-sheet--100x60 .label-brand { font-size: 7.5pt; }
.doc-labels--100x60 .label-food, .doc-sheet--100x60 .label-food { font-size: 7.5pt; }
.doc-labels--100x60 .label-notes, .doc-sheet--100x60 .label-notes { font-size: 8.5pt; }
.doc-labels--100x60 .label-facts, .doc-sheet--100x60 .label-facts { --facts-cols: 3; gap: 1mm 5mm; }
.doc-labels--100x60 .label-facts dt, .doc-sheet--100x60 .label-facts dt { font-size: 7pt; }
.doc-labels--100x60 .label-facts dd, .doc-sheet--100x60 .label-facts dd { font-size: 9pt; }
.doc-labels--100x60 .label-foot, .doc-sheet--100x60 .label-foot { font-size: 7pt; }

/* A4 sheets: one .doc-sheet per page; the grid sits where a full sheet of the stock sits (centred),
   and a partial last sheet fills positions from the top, like the physical stock it is printed on.
   Tune --cols, --rows, --label-w/-h, --gap-x/-y or --sheet-top (inline style) for another stock. */
.doc.doc-labels--a4 { flex-direction: column; align-items: center; gap: 8mm; }
.doc-sheet {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), var(--label-w, 60mm));
  grid-auto-rows: var(--label-h, 40mm);
  gap: var(--gap-y, 0mm) var(--gap-x, 0mm);
  justify-content: center;
  align-content: start;
  inline-size: 210mm;
  block-size: 297mm;
  padding-block-start: var(--sheet-top, calc((297mm - var(--rows, 7) * var(--label-h, 40mm) - (var(--rows, 7) - 1) * var(--gap-y, 0mm)) / 2));
  overflow: hidden;
  background: var(--paper);
  break-after: page;
}
.doc-sheet--60x40 { --cols: 3; --rows: 7; --label-w: 60mm; --label-h: 40mm; --gap-x: 5mm; }
.doc-sheet--100x60 { --cols: 2; --rows: 4; --label-w: 100mm; --label-h: 60mm; --gap-x: 4mm; --gap-y: 6mm; }
.doc-sheet--70x37 { --cols: 3; --rows: 8; --label-w: 70mm; --label-h: 37mm; }
.doc-sheet--70x37 .doc-label { --label-qr: 18mm; padding: 2.2mm 3mm; }

/* ------------------------------------------------------------------ on-screen preview (paper look) */

.doc-preview {
  container: doc-preview / inline-size;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: var(--s-6);
  padding: var(--s-6) var(--s-4);
  overflow: auto;
  border-radius: var(--r-lg);
  background: var(--paper-desk);
}
.doc-preview .doc { box-shadow: var(--paper-shadow); border-radius: 2px; }
.doc-preview .doc.doc-labels { justify-content: center; box-shadow: none; border-radius: 0; }
.doc-preview .doc-label { box-shadow: var(--paper-shadow); border-radius: 1.5mm; }
.doc-preview .doc-sheet { box-shadow: var(--paper-shadow); border-radius: 2px; }
.doc-preview .doc-sheet .doc-label { box-shadow: inset 0 0 0 0.25mm var(--paper-line); border-radius: 1.5mm; }

/* Step the paper down so it always fits the preview (A4 is 794px wide at 100%). */
@container doc-preview (width < 826px) { :is(.doc-a4, .doc-pricelist, .doc-sheet) { zoom: 0.9; } }
@container doc-preview (width < 746px) { :is(.doc-a4, .doc-pricelist, .doc-sheet) { zoom: 0.8; } }
@container doc-preview (width < 667px) { :is(.doc-a4, .doc-pricelist, .doc-sheet) { zoom: 0.7; } }
@container doc-preview (width < 588px) { :is(.doc-a4, .doc-pricelist, .doc-sheet) { zoom: 0.6; } }
@container doc-preview (width < 508px) { :is(.doc-a4, .doc-pricelist, .doc-sheet) { zoom: 0.5; } }
@container doc-preview (width < 429px) { :is(.doc-a4, .doc-pricelist, .doc-sheet) { zoom: 0.45; } .doc-tent { zoom: 0.9; } }
@container doc-preview (width < 410px) { .doc-labels--100x60 .doc-label { zoom: 0.9; } }
@container doc-preview (width < 389px) { :is(.doc-a4, .doc-pricelist, .doc-sheet) { zoom: 0.4; } .doc-tent { zoom: 0.8; } }
@container doc-preview (width < 372px) { .doc-labels--100x60 .doc-label { zoom: 0.8; } }
@container doc-preview (width < 350px) { :is(.doc-a4, .doc-pricelist, .doc-sheet) { zoom: 0.35; } .doc-tent { zoom: 0.7; } }
@container doc-preview (width < 334px) { .doc-slip:not(.doc-slip--58) { zoom: 0.9; } .doc-labels--100x60 .doc-label { zoom: 0.7; } }
@container doc-preview (width < 310px) { :is(.doc-a4, .doc-pricelist, .doc-sheet) { zoom: 0.3; } .doc-tent { zoom: 0.6; } .doc-slip:not(.doc-slip--58) { zoom: 0.8; } }

/* ------------------------------------------------------------------ paper widths per job */

/* Not print-only: print.js measures a roll's length off screen in a .print-measure.printing-slip58 box
   and renders html2pdf files in a .print-pdf.printing-<kind> box, so those need the same widths. */
.printing-slip58 .doc-slip { inline-size: 58mm; padding-inline: 5mm; font-size: 8pt; }
.printing-slip80 .doc-slip { inline-size: 80mm; padding-inline: 4mm; font-size: 9pt; }
:is(.printing-slip58, .printing-slip80) .doc-slip--ticket { font-size: 11pt; }
/* html2pdf adds the page margins itself and lays out at the text-block width. */
.print-pdf :is(.doc-a4, .doc-pricelist) { inline-size: auto; min-block-size: 0; padding: 0; }
.print-pdf .doc { box-shadow: none; border-radius: 0; }
.print-pdf:is(.printing-label60x40, .printing-label100x60) .doc-label { break-after: page; }

/* ------------------------------------------------------------------ screen vs print */

@media screen {
  #print-root, .print-only { display: none !important; }
}

@page { margin: 10mm; }
@page cgx-slip58 { size: 58mm 297mm; margin: 0; }
@page cgx-slip80 { size: 80mm 297mm; margin: 0; }
@page cgx-a4 { size: 210mm 297mm; margin: 16mm 16mm 14mm; }
@page cgx-a6 { size: 105mm 148mm; margin: 0; }
@page cgx-label60x40 { size: 60mm 40mm; margin: 0; }
@page cgx-label100x60 { size: 100mm 60mm; margin: 0; }
@page cgx-labelsA4 { size: 210mm 297mm; margin: 0; }

@media print {
  .no-print { display: none !important; }

  /* Ctrl+P on a page without a job (a report, a list): print the content, not the app frame. */
  :is(.shell-sidebar, .shell-topbar, .shell-tabbar, .shell-banners, .shell-skip, .shell-scrim, .shell-palette, .shell-tip, .toasts) { display: none !important; }
  .shell { display: block !important; min-block-size: 0 !important; block-size: auto !important; overflow: visible !important; }
  .shell-column, .shell-content, .shell-view { display: block !important; block-size: auto !important; overflow: visible !important; }
  .shell .shell-view { max-inline-size: none !important; margin: 0 !important; padding: 0 !important; }

  /* A print job is active when #print-root has content (or print.js set a printing-* class). */
  html:has(> body > #print-root > *),
  html:is(.printing-slip58, .printing-slip80, .printing-a4, .printing-a6, .printing-label60x40, .printing-label100x60, .printing-labelsA4) {
    background: var(--paper) !important;
  }
  html:has(> body > #print-root > *) > body,
  html:is(.printing-slip58, .printing-slip80, .printing-a4, .printing-a6, .printing-label60x40, .printing-label100x60, .printing-labelsA4) > body {
    display: block !important;
    block-size: auto !important;
    min-block-size: 0 !important;
    max-block-size: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: var(--paper) !important;
  }
  html:has(> body > #print-root > *) > body > :not(#print-root),
  html:is(.printing-slip58, .printing-slip80, .printing-a4, .printing-a6, .printing-label60x40, .printing-label100x60, .printing-labelsA4) > body > :not(#print-root) {
    display: none !important;
  }
  #print-root { display: block !important; position: static !important; margin: 0; padding: 0; }
  #print-root .doc { margin: 0; box-shadow: none; border-radius: 0; zoom: 1; }
  #print-root > * + * { break-before: page; }

  /* Named pages pick the paper; the document fills it. */
  .printing-slip58 #print-root { page: cgx-slip58; }
  .printing-slip80 #print-root { page: cgx-slip80; }
  .printing-a4 #print-root { page: cgx-a4; }
  .printing-a6 #print-root { page: cgx-a6; }
  .printing-label60x40 #print-root { page: cgx-label60x40; }
  .printing-label100x60 #print-root { page: cgx-label100x60; }
  .printing-labelsA4 #print-root { page: cgx-labelsA4; }

  /* A4: the page margins (16/16/14 mm) replace the on-screen padding, so the text block is the same
     178 mm wide on screen and on paper, and every page of a long invoice gets them. The min height
     (1 mm short of the text block) keeps the footer at the foot of a one-page document. */
  .printing-a4 :is(.doc-a4, .doc-pricelist) { inline-size: auto; min-block-size: 266mm; padding: 0; }
  .printing-a4 .doc-pricelist { padding: 2mm 2mm 0; }

  .printing-a6 .doc-tent { inline-size: 105mm; }
  .printing-a6 .doc-tent:not(.doc-tent--single) { block-size: 148mm; }

  .printing-label60x40 .doc.doc-labels,
  .printing-label100x60 .doc.doc-labels { display: block; }
  .printing-label60x40 .doc-label { --label-w: 60mm; --label-h: 40mm; break-after: page; }
  .printing-label100x60 .doc-label { --label-w: 100mm; --label-h: 60mm; break-after: page; }
  :is(.printing-label60x40, .printing-label100x60) .doc-label:last-child { break-after: auto; }

  .printing-labelsA4 .doc.doc-labels--a4 { display: block; }
  .printing-labelsA4 .doc-sheet { margin: 0; box-shadow: none; }
  .printing-labelsA4 .doc-sheet:last-child { break-after: auto; }
  .printing-labelsA4 .doc-sheet .doc-label { box-shadow: none; }
}
