/* ============================================================================
 * paper.css - printable documents (ERP.paper)
 *
 * .paper is always a white sheet (A4 210x297 mm, or an 80 mm thermal roll), in light and dark UI themes.
 * Logical properties only (so the same rules serve the LTR "bilingual" sheet and the RTL Arabic sheet);
 * the few physical needs (QR at the physical top-left, transform origin) use `direction` / keyword-free values.
 * Class prefix: paper-* (sheet furniture, preview) and pp-* (document parts).
 * ========================================================================== */

.paper {
  --pp-ink: #12181f;
  --pp-muted: #566170;
  --pp-line: #c7ced6;
  --pp-line-soft: #e1e5ea;
  --pp-soft: #f1f3f6;
  --pp-accent: #0b6b5a;
  --pp-danger: #b3261e;
  --pp-ok: #0a7a47;
  --pp-warn: #b45309;
  box-sizing: border-box;
  position: relative;
  inline-size: 210mm;
  min-block-size: 297mm;
  margin: 0;
  padding: 10mm 12mm;
  background: #fff;
  color: var(--pp-ink);
  color-scheme: light;
  font: 400 8.4pt/1.38 ui-sans-serif, system-ui, -apple-system, "Segoe UI", "SF Arabic", "Geeza Pro", Tahoma, Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  text-align: start;
  overflow-wrap: break-word;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12), 0 12px 32px rgba(15, 23, 42, 0.14);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.paper *, .paper *::before, .paper *::after { box-sizing: border-box; }
.paper table { border-collapse: collapse; }
.paper bdi, .paper .pp-ltr { unicode-bidi: isolate; }
.paper .qr { border: 0; border-radius: 0; background: #fff; }
.paper--thermal80 {
  inline-size: 80mm;
  min-block-size: 0;
  padding: 4mm 3.5mm 6mm;
  font-size: 7.6pt;
  line-height: 1.32;
}
.paper--error { min-block-size: 0; padding: 10mm; }
.pp-error { color: var(--pp-danger); font-weight: 600; }

.paper .pp-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-block-size: calc(297mm - 20mm);
}
.paper--thermal80 .pp-content { min-block-size: 0; }
.paper .pp-content > * + * { margin-block-start: 3mm; }
.paper .pp-content > .pp-spacer { flex: 1 1 auto; margin-block-start: 0; min-block-size: 0; }
.paper--thermal80 .pp-content > * + * { margin-block-start: 2.4mm; }

/* ---------- bilingual primitives ---------- */
.pp-bi { display: flex; align-items: baseline; justify-content: space-between; gap: 2.5mm; min-inline-size: 0; }
.pp-bi > .pp-en, .pp-bi > .pp-ar { min-inline-size: 0; }
.pp-bi > .pp-ar { text-align: start; margin-inline-end: auto; }
.pp-bis { display: flex; flex-direction: column; align-items: inherit; gap: 0; line-height: 1.22; }
.pp-bis > span { display: block; }
.pp-en, .pp-ar { unicode-bidi: isolate; }
.pp-ar { font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "SF Arabic", "Geeza Pro", Tahoma, Arial, sans-serif; }
.pp-ltr { white-space: nowrap; }
.pp-amt { white-space: nowrap; font-variant-numeric: tabular-nums; }
.pp-money { white-space: nowrap; }
.pp-cur { margin-inline-start: 0.35em; font-size: 0.82em; color: var(--pp-muted); font-weight: 600; }
.pp-strong { font-weight: 700; }
.pp-sub { font-size: 0.82em; color: var(--pp-muted); }
.pp-dot { margin-inline: 0.55em; color: var(--pp-muted); }
.pp-free { white-space: pre-line; }
.pp-id { font-weight: 700; letter-spacing: 0; }
.pp-pending { color: var(--pp-muted); font-style: italic; }

.pp-pair { display: flex; align-items: flex-start; justify-content: space-between; gap: 3mm; min-inline-size: 0; }
.pp-pair > div { flex: 1 1 0; min-inline-size: 0; }
.pp-pair-ar { text-align: start; }
.pp-pair-one > div { flex: 1 1 auto; }
.pp-line + .pp-line { margin-block-start: 0.2mm; }

/* ---------- header: QR at the physical top-left, letterhead + title ---------- */
.pp-head { display: grid; grid-template-columns: 1fr; gap: 4.5mm; align-items: start; direction: ltr; }
.pp-head.has-qr { grid-template-columns: auto 1fr; }
.paper[dir="rtl"] .pp-head-main { direction: rtl; }
.pp-head-main { min-inline-size: 0; display: flex; flex-direction: column; gap: 1.8mm; }
.pp-qr { inline-size: 31mm; block-size: 31mm; flex: none; background: #fff; }
.pp-qr svg { display: block; inline-size: 100%; block-size: 100%; }
.pp-qr-empty { border: 0.3mm dashed var(--pp-line); border-radius: 1.5mm; display: grid; place-items: center; text-align: center; padding: 2mm; color: var(--pp-muted); font-size: 6.6pt; }
.pp-qr-empty-in { display: block; }
.pp-qr-empty .pp-bis { align-items: center; }
.pp-qr-t { inline-size: 36mm; block-size: 36mm; margin-inline: auto; }

.pp-brand { display: grid; grid-template-columns: 1fr auto 1fr; gap: 4mm; align-items: center; }
.pp-brand-one { grid-template-columns: auto 1fr; }
.pp-brand-en, .pp-brand-ar { min-inline-size: 0; }
.pp-brand-name { font-size: 12.5pt; font-weight: 700; line-height: 1.2; color: var(--pp-ink); }
.pp-brand-sub { font-size: 7.2pt; color: var(--pp-muted); margin-block-start: 0.6mm; }
.pp-logo { inline-size: 11mm; block-size: 11mm; flex: none; display: block; }
.pp-contact { font-size: 7pt; color: var(--pp-muted); text-align: center; }
.pp-title { padding-block: 1.2mm 1.4mm; border-block: 0.45mm solid var(--pp-accent); }
.pp-title-t { font-size: 16pt; font-weight: 800; line-height: 1.2; color: var(--pp-accent); }
.pp-title-t .pp-bi { align-items: center; }
.pp-title-s { font-size: 8.2pt; color: var(--pp-muted); margin-block-start: 0.8mm; }

/* ---------- meta strip ---------- */
.pp-meta { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); border: 0.25mm solid var(--pp-line); border-radius: 1.2mm; overflow: hidden; }
.pp-meta-1 { --n: 1; } .pp-meta-2 { --n: 2; } .pp-meta-3 { --n: 3; } .pp-meta-4 { --n: 4; } .pp-meta-5 { --n: 5; }
.pp-cell { padding: 1.4mm 2.4mm; min-inline-size: 0; }
.pp-cell + .pp-cell { border-inline-start: 0.25mm solid var(--pp-line-soft); }
.pp-cell-l, .pp-fld-l { font-size: 6.6pt; color: var(--pp-muted); line-height: 1.25; }
.pp-cell-v { margin-block-start: 0.7mm; font-size: 9pt; text-align: center; }
.pp-cell-id .pp-cell-v { font-size: 9.6pt; }
.pp-datev { line-height: 1.25; }
.pp-time { color: var(--pp-muted); font-size: 0.88em; }
.pp-hijri { font-size: 7pt; color: var(--pp-muted); margin-block-start: 0.4mm; }
.pp-period { display: flex; align-items: center; justify-content: center; gap: 1.6mm; }
.pp-arrow { color: var(--pp-muted); }
.paper[dir="rtl"] .pp-arrow { display: inline-block; transform: scaleX(-1); }

/* ---------- parties ---------- */
.pp-parties { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4mm; align-items: stretch; }
.pp-parties-one { grid-template-columns: minmax(0, 1fr); }
.pp-party { border: 0.25mm solid var(--pp-line); border-radius: 1.2mm; overflow: hidden; break-inside: avoid; display: flex; flex-direction: column; }
.pp-party-t { background: var(--pp-soft); padding: 1mm 2.6mm; font-weight: 700; font-size: 8pt; border-block-end: 0.25mm solid var(--pp-line); }
.pp-party-b { padding: 1.6mm 2.6mm 2mm; display: flex; flex-direction: column; gap: 1.3mm; flex: 1 1 auto; }
.pp-fld-v { margin-block-start: 0.5mm; font-size: 8.6pt; }
.pp-name { font-weight: 700; }
.pp-addr { font-size: 7.8pt; color: #2a323c; line-height: 1.35; }
.pp-addr-ar { margin-block-start: 0.3mm; }
.pp-addr-en, .pp-addr-ar { text-align: start; }
.pp-ids { display: grid; grid-template-columns: repeat(auto-fit, minmax(30mm, 1fr)); gap: 1.7mm 3mm; }
.pp-ids-stack { grid-template-columns: minmax(0, 1fr); }
.pp-fld-id .pp-fld-v { font-weight: 600; text-align: center; letter-spacing: 0.02em; }
.pp-ids-stack .pp-fld-id .pp-fld-v { text-align: start; }

/* ---------- boxes (words, payment, notes, terms...) ---------- */
.pp-box { border: 0.25mm solid var(--pp-line); border-radius: 1.2mm; break-inside: avoid; overflow: hidden; }
.pp-box-t { background: var(--pp-soft); padding: 1mm 2.6mm; font-size: 7pt; font-weight: 700; color: #36404c; border-block-end: 0.25mm solid var(--pp-line-soft); }
.pp-box-b { padding: 1.4mm 2.6mm 1.7mm; font-size: 8.2pt; }
.pp-words-en { font-weight: 600; }
.pp-words-ar { font-weight: 600; margin-block-start: 0.8mm; font-size: 9pt; }
.pp-disclaimer { font-size: 8pt; color: var(--pp-muted); text-align: center; padding-block: 1mm; border-block: 0.2mm dashed var(--pp-line); }
.pp-subject { font-weight: 600; font-size: 9.4pt; }

/* ---------- lines table ---------- */
.pp-lines { break-inside: auto; }
.pp-cap { display: flex; align-items: baseline; justify-content: space-between; gap: 4mm; margin-block-end: 1mm; font-size: 6.8pt; color: var(--pp-muted); font-weight: 600; }
.pp-cap-note { font-weight: 400; }
.pp-cap > .pp-bi:only-child { flex: 1 1 auto; }
.pp-cap-foot { margin-block: 1.2mm 0; font-weight: 400; }
.pp-td .pp-bi { flex-wrap: wrap; gap: 0 2.5mm; }
.pp-cell-v .pp-bis { align-items: center; }
.pp-table { inline-size: 100%; table-layout: fixed; font-size: 8.2pt; }
.pp-table thead { display: table-header-group; }
.pp-table tr { break-inside: avoid; page-break-inside: avoid; }
.pp-th { background: var(--pp-soft); border-block: 0.35mm solid #2b3440; padding: 1.2mm 1.4mm; font-size: 6.7pt; font-weight: 700; color: #26303b; vertical-align: bottom; line-height: 1.2; }
.pp-th .pp-bis > span:first-child { font-size: 6.4pt; font-weight: 600; color: #4a5461; }
.pp-th .pp-bis > span + span { font-size: 6.9pt; }
.pp-td { padding: 1.2mm 1.4mm; border-block-end: 0.2mm solid var(--pp-line-soft); vertical-align: top; }
.pp-table tbody tr:last-child .pp-td { border-block-end: 0.35mm solid #2b3440; }
.pp-a-start { text-align: start; }
.pp-a-end { text-align: end; }
.pp-a-center { text-align: center; }
.pp-th.pp-a-end .pp-bis { align-items: flex-end; }
.pp-th.pp-a-center .pp-bis { align-items: center; }
.pp-th.pp-a-start .pp-bis { align-items: flex-start; }
.pp-td .pp-bis { align-items: inherit; font-size: 7.4pt; }
.pp-td.pp-a-center .pp-bis { align-items: center; }
.pp-td.pp-a-end .pp-bis { align-items: flex-end; }
.pp-td.pp-a-start .pp-bis { align-items: flex-start; }
.pp-td.pp-c-no { color: var(--pp-muted); }
.pp-desc-ar { text-align: start; font-weight: 600; }
.pp-desc-en { text-align: start; color: #3a4350; font-size: 7.8pt; }
.pp-desc-ar + .pp-desc-en { margin-block-start: 0.2mm; }
.pp-desc[dir] { font-weight: 600; }
.pp-cat { display: inline-block; min-inline-size: 4mm; padding-inline: 1mm; border: 0.2mm solid var(--pp-line); border-radius: 1mm; font-size: 7pt; color: var(--pp-muted); }
.pp-empty { text-align: center; color: var(--pp-muted); padding-block: 5mm; }
.pp-zero { color: var(--pp-line); }
.pp-table-sm { font-size: 7.8pt; }
.pp-table-sm .pp-td { padding-block: 1.1mm; }
.pp-reason { font-size: 7.2pt; color: var(--pp-muted); margin-block-start: 0.5mm; }
.pp-reason .pp-bi { display: inline-flex; gap: 2mm; }
.pp-row-open .pp-td { background: #fafbfc; font-size: 8pt; }
.pp-row-total .pp-td { background: var(--pp-soft); border-block-start: 0.35mm solid #2b3440; border-block-end: 0.35mm solid #2b3440; font-size: 8.4pt; }
.pp-table-aging .pp-td { font-size: 8.4pt; padding-block: 1.6mm; }
.pp-stmt .pp-td { padding-block: 1.15mm; }
.pp-c-date { white-space: nowrap; }

/* ---------- bottom area: words/payment/notes beside totals ---------- */
.pp-bottom { display: grid; grid-template-columns: minmax(0, 1fr) 100mm; gap: 5mm; align-items: start; break-inside: avoid; }
.pp-bottom-even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pp-bottom-l { display: flex; flex-direction: column; gap: 2.6mm; min-inline-size: 0; }
.pp-totals { border: 0.25mm solid var(--pp-line); border-radius: 1.2mm; overflow: hidden; }
.pp-tot { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3mm; align-items: baseline; padding: 0.95mm 2.6mm; border-block-end: 0.2mm solid var(--pp-line-soft); font-size: 8.2pt; }
.pp-tot-v { text-align: end; font-weight: 600; min-inline-size: 28mm; }
.pp-tot.is-zero { color: var(--pp-muted); }
.pp-tot.is-grand { background: var(--pp-soft); font-weight: 800; font-size: 9.2pt; border-block: 0.35mm solid #2b3440; padding-block: 1.5mm; }
.pp-tot.is-grand .pp-tot-v { font-weight: 800; }
.pp-tot-note { padding: 0.6mm 2.6mm 1.2mm; font-size: 6.8pt; color: var(--pp-muted); border-block-end: 0.2mm solid var(--pp-line-soft); }
.pp-tot-note .pp-bi { justify-content: space-between; }
.pp-tot.is-paid { color: var(--pp-ok); }
.pp-tot.is-due { border-block-end: 0; background: #fff; font-weight: 800; font-size: 9.2pt; }
.pp-tot.is-due .pp-tot-v { font-weight: 800; color: var(--pp-ink); }

/* ---------- signatures ---------- */
.pp-sign-wrap { break-inside: avoid; }
.pp-sign { display: grid; gap: 4mm; }
.pp-sign-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pp-sign-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pp-signbox { border: 0.25mm solid var(--pp-line); border-radius: 1.2mm; padding: 1.6mm 2.4mm 1.5mm; }
.pp-sign-area { min-block-size: 11mm; display: flex; flex-direction: column; justify-content: flex-end; gap: 0.4mm; border-block-end: 0.25mm dashed var(--pp-line); padding-block-end: 1mm; margin-block-end: 1mm; }
.pp-sign-name { font-weight: 600; font-size: 8.2pt; }
.pp-sign-when { font-size: 7pt; color: var(--pp-muted); }
.pp-sign-l { font-size: 6.8pt; color: var(--pp-muted); }

/* ---------- statement summary ---------- */
.pp-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 0.25mm solid var(--pp-line); border-radius: 1.2mm; overflow: hidden; }
.pp-sum { padding: 2mm 2.6mm; min-inline-size: 0; }
.pp-sum + .pp-sum { border-inline-start: 0.25mm solid var(--pp-line-soft); }
.pp-sum-l { font-size: 6.8pt; color: var(--pp-muted); line-height: 1.25; }
.pp-sum-l .pp-bi { flex-wrap: wrap; }
.pp-sum-v { margin-block-start: 1mm; font-size: 10.5pt; font-weight: 700; text-align: end; }
.pp-sum.is-grand { background: var(--pp-soft); }
.pp-sum.is-grand .pp-sum-v { font-size: 11.5pt; font-weight: 800; color: var(--pp-accent); }

/* ---------- ZATCA footer ---------- */
.pp-zatca { border-block-start: 0.25mm solid var(--pp-line); padding-block-start: 1.6mm; font-size: 6.6pt; color: var(--pp-muted); line-height: 1.35; }
.pp-zatca-msg { display: flex; flex-wrap: wrap; align-items: baseline; gap: 1mm 3mm; font-weight: 600; color: #34404c; }
.pp-zatca-ids { display: flex; flex-wrap: wrap; gap: 0.6mm 5mm; margin-block-start: 0.6mm; }
.pp-zatca-ids .pp-bi { display: inline-flex; gap: 1.2mm; }
.pp-zatca-ids .pp-bi + * { margin-inline-start: 0; }
.pp-hash { overflow-wrap: anywhere; }
.pp-hash .pp-ltr { white-space: normal; overflow-wrap: anywhere; }

/* ---------- watermark and stamp ---------- */
.paper-watermark { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; pointer-events: none; overflow: hidden; }
.paper-watermark-in { transform: rotate(-30deg); text-align: center; font-weight: 800; font-size: 40pt; line-height: 1.1; color: rgba(86, 97, 112, 0.2); border: 1.3mm solid currentColor; border-radius: 4mm; padding: 2.5mm 9mm; max-inline-size: 165mm; }
.paper-watermark-in .pp-bi { flex-direction: column; align-items: center; gap: 0.5mm; }
.paper-watermark-in .pp-en { font-size: 0.8em; }
.paper-watermark.tone-warn .paper-watermark-in { color: rgba(180, 83, 9, 0.22); }
.paper-watermark.tone-danger .paper-watermark-in { color: rgba(179, 38, 30, 0.22); }
.paper--thermal80 .paper-watermark-in { font-size: 20pt; padding: 1.5mm 4mm; max-inline-size: 70mm; }
.pp-title { position: relative; }
.paper-stamp { position: absolute; inset: 0; margin: auto; inline-size: fit-content; block-size: fit-content; transform: rotate(-4deg); border: 0.6mm double currentColor; border-radius: 1.6mm; padding: 0.5mm 3.5mm; text-align: center; font-weight: 800; font-size: 8.6pt; line-height: 1.12; opacity: 0.9; pointer-events: none; background: rgba(255, 255, 255, 0.55); z-index: 3; }
.paper-stamp .pp-bis { align-items: center; }
.paper-stamp .pp-bis > span + span { font-size: 1.1em; }
.paper-stamp .pp-bis > span:first-child { font-size: 0.8em; }
.paper--thermal80 .paper-stamp { position: static; margin: 1.2mm auto; font-size: 8.4pt; }
.paper-stamp-s { font-size: 6.6pt; font-weight: 600; margin-block-start: 0.2mm; }
.paper-stamp.tone-danger { color: var(--pp-danger); }
.paper-stamp.tone-ok { color: var(--pp-ok); }
.paper-stamp.tone-muted { color: #566170; }

/* ---------- 80 mm thermal receipt ---------- */
.paper--thermal80 .pp-t-head { text-align: center; }
.pp-t-brand { font-weight: 800; }
.pp-t-bn-ar { font-size: 11.5pt; line-height: 1.25; }
.pp-t-bn-en { font-size: 9.5pt; line-height: 1.25; }
.pp-t-addr { font-size: 6.9pt; color: #2a323c; margin-block-start: 0.8mm; }
.pp-t-ids-co { font-size: 7pt; margin-block-start: 0.8mm; }
.pp-t-ids-co .pp-bi { display: inline-flex; gap: 1mm; }
.pp-t-title { text-align: center; border-block: 0.3mm dashed #222; padding-block: 1.4mm; font-weight: 800; }
.pp-t-title-ar { font-size: 12pt; line-height: 1.25; }
.pp-t-title-en { font-size: 9pt; line-height: 1.25; }
.pp-t-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2mm; align-items: baseline; padding-block: 0.35mm; }
.pp-t-l { font-size: 6.9pt; color: #3a434e; }
.pp-t-l .pp-bi { flex-wrap: wrap; gap: 0 2mm; }
.pp-t-v { text-align: end; font-weight: 600; }
.pp-t-items { border-block-start: 0.3mm dashed #222; padding-block-start: 1.4mm; }
.pp-t-item { padding-block: 1mm; border-block-end: 0.2mm dotted #999; break-inside: avoid; }
.pp-t-name { display: flex; justify-content: space-between; align-items: baseline; gap: 2mm; flex-wrap: wrap; }
.pp-t-name-ar, .pp-t-name-en { text-align: start; }
.pp-t-name-ar { font-weight: 700; font-size: 8pt; }
.pp-t-name-en { font-size: 7pt; color: #2f3842; }
.pp-t-name[dir] { display: block; font-weight: 700; }
.pp-t-calc { display: grid; grid-template-columns: 1fr auto auto; gap: 2.5mm; align-items: baseline; font-size: 7.2pt; margin-block-start: 0.5mm; }
.pp-t-vatrate { color: var(--pp-muted); font-size: 6.4pt; }
.pp-t-totals { border-block-start: 0.3mm dashed #222; padding-block-start: 1.2mm; }
.pp-t-totals .pp-t-row.is-grand { font-weight: 800; font-size: 10pt; padding-block: 1.2mm; border-block: 0.3mm solid #222; margin-block: 0.8mm; }
.pp-t-totals .pp-t-row.is-grand .pp-t-l { color: #000; font-size: 8pt; }
.pp-t-note { text-align: center; padding: 0; border: 0; }
.pp-t-note .pp-bi { justify-content: center; }
.pp-t-pay { border-block-start: 0.3mm dashed #222; padding-block-start: 1mm; }
.pp-t-reason { font-size: 7.2pt; }
.pp-t-reason-l { color: var(--pp-muted); font-size: 6.6pt; }
.pp-t-words { font-size: 6.9pt; text-align: center; color: #2a323c; border-block-start: 0.3mm dashed #222; padding-block-start: 1.2mm; }
.pp-t-words > div + div { margin-block-start: 0.6mm; }
.paper--thermal80 .pp-qr { margin-block: 0.5mm; }
.pp-t-ids .pp-bi { display: inline-flex; gap: 1mm; }
.pp-t-ids { text-align: center; font-size: 5.8pt; color: var(--pp-muted); line-height: 1.35; overflow-wrap: anywhere; }
.pp-t-ids .pp-ltr { white-space: normal; overflow-wrap: anywhere; }
.pp-t-queued { margin-block-start: 0.6mm; font-weight: 600; color: var(--pp-warn); }
.pp-t-foot { text-align: center; font-size: 7.4pt; font-weight: 600; border-block-start: 0.3mm dashed #222; padding-block-start: 1.4mm; }
.pp-t-foot .pp-bi { justify-content: center; }
.paper--thermal80 .pp-empty { padding-block: 3mm; }

/* ---------- scale-to-fit container, stage, modal preview ---------- */
.paper-fit {
  position: relative; overflow: hidden; display: flex; justify-content: center; align-items: flex-start;
  inline-size: 100%; margin-inline: auto; visibility: hidden;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12), 0 12px 32px rgba(15, 23, 42, 0.14); background: #fff;
}
.paper-fit.is-ready { visibility: visible; }
.paper-fit__inner { flex: none; transform: scale(var(--paper-scale, 1)); transform-origin: 50% 0; }
.paper-fit .paper { box-shadow: none; }
.paper-stage { display: flex; flex-direction: column; gap: 12px; min-inline-size: 0; padding: 12px; background: var(--surface-2, #eef0f3); border: 1px solid var(--border, #e2e5ea); border-radius: var(--radius, 8px); }
.paper-stage-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.paper-stage-grow { flex: 1 1 auto; }
.paper-stage-body { min-inline-size: 0; }

/* ---------- print ---------- */
@page paperA4 {
  size: A4 portrait;
  margin: 10mm 12mm;
  @bottom-center { content: counter(page) " / " counter(pages); font: 7pt ui-sans-serif, system-ui, Arial, sans-serif; color: #667; }
}
@page paperThermal { size: 80mm 297mm; margin: 0; }
.paper--a4 { page: paperA4; }
.paper--thermal80 { page: paperThermal; }

@media screen { #paper-print-root { display: none; } }

@media print {
  html.paper-printing body > *:not(#paper-print-root) { display: none !important; }
  html.paper-printing, html.paper-printing body { background: #fff !important; margin: 0; padding: 0; }
  #paper-print-root { display: block; }
  .paper { box-shadow: none !important; margin: 0; inline-size: auto; min-block-size: 0; padding: 0; background: #fff; }
  .paper--thermal80 { inline-size: 80mm; padding: 4mm 3.5mm 6mm; }
  .paper .pp-content { display: block; min-block-size: 0; }
  .paper .pp-content > .pp-spacer { display: none; }
  .paper .pp-content > * + * { margin-block-start: 3mm; }
  .paper-watermark { position: fixed; }
  .paper-fit { position: static; overflow: visible; visibility: visible; box-shadow: none; inline-size: auto; max-inline-size: none !important; block-size: auto !important; display: block; }
  .paper-fit__inner { transform: none !important; }
  .paper-stage { padding: 0; background: none; border: 0; }
  .paper-stage-tools { display: none; }
  .pp-party, .pp-box, .pp-totals, .pp-sum, .pp-signbox { break-inside: avoid; }
}

/* ---------- compact strips and long text boxes ---------- */
.pp-inline { display: grid; grid-template-columns: 24mm minmax(0, 1fr); gap: 3mm; align-items: center; border: 0.25mm solid var(--pp-line); border-radius: 1.2mm; padding: 1.2mm 2.6mm; break-inside: avoid; }
.pp-inline-l { font-size: 6.6pt; color: var(--pp-muted); }
.pp-inline-l .pp-bis { align-items: flex-start; }
.pp-inline-v .pp-bi { align-items: center; }
.pp-terms-body { display: flex; flex-direction: column; gap: 1mm; }
.pp-terms-body .pp-bi { align-items: flex-start; gap: 6mm; }
.pp-terms-body .pp-bi > span { flex: 1 1 0; }
.pp-terms-extra { font-size: 7.6pt; color: var(--pp-muted); border-block-start: 0.2mm dashed var(--pp-line-soft); padding-block-start: 1mm; }
.pp-terms-extra .pp-bi > span { flex: 1 1 0; }
.pp-terms .pp-free { font-size: 7.8pt; }
