/* AFV CRM print QA final layer. Loaded after legacy document overrides. */

#modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned:not(.document-attachment-page) {
  display: block !important;
  position: relative !important;
  box-sizing: border-box !important;
  width: 210mm !important;
  min-width: 210mm !important;
  max-width: 210mm !important;
  height: 297mm !important;
  min-height: 297mm !important;
  max-height: 297mm !important;
  overflow: hidden !important;
}

/* Invoice seller signature/stamp are intentionally disabled in both preview
   and final print so the two modes cannot diverge. */
html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content > .invoice-paper-signature-band,
html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content > .print-flow-signature-band {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  min-height: 0 !important;
  max-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
}

/* INVOICE-ONLY RELEASE GATE — the cloned A4 pages must each carry the same
   physical letterhead.  The previous background-only approach was visible on
   the first page but was not reliably painted on middle pages by Chromium's
   print compositor.  Keep the cloned image as the page-owned artwork and let
   the invoice content/meta sit above it. */
@media screen, print {
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) {
    background-color: #fff !important;
    background-image: none !important;
    background-repeat: no-repeat !important;
    background-position: 0 0 !important;
    background-size: auto !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image {
    display: block !important;
    visibility: visible !important;
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    object-fit: fill !important;
    object-position: center !important;
    clip-path: none !important;
    transform: none !important;
    opacity: 1 !important;
    z-index: 0 !important;
    pointer-events: none !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) > .invoice-paper-content {
    z-index: 2 !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) > .official-document-meta {
    z-index: 4 !important;
  }

  /* The official reference artwork owns the footer.  The legacy in-body
     footer must never create a second, shifted footer or survive without a
     matching header. */
  html body #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) .invoice-paper-footer {
    display: none !important;
    visibility: hidden !important;
  }
}

/* نامهٔ صادره اکنون همان اسکلت پیش‌فاکتور را دارد. در نمایشگر قاب باید
   داخل کارت بماند؛ در چاپ فقط دو برگهٔ واقعی (نامه و پیوست) مجاز به صفحه‌بندی
   هستند و هیچ شکست اجباریِ دوتایی نباید بینشان ساخته شود. */
@media screen {
  html body #modal-root .letter-preview-wrap.invoice-preview {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 0 !important;
    box-sizing: border-box !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    padding: 12px !important;
  }

  html body #modal-root .letter-preview-wrap.invoice-preview > .invoice-paper.letter-invoice-paper,
  html body #modal-root .letter-preview-wrap.invoice-preview > .document-attachment-print-page {
    flex: 0 0 auto !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }
}

@media screen and (max-width: 820px) {
  html body #modal-root .letter-preview-wrap.invoice-preview {
    align-items: flex-start !important;
  }
}

@media print {
  html body.printing-invoice #modal-root .letter-preview-wrap.invoice-preview {
    display: block !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    position: static !important;
    background: #fff !important;
  }

  html body.printing-invoice #modal-root .letter-preview-wrap.invoice-preview > .invoice-paper.letter-invoice-paper,
  html body.printing-invoice #modal-root .letter-preview-wrap.invoice-preview > .document-attachment-print-page {
    display: block !important;
    position: relative !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    break-before: auto !important;
    page-break-before: auto !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  html body.printing-invoice #modal-root .letter-preview-wrap.invoice-preview > .invoice-paper.letter-invoice-paper:not(:last-child) {
    break-after: page !important;
    page-break-after: always !important;
  }

  html body.printing-invoice #modal-root .letter-preview-wrap.invoice-preview > .document-attachment-print-page {
    break-after: auto !important;
    page-break-after: auto !important;
  }
}

/* Chromium's PDF compositor paints the real image element reliably; keep the
   pseudo-layer experiment disabled and use the same physical A4 artwork on
   every invoice page while the footer alignment is handled below. */
@media screen, print {
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) {
    background-image: url("/assets/afv-letterhead-main-clean-20260920.png?v=20260920-header-clean-01") !important;
    background-repeat: no-repeat !important;
    background-position: center top !important;
    background-size: 100% 100% !important;
    background-origin: border-box !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page)::after {
    display: none !important;
    content: none !important;
    visibility: hidden !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image {
    display: block !important;
    visibility: visible !important;
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    object-fit: fill !important;
    object-position: center center !important;
    clip-path: none !important;
    transform: none !important;
    opacity: 1 !important;
    z-index: 0 !important;
    pointer-events: none !important;
  }
}

/* EARLY PRECEDENCE — reference-sheet footer and safe content bottom.
   This is intentionally last: older document presets above it are allowed to
   define the form, but not to move the shared background or let content enter
   the footer artwork. */
@media screen, print {
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image {
    clip-path: inset(0 0 14% 0) !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page)::before {
    content: "" !important;
    position: absolute !important;
    inset: 0 !important;
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: url("/assets/afv-letterhead-main-clean-20260920.png?v=20260920-header-clean-01") 0 0 / 100% 100% no-repeat !important;
    clip-path: inset(86% 0 0 0) !important;
    transform: translateX(8mm) !important;
    pointer-events: none !important;
    z-index: 1 !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content:not(.print-page-has-signature),
  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) > .receipt-redesigned-content,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page) > .check-receipt-v3-content {
    bottom: 40mm !important;
  }

  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) {
    padding-bottom: 40mm !important;
  }
}

/* Multi-page invoices: the legacy title rule used `flex-basis: 100%`, which
   consumes the whole A4 content column and paints over the first table chunk.
   It is a heading, not a page-sized flow item; keep it compact so the same
   rows are visible in preview and in the browser PDF. */
@media screen, print {
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page):not(.invoice-single-page-compact) .invoice-document-section-title {
    flex: 0 0 auto !important;
    display: block !important;
    position: relative !important;
    z-index: 2 !important;
    width: 100% !important;
    height: auto !important;
    min-height: 5mm !important;
    max-height: none !important;
    margin: 2mm 0 1mm !important;
    padding: 1.5mm 2mm !important;
    box-sizing: border-box !important;
    line-height: 1.2 !important;
  }
}

/* FINAL PRINT A4 LETTERHEAD PER PAGE — keep the reference sheet attached to
   every cloned A4 page.  The old absolute image/pseudo-element strategy can
   disappear from middle pages during Chromium print fragmentation. */
@media screen, print {
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) {
    background-color: #fff !important;
    background-image: url("/assets/afv-letterhead-main-clean-20260920.png?v=20260920-header-clean-01") !important;
    background-repeat: no-repeat !important;
    background-position: center center !important;
    background-size: 100% 100% !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page)::before {
    display: none !important;
    content: none !important;
    visibility: hidden !important;
  }
}

/* FINAL A4 LETTERHEAD PER PAGE — an absolutely positioned image can disappear
   from middle pages when Chromium fragments the print flow.  Paint the
   reference sheet as the paper's own background instead.  Each cloned A4
   page therefore owns its logo/footer independently, while attachment pages
   remain document-only and are excluded by the selector. */
@media screen, print {
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) {
    background-color: #fff !important;
    background-image: url("/assets/afv-letterhead-main-clean-20260920.png?v=20260920-header-clean-01") !important;
    background-repeat: no-repeat !important;
    background-position: center center !important;
    background-size: 100% 100% !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page)::before {
    display: none !important;
    content: none !important;
    visibility: hidden !important;
  }
}

/* Initial visual lock: the shared letterhead image is the only header-side
   decoration. Legacy document layers used to add a second orange vertical
   rule beside it; the final lock remains at EOF. */
@media print {
  body.printing-invoice #modal-root .invoice-preview .invoice-paper::after,
  body.printing-receipt #modal-root .receipt-preview-wrap .receipt-paper::after,
  body.printing-check-receipt #modal-root .check-receipt-print-wrap .check-receipt-paper::after,
  body.printing-check-receipt-a4 #modal-root .check-receipt-print-wrap .check-receipt-paper::after,
  body.printing-quality #modal-root .quality-preview-wrap .quality-paper::after,
  body.printing-technical-report #modal-root .technical-preview-wrap .technical-paper::after {
    content: none !important;
    display: none !important;
    border: 0 !important;
  }

  body.printing-invoice #modal-root .invoice-preview .invoice-native-side-rule,
  body.printing-invoice #modal-root .invoice-preview .print-flow-side-rule,
  body.printing-receipt #modal-root .receipt-preview-wrap .invoice-native-side-rule,
  body.printing-receipt #modal-root .receipt-preview-wrap .print-flow-side-rule,
  body.printing-check-receipt #modal-root .check-receipt-print-wrap .invoice-native-side-rule,
  body.printing-check-receipt-a4 #modal-root .check-receipt-print-wrap .invoice-native-side-rule,
  body.printing-quality #modal-root .quality-preview-wrap .invoice-native-side-rule,
  body.printing-technical-report #modal-root .technical-preview-wrap .invoice-native-side-rule {
    display: none !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    border: 0 !important;
  }
}

/* Closed-loop PDF Reader status. It is deliberately outside the printable
   document so a failed diagnostic cycle never changes page geometry. */
#pdf-reader-loop-root {
  position: fixed;
  z-index: 2147483000;
  inset-inline: 24px;
  bottom: 24px;
  max-width: 560px;
  margin-inline: auto;
  padding: 14px 18px;
  border: 1px solid #f59e0b;
  border-inline-start: 5px solid #f15a24;
  border-radius: 14px;
  background: #fffaf3;
  color: #26313d;
  box-shadow: 0 14px 38px rgba(27, 42, 56, .18);
  direction: rtl;
  font-family: inherit;
  line-height: 1.8;
}
#pdf-reader-loop-root strong,
#pdf-reader-loop-root span,
#pdf-reader-loop-root small { display: block; }
#pdf-reader-loop-root strong { color: #bd4b15; font-size: 14px; }
#pdf-reader-loop-root span { color: #586675; font-size: 12px; }
#pdf-reader-loop-root small { color: #66727e; font-size: 11px; }
#pdf-reader-loop-root ul { margin: 6px 0; padding-inline-start: 20px; color: #8c3b12; font-size: 12px; }
#pdf-reader-loop-root.is-pending { border-color: #6ea8df; background: #f4f9ff; }
#pdf-reader-loop-root.is-pending strong { color: #1f5d96; }
#pdf-reader-loop-root.is-blocked { border-color: #d64545; background: #fff5f5; }
#pdf-reader-loop-root.is-blocked strong { color: #a32121; }
@media print {
  #pdf-reader-loop-root { display: none !important; }
}

/* OUTGOING LETTER UNIFIED THEME DEFAULT (2026-09-20)
   Outgoing letters use the same released A4 paper geometry as the invoice and
   other official documents.  Incoming originals are deliberately excluded:
   they remain document-only pages without AFV letterhead. */
@media screen, print {
  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) {
    position: relative !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    isolation: isolate !important;
    background-color: #fff !important;
    background-image: url("/assets/afv-letterhead-main-clean-20260920.png?v=20260920-header-clean-01") !important;
    background-repeat: no-repeat !important;
    background-position: center center !important;
    background-size: 100% 100% !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page)::after {
    display: none !important;
    visibility: hidden !important;
    content: none !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) > .letter-meta {
    top: 9mm !important;
    left: 8mm !important;
    right: auto !important;
    z-index: 4 !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) > .letter-document {
    position: absolute !important;
    top: 34mm !important;
    right: 24mm !important;
    bottom: 40mm !important;
    left: 14mm !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    z-index: 2 !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) .letter-signature-area {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }
}

@media print {
  html body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) {
    page: afv-final-document-a4 !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }
}

/* Stable Persian page counter: keep both numbers isolated and put «از»
   between them in a fixed left-to-right visual sequence. */
html body #modal-root .invoice-preview .invoice-page-count,
html body #modal-root .invoice-preview .official-page-count {
  display: inline-flex !important;
  align-items: baseline !important;
  flex-direction: row !important;
  gap: 0 !important;
  direction: ltr !important;
  unicode-bidi: isolate !important;
  white-space: nowrap !important;
  font-family: "BNazanin", "B Nazanin", "Vazirmatn", Tahoma, Arial, sans-serif !important;
  font-variant-numeric: normal !important;
}

html body #modal-root .invoice-preview .invoice-page-count .page-count-current,
html body #modal-root .invoice-preview .invoice-page-count .page-count-total,
html body #modal-root .invoice-preview .official-page-count .page-count-current,
html body #modal-root .invoice-preview .official-page-count .page-count-total {
  display: inline-block !important;
  direction: ltr !important;
  unicode-bidi: isolate !important;
  font-family: inherit !important;
  font-variant-numeric: normal !important;
}

html body #modal-root .invoice-preview .invoice-page-count .page-count-separator,
html body #modal-root .invoice-preview .official-page-count .page-count-separator {
  display: inline-block !important;
  padding-inline: .28em !important;
  order: 2 !important;
  direction: rtl !important;
  unicode-bidi: isolate !important;
  font-family: inherit !important;
  font-weight: 400 !important;
}

html body #modal-root .invoice-preview .invoice-page-count .page-count-current,
html body #modal-root .invoice-preview .official-page-count .page-count-current {
  order: 1 !important;
}

html body #modal-root .invoice-preview .invoice-page-count .page-count-total,
html body #modal-root .invoice-preview .official-page-count .page-count-total {
  order: 3 !important;
}

html body #modal-root .invoice-preview .invoice-seller-signature .signature-title,
html body #modal-root .invoice-preview .invoice-seller-signature .signature-name {
  font-family: "BNazanin", "B Nazanin", "Vazirmatn", Tahoma, Arial, sans-serif !important;
}

@media print {
  html body.printing-invoice #modal-root .invoice-preview .invoice-page-count,
  html body.printing-invoice #modal-root .invoice-preview .official-page-count {
    display: inline-flex !important;
    direction: ltr !important;
    unicode-bidi: isolate !important;
    font-family: "BNazanin", "B Nazanin", "Vazirmatn", Tahoma, Arial, sans-serif !important;
  }

  /* The printed/PDF metadata follows the reference sheet's visual order:
     swap only the two isolated numbers while keeping «از» in the middle. */
  html body.printing-invoice #modal-root .invoice-preview .invoice-page-count .page-count-current,
  html body.printing-invoice #modal-root .invoice-preview .official-page-count .page-count-current {
    order: 3 !important;
  }

  html body.printing-invoice #modal-root .invoice-preview .invoice-page-count .page-count-separator,
  html body.printing-invoice #modal-root .invoice-preview .official-page-count .page-count-separator {
    order: 2 !important;
  }

  html body.printing-invoice #modal-root .invoice-preview .invoice-page-count .page-count-total,
  html body.printing-invoice #modal-root .invoice-preview .official-page-count .page-count-total {
    order: 1 !important;
  }
}

/* INVOICE-ONLY FINAL FIX (2026-09-20): paint the reference sheet in two
   independent layers. The source artwork has a deliberately right-heavy
   header and a left-heavy footer; splitting the layers lets the footer be
   centered without moving the logo. It also avoids Chromium's intermittent
   loss of an absolutely-positioned letterhead image on page 2. */
@media screen, print {
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) {
    background-image: none !important;
    background-color: #fff !important;
    isolation: isolate !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page)::after {
    content: "" !important;
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    background-image: url("/assets/afv-letterhead-main-clean-20260920.png?v=20260920-header-clean-01") !important;
    background-repeat: no-repeat !important;
    background-position: center top !important;
    background-size: 100% 100% !important;
    background-color: transparent !important;
    print-color-adjust: exact !important;
    -webkit-print-color-adjust: exact !important;
    pointer-events: none !important;
    z-index: 0 !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page)::before {
    clip-path: inset(0 0 14% 0) !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page)::after {
    clip-path: inset(84% 0 0 0) !important;
    transform: translateX(14mm) !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image {
    display: none !important;
    visibility: hidden !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content {
    z-index: 2 !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content.print-page-has-signature {
    bottom: 54mm !important;
  }

  /* This selector deliberately repeats the older high-specificity rule so
     the reserved footer zone also applies to pages without signatures. */
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content:not(.print-page-has-signature) {
    bottom: 54mm !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content.print-page-has-signature {
    bottom: 54mm !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content > .invoice-paper-signature-band,
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content > .print-flow-signature-band {
    position: static !important;
    flex: 0 0 42mm !important;
    width: 88mm !important;
    min-width: 88mm !important;
    max-width: 88mm !important;
    height: 42mm !important;
    min-height: 42mm !important;
    max-height: 42mm !important;
    margin: 8mm auto 0 0 !important;
    padding: 0 !important;
    display: block !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    direction: rtl !important;
    z-index: 8 !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  /* Print-only suppression comes after the preview layout rule so the
     signature/stamp cannot be resurrected by the static band styling. */
  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) .invoice-paper-signature-band,
  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) .print-flow-signature-band {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
  }
}

/* Invoice print compositor fallback: each cloned invoice is an independent
   A4 page, so paint the reference sheet as that page's own background.  This
   avoids Chromium dropping an absolutely-positioned image on an intermediate
   page while keeping the footer centered in the paper coordinate system. */
@media screen, print {
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) {
    background-color: #fff !important;
    background-image: url("/assets/afv-letterhead-main-clean-20260920.png?v=20260920-header-clean-01") !important;
    background-repeat: no-repeat !important;
    background-position: center top !important;
    background-size: 100% 100% !important;
    background-origin: border-box !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image {
    display: block !important;
    visibility: visible !important;
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    object-fit: fill !important;
    object-position: center center !important;
    clip-path: none !important;
    transform: none !important;
    opacity: 1 !important;
    z-index: 0 !important;
    pointer-events: none !important;
  }
}

/* EARLY EOF PRECEDENCE — reference-sheet footer and safe content bottom. */
@media screen, print {
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image {
    clip-path: inset(0 0 14% 0) !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page)::before {
    content: "" !important;
    position: absolute !important;
    inset: 0 !important;
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: url("/assets/afv-letterhead-main-clean-20260920.png?v=20260920-header-clean-01") 0 0 / 100% 100% no-repeat !important;
    clip-path: inset(86% 0 0 0) !important;
    transform: translateX(8mm) !important;
    pointer-events: none !important;
    z-index: 1 !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content:not(.print-page-has-signature),
  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) > .receipt-redesigned-content,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page) > .check-receipt-v3-content {
    bottom: 40mm !important;
  }

  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) {
    padding-bottom: 35mm !important;
  }
}

/* 2026-09-20 / reference letterhead + honest one-page invoice fit.
   The supplied A4 reference is artwork, not content. Keep it out of layout
   flow, clip its embedded footer, and paint that footer as an independent
   centered layer so the document body can never push it sideways. */
@media screen, print {
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image {
    clip-path: inset(0 0 10% 0) !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page)::before {
    content: "" !important;
    position: absolute !important;
    inset: 0 !important;
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: url("/assets/afv-letterhead-main-clean-20260920.png?v=20260920-header-clean-01") 0 0 / 100% 100% no-repeat !important;
    clip-path: inset(90% 0 0 0) !important;
    transform: translateX(8mm) !important;
    pointer-events: none !important;
    z-index: 1 !important;
  }

  /* Keep the common body zone tied to the reference sheet, not to the
     intrinsic size of the header image. */
  html body #modal-root .invoice-preview > .invoice-paper.invoice-single-page-compact:not(.document-attachment-page) > .invoice-paper-content {
    top: 34mm !important;
    right: 24mm !important;
    bottom: 67mm !important;
    left: 14mm !important;
    width: auto !important;
    height: auto !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.invoice-single-page-compact:not(.document-attachment-page) .invoice-paper-head {
    height: 16mm !important;
    min-height: 16mm !important;
    max-height: 16mm !important;
    padding: 0 0 2mm !important;
    gap: 2mm !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.invoice-single-page-compact:not(.document-attachment-page) .invoice-document-title,
  html body #modal-root .invoice-preview > .invoice-paper.invoice-single-page-compact:not(.document-attachment-page) .invoice-document-title h1 {
    line-height: 1.1 !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.invoice-single-page-compact:not(.document-attachment-page) .invoice-basmalah {
    margin-bottom: 1mm !important;
    font-size: 8.5pt !important;
    line-height: 1.05 !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.invoice-single-page-compact:not(.document-attachment-page) .invoice-document-title h1 {
    font-size: 15pt !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.invoice-single-page-compact:not(.document-attachment-page) .invoice-parties-row {
    height: 24mm !important;
    min-height: 24mm !important;
    max-height: 24mm !important;
    margin: 2mm 0 0 !important;
    overflow: hidden !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.invoice-single-page-compact:not(.document-attachment-page) .invoice-party-section > h2 {
    height: 4mm !important;
    min-height: 4mm !important;
    max-height: 4mm !important;
    padding: .7mm 1.5mm !important;
    font-size: 7.5pt !important;
    line-height: 1 !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.invoice-single-page-compact:not(.document-attachment-page) .invoice-party-grid {
    height: 20mm !important;
    min-height: 20mm !important;
    max-height: 20mm !important;
    gap: 1mm !important;
    padding: 1mm !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.invoice-single-page-compact:not(.document-attachment-page) .invoice-party-field {
    min-height: 0 !important;
    height: 5.5mm !important;
    padding: .65mm 1mm !important;
    font-size: 7pt !important;
    line-height: 1.05 !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.invoice-single-page-compact:not(.document-attachment-page) .invoice-party-field > span,
  html body #modal-root .invoice-preview > .invoice-paper.invoice-single-page-compact:not(.document-attachment-page) .invoice-party-field > strong {
    font-size: 6.5pt !important;
    line-height: 1.05 !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.invoice-single-page-compact:not(.document-attachment-page) .invoice-document-section-title {
    height: 5mm !important;
    min-height: 5mm !important;
    max-height: 5mm !important;
    margin: 2mm 0 0 !important;
    padding: .8mm 1.5mm !important;
    font-size: 7.5pt !important;
    line-height: 1 !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.invoice-single-page-compact:not(.document-attachment-page) .invoice-paper-table th {
    height: 5mm !important;
    padding: .55mm 1mm !important;
    font-size: 6.5pt !important;
    line-height: 1 !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.invoice-single-page-compact:not(.document-attachment-page) .invoice-paper-table td {
    height: 4.25mm !important;
    padding: .45mm 1mm !important;
    font-size: 6.5pt !important;
    line-height: 1.02 !important;
    vertical-align: middle !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.invoice-single-page-compact:not(.document-attachment-page) .invoice-paper-table td > *,
  html body #modal-root .invoice-preview > .invoice-paper.invoice-single-page-compact:not(.document-attachment-page) .invoice-paper-table td small,
  html body #modal-root .invoice-preview > .invoice-paper.invoice-single-page-compact:not(.document-attachment-page) .invoice-paper-table td strong {
    font-size: 6.5pt !important;
    line-height: 1.02 !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.invoice-single-page-compact:not(.document-attachment-page) .invoice-summary-grid {
    height: 23mm !important;
    min-height: 23mm !important;
    max-height: 23mm !important;
    margin: 2mm 0 0 !important;
    gap: 3mm !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.invoice-single-page-compact:not(.document-attachment-page) .invoice-total-box,
  html body #modal-root .invoice-preview > .invoice-paper.invoice-single-page-compact:not(.document-attachment-page) .invoice-paper-notes {
    min-height: 0 !important;
    height: 23mm !important;
    max-height: 23mm !important;
    padding: 1.5mm 2mm !important;
    overflow: hidden !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.invoice-single-page-compact:not(.document-attachment-page) .invoice-total-line {
    min-height: 0 !important;
    height: 3.7mm !important;
    padding: .45mm 0 !important;
    font-size: 6.5pt !important;
    line-height: 1 !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.invoice-single-page-compact:not(.document-attachment-page) .invoice-total-line strong,
  html body #modal-root .invoice-preview > .invoice-paper.invoice-single-page-compact:not(.document-attachment-page) .invoice-paper-notes strong {
    font-size: 6.8pt !important;
    line-height: 1 !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.invoice-single-page-compact:not(.document-attachment-page) .invoice-paper-notes {
    font-size: 6.3pt !important;
    line-height: 1.15 !important;
  }
}

/* The reference footer starts at the lower 10% of the A4 sheet. Reserve that
   zone for every flowing document so confirmations, notes and tables cannot
   sit on top of the logo strip. Invoice signature pages already reserve their
   larger signature zone above this footer. */
@media screen, print {
  html body #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page):not(.invoice-single-page-compact) > .invoice-paper-content:not(.print-page-has-signature),
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page) > .receipt-redesigned-content,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page) > .check-receipt-v3-content {
    bottom: 45mm !important;
  }

  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) {
    padding-bottom: 45mm !important;
  }
}

/* The desktop test harness may append an empty overlay root after the print
   modal.  It is visually hidden but still participates in print pagination;
   when the document ends exactly on the A4 boundary Chrome can emit a blank
   trailing sheet.  Keep the harness out of the printable flow. */
@media print {
  #codex-agent-overlay-root {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    break-before: auto !important;
    break-after: auto !important;
    page-break-before: auto !important;
    page-break-after: auto !important;
  }
}

#modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned:not(.document-attachment-page) > .receipt-redesigned-content {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  position: absolute !important;
  top: 34mm !important;
  right: 24mm !important;
  bottom: 19mm !important;
  left: 14mm !important;
  width: auto !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  padding: 0 !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
}

html body #modal-root .invoice-preview .official-page-count,
html body #modal-root .invoice-preview .invoice-page-count {
  white-space: nowrap !important;
  display: inline-block !important;
  direction: ltr !important;
  unicode-bidi: isolate !important;
}

#modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned:not(.document-attachment-page) > .print-flow-logo {
  position: absolute !important;
  top: 8mm !important;
  right: 13mm !important;
  width: 30mm !important;
  max-width: 30mm !important;
  height: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  visibility: visible !important;
  z-index: 21 !important;
}

#modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned:not(.document-attachment-page) > .print-flow-side-rule {
  position: absolute !important;
  top: 34mm !important;
  right: 14mm !important;
  bottom: 15mm !important;
  width: 11mm !important;
  height: auto !important;
  border: 0 !important;
  border-right: .35mm solid #f15a24 !important;
  visibility: visible !important;
  z-index: 20 !important;
}

#modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned:not(.document-attachment-page) > .print-flow-footer {
  position: absolute !important;
  right: 13mm !important;
  bottom: 8mm !important;
  left: 13mm !important;
  width: auto !important;
  height: 7mm !important;
  min-height: 7mm !important;
  max-height: 7mm !important;
  margin: 0 !important;
  padding: 2mm 0 0 !important;
  display: grid !important;
  visibility: visible !important;
  overflow: visible !important;
  box-sizing: border-box !important;
  border-top: .35mm solid #f15a24 !important;
  background: #fff !important;
  z-index: 22 !important;
}

#modal-root .receipt-redesigned .receipt-redesign-head,
#modal-root .receipt-redesigned .receipt-redesign-total,
#modal-root .receipt-redesigned .receipt-redesign-note,
#modal-root .receipt-redesigned .receipt-redesign-confirmation,
#modal-root .receipt-redesigned .receipt-redesigned-signatures,
#modal-root .receipt-redesigned .receipt-redesign-signatures {
  flex: 0 0 auto !important;
}

#modal-root .receipt-redesigned .receipt-redesign-items-section {
  display: flex !important;
  flex: 1 1 auto !important;
  flex-direction: column !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

#modal-root .receipt-redesigned .receipt-redesign-items-section .receipt-redesign-section-title {
  flex: 0 0 auto !important;
}

#modal-root .receipt-redesigned .receipt-redesign-items-section .receipt-redesign-items {
  display: table !important;
  flex: 1 1 auto !important;
  height: 100% !important;
  min-height: 0 !important;
  margin-bottom: 0 !important;
}

#modal-root .technical-preview-wrap > .technical-paper:not(.document-attachment-page) {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  position: relative !important;
  box-sizing: border-box !important;
  width: 210mm !important;
  min-width: 210mm !important;
  max-width: 210mm !important;
  height: 297mm !important;
  min-height: 297mm !important;
  max-height: 297mm !important;
  margin: 0 auto !important;
  padding: 0 24mm 8mm 14mm !important;
  overflow: hidden !important;
  background: #fff !important;
}

#modal-root .technical-preview-wrap > .technical-paper:not(.document-attachment-page) > .official-letterhead-image,
#modal-root .technical-preview-wrap > .technical-paper:not(.document-attachment-page) > .technical-official-letterhead,
#modal-root .technical-preview-wrap > .technical-paper:not(.document-attachment-page) > .invoice-native-letterhead {
  position: absolute !important;
  inset: 0 !important;
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  object-fit: fill !important;
  z-index: 1 !important;
  visibility: visible !important;
}

#modal-root .technical-preview-wrap > .technical-paper:not(.document-attachment-page) > :not(.official-letterhead-image):not(.technical-official-letterhead):not(.invoice-native-letterhead) {
  position: relative !important;
  z-index: 2 !important;
}

#modal-root .technical-preview-wrap > .technical-paper:not(.document-attachment-page) > .technical-paper-head {
  flex: 0 0 34mm !important;
  min-height: 34mm !important;
  margin: 0 !important;
  padding: 0 0 5mm !important;
  border-bottom: 0 !important;
  z-index: 2 !important;
}

#modal-root .technical-preview-wrap > .technical-paper:not(.document-attachment-page) > .technical-paper-footer {
  position: static !important;
  order: 99 !important;
  flex: 0 0 7mm !important;
  min-height: 7mm !important;
  width: auto !important;
  margin: auto -11mm 0 -1mm !important;
  padding: 2mm 0 0 !important;
  border-top: .35mm solid #f15a24 !important;
  box-sizing: border-box !important;
  background: #fff !important;
  z-index: 3 !important;
}

@media print {
  body.printing-receipt #modal-root .receipt-preview-wrap > .receipt-paper.print-page > .receipt-redesigned-content {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    position: absolute !important;
    top: 34mm !important;
    right: 24mm !important;
    bottom: 19mm !important;
    left: 14mm !important;
    width: auto !important;
    height: auto !important;
    max-height: none !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  body.printing-receipt #modal-root .receipt-preview-wrap > .receipt-paper.print-page .receipt-redesign-items-section {
    display: flex !important;
    flex: 1 1 auto !important;
    flex-direction: column !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  body.printing-receipt #modal-root .receipt-preview-wrap > .receipt-paper.print-page .receipt-redesign-items-section .receipt-redesign-items {
    flex: 1 1 auto !important;
    height: 100% !important;
    min-height: 0 !important;
    margin-bottom: 0 !important;
  }

  body.printing-technical-report #modal-root .technical-preview-wrap > .technical-paper.print-page:not(.document-attachment-page) {
    display: flex !important;
    flex-direction: column !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    margin: 0 !important;
    padding: 0 24mm 8mm 14mm !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  body.printing-technical-report #modal-root .technical-preview-wrap > .technical-paper.print-page:not(.document-attachment-page) > .technical-paper-footer {
    position: static !important;
    order: 99 !important;
    flex: 0 0 7mm !important;
    margin: auto -11mm 0 -1mm !important;
  }

  body.printing-invoice #modal-root .invoice-preview-wrap > .document-attachment-print-page,
  body.printing-invoice #modal-root .invoice-preview > .document-attachment-print-page,
  body.printing-receipt #modal-root .receipt-preview-wrap > .document-attachment-print-page,
  body.printing-quality #modal-root .quality-preview-wrap > .document-attachment-print-page,
  body.printing-technical-report #modal-root .technical-preview-wrap > .document-attachment-print-page,
  body.printing-letter #modal-root .letter-preview-wrap > .document-attachment-print-page {
    display: block !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    break-before: page !important;
    page-break-before: always !important;
    break-after: page !important;
    page-break-after: always !important;
  }

  body.printing-invoice #modal-root .invoice-preview > .document-attachment-print-page.print-page-last,
  body.printing-receipt #modal-root .receipt-preview-wrap > .document-attachment-print-page.print-page-last,
  body.printing-quality #modal-root .quality-preview-wrap > .document-attachment-print-page.print-page-last,
  body.printing-technical-report #modal-root .technical-preview-wrap > .document-attachment-print-page.print-page-last,
  body.printing-letter #modal-root .letter-preview-wrap > .document-attachment-print-page.print-page-last {
    break-after: auto !important;
    page-break-after: auto !important;
  }
}

/* Keep the DOM geometry identical during the print transition too. The
   preview is measured on screen while the browser toggles body.printing-letter;
   old screen rules must not temporarily shrink it to the legacy A5 preset. */
@media screen, print {
  html body #modal-root .letter-preview-wrap > .letter-paper:not(.letterhead-horizontal) {
    page: afv-document-a4-locked !important;
    display: block !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  html body.printing-letter #modal-root .letter-preview-wrap {
    display: block !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  html body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.print-page:not(.letterhead-horizontal),
  html body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.print-page.letter-attachment-page:not(.letterhead-horizontal) {
    page: afv-document-a4-locked !important;
    display: block !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    break-before: auto !important;
    break-inside: avoid !important;
    break-after: page !important;
  }

html body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.print-page:last-child {
    break-after: auto !important;
    page-break-after: auto !important;
  }
}

/* Unified outgoing letterhead lock (2026-09-19 / q40).
   Every outgoing CRM document uses the same A4 image as the outgoing letter.
   Attachments are separate pages and are intentionally excluded.  The common
   metadata block is anchored in the blank upper-left area of that letterhead;
   all document bodies use the same 34/24/19/14mm safe zone. */
@media screen, print {
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) {
    position: relative !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    isolation: isolate !important;
    background: #fff !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image {
    position: absolute !important;
    inset: 0 !important;
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    object-fit: fill !important;
    object-position: center !important;
    pointer-events: none !important;
    visibility: visible !important;
    z-index: 1 !important;
  }

  html body #modal-root .official-document-meta {
    position: absolute !important;
    top: 9mm !important;
    right: auto !important;
    bottom: auto !important;
    left: 8mm !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    width: max-content !important;
    min-width: 0 !important;
    max-width: 52mm !important;
    gap: 1mm !important;
    margin: 0 !important;
    padding: 0 !important;
    direction: ltr !important;
    text-align: left !important;
    color: #17202b !important;
    background: transparent !important;
    border: 0 !important;
    z-index: 4 !important;
    pointer-events: none !important;
  }

  html body #modal-root .official-document-meta > div {
    display: grid !important;
    grid-template-columns: 34mm max-content !important;
    grid-template-areas: "value label" !important;
    grid-template-rows: auto !important;
    align-items: baseline !important;
    justify-content: start !important;
    width: max-content !important;
    min-width: 0 !important;
    max-width: 52mm !important;
    gap: 3mm !important;
    direction: ltr !important;
    white-space: nowrap !important;
  }

  html body #modal-root .official-document-meta > div > strong {
    grid-area: label !important;
    display: block !important;
    width: max-content !important;
    min-width: 0 !important;
    color: #17202b !important;
    font-size: 8.5pt !important;
    font-weight: 400 !important;
    line-height: 1.25 !important;
    direction: rtl !important;
    text-align: right !important;
    white-space: nowrap !important;
  }

  html body #modal-root .official-document-meta > div > span {
    grid-area: value !important;
    display: block !important;
    width: 34mm !important;
    min-width: 34mm !important;
    max-width: 34mm !important;
    overflow: visible !important;
    color: #17202b !important;
    font-size: 8.5pt !important;
    font-weight: 400 !important;
    line-height: 1.25 !important;
    direction: ltr !important;
    text-align: left !important;
    unicode-bidi: isolate !important;
    white-space: nowrap !important;
  }

  /* The old in-body metadata is retained in the markup for non-print fallback,
     but the unified top-left block is the only printed organization metadata. */
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) .invoice-paper-meta,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page) .receipt-redesign-meta,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page) .receipt-meta-grid,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page) .check-receipt-meta,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) .technical-paper-code {
    display: none !important;
    visibility: hidden !important;
  }

  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) .receipt-redesign-head {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) .receipt-redesign-head > div:first-child:has(.receipt-redesign-meta) {
    display: none !important;
  }

  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) .receipt-redesign-title {
    grid-column: 1 !important;
    text-align: center !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content {
    position: relative !important;
    z-index: 2 !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 100% !important;
    max-height: 100% !important;
    margin: 0 !important;
    padding: 34mm 24mm 19mm 14mm !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) > .receipt-redesigned-content,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page) > .check-receipt-v3-content {
    position: absolute !important;
    top: 34mm !important;
    right: 24mm !important;
    bottom: 19mm !important;
    left: 14mm !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    z-index: 2 !important;
  }

  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-paper-head,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-head,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-meta-grid,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-meta-grid,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > section,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > section,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-signature-grid,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-signature-grid,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-paper-footer,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-footer {
    position: relative !important;
    z-index: 2 !important;
  }

  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-paper-head,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-head {
    flex: 0 0 34mm !important;
    height: 34mm !important;
    min-height: 34mm !important;
    max-height: 34mm !important;
    margin: 0 !important;
    padding: 0 0 5mm !important;
    box-sizing: border-box !important;
    border: 0 !important;
  }

  /* The image already owns the official footer; internal document footers only
     carry page/coding metadata and stay above the orange rule. */
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) .invoice-paper-footer,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page) .receipt-paper-footer,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page) .check-receipt-footer,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-official-footer,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-official-footer {
    display: none !important;
  }
}

@media print {
  html body #modal-root .official-document-meta {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}

/* Release-gate print shell reset.
   The document must be paginated as one A4 flow, not as the scrollable modal
   that hosts the on-screen preview.  Keeping the modal max-height/overflow in
   the print tree clips later rows and produces blank trailing pages in saved
   PDFs.  Approval/readiness controls are interaction-only and must not enter
   the printable flow. */
@media print {
  html body.printing-invoice #modal-root,
  html body.printing-letter #modal-root,
  html body.printing-receipt #modal-root,
  html body.printing-check-receipt #modal-root,
  html body.printing-check-receipt-a4 #modal-root,
  html body.printing-quality #modal-root,
  html body.printing-technical-report #modal-root,
  html body.printing-invoice #modal-root > .modal-backdrop,
  html body.printing-letter #modal-root > .modal-backdrop,
  html body.printing-receipt #modal-root > .modal-backdrop,
  html body.printing-check-receipt #modal-root > .modal-backdrop,
  html body.printing-check-receipt-a4 #modal-root > .modal-backdrop,
  html body.printing-quality #modal-root > .modal-backdrop,
  html body.printing-technical-report #modal-root > .modal-backdrop,
  html body.printing-invoice #modal-root .modal-card,
  html body.printing-letter #modal-root .modal-card,
  html body.printing-receipt #modal-root .modal-card,
  html body.printing-check-receipt #modal-root .modal-card,
  html body.printing-check-receipt-a4 #modal-root .modal-card,
  html body.printing-quality #modal-root .modal-card,
  html body.printing-technical-report #modal-root .modal-card {
    position: static !important;
    inset: auto !important;
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    transform: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
  }

  html body.printing-invoice #modal-root > .modal-backdrop,
  html body.printing-letter #modal-root > .modal-backdrop,
  html body.printing-receipt #modal-root > .modal-backdrop,
  html body.printing-check-receipt #modal-root > .modal-backdrop,
  html body.printing-check-receipt-a4 #modal-root > .modal-backdrop,
  html body.printing-quality #modal-root > .modal-backdrop,
  html body.printing-technical-report #modal-root > .modal-backdrop {
    background: transparent !important;
    backdrop-filter: none !important;
  }

  html body.printing-invoice #modal-root .modal-header,
  html body.printing-letter #modal-root .modal-header,
  html body.printing-receipt #modal-root .modal-header,
  html body.printing-check-receipt #modal-root .modal-header,
  html body.printing-check-receipt-a4 #modal-root .modal-header,
  html body.printing-quality #modal-root .modal-header,
  html body.printing-technical-report #modal-root .modal-header,
  html body.printing-invoice #modal-root .modal-footer,
  html body.printing-letter #modal-root .modal-footer,
  html body.printing-receipt #modal-root .modal-footer,
  html body.printing-check-receipt #modal-root .modal-footer,
  html body.printing-check-receipt-a4 #modal-root .modal-footer,
  html body.printing-quality #modal-root .modal-footer,
  html body.printing-technical-report #modal-root .modal-footer,
  html body.printing-invoice #modal-root .invoice-approval-panel,
  html body.printing-invoice #modal-root .delivery-readiness-panel {
    display: none !important;
  }

  html body.printing-invoice #modal-root .invoice-preview,
  html body.printing-letter #modal-root .letter-preview-wrap,
  html body.printing-receipt #modal-root .receipt-preview-wrap,
  html body.printing-check-receipt #modal-root .check-receipt-preview-wrap,
  html body.printing-check-receipt-a4 #modal-root .check-receipt-preview-wrap,
  html body.printing-quality #modal-root .quality-preview-wrap,
  html body.printing-technical-report #modal-root .technical-preview-wrap {
    max-height: none !important;
    overflow: visible !important;
  }
}

/* Last screen/print parity lock for letters. */
@media screen, print {
  html body.printing-letter #modal-root .letter-preview-wrap {
    display: block !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  html body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.print-page:not(.letterhead-horizontal),
  html body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.print-page.letter-attachment-page:not(.letterhead-horizontal) {
    page: afv-document-a4-locked !important;
    display: block !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    break-before: auto !important;
    break-inside: avoid !important;
    break-after: page !important;
  }

  html body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.print-page:last-child {
    break-after: auto !important;
    page-break-after: auto !important;
  }
}

/* Final precedence lock: unified outgoing letterhead and organization metadata.
   This block is deliberately the last rule in the file so legacy document
   presets cannot move the shared header, metadata, or safe content zone. */
@media screen, print {
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) {
    position: relative !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    isolation: isolate !important;
    background: #fff !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image {
    position: absolute !important;
    inset: 0 !important;
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    object-fit: fill !important;
    object-position: center !important;
    pointer-events: none !important;
    visibility: visible !important;
    z-index: 1 !important;
  }

  html body #modal-root .official-document-meta {
    position: absolute !important;
    top: 9mm !important;
    right: auto !important;
    bottom: auto !important;
    left: 8mm !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    width: max-content !important;
    min-width: 0 !important;
    max-width: 52mm !important;
    gap: 1mm !important;
    margin: 0 !important;
    padding: 0 !important;
    direction: ltr !important;
    text-align: left !important;
    background: transparent !important;
    border: 0 !important;
    z-index: 4 !important;
    pointer-events: none !important;
  }

  html body #modal-root .official-document-meta > div {
    display: grid !important;
    grid-template-columns: 34mm max-content !important;
    grid-template-areas: "value label" !important;
    align-items: baseline !important;
    justify-content: start !important;
    width: max-content !important;
    min-width: 0 !important;
    max-width: 52mm !important;
    gap: 3mm !important;
    direction: ltr !important;
    white-space: nowrap !important;
  }

  html body #modal-root .official-document-meta > div > strong {
    grid-area: label !important;
    display: block !important;
    width: max-content !important;
    color: #17202b !important;
    font-size: 8.5pt !important;
    font-weight: 400 !important;
    line-height: 1.25 !important;
    direction: rtl !important;
    text-align: right !important;
    white-space: nowrap !important;
  }

  html body #modal-root .official-document-meta > div > span {
    grid-area: value !important;
    display: block !important;
    width: 34mm !important;
    min-width: 34mm !important;
    max-width: 34mm !important;
    overflow: visible !important;
    color: #17202b !important;
    font-size: 8.5pt !important;
    font-weight: 400 !important;
    line-height: 1.25 !important;
    direction: ltr !important;
    text-align: left !important;
    unicode-bidi: isolate !important;
    white-space: nowrap !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content {
    position: relative !important;
    z-index: 2 !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 100% !important;
    max-height: 100% !important;
    margin: 0 !important;
    padding: 34mm 24mm 19mm 14mm !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) > .receipt-redesigned-content,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page) > .check-receipt-v3-content {
    position: absolute !important;
    top: 34mm !important;
    right: 24mm !important;
    bottom: 19mm !important;
    left: 14mm !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    z-index: 2 !important;
  }

  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) .receipt-redesign-head {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) .receipt-redesign-head > div:first-child:has(.receipt-redesign-meta),
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) .invoice-paper-meta,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page) .receipt-redesign-meta,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page) .receipt-meta-grid,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page) .check-receipt-meta,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) .technical-paper-code {
    display: none !important;
    visibility: hidden !important;
  }

  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) .receipt-redesign-title {
    grid-column: 1 !important;
    text-align: center !important;
  }

  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-paper-head,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-head,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-meta-grid,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-meta-grid,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > section,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > section,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-signature-grid,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-signature-grid,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-paper-footer,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-footer {
    position: relative !important;
    z-index: 2 !important;
  }

  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-paper-head,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-head {
    flex: 0 0 34mm !important;
    height: 34mm !important;
    min-height: 34mm !important;
    max-height: 34mm !important;
    margin: 0 !important;
    padding: 0 0 5mm !important;
    box-sizing: border-box !important;
    border: 0 !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) .invoice-paper-footer,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page) .receipt-paper-footer,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page) .check-receipt-footer,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-official-footer,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-official-footer {
    display: none !important;
  }
}

/* Keep report titles in the same three-column safe zone used by invoices. */
@media screen, print {
  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-paper-head,
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-head {
    display: grid !important;
    grid-template-columns: 48mm minmax(0, 1fr) 48mm !important;
    align-items: center !important;
    gap: 4mm !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-paper-head > div:first-child,
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-head > div:first-child {
    grid-column: 2 !important;
    grid-row: 1 !important;
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    text-align: center !important;
  }

  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-head > .technical-paper-code {
    grid-column: 3 !important;
    grid-row: 1 !important;
    width: auto !important;
    min-width: 0 !important;
    margin: 0 !important;
  }
}

/* Non-letter documents use the invoice letterhead as the single source of truth.
   The legacy check-receipt paper draws its blue top stripe with ::before;
   suppress it whenever the unified A4 letterhead is present. */
#modal-root .check-receipt-paper.has-letterhead::before,
#modal-root .check-receipt-paper.has-letterhead::after {
  display: none !important;
  content: none !important;
  background: none !important;
  border: 0 !important;
}

#modal-root .check-receipt-paper.has-letterhead {
  border-top: 0 !important;
}

/* Letter metadata alignment and normal typography (2026-09-19 / qa13). */
#modal-root .letter-paper > .letter-meta,
#modal-root .letter-paper.has-letterhead > .letter-meta,
#modal-root .letter-paper > .letter-meta > div > strong,
#modal-root .letter-paper > .letter-meta > div > span,
#modal-root .letter-paper.has-letterhead > .letter-meta > div > strong,
#modal-root .letter-paper.has-letterhead > .letter-meta > div > span {
  font-weight: 400 !important;
}

#modal-root .letter-paper > .letter-meta > div > strong,
#modal-root .letter-paper.has-letterhead > .letter-meta > div > strong {
  text-align: right !important;
}

#modal-root .letter-paper > .letter-meta > div > span,
#modal-root .letter-paper.has-letterhead > .letter-meta > div > span {
  direction: ltr !important;
  text-align: left !important;
  unicode-bidi: plaintext !important;
}

/* Readable A4 outgoing letters (2026-09-27 / v1.2.1).
   The released letterhead and safe zone remain unchanged.  Only the letter's
   own typography and vertical rhythm are enlarged so the preview and browser
   PDF use the available A4 content area instead of rendering a tiny block. */
@media screen, print {
  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) > .letter-document {
    top: 34mm !important;
    right: 24mm !important;
    bottom: 34mm !important;
    left: 14mm !important;
    padding: 0 !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) .letter-basmala {
    font-size: 22pt !important;
    line-height: 1.35 !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) .letter-recipient {
    margin-top: 20mm !important;
    font-size: 16pt !important;
    line-height: 1.8 !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) .letter-subject {
    margin-top: 10mm !important;
    font-size: 14pt !important;
    line-height: 1.8 !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) .letter-body-content {
    margin-top: 10mm !important;
    font-size: 14pt !important;
    line-height: 2.15 !important;
    text-align: justify !important;
    text-align-last: right !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) .letter-body-content p {
    margin-bottom: 6mm !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) .letter-attachment-detail {
    margin-top: 7mm !important;
    padding: 4mm 5mm !important;
    font-size: 10.5pt !important;
    line-height: 1.8 !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) .letter-signature-area {
    width: 70mm !important;
    margin-top: 13mm !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) .letter-closing {
    font-size: 13pt !important;
    line-height: 1.7 !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) .letter-signature-area > strong {
    font-size: 13pt !important;
    line-height: 1.7 !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) .letter-signature-area > span {
    margin-top: 2mm !important;
    font-size: 11.5pt !important;
    line-height: 1.6 !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) .letter-meta > div > strong,
  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) .letter-meta > div > span {
    font-size: 10.5pt !important;
    line-height: 1.45 !important;
  }
}

@media print {
  #modal-root .letter-paper > .letter-meta > div > strong,
  #modal-root .letter-paper > .letter-meta > div > span,
  #modal-root .letter-paper.has-letterhead > .letter-meta > div > strong,
  #modal-root .letter-paper.has-letterhead > .letter-meta > div > span {
    font-weight: 400 !important;
  }

  #modal-root .letter-paper > .letter-meta > div > span,
  #modal-root .letter-paper.has-letterhead > .letter-meta > div > span {
    direction: ltr !important;
    text-align: left !important;
    unicode-bidi: plaintext !important;
  }
}

/* فاکتور: صفحهٔ نهایی باید جدول، جمع و توضیحات را پشت‌سرهم نگه دارد.
   این لایه بعد از overrideهای قدیمی بارگذاری می‌شود تا tbody نتواند
   فضای summary/توضیحات را بپوشاند یا برای صفحهٔ سفید بعدی overflow بسازد. */
#modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) {
  position: relative !important;
  display: block !important;
  width: 210mm !important;
  min-width: 210mm !important;
  max-width: 210mm !important;
  height: 297mm !important;
  min-height: 297mm !important;
  max-height: 297mm !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
  page-break-inside: avoid !important;
  break-inside: avoid !important;
}

#modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) > .invoice-paper-content {
  position: absolute !important;
  top: 34mm !important;
  right: 24mm !important;
  bottom: 19mm !important;
  left: 14mm !important;
  width: auto !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
}

#modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) > .invoice-paper-content > .invoice-paper-table {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  max-height: none !important;
}

#modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) > .invoice-paper-content > .invoice-paper-table > tbody {
  height: 100% !important;
}

/* فقط صفحه‌ای که جمع/توضیحات دارد، جدول را به ارتفاع مصنوعی نمی‌کشیم. */
#modal-root .invoice-preview > .invoice-paper:has(> .invoice-paper-content.print-page-has-signature) > .invoice-paper-content > .invoice-paper-table {
  flex: 0 0 auto !important;
  height: auto !important;
  min-height: 0 !important;
}

#modal-root .invoice-preview > .invoice-paper:has(> .invoice-paper-content.print-page-has-signature) > .invoice-paper-content > .invoice-paper-table > tbody {
  height: auto !important;
}

#modal-root .invoice-preview > .invoice-paper:has(> .invoice-paper-content.print-page-has-signature) > .invoice-paper-content > .invoice-summary-grid {
  flex: 0 0 auto !important;
  height: auto !important;
  min-height: 0 !important;
  margin-top: 4mm !important;
  break-inside: avoid !important;
  page-break-inside: avoid !important;
}

#modal-root .invoice-preview > .invoice-paper.print-page {
  break-after: page !important;
  page-break-after: always !important;
}

#modal-root .invoice-preview > .invoice-paper.print-page.print-page-last {
  break-after: auto !important;
  page-break-after: auto !important;
}

@media print {
  body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page > .invoice-paper-content {
    position: absolute !important;
    top: 34mm !important;
    right: 24mm !important;
    bottom: 19mm !important;
    left: 14mm !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page > .invoice-paper-content > .invoice-paper-table {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    flex: 1 1 auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    box-sizing: border-box !important;
  }

  body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page > .invoice-paper-content > .invoice-paper-table > tbody {
    height: 100% !important;
  }

  body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page > .invoice-paper-content.print-page-has-signature > .invoice-paper-table {
    flex: 0 0 auto !important;
    height: auto !important;
    min-height: 0 !important;
  }

  body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page > .invoice-paper-content.print-page-has-signature > .invoice-paper-table > tbody {
    height: auto !important;
  }

  body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page > .invoice-paper-content.print-page-has-signature > .invoice-summary-grid {
    flex: 0 0 auto !important;
    height: auto !important;
    min-height: 0 !important;
    margin-top: 4mm !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page {
    break-after: page !important;
    page-break-after: always !important;
  }

  body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page.print-page-last {
    break-after: auto !important;
    page-break-after: auto !important;
  }
}

/* Final letter visual lock (2026-09-19 / qa10). */
#modal-root .letter-paper > .letter-meta,
#modal-root .letter-paper.has-letterhead > .letter-meta {
  top: 9mm !important;
  left: 8mm !important;
  width: max-content !important;
  min-width: 0 !important;
  max-width: none !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  gap: 1mm !important;
  text-align: left !important;
}

#modal-root .letter-paper > .letter-meta > div,
#modal-root .letter-paper.has-letterhead > .letter-meta > div {
  display: grid !important;
  grid-template-columns: max-content max-content !important;
  width: max-content !important;
  min-width: 0 !important;
  max-width: none !important;
  gap: 2mm !important;
  justify-content: start !important;
  align-items: baseline !important;
  direction: rtl !important;
}

#modal-root .letter-paper > .letter-meta > div > strong,
#modal-root .letter-paper > .letter-meta > div > span,
#modal-root .letter-paper.has-letterhead > .letter-meta > div > strong,
#modal-root .letter-paper.has-letterhead > .letter-meta > div > span {
  display: block !important;
  width: max-content !important;
  min-width: 0 !important;
  white-space: nowrap !important;
}

#modal-root .letter-signature-area,
#modal-root .letter-signature-image {
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
}

/* Letter stamp: render at a physical, readable size in both preview and PDF.
   The previous generic image rules left the stamp at its intrinsic pixel size,
   which made it appear much smaller than the real stamp on printed letters. */
#modal-root .letter-stamp-image {
  display: block !important;
  width: 40mm !important;
  max-width: 40mm !important;
  height: auto !important;
  max-height: 40mm !important;
  object-fit: contain !important;
  object-position: center !important;
  margin: 4mm auto 0 !important;
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  image-rendering: auto !important;
}

#modal-root .letter-signature-filter-defs {
  position: fixed !important;
  top: -2px !important;
  left: -2px !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

#modal-root .letter-signature-image {
  width: 140px !important;
  max-width: 140px !important;
  max-height: 30mm !important;
  height: auto !important;
  object-fit: contain !important;
  object-position: center !important;
  margin: 0 auto -1px !important;
  clip-path: inset(1.5% 1.2% 1.5% 1.2%) !important;
  filter: none !important;
  mix-blend-mode: multiply !important;
  image-rendering: auto !important;
}

@media print {
  #modal-root .letter-paper > .letter-meta,
  #modal-root .letter-paper.has-letterhead > .letter-meta {
    width: max-content !important;
    gap: 1mm !important;
  }

  #modal-root .letter-paper > .letter-meta > div,
  #modal-root .letter-paper.has-letterhead > .letter-meta > div {
    grid-template-columns: max-content max-content !important;
    width: max-content !important;
    gap: 2mm !important;
  }

  #modal-root .letter-signature-image {
    width: 140px !important;
    max-width: 140px !important;
    filter: none !important;
    mix-blend-mode: multiply !important;
  }

  #modal-root .letter-stamp-image {
    width: 40mm !important;
    max-width: 40mm !important;
    max-height: 40mm !important;
    margin-top: 4mm !important;
  }
}

/* Final QC / Technical report print lock (2026-09-19 / document-qa-12). */
#modal-root .quality-signature-image,
#modal-root .technical-signature-image {
  width: 130px !important;
  max-width: 100% !important;
  height: auto !important;
  max-height: 25mm !important;
  object-fit: contain !important;
  object-position: center !important;
  margin: 4px auto 0 !important;
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  clip-path: inset(1.5% 1.2% 1.5% 1.2%) !important;
  filter: url("#afv-signature-remove-white") !important;
  mix-blend-mode: multiply !important;
  image-rendering: auto !important;
}

#modal-root .afv-signature-filter-defs {
  position: fixed !important;
  top: -2px !important;
  left: -2px !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

@media print {
  /* Firefox با شکست before و after هم‌زمان یک صفحهٔ سفید تولید می‌کند. */
  body.printing-quality #modal-root .quality-preview-wrap > .document-attachment-print-page,
  body.printing-technical-report #modal-root .technical-preview-wrap > .document-attachment-print-page {
    break-before: auto !important;
    page-break-before: auto !important;
  }

  body.printing-quality #modal-root .quality-preview-wrap > .quality-paper.print-page:not(.print-page-last),
  body.printing-technical-report #modal-root .technical-preview-wrap > .technical-paper.print-page:not(.print-page-last) {
    break-after: page !important;
    page-break-after: always !important;
  }

  body.printing-quality #modal-root .quality-preview-wrap > .print-page-last,
  body.printing-technical-report #modal-root .technical-preview-wrap > .print-page-last {
    break-after: auto !important;
    page-break-after: auto !important;
  }

  body.printing-quality #modal-root .quality-signature-image,
  body.printing-technical-report #modal-root .technical-signature-image {
    filter: url("#afv-signature-remove-white") !important;
    mix-blend-mode: multiply !important;
  }
}

/* Technical report header safe zone (2026-09-19 / qa14).
   The official letterhead image already contains the logo and vertical rule.
   Keep the report title below that artwork instead of painting it at y=0. */
#modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) {
  padding-top: 28mm !important;
}

#modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-head {
  flex-basis: 28mm !important;
  height: 28mm !important;
  min-height: 28mm !important;
  max-height: 28mm !important;
}

@media print {
  body.printing-technical-report #modal-root .technical-preview-wrap > .technical-paper.print-page.has-letterhead:not(.document-attachment-page) {
    padding-top: 28mm !important;
  }

  body.printing-technical-report #modal-root .technical-preview-wrap > .technical-paper.print-page.has-letterhead:not(.document-attachment-page) > .technical-paper-head {
    flex-basis: 28mm !important;
    height: 28mm !important;
    min-height: 28mm !important;
    max-height: 28mm !important;
  }
}

/* Letter metadata four-row alignment (2026-09-19 / qa16).
   Keep the labels in one right-hand column and the values in one fixed
   left-hand column, matching the approved reference image in preview/print. */
#modal-root .letter-paper > .letter-meta,
#modal-root .letter-paper.has-letterhead > .letter-meta {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: 1mm !important;
  width: max-content !important;
  min-width: 0 !important;
}

#modal-root .letter-paper > .letter-meta > div,
#modal-root .letter-paper.has-letterhead > .letter-meta > div {
  display: grid !important;
  grid-template-columns: 32px 140px !important;
  grid-template-rows: auto !important;
  width: max-content !important;
  min-width: 0 !important;
  gap: 2mm !important;
  justify-content: start !important;
  align-items: baseline !important;
  direction: rtl !important;
}

#modal-root .letter-paper > .letter-meta > div > strong,
#modal-root .letter-paper.has-letterhead > .letter-meta > div > strong {
  grid-column: 1 !important;
  text-align: left !important;
  direction: rtl !important;
}

#modal-root .letter-paper > .letter-meta > div > span,
#modal-root .letter-paper.has-letterhead > .letter-meta > div > span {
  grid-column: 2 !important;
  text-align: right !important;
  direction: ltr !important;
  unicode-bidi: plaintext !important;
}

@media print {
  #modal-root .letter-paper > .letter-meta > div,
  #modal-root .letter-paper.has-letterhead > .letter-meta > div {
    grid-template-columns: 32px 140px !important;
  }

  #modal-root .letter-paper > .letter-meta > div > strong,
  #modal-root .letter-paper.has-letterhead > .letter-meta > div > strong {
    grid-column: 1 !important;
    text-align: left !important;
  }

  #modal-root .letter-paper > .letter-meta > div > span,
  #modal-root .letter-paper.has-letterhead > .letter-meta > div > span {
    grid-column: 2 !important;
    text-align: right !important;
    direction: ltr !important;
  }
}

/* Unified non-letter document letterhead (2026-09-19 / unified-doc-head-20).
   Quality and technical reports must use the same native A4 header/footer as
   the approved invoice template. The native footer owns the orange rule;
   page metadata sits immediately above it and never becomes a second footer. */
@page afv-document-a4-unified {
  size: A4 portrait;
  margin: 0;
}

@media screen, print {
  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page),
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    position: relative !important;
    box-sizing: border-box !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    margin: 0 auto !important;
    padding: 0 24mm 15mm 14mm !important;
    overflow: hidden !important;
    background: #fff !important;
    page: afv-document-a4-unified !important;
  }

  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .invoice-native-letterhead,
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .invoice-native-letterhead {
    position: absolute !important;
    inset: 0 !important;
    display: block !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-width: none !important;
    overflow: visible !important;
    pointer-events: none !important;
    z-index: 20 !important;
  }

  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > :not(.invoice-native-letterhead),
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > :not(.invoice-native-letterhead) {
    position: relative !important;
    z-index: 2 !important;
  }

  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-paper-head,
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-head {
    flex: 0 0 34mm !important;
    height: 34mm !important;
    min-height: 34mm !important;
    max-height: 34mm !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 0 5mm !important;
    box-sizing: border-box !important;
    border: 0 !important;
  }

  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-page-info,
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-footer {
    order: 98 !important;
    flex: 0 0 5mm !important;
    height: 5mm !important;
    min-height: 5mm !important;
    max-height: 5mm !important;
    width: 100% !important;
    margin: auto 0 0 !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 5mm !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    background: #fff !important;
    border: 0 !important;
    color: #43515a !important;
    font-size: 7.5pt !important;
    font-weight: 400 !important;
    line-height: 1.35 !important;
    direction: rtl !important;
    z-index: 22 !important;
  }

  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-page-info > span,
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-footer > span {
    display: block !important;
    flex: 0 1 auto !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    font-size: 7.5pt !important;
    font-weight: 400 !important;
    line-height: 1.35 !important;
  }

  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-page-info > span:first-child,
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-footer > span:first-child {
    text-align: right !important;
    direction: rtl !important;
  }

  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-page-info > span:last-child,
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-footer > span:last-child {
    text-align: left !important;
    direction: rtl !important;
  }

  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) .invoice-native-footer,
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) .invoice-native-footer {
    position: absolute !important;
    top: auto !important;
    right: 13mm !important;
    bottom: 8mm !important;
    left: 13mm !important;
    width: auto !important;
    height: 7mm !important;
    min-height: 7mm !important;
    max-height: 7mm !important;
    margin: 0 !important;
    padding: 2mm 0 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 4mm !important;
    box-sizing: border-box !important;
    overflow: visible !important;
    border-top: .35mm solid #f15a24 !important;
    background: #fff !important;
    color: #43515a !important;
    font-size: 7.5pt !important;
    font-weight: 400 !important;
    line-height: 1.35 !important;
    white-space: nowrap !important;
    direction: rtl !important;
    z-index: 24 !important;
  }

  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) .invoice-native-footer > *,
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) .invoice-native-footer > * {
    display: block !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    font-size: 7.5pt !important;
    font-weight: 400 !important;
    line-height: 1.35 !important;
  }

  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) .invoice-native-footer > .invoice-footer-address,
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) .invoice-native-footer > .invoice-footer-address {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    text-align: right !important;
    direction: rtl !important;
  }

  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) .invoice-native-footer > .invoice-footer-contacts,
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) .invoice-native-footer > .invoice-footer-contacts {
    flex: 0 0 auto !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4mm !important;
    direction: ltr !important;
    color: #f15a24 !important;
  }

  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) .invoice-native-footer > .invoice-footer-website,
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) .invoice-native-footer > .invoice-footer-website {
    flex: 0 0 auto !important;
    color: #f15a24 !important;
    font-weight: 800 !important;
    text-align: left !important;
    direction: ltr !important;
  }

  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) .invoice-footer-phone,
  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) .invoice-footer-fax,
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) .invoice-footer-phone,
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) .invoice-footer-fax,
  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) .invoice-footer-phone *,
  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) .invoice-footer-fax *,
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) .invoice-footer-phone *,
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) .invoice-footer-fax * {
    font-size: 7.5pt !important;
    line-height: 1.35 !important;
  }

  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-official-header,
  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-official-footer {
    display: none !important;
  }
}

@media print {
  body.printing-quality #modal-root .quality-preview-wrap > .quality-paper.print-page.has-letterhead:not(.document-attachment-page),
  body.printing-technical-report #modal-root .technical-preview-wrap > .technical-paper.print-page.has-letterhead:not(.document-attachment-page) {
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    margin: 0 !important;
    padding: 0 24mm 15mm 14mm !important;
    page: afv-document-a4-unified !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  body.printing-quality #modal-root .quality-preview-wrap > .quality-paper.print-page.has-letterhead:not(.document-attachment-page) > .invoice-native-letterhead,
  body.printing-technical-report #modal-root .technical-preview-wrap > .technical-paper.print-page.has-letterhead:not(.document-attachment-page) > .invoice-native-letterhead {
    display: block !important;
    position: absolute !important;
    inset: 0 !important;
    width: auto !important;
    height: auto !important;
    z-index: 20 !important;
  }
}

/* Letter metadata final geometry (2026-09-19 / qa25).
   The previous qa17 rule used an RTL grid and right-aligned the value cell.
   Keep the DOM order, but make the two columns explicit: value on the left,
   label on the right. This keeps mixed Persian and Latin digits stable. */
@media screen, print {
  #modal-root .letter-paper > .letter-meta,
  #modal-root .letter-paper.has-letterhead > .letter-meta {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    width: max-content !important;
    min-width: 0 !important;
    max-width: none !important;
    gap: 1mm !important;
    direction: ltr !important;
    text-align: left !important;
  }

  #modal-root .letter-paper > .letter-meta > div,
  #modal-root .letter-paper.has-letterhead > .letter-meta > div {
    display: grid !important;
    grid-template-columns: 34mm max-content !important;
    grid-template-areas: "value label" !important;
    grid-template-rows: auto !important;
    width: max-content !important;
    min-width: 0 !important;
    max-width: none !important;
    gap: 3mm !important;
    justify-content: start !important;
    align-items: baseline !important;
    direction: ltr !important;
  }

  #modal-root .letter-paper > .letter-meta > div > strong,
  #modal-root .letter-paper.has-letterhead > .letter-meta > div > strong {
    grid-area: label !important;
    display: block !important;
    width: max-content !important;
    min-width: 0 !important;
    white-space: nowrap !important;
    direction: rtl !important;
    text-align: right !important;
    font-weight: 400 !important;
  }

  #modal-root .letter-paper > .letter-meta > div > span,
  #modal-root .letter-paper.has-letterhead > .letter-meta > div > span {
    grid-area: value !important;
    display: block !important;
    width: 34mm !important;
    min-width: 34mm !important;
    max-width: 34mm !important;
    white-space: nowrap !important;
    direction: ltr !important;
    text-align: left !important;
    unicode-bidi: isolate !important;
    font-weight: 400 !important;
  }
}

/* Keep the A4 preview anchored from the left edge of its scroll viewport.
   The paper itself remains RTL; only the outer viewport is LTR so the fixed
   left value column is not clipped when the paper is wider than the modal. */
@media screen {
  #modal-root .letter-preview-wrap {
    direction: ltr !important;
    text-align: left !important;
  }

  #modal-root .letter-preview-wrap > .letter-paper {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}

/* Release gate geometry lock (2026-09-19 / q27).
   The legacy invoice rules contain several historical signature/footer
   layouts.  These final rules keep every live A4 page inside its own paper
   box in both preview and browser print, so stamps, signatures, footers and
   page metadata cannot create horizontal or vertical overflow. */
@media screen, print {
  /* Invoice signature: keep the complete stamp/signature inside the A4 page. */
  #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) > .invoice-paper-signature-band,
  #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) > .print-flow-signature-band {
    position: absolute !important;
    left: 14mm !important;
    right: auto !important;
    bottom: 19mm !important;
    width: 88mm !important;
    height: 42mm !important;
    min-width: 88mm !important;
    max-width: 88mm !important;
    min-height: 42mm !important;
    max-height: 42mm !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    direction: rtl !important;
    z-index: 8 !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) .invoice-seller-signature {
    width: 88mm !important;
    height: 42mm !important;
    min-width: 88mm !important;
    max-width: 88mm !important;
    min-height: 42mm !important;
    max-height: 42mm !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    border: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) .invoice-seller-signature .invoice-signature-assets {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 88mm !important;
    height: 29mm !important;
    min-width: 88mm !important;
    max-width: 88mm !important;
    min-height: 29mm !important;
    max-height: 29mm !important;
    margin: 0 !important;
    gap: 3mm !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) .invoice-seller-signature .invoice-signature-person {
    flex: 0 0 50mm !important;
    width: 50mm !important;
    min-width: 50mm !important;
    max-width: 50mm !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) .invoice-seller-signature .invoice-signature-image {
    display: block !important;
    width: 42mm !important;
    height: 20mm !important;
    max-width: 42mm !important;
    max-height: 20mm !important;
    margin: 0 auto !important;
    object-fit: contain !important;
    object-position: center !important;
  }

  #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) .invoice-seller-signature .invoice-stamp-image {
    flex: 0 0 24mm !important;
    display: block !important;
    width: 24mm !important;
    height: 24mm !important;
    max-width: 24mm !important;
    max-height: 24mm !important;
    margin: 0 !important;
    object-fit: contain !important;
  }

  /* One stable footer row for invoice, receipt, quality and technical pages. */
  #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) .invoice-native-footer,
  #modal-root .receipt-preview-wrap > .receipt-paper:not(.document-attachment-page) .invoice-native-footer,
  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) .invoice-native-footer,
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) .invoice-native-footer {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 4mm !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    white-space: nowrap !important;
  }

  #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) .invoice-native-footer > .invoice-footer-address,
  #modal-root .receipt-preview-wrap > .receipt-paper:not(.document-attachment-page) .invoice-native-footer > .invoice-footer-address,
  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) .invoice-native-footer > .invoice-footer-address,
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) .invoice-native-footer > .invoice-footer-address {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    text-align: right !important;
  }

  #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) .invoice-native-footer > .invoice-footer-contacts,
  #modal-root .receipt-preview-wrap > .receipt-paper:not(.document-attachment-page) .invoice-native-footer > .invoice-footer-contacts,
  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) .invoice-native-footer > .invoice-footer-contacts,
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) .invoice-native-footer > .invoice-footer-contacts {
    flex: 0 0 auto !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 3mm !important;
    direction: ltr !important;
    white-space: nowrap !important;
  }

  #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) .invoice-native-footer > .invoice-footer-website,
  #modal-root .receipt-preview-wrap > .receipt-paper:not(.document-attachment-page) .invoice-native-footer > .invoice-footer-website,
  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) .invoice-native-footer > .invoice-footer-website,
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) .invoice-native-footer > .invoice-footer-website {
    flex: 0 0 auto !important;
    white-space: nowrap !important;
    direction: ltr !important;
  }

  /* Metadata belongs above the orange footer rule and inside the A4 edges. */
  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-page-info,
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-footer {
    position: absolute !important;
    top: auto !important;
    right: 24mm !important;
    bottom: 18mm !important;
    left: 14mm !important;
    width: auto !important;
    height: 5mm !important;
    min-height: 5mm !important;
    max-height: 5mm !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 4mm !important;
    overflow: hidden !important;
  }
}

/* Higher-specificity final lock for the legacy print-flow footer rule. */
html body #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) > .print-flow-footer,
html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned:not(.document-attachment-page) > .print-flow-footer,
html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) .invoice-native-footer,
html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) .invoice-native-footer {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 4mm !important;
  overflow: hidden !important;
  white-space: nowrap !important;
}

html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-page-info,
html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-footer {
  position: absolute !important;
  top: auto !important;
  right: 24mm !important;
  bottom: 18mm !important;
  left: 14mm !important;
  width: auto !important;
  height: 5mm !important;
  min-height: 5mm !important;
  max-height: 5mm !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 4mm !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
}

/* Technical reports carry an extra mode class; include it so no earlier
   mode-specific position rule can move the metadata back into the flow. */
html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead.invoice-print-mode-header-stamp-signature:not(.document-attachment-page) > .technical-paper-footer {
  position: absolute !important;
  top: auto !important;
  right: 24mm !important;
  bottom: 18mm !important;
  left: 14mm !important;
  width: auto !important;
  height: 5mm !important;
  min-height: 5mm !important;
  max-height: 5mm !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 4mm !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
}

/* Final screen/print lock for letters. Older shared rules still carry an A5 print
   preset; this last, high-specificity gate makes every letter page A4, just
   like the other released documents, while leaving the incoming original
   page without AFV letterhead. */
@media screen, print {
  html body #modal-root .letter-preview-wrap > .letter-paper:not(.letterhead-horizontal) {
    page: afv-document-a4-locked !important;
    display: block !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  html body.printing-letter #modal-root .letter-preview-wrap {
    display: block !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  html body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.print-page:not(.letterhead-horizontal),
  html body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.print-page.letter-attachment-page:not(.letterhead-horizontal) {
    page: afv-document-a4-locked !important;
    display: block !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    break-before: auto !important;
    break-inside: avoid !important;
    break-after: page !important;
  }

  html body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.print-page:last-child {
    break-after: auto !important;
    page-break-after: auto !important;
  }
}
/* q40-end-marker */

/* q40 final precedence: no legacy selector below this point can move the
   shared A4 artwork or the upper-left organization metadata. */
@media screen, print {
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) {
    position: relative !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    isolation: isolate !important;
    background: #fff !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image {
    position: absolute !important;
    inset: 0 !important;
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    object-fit: fill !important;
    object-position: center !important;
    pointer-events: none !important;
    visibility: visible !important;
    z-index: 1 !important;
  }

  html body #modal-root .official-document-meta {
    position: absolute !important;
    top: 9mm !important;
    right: auto !important;
    bottom: auto !important;
    left: 8mm !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    width: max-content !important;
    max-width: 52mm !important;
    gap: 1mm !important;
    margin: 0 !important;
    padding: 0 !important;
    direction: ltr !important;
    text-align: left !important;
    background: transparent !important;
    border: 0 !important;
    z-index: 4 !important;
    pointer-events: none !important;
  }

  html body #modal-root .official-document-meta > div {
    display: grid !important;
    grid-template-columns: 34mm max-content !important;
    grid-template-areas: "value label" !important;
    align-items: baseline !important;
    justify-content: start !important;
    width: max-content !important;
    max-width: 52mm !important;
    gap: 3mm !important;
    direction: ltr !important;
    white-space: nowrap !important;
  }

  html body #modal-root .official-document-meta > div > strong {
    grid-area: label !important;
    display: block !important;
    width: max-content !important;
    color: #17202b !important;
    font-size: 8.5pt !important;
    font-weight: 400 !important;
    line-height: 1.25 !important;
    direction: rtl !important;
    text-align: right !important;
    white-space: nowrap !important;
  }

  html body #modal-root .official-document-meta > div > span {
    grid-area: value !important;
    display: block !important;
    width: 34mm !important;
    min-width: 34mm !important;
    max-width: 34mm !important;
    overflow: visible !important;
    color: #17202b !important;
    font-size: 8.5pt !important;
    font-weight: 400 !important;
    line-height: 1.25 !important;
    direction: ltr !important;
    text-align: left !important;
    unicode-bidi: isolate !important;
    white-space: nowrap !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content {
    position: relative !important;
    z-index: 2 !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 100% !important;
    max-height: 100% !important;
    margin: 0 !important;
    padding: 34mm 24mm 19mm 14mm !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) > .receipt-redesigned-content,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page) > .check-receipt-v3-content {
    position: absolute !important;
    top: 34mm !important;
    right: 24mm !important;
    bottom: 19mm !important;
    left: 14mm !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    z-index: 2 !important;
  }

  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 0 24mm 15mm 14mm !important;
  }

  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-paper-head,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-head {
    position: relative !important;
    z-index: 2 !important;
    flex: 0 0 34mm !important;
    height: 34mm !important;
    min-height: 34mm !important;
    max-height: 34mm !important;
    margin: 0 !important;
    padding: 0 0 5mm !important;
    box-sizing: border-box !important;
    border: 0 !important;
  }

  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-meta-grid,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-meta-grid,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > section,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > section,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-signature-grid,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-signature-grid,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-paper-footer,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-footer {
    position: relative !important;
    z-index: 2 !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) .invoice-paper-meta,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page) .receipt-redesign-meta,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page) .receipt-meta-grid,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page) .check-receipt-meta,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) .technical-paper-code,
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) .invoice-paper-footer,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page) .receipt-paper-footer,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page) .check-receipt-footer,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-official-footer,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-official-footer {
    display: none !important;
    visibility: hidden !important;
  }

  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) .receipt-redesign-head {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) .receipt-redesign-head > div:first-child:has(.receipt-redesign-meta) {
    display: none !important;
  }

  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) .receipt-redesign-title {
    grid-column: 1 !important;
    text-align: center !important;
  }
}

/* q40 final left metadata lock for RTL quality/technical wrappers */
html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .official-document-meta,
html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .official-document-meta {
  position: absolute !important;
  left: 8mm !important;
  right: auto !important;
  top: 9mm !important;
  direction: ltr !important;
  text-align: left !important;
  align-items: flex-start !important;
}

html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .official-document-meta > div,
html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .official-document-meta > div {
  direction: ltr !important;
  grid-template-areas: "value label" !important;
  grid-template-columns: 34mm max-content !important;
}

/* q42 precedence over the legacy technical child-position rule */
html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .official-document-meta.official-document-meta {
  position: absolute !important;
  left: 8mm !important;
  right: auto !important;
  top: 9mm !important;
}

/* 2026-09-20 / final-document-flow-01
   The previous release contained several historical print layers that fought
   over the same boxes. This last layer is intentionally small and explicit:
   one A4 article = one physical page, the document body ends before the
   metadata/footer zone, and tables keep their natural height. */
@page afv-final-document-a4 { size: A4 portrait; margin: 0; }

@media screen, print {
  html body #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page),
  html body #modal-root .receipt-preview-wrap > .receipt-paper:not(.document-attachment-page),
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper:not(.document-attachment-page),
  html body #modal-root .quality-preview-wrap > .quality-paper:not(.document-attachment-page),
  html body #modal-root .technical-preview-wrap > .technical-paper:not(.document-attachment-page) {
    position: relative !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    background: #fff !important;
    isolation: isolate !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content {
    position: absolute !important;
    top: 34mm !important;
    right: 24mm !important;
    bottom: 24mm !important;
    left: 14mm !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    z-index: 2 !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content.print-page-has-signature {
    bottom: 67mm !important;
  }

  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) > .receipt-redesigned-content,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page) > .check-receipt-v3-content {
    position: absolute !important;
    top: 34mm !important;
    right: 24mm !important;
    bottom: 24mm !important;
    left: 14mm !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    z-index: 2 !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content > .invoice-paper-table,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) > .receipt-redesigned-content .receipt-items-table,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page) > .check-receipt-v3-content .check-receipt-v3-table {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    flex: 0 0 auto !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
    box-sizing: border-box !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content > .invoice-paper-table > tbody,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) > .receipt-redesigned-content .receipt-items-table > tbody,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page) > .check-receipt-v3-content .check-receipt-v3-table > tbody {
    height: auto !important;
    min-height: 0 !important;
  }

  html body #modal-root .invoice-preview .invoice-paper-table th,
  html body #modal-root .invoice-preview .invoice-paper-table td,
  html body #modal-root .receipt-preview-wrap .receipt-items-table th,
  html body #modal-root .receipt-preview-wrap .receipt-items-table td,
  html body #modal-root .check-receipt-print-wrap .check-receipt-v3-table th,
  html body #modal-root .check-receipt-print-wrap .check-receipt-v3-table td {
    min-width: 0 !important;
    max-width: none !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    white-space: normal !important;
    vertical-align: middle !important;
  }

  html body #modal-root .invoice-preview .invoice-paper-table .col-index { width: 7% !important; }
  html body #modal-root .invoice-preview .invoice-paper-table .col-code { width: 17% !important; }
  html body #modal-root .invoice-preview .invoice-paper-table .col-brand { width: 11% !important; }
  html body #modal-root .invoice-preview .invoice-paper-table .col-description { width: 31% !important; }
  html body #modal-root .invoice-preview .invoice-paper-table .col-quantity { width: 10% !important; }
  html body #modal-root .invoice-preview .invoice-paper-table .col-unit-price { width: 12% !important; }
  html body #modal-root .invoice-preview .invoice-paper-table .col-total { width: 12% !important; }

  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 0 24mm 24mm 14mm !important;
  }

  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-paper-head,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-head {
    flex: 0 0 34mm !important;
    height: 34mm !important;
    min-height: 34mm !important;
    max-height: 34mm !important;
    margin: 0 !important;
    padding: 0 0 5mm !important;
    box-sizing: border-box !important;
    border: 0 !important;
  }

  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-page-info,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-footer {
    position: absolute !important;
    right: 24mm !important;
    bottom: 18mm !important;
    left: 14mm !important;
    width: auto !important;
    height: 5mm !important;
    min-height: 5mm !important;
    max-height: 5mm !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    z-index: 30 !important;
  }

  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-meta-grid,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-meta-grid,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > section,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > section,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-signature-grid,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-signature-grid {
    position: relative !important;
    z-index: 2 !important;
    flex: 0 0 auto !important;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow-wrap: anywhere !important;
  }
}

@media print {
  html,
  body,
  body.printing-invoice,
  body.printing-letter,
  body.printing-letter-horizontal,
  body.printing-receipt,
  body.printing-check-receipt,
  body.printing-check-receipt-a4,
  body.printing-quality,
  body.printing-technical-report {
    width: 210mm !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: #fff !important;
  }

  body.printing-invoice > #app,
  body.printing-invoice > #auth-root,
  body.printing-letter > #app,
  body.printing-letter > #auth-root,
  body.printing-letter-horizontal > #app,
  body.printing-letter-horizontal > #auth-root,
  body.printing-receipt > #app,
  body.printing-receipt > #auth-root,
  body.printing-check-receipt > #app,
  body.printing-check-receipt > #auth-root,
  body.printing-check-receipt-a4 > #app,
  body.printing-check-receipt-a4 > #auth-root,
  body.printing-quality > #app,
  body.printing-quality > #auth-root,
  body.printing-technical-report > #app,
  body.printing-technical-report > #auth-root {
    display: none !important;
    visibility: hidden !important;
  }

  body.printing-invoice > #modal-root,
  body.printing-letter > #modal-root,
  body.printing-letter-horizontal > #modal-root,
  body.printing-receipt > #modal-root,
  body.printing-check-receipt > #modal-root,
  body.printing-check-receipt-a4 > #modal-root,
  body.printing-quality > #modal-root,
  body.printing-technical-report > #modal-root,
  body.printing-invoice #modal-root > .modal-backdrop,
  body.printing-letter #modal-root > .modal-backdrop,
  body.printing-letter-horizontal #modal-root > .modal-backdrop,
  body.printing-receipt #modal-root > .modal-backdrop,
  body.printing-check-receipt #modal-root > .modal-backdrop,
  body.printing-check-receipt-a4 #modal-root > .modal-backdrop,
  body.printing-quality #modal-root > .modal-backdrop,
  body.printing-technical-report #modal-root > .modal-backdrop,
  body.printing-invoice #modal-root .modal-card,
  body.printing-letter #modal-root .modal-card,
  body.printing-letter-horizontal #modal-root .modal-card,
  body.printing-receipt #modal-root .modal-card,
  body.printing-check-receipt #modal-root .modal-card,
  body.printing-check-receipt-a4 #modal-root .modal-card,
  body.printing-quality #modal-root .modal-card,
  body.printing-technical-report #modal-root .modal-card,
  body.printing-invoice #modal-root .modal-body,
  body.printing-letter #modal-root .modal-body,
  body.printing-letter-horizontal #modal-root .modal-body,
  body.printing-receipt #modal-root .modal-body,
  body.printing-check-receipt #modal-root .modal-body,
  body.printing-check-receipt-a4 #modal-root .modal-body,
  body.printing-quality #modal-root .modal-body,
  body.printing-technical-report #modal-root .modal-body {
    position: static !important;
    inset: auto !important;
    display: block !important;
    width: 210mm !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: #fff !important;
    box-shadow: none !important;
    transform: none !important;
  }

  body.printing-invoice #modal-root .invoice-preview,
  body.printing-letter #modal-root .letter-preview-wrap,
  body.printing-letter-horizontal #modal-root .letter-preview-wrap,
  body.printing-receipt #modal-root .receipt-preview-wrap,
  body.printing-check-receipt #modal-root .check-receipt-print-wrap,
  body.printing-check-receipt-a4 #modal-root .check-receipt-print-wrap,
  body.printing-quality #modal-root .quality-preview-wrap,
  body.printing-technical-report #modal-root .technical-preview-wrap {
    display: block !important;
    width: 210mm !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page,
  body.printing-receipt #modal-root .receipt-preview-wrap > .receipt-paper.print-page,
  body.printing-check-receipt #modal-root .check-receipt-print-wrap > .check-receipt-paper.print-page,
  body.printing-check-receipt-a4 #modal-root .check-receipt-print-wrap > .check-receipt-paper.print-page,
  body.printing-quality #modal-root .quality-preview-wrap > .quality-paper.print-page,
  body.printing-technical-report #modal-root .technical-preview-wrap > .technical-paper.print-page,
  body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.print-page:not(.letterhead-horizontal),
  body.printing-letter-horizontal #modal-root .letter-preview-wrap > .letter-paper.print-page:not(.letterhead-horizontal) {
    page: afv-final-document-a4 !important;
    display: block !important;
    position: relative !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    height: 296.5mm !important;
    min-height: 296.5mm !important;
    max-height: 296.5mm !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    break-before: auto !important;
    page-break-before: auto !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page:not(.print-page-last),
  body.printing-receipt #modal-root .receipt-preview-wrap > .receipt-paper.print-page:not(.print-page-last),
  body.printing-check-receipt #modal-root .check-receipt-print-wrap > .check-receipt-paper.print-page:not(.print-page-last),
  body.printing-check-receipt-a4 #modal-root .check-receipt-print-wrap > .check-receipt-paper.print-page:not(.print-page-last),
  body.printing-quality #modal-root .quality-preview-wrap > .quality-paper.print-page:not(.print-page-last),
  body.printing-technical-report #modal-root .technical-preview-wrap > .technical-paper.print-page:not(.print-page-last),
  body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.print-page:not(.print-page-last),
  body.printing-letter-horizontal #modal-root .letter-preview-wrap > .letter-paper.print-page:not(.print-page-last) {
    break-after: page !important;
    page-break-after: always !important;
  }

  body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page-last,
  body.printing-receipt #modal-root .receipt-preview-wrap > .receipt-paper.print-page-last,
  body.printing-check-receipt #modal-root .check-receipt-print-wrap > .check-receipt-paper.print-page-last,
  body.printing-check-receipt-a4 #modal-root .check-receipt-print-wrap > .check-receipt-paper.print-page-last,
  body.printing-quality #modal-root .quality-preview-wrap > .quality-paper.print-page-last,
  body.printing-technical-report #modal-root .technical-preview-wrap > .technical-paper.print-page-last,
  body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.print-page-last,
  body.printing-letter-horizontal #modal-root .letter-preview-wrap > .letter-paper.print-page-last {
    break-after: auto !important;
    page-break-after: auto !important;
  }

  body.printing-invoice #modal-root .invoice-preview > .document-attachment-print-page,
  body.printing-receipt #modal-root .receipt-preview-wrap > .document-attachment-print-page,
  body.printing-check-receipt #modal-root .check-receipt-print-wrap > .document-attachment-print-page,
  body.printing-quality #modal-root .quality-preview-wrap > .document-attachment-print-page,
  body.printing-technical-report #modal-root .technical-preview-wrap > .document-attachment-print-page,
  body.printing-letter #modal-root .letter-preview-wrap > .document-attachment-print-page {
    display: block !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    height: 296.5mm !important;
    min-height: 296.5mm !important;
    max-height: 296.5mm !important;
    margin: 0 !important;
    padding: 0 !important;
    break-before: page !important;
    page-break-before: always !important;
    break-after: page !important;
    page-break-after: always !important;
    box-sizing: border-box !important;
  }

  body.printing-invoice #modal-root .invoice-preview > .document-attachment-print-page.print-page-last,
  body.printing-receipt #modal-root .receipt-preview-wrap > .document-attachment-print-page.print-page-last,
  body.printing-check-receipt #modal-root .check-receipt-print-wrap > .document-attachment-print-page.print-page-last,
  body.printing-quality #modal-root .quality-preview-wrap > .document-attachment-print-page.print-page-last,
  body.printing-technical-report #modal-root .technical-preview-wrap > .document-attachment-print-page.print-page-last,
  body.printing-letter #modal-root .letter-preview-wrap > .document-attachment-print-page.print-page-last {
    break-after: auto !important;
    page-break-after: auto !important;
  }

  body.printing-invoice #modal-root .print-non-page,
  body.printing-letter #modal-root .print-non-page,
  body.printing-letter-horizontal #modal-root .print-non-page,
  body.printing-receipt #modal-root .print-non-page,
  body.printing-check-receipt #modal-root .print-non-page,
  body.printing-check-receipt-a4 #modal-root .print-non-page,
  body.printing-quality #modal-root .print-non-page,
  body.printing-technical-report #modal-root .print-non-page {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    break-after: auto !important;
    page-break-after: auto !important;
  }
}

/* Final visual lock: the shared letterhead image is the only header-side
   decoration. Legacy document layers must not paint a second orange rule. */
@media print {
  body.printing-invoice #modal-root .invoice-preview .invoice-paper::after,
  body.printing-receipt #modal-root .receipt-preview-wrap .receipt-paper::after,
  body.printing-check-receipt #modal-root .check-receipt-print-wrap .check-receipt-paper::after,
  body.printing-check-receipt-a4 #modal-root .check-receipt-print-wrap .check-receipt-paper::after,
  body.printing-quality #modal-root .quality-preview-wrap .quality-paper::after,
  body.printing-technical-report #modal-root .technical-preview-wrap .technical-paper::after {
    content: none !important;
    display: none !important;
    border: 0 !important;
  }

  body.printing-invoice #modal-root .invoice-preview .invoice-native-side-rule,
  body.printing-invoice #modal-root .invoice-preview .print-flow-side-rule,
  body.printing-receipt #modal-root .receipt-preview-wrap .invoice-native-side-rule,
  body.printing-receipt #modal-root .receipt-preview-wrap .print-flow-side-rule,
  body.printing-check-receipt #modal-root .check-receipt-print-wrap .invoice-native-side-rule,
  body.printing-check-receipt-a4 #modal-root .check-receipt-print-wrap .invoice-native-side-rule,
  body.printing-quality #modal-root .quality-preview-wrap .invoice-native-side-rule,
  body.printing-technical-report #modal-root .technical-preview-wrap .invoice-native-side-rule {
    display: none !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    border: 0 !important;
  }
}

/* FINAL EOF PRECEDENCE — reference-sheet footer and safe content bottom. */
@media screen, print {
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image {
    clip-path: inset(0 0 14% 0) !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page)::before {
    content: "" !important;
    position: absolute !important;
    inset: 0 !important;
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: url("/assets/afv-letterhead-main-clean-20260920.png?v=20260920-header-clean-01") 0 0 / 100% 100% no-repeat !important;
    clip-path: inset(86% 0 0 0) !important;
    transform: translateX(8mm) !important;
    pointer-events: none !important;
    z-index: 1 !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content:not(.print-page-has-signature),
  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) > .receipt-redesigned-content,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page) > .check-receipt-v3-content {
    bottom: 45mm !important;
  }

  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) {
    padding-bottom: 45mm !important;
  }

  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-page-info,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-footer {
    bottom: 45mm !important;
  }
}

/* FINAL RELEASE FOOTER BAND — keep all flowing content above the reference
   sheet footer while leaving enough space for dense receipt pages. */
@media screen, print {
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content:not(.print-page-has-signature),
  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) > .receipt-redesigned-content,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page) > .check-receipt-v3-content {
    bottom: 40mm !important;
  }

  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) {
    padding-bottom: 40mm !important;
  }

  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-page-info,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-footer {
    bottom: 40mm !important;
  }
}

/* The official document meta block at the upper-left is the single source of
   page/code/date information. Keep the internal pagination footer measurable
   for the JS page splitter, but do not paint a duplicate over the reference
   sheet's logo band. */
@media screen, print {
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-page-info,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-footer {
    color: transparent !important;
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
    text-shadow: none !important;
    pointer-events: none !important;
  }

  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-page-info *,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-footer * {
    color: transparent !important;
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
}

/* FINAL INVOICE TABLE HEADING LOCK — it must occupy only its own heading row. */
@media screen, print {
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page):not(.invoice-single-page-compact) .invoice-document-section-title {
    flex: 0 0 auto !important;
    display: block !important;
    position: relative !important;
    z-index: 2 !important;
    width: 100% !important;
    height: auto !important;
    min-height: 5mm !important;
    max-height: none !important;
    margin: 2mm 0 1mm !important;
    padding: 1.5mm 2mm !important;
    box-sizing: border-box !important;
    line-height: 1.2 !important;
  }
}

/* FINAL PRINTING A4 LETTERHEAD PER PAGE — keep the reference sheet attached to
   every cloned A4 page.  The old absolute image/pseudo-element strategy can
   disappear from middle pages during Chromium print fragmentation. */
@media screen, print {
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) {
    background-color: #fff !important;
    background-image: url("/assets/afv-letterhead-main-clean-20260920.png?v=20260920-header-clean-01") !important;
    background-repeat: no-repeat !important;
    background-position: center center !important;
    background-size: 100% 100% !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page)::before {
    display: none !important;
    content: none !important;
    visibility: hidden !important;
  }

  /* The print-mode rules carry a higher specificity than the screen preview
     rules. Repeat the background at that specificity so the outgoing letter
     keeps its header/footer when window.print() toggles body.printing-letter. */
  html body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page),
  html body.printing-letter-horizontal #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) {
    background-color: #fff !important;
    background-image: url("/assets/afv-letterhead-main-clean-20260920.png?v=20260920-header-clean-01") !important;
    background-repeat: no-repeat !important;
    background-position: center center !important;
    background-size: 100% 100% !important;
  }

  html body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body.printing-letter-horizontal #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image {
    display: none !important;
    visibility: hidden !important;
  }
}

/* INVOICE-ONLY RELEASE GATE — each cloned A4 page owns the same artwork. */
@media screen, print {
  html body #modal-root .invoice-preview {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    margin-inline: auto !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) {
    margin-inline: auto !important;
    inset-inline: auto !important;
    align-self: center !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) {
    background-color: #fff !important;
    background-image: none !important;
    background-repeat: no-repeat !important;
    background-position: 0 0 !important;
    background-size: auto !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image {
    display: block !important;
    visibility: visible !important;
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    object-fit: fill !important;
    object-position: center center !important;
    clip-path: none !important;
    transform: none !important;
    opacity: 1 !important;
    z-index: 0 !important;
    pointer-events: none !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) > .invoice-paper-content { z-index: 2 !important; }
  html body #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) > .official-document-meta { z-index: 4 !important; }
  html body #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) .invoice-paper-footer { display: none !important; visibility: hidden !important; }
}

/* Invoice print compositor fallback: each cloned invoice is an independent
   A4 page, so paint the reference sheet as that page's own background.  This
   avoids Chromium dropping an absolutely-positioned image on an intermediate
   page while keeping the footer centered in the paper coordinate system. */
@media screen, print {
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) {
    background-color: #fff !important;
    background-image: url("/assets/afv-letterhead-main-clean-20260920.png?v=20260920-header-clean-01") !important;
    background-repeat: no-repeat !important;
    background-position: center top !important;
    background-size: 100% 100% !important;
    background-origin: border-box !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image {
    display: block !important;
    visibility: visible !important;
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    object-fit: fill !important;
    object-position: center center !important;
    clip-path: none !important;
    transform: none !important;
    opacity: 1 !important;
    z-index: 0 !important;
    pointer-events: none !important;
  }
}

@media print {
  /* Approval cards, print-mode notes and other controls remain useful in the
     preview but are never allowed to become pages in the PDF sequence. */
  html body.printing-invoice #modal-root .invoice-preview > .print-non-page,
  html body.printing-invoice #modal-root .invoice-preview > .invoice-screen-only,
  html body.printing-invoice #modal-root .invoice-preview > .print-mode-note {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
  }

  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page,
  html body.printing-invoice #modal-root .invoice-preview > .document-attachment-print-page {
    break-after: auto !important;
    page-break-after: auto !important;
  }
}

/* INVOICE ARTWORK DIRECT FALLBACK — final precedence. */
@media screen, print {
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) {
    background-image: url("/assets/afv-letterhead-main-clean-20260920.png?v=20260920-header-clean-01") !important;
    background-repeat: no-repeat !important;
    background-position: center top !important;
    background-size: 100% 100% !important;
    background-origin: border-box !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page)::after {
    display: none !important;
    content: none !important;
    visibility: hidden !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image {
    display: block !important;
    visibility: visible !important;
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    object-fit: fill !important;
    object-position: center center !important;
    clip-path: none !important;
    transform: none !important;
    opacity: 1 !important;
    z-index: 0 !important;
    pointer-events: none !important;
  }
}

/* INVOICE-ONLY FINAL FIX (2026-09-20): use real image layers for the header
   and footer. Each cloned A4 article owns both layers, so page 2 and the last
   page cannot lose the artwork during PDF pagination. */
@media screen, print {
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) {
    background-image: none !important;
    background-color: #fff !important;
    isolation: isolate !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page)::after {
    display: none !important;
    content: none !important;
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    background-image: url("/assets/afv-letterhead-main-clean-20260920.png?v=20260920-header-clean-01") !important;
    background-repeat: no-repeat !important;
    background-position: center top !important;
    background-size: 100% 100% !important;
    background-color: transparent !important;
    print-color-adjust: exact !important;
    -webkit-print-color-adjust: exact !important;
    pointer-events: none !important;
    z-index: 0 !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page)::before {
    clip-path: inset(0 0 14% 0) !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page)::after {
    clip-path: inset(84% 0 0 0) !important;
    transform: translateX(14mm) !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image {
    display: block !important;
    visibility: visible !important;
    clip-path: inset(0 0 14% 0) !important;
  }

html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-footer-artwork {
    display: block !important;
    visibility: visible !important;
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    object-fit: fill !important;
    object-position: center center !important;
    clip-path: inset(84% 0 0 0) !important;
    transform: translateX(14mm) !important;
    opacity: 1 !important;
    z-index: 0 !important;
    pointer-events: none !important;
  }

  /* Equal A4 side margins for the table/body, plus a reserved footer zone. */
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content {
    left: 19mm !important;
    right: 19mm !important;
    bottom: 54mm !important;
  }

  /* The supplied footer strip is already centered artwork; size and center it
     as a single object instead of inheriting the asymmetry of the full sheet. */
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-footer-artwork {
    inset: auto !important;
    left: 50% !important;
    right: auto !important;
    top: auto !important;
    bottom: 7mm !important;
    width: 190mm !important;
    min-width: 190mm !important;
    max-width: 190mm !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    clip-path: none !important;
    transform: translateX(-50%) !important;
    object-fit: contain !important;
    object-position: center bottom !important;
  }

  /* Signature/stamp remain visible in preview for review, but the final
     invoice print must not contain the seller's seal or signature. */
  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) .invoice-paper-signature-band,
  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) .print-flow-signature-band {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content {
    z-index: 2 !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content.print-page-has-signature {
    bottom: 40mm !important;
  }

  /* FINAL INVOICE FOOTER RESERVATION: override the legacy high-specificity
     non-signature rule so every invoice page stops above the centered footer. */
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content:not(.print-page-has-signature) {
    bottom: 54mm !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content.print-page-has-signature {
    bottom: 54mm !important;
  }

  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content > .invoice-paper-signature-band,
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content > .print-flow-signature-band {
    position: static !important;
    flex: 0 0 42mm !important;
    width: 88mm !important;
    min-width: 88mm !important;
    max-width: 88mm !important;
    height: 42mm !important;
    min-height: 42mm !important;
    max-height: 42mm !important;
    margin: 8mm auto 0 0 !important;
    padding: 0 !important;
    display: block !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    direction: rtl !important;
    z-index: 8 !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  /* Print-only suppression comes after the preview layout rule so the
     signature/stamp cannot be resurrected by the static band styling. */
  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) .invoice-paper-signature-band,
  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper:not(.document-attachment-page) .print-flow-signature-band {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
  }

  /* Match the static signature-band selector with higher specificity in
     print mode; otherwise its display:block rule wins despite !important. */
  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content > .invoice-paper-signature-band,
  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content > .print-flow-signature-band {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
  }

  /* Latest invoice print decision: seller stamp/signature must not be present
     in the final PDF. Keep this after every legacy signature layout rule. */
  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content > .invoice-paper-signature-band,
  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content > .print-flow-signature-band {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
  }

  /* No border or outline around the signature assets in preview or print. */
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) .invoice-paper-signature-band,
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) .invoice-signature-box,
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) .invoice-signature-assets,
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) .invoice-signature-image,
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) .invoice-stamp-image {
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
  }

  /* Print only the materialized invoice pages. The wrapper itself must not
     create a trailing sheet after the last page. */
  html body.printing-invoice #modal-root .invoice-preview {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  html body.printing-invoice #modal-root .invoice-preview > .print-non-page {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
  }

  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page-last {
    break-after: auto !important;
    page-break-after: auto !important;
  }

  /* Reuse the high-resolution original letterhead for the footer. Its lower
     band is cropped before the QR column and shifted back to A4 center. */
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-footer-artwork {
    inset: 0 !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    min-height: 100% !important;
    max-height: 100% !important;
    object-fit: fill !important;
    object-position: center center !important;
    clip-path: inset(84% 15% 0 0) !important;
    transform: translateX(14mm) !important;
  }
}

/* Final browser-print lock: one physical A4 box equals one PDF page. */
@page afv-final-document-a4 {
  size: A4 portrait;
  margin: 0;
}

@media print {
  html body.printing-invoice,
  html body.printing-invoice #modal-root,
  html body.printing-invoice #modal-root .modal-body,
  html body.printing-invoice #modal-root .invoice-preview {
    margin: 0 !important;
    padding: 0 !important;
    min-height: 0 !important;
    height: auto !important;
    overflow: visible !important;
  }

  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page {
    page: afv-final-document-a4 !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page.print-page-last {
    break-after: auto !important;
    page-break-after: auto !important;
  }
}

/* نامه صادره: همان سکشن فوتر پیش‌فاکتور، با مرکز دقیق روی کاغذ A4. */
@media screen, print {
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) > .letter-invoice-footer-artwork {
    display: block !important;
    visibility: visible !important;
    position: absolute !important;
    left: 50% !important;
    right: auto !important;
    top: auto !important;
    bottom: 7mm !important;
    width: 190mm !important;
    min-width: 190mm !important;
    max-width: 190mm !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    clip-path: none !important;
    transform: translateX(-50%) !important;
    object-fit: contain !important;
    object-position: center bottom !important;
    opacity: 1 !important;
    z-index: 1 !important;
    pointer-events: none !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) > .official-document-meta {
    top: 9mm !important;
    left: 8mm !important;
    z-index: 4 !important;
  }
}

/* صفحهٔ سربرگ یک مقدار واحد است: عدد فعلی، واژهٔ «از» و عدد کل در یک
   inline-flex ایزوله می‌مانند تا موتور چاپ ترتیب ۱ از ۳ را جابه‌جا نکند. */
html body #modal-root .official-document-meta .official-page-count-fixed {
  display: inline-flex !important;
  align-items: baseline !important;
  flex-direction: row !important;
  direction: rtl !important;
  unicode-bidi: isolate !important;
  white-space: nowrap !important;
  /* مقادیر سه ردیف بالاتر از سمت چپ ستون مقدار شروع می‌شوند؛ ترکیب صفحه
     نیز باید دقیقاً از همان خط شروع شود، نه چسبیده به عنوان «صفحه». */
  justify-content: flex-end !important;
  gap: 0 !important;
  font-family: 'BNazanin', 'B Nazanin', Vazirmatn, Tahoma, sans-serif !important;
  font-variant-numeric: normal !important;
}

html body #modal-root .official-document-meta .official-page-current,
html body #modal-root .official-document-meta .official-page-total {
  display: inline-block !important;
  direction: ltr !important;
  unicode-bidi: isolate !important;
  font-family: inherit !important;
}

html body #modal-root .official-document-meta .official-page-separator {
  display: inline-block !important;
  direction: rtl !important;
  unicode-bidi: isolate !important;
  padding-inline: .28em !important;
  font-family: inherit !important;
  font-weight: 400 !important;
}

/* شماره سازمانی باید دقیقاً به ترتیب ثبت‌شده خوانده شود؛ کد بایگانی نیز
   در خروجی‌های بعدی با ارقام لاتین تولید و نمایش داده می‌شود. */
html body #modal-root .official-document-meta .official-document-meta-number,
html body #modal-root .official-document-meta .official-document-meta-number > bdi {
  direction: ltr !important;
  unicode-bidi: isolate-override !important;
  text-align: left !important;
  white-space: nowrap !important;
}

/* Final outgoing-letter lock: use the invoice page container without allowing
   legacy letter pagination rules to add a trailing sheet. */
@media screen {
  html body #modal-root .letter-preview-wrap.invoice-preview {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 0 !important;
    box-sizing: border-box !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    padding: 12px !important;
  }

  html body #modal-root .letter-preview-wrap.invoice-preview > .invoice-paper.letter-invoice-paper,
  html body #modal-root .letter-preview-wrap.invoice-preview > .document-attachment-print-page {
    flex: 0 0 auto !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }
}

@media screen and (max-width: 820px) {
  html body #modal-root .letter-preview-wrap.invoice-preview {
    align-items: flex-start !important;
  }
}

@media print {
  html body.printing-invoice #modal-root .letter-preview-wrap.invoice-preview {
    display: block !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    position: static !important;
    background: #fff !important;
  }

  html body.printing-invoice #modal-root .letter-preview-wrap.invoice-preview > .invoice-paper.letter-invoice-paper,
  html body.printing-invoice #modal-root .letter-preview-wrap.invoice-preview > .document-attachment-print-page {
    display: block !important;
    position: relative !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    break-before: auto !important;
    page-break-before: auto !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  html body.printing-invoice #modal-root .letter-preview-wrap.invoice-preview > .invoice-paper.letter-invoice-paper:not(:last-child) {
    break-after: page !important;
    page-break-after: always !important;
  }

  html body.printing-invoice #modal-root .letter-preview-wrap.invoice-preview > .document-attachment-print-page {
    break-after: auto !important;
    page-break-after: auto !important;
  }
}

/* Outgoing letters use the invoice page skeleton; only the letter body is
   different. Keep the same A4 content rectangle so print cannot create a
   second overflow page. */
@media screen, print {
  html body #modal-root .letter-preview-wrap.invoice-preview > .invoice-paper.letter-invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content,
  html body.printing-invoice #modal-root .letter-preview-wrap.invoice-preview > .invoice-paper.letter-invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content {
    position: absolute !important;
    inset: 34mm 24mm 19mm 14mm !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  html body #modal-root .letter-preview-wrap.invoice-preview > .invoice-paper.letter-invoice-paper .letter-invoice-body {
    position: relative !important;
    z-index: 2 !important;
    display: flex !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    flex-direction: column !important;
    align-items: stretch !important;
    margin: 8mm 0 0 !important;
    overflow: hidden !important;
    color: #1f2b33 !important;
    font-family: "BNazanin", "B Nazanin", Tahoma, sans-serif !important;
  }

  html body #modal-root .letter-preview-wrap.invoice-preview > .invoice-paper.letter-invoice-paper .letter-invoice-recipient {
    margin: 0 0 7mm !important;
    padding: 0 0 4mm !important;
    border-bottom: 1px solid #d8e0e6 !important;
    font-size: 12pt !important;
    line-height: 1.8 !important;
  }

  html body #modal-root .letter-preview-wrap.invoice-preview > .invoice-paper.letter-invoice-paper .letter-invoice-recipient > strong {
    display: block !important;
    margin-bottom: 2mm !important;
    color: #6f7d85 !important;
    font-size: 10pt !important;
    font-weight: 400 !important;
  }

  html body #modal-root .letter-preview-wrap.invoice-preview > .invoice-paper.letter-invoice-paper .letter-recipient-stack > div {
    color: #20333e !important;
    font-size: 13pt !important;
    font-weight: 700 !important;
  }

  html body #modal-root .letter-preview-wrap.invoice-preview > .invoice-paper.letter-invoice-paper .letter-invoice-subject {
    flex: 0 0 auto !important;
    margin: 0 0 7mm !important;
    padding: 4mm 5mm !important;
    border: 1px solid #d8e0e6 !important;
    border-radius: 0 !important;
    background: #fffaf6 !important;
    font-size: 11pt !important;
    line-height: 1.8 !important;
  }

  html body #modal-root .letter-preview-wrap.invoice-preview > .invoice-paper.letter-invoice-paper .letter-invoice-subject strong {
    display: inline-block !important;
    margin-left: 5mm !important;
    color: #d95420 !important;
    font-weight: 700 !important;
  }

  html body #modal-root .letter-preview-wrap.invoice-preview > .invoice-paper.letter-invoice-paper .letter-body-content {
    flex: 0 1 auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
    color: #262626 !important;
    font-size: 11pt !important;
    line-height: 2.25 !important;
    text-align: justify !important;
  }

  html body #modal-root .letter-preview-wrap.invoice-preview > .invoice-paper.letter-invoice-paper .letter-body-content p {
    margin: 0 0 5mm !important;
  }

  html body #modal-root .letter-preview-wrap.invoice-preview > .invoice-paper.letter-invoice-paper .letter-invoice-signature-band {
    flex: 0 0 auto !important;
    position: relative !important;
    z-index: 2 !important;
    margin-top: 10mm !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }
}

/* Correct print decision: keep the expert's seal/signature, name and title;
   only the old seller wording is removed from the caption. */
html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content > .invoice-paper-signature-band,
html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content > .print-flow-signature-band {
  display: block !important;
  visibility: visible !important;
  height: 32mm !important;
  min-height: 32mm !important;
  max-height: 32mm !important;
  margin: 5mm auto 0 0 !important;
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  overflow: hidden !important;
}

@media print {
  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content > .invoice-paper-signature-band,
  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-paper-content > .print-flow-signature-band {
    display: block !important;
    visibility: visible !important;
    height: 32mm !important;
    min-height: 32mm !important;
    max-height: 32mm !important;
    margin: 5mm auto 0 0 !important;
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
    overflow: hidden !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }
}

/* FINAL TRAILING-SHEET LOCK (2026-09-20): the printable surface is only the
   modal document tree.  Keep the modal boundary in normal flow and remove
   browser/test harness roots from pagination.  This is intentionally last so
   it wins over the screen modal's fixed/grid layout and old page-break rules. */
@media print {
  html body.printing-invoice > #modal-root,
  html body.printing-letter > #modal-root,
  html body.printing-letter-horizontal > #modal-root,
  html body.printing-receipt > #modal-root,
  html body.printing-check-receipt > #modal-root,
  html body.printing-check-receipt-a4 > #modal-root,
  html body.printing-quality > #modal-root,
  html body.printing-technical-report > #modal-root {
    display: block !important;
    position: static !important;
    inset: auto !important;
    width: 210mm !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    break-after: auto !important;
    page-break-after: auto !important;
  }

  html body.printing-invoice > #modal-root > .modal-backdrop,
  html body.printing-letter > #modal-root > .modal-backdrop,
  html body.printing-letter-horizontal > #modal-root > .modal-backdrop,
  html body.printing-receipt > #modal-root > .modal-backdrop,
  html body.printing-check-receipt > #modal-root > .modal-backdrop,
  html body.printing-check-receipt-a4 > #modal-root > .modal-backdrop,
  html body.printing-quality > #modal-root > .modal-backdrop,
  html body.printing-technical-report > #modal-root > .modal-backdrop {
    display: block !important;
    position: static !important;
    inset: auto !important;
    width: 210mm !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    backdrop-filter: none !important;
    break-after: auto !important;
    page-break-after: auto !important;
  }

  html body.printing-invoice > #modal-root > .modal-backdrop > .modal-card,
  html body.printing-letter > #modal-root > .modal-backdrop > .modal-card,
  html body.printing-letter-horizontal > #modal-root > .modal-backdrop > .modal-card,
  html body.printing-receipt > #modal-root > .modal-backdrop > .modal-card,
  html body.printing-check-receipt > #modal-root > .modal-backdrop > .modal-card,
  html body.printing-check-receipt-a4 > #modal-root > .modal-backdrop > .modal-card,
  html body.printing-quality > #modal-root > .modal-backdrop > .modal-card,
  html body.printing-technical-report > #modal-root > .modal-backdrop > .modal-card {
    display: block !important;
    position: static !important;
    width: 210mm !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    transform: none !important;
    break-after: auto !important;
    page-break-after: auto !important;
  }

  html body.printing-invoice > #toast-root,
  html body.printing-invoice > #telephony-root,
  html body.printing-letter > #toast-root,
  html body.printing-letter > #telephony-root,
  html body.printing-letter-horizontal > #toast-root,
  html body.printing-letter-horizontal > #telephony-root,
  html body.printing-receipt > #toast-root,
  html body.printing-receipt > #telephony-root,
  html body.printing-check-receipt > #toast-root,
  html body.printing-check-receipt > #telephony-root,
  html body.printing-check-receipt-a4 > #toast-root,
  html body.printing-check-receipt-a4 > #telephony-root,
  html body.printing-quality > #toast-root,
  html body.printing-quality > #telephony-root,
  html body.printing-technical-report > #toast-root,
  html body.printing-technical-report > #telephony-root,
  html body.printing-invoice > #codex-agent-overlay-root,
  html body.printing-letter > #codex-agent-overlay-root,
  html body.printing-letter-horizontal > #codex-agent-overlay-root,
  html body.printing-receipt > #codex-agent-overlay-root,
  html body.printing-check-receipt > #codex-agent-overlay-root,
  html body.printing-check-receipt-a4 > #codex-agent-overlay-root,
  html body.printing-quality > #codex-agent-overlay-root,
  html body.printing-technical-report > #codex-agent-overlay-root,
  html body.printing-invoice > .codex-agent-overlay-root,
  html body.printing-letter > .codex-agent-overlay-root,
  html body.printing-letter-horizontal > .codex-agent-overlay-root,
  html body.printing-receipt > .codex-agent-overlay-root,
  html body.printing-check-receipt > .codex-agent-overlay-root,
  html body.printing-check-receipt-a4 > .codex-agent-overlay-root,
  html body.printing-quality > .codex-agent-overlay-root,
  html body.printing-technical-report > .codex-agent-overlay-root,
  html body.printing-invoice > [data-codex-agent-overlay],
  html body.printing-letter > [data-codex-agent-overlay],
  html body.printing-letter-horizontal > [data-codex-agent-overlay],
  html body.printing-receipt > [data-codex-agent-overlay],
  html body.printing-check-receipt > [data-codex-agent-overlay],
  html body.printing-check-receipt-a4 > [data-codex-agent-overlay],
  html body.printing-quality > [data-codex-agent-overlay],
  html body.printing-technical-report > [data-codex-agent-overlay] {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    break-before: auto !important;
    break-after: auto !important;
    page-break-before: auto !important;
    page-break-after: auto !important;
  }

  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page:not(.print-page-last),
  html body.printing-receipt #modal-root .receipt-preview-wrap > .receipt-paper.print-page:not(.print-page-last),
  html body.printing-check-receipt #modal-root .check-receipt-print-wrap > .check-receipt-paper.print-page:not(.print-page-last),
  html body.printing-check-receipt-a4 #modal-root .check-receipt-print-wrap > .check-receipt-paper.print-page:not(.print-page-last),
  html body.printing-quality #modal-root .quality-preview-wrap > .quality-paper.print-page:not(.print-page-last),
  html body.printing-technical-report #modal-root .technical-preview-wrap > .technical-paper.print-page:not(.print-page-last),
  html body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.print-page:not(.print-page-last),
  html body.printing-letter-horizontal #modal-root .letter-preview-wrap > .letter-paper.print-page:not(.print-page-last) {
    break-after: page !important;
    page-break-after: always !important;
  }

  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page-last,
  html body.printing-receipt #modal-root .receipt-preview-wrap > .receipt-paper.print-page-last,
  html body.printing-check-receipt #modal-root .check-receipt-print-wrap > .check-receipt-paper.print-page-last,
  html body.printing-check-receipt-a4 #modal-root .check-receipt-print-wrap > .check-receipt-paper.print-page-last,
  html body.printing-quality #modal-root .quality-preview-wrap > .quality-paper.print-page-last,
  html body.printing-technical-report #modal-root .technical-preview-wrap > .technical-paper.print-page-last,
  html body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.print-page-last,
  html body.printing-letter-horizontal #modal-root .letter-preview-wrap > .letter-paper.print-page-last,
  html body.printing-invoice #modal-root .invoice-preview > .document-attachment-print-page.print-page-last,
  html body.printing-receipt #modal-root .receipt-preview-wrap > .document-attachment-print-page.print-page-last,
  html body.printing-check-receipt #modal-root .check-receipt-print-wrap > .document-attachment-print-page.print-page-last,
  html body.printing-quality #modal-root .quality-preview-wrap > .document-attachment-print-page.print-page-last,
  html body.printing-technical-report #modal-root .technical-preview-wrap > .document-attachment-print-page.print-page-last,
  html body.printing-letter #modal-root .letter-preview-wrap > .document-attachment-print-page.print-page-last {
    break-after: auto !important;
    page-break-after: auto !important;
  }

  html body:is(.printing-invoice, .printing-letter, .printing-letter-horizontal, .printing-receipt, .printing-check-receipt, .printing-check-receipt-a4, .printing-quality, .printing-technical-report) #codex-agent-overlay-root,
  html body:is(.printing-invoice, .printing-letter, .printing-letter-horizontal, .printing-receipt, .printing-check-receipt, .printing-check-receipt-a4, .printing-quality, .printing-technical-report) .codex-agent-overlay-root,
  html body:is(.printing-invoice, .printing-letter, .printing-letter-horizontal, .printing-receipt, .printing-check-receipt, .printing-check-receipt-a4, .printing-quality, .printing-technical-report) [data-codex-agent-overlay] {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    break-before: auto !important;
    break-after: auto !important;
    page-break-before: auto !important;
    page-break-after: auto !important;
  }
}

/* Shared invoice frame for the four operational documents.  The approved
   invoice artwork is the only header/footer source; document-specific legacy
   artwork is suppressed so preview and browser PDF use the same A4 geometry. */
@media screen, print {
  #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page),
  #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page),
  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page),
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) {
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    box-sizing: border-box !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    margin: 0 auto !important;
    padding: 0 24mm 40mm 14mm !important;
    overflow: hidden !important;
    background: #fff url("/assets/afv-letterhead-main-clean-20260920.png?v=20260920-header-clean-01") center top / 100% 100% no-repeat !important;
    page: afv-document-a4-unified !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) > .invoice-native-letterhead,
  #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page) > .invoice-native-letterhead {
    display: none !important;
    visibility: hidden !important;
  }

  #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) > .receipt-redesigned-content,
  #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page) > .check-receipt-v3-content {
    position: relative !important;
    z-index: 2 !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    margin-top: 34mm !important;
    margin-bottom: 0 !important;
    overflow: hidden !important;
  }

  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > :not(.official-letterhead-image),
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > :not(.official-letterhead-image) {
    position: relative !important;
    z-index: 2 !important;
  }

  #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) .receipt-paper-footer,
  #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page) .check-receipt-footer,
  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) .quality-paper-footer,
  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) .technical-paper-footer {
    display: none !important;
    visibility: hidden !important;
  }

  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) .technical-paper-head {
    flex: 0 0 34mm !important;
    height: 34mm !important;
    min-height: 34mm !important;
    max-height: 34mm !important;
    padding: 0 0 5mm !important;
    box-sizing: border-box !important;
  }

  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) .technical-english-title,
  #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) .quality-english-title {
    display: block !important;
    color: #f15a24 !important;
    font-size: 10pt !important;
    font-weight: 500 !important;
    line-height: 1.3 !important;
    text-align: right !important;
    direction: ltr !important;
  }

  #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) .technical-meta-grid {
    margin-top: 10mm !important;
  }
}

@media print {
  body.printing-receipt #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page),
  body.printing-check-receipt #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page),
  body.printing-check-receipt-a4 #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page),
  body.printing-quality #modal-root .quality-preview-wrap > .quality-paper.print-page.has-letterhead:not(.document-attachment-page),
  body.printing-technical-report #modal-root .technical-preview-wrap > .technical-paper.print-page.has-letterhead:not(.document-attachment-page) {
    margin: 0 !important;
    page: afv-document-a4-unified !important;
  }
}

/* PRINT-FLOW CLEANUP — mode notes and screen-only relationship rows sit
   before the A4 paper in the preview DOM.  They are useful on screen, but
   their small height can fragment the first A4 sheet and create a trailing
   blank sheet in Chromium's PDF output.  Keep this scoped to the three
   unified operational forms; artwork, footer geometry and paper dimensions
   remain unchanged. */
@media print {
  html body.printing-check-receipt #modal-root .print-mode-note,
  html body.printing-check-receipt-a4 #modal-root .print-mode-note,
  html body.printing-quality #modal-root .quality-print-mode-note,
  html body.printing-technical-report #modal-root .technical-print-mode-note,
  html body.printing-quality #modal-root .document-relation,
  html body.printing-quality #modal-root .quality-screen-only,
  html body.printing-technical-report #modal-root .document-relation,
  html body.printing-technical-report #modal-root .technical-screen-only {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    break-before: auto !important;
    break-after: auto !important;
    page-break-before: auto !important;
    page-break-after: auto !important;
  }
}

/* Invoice-equivalent body start for QC and engineering reports.
   Their markup has a direct paper header (unlike the invoice content wrapper),
   so the header must start inside the same 34mm top safe zone as the invoice. */
@media screen, print {
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) {
    padding-top: 34mm !important;
    padding-right: 24mm !important;
    padding-bottom: 15mm !important;
    padding-left: 14mm !important;
  }

  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-paper-head,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .technical-paper-head {
    flex: 0 0 auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 0 5mm !important;
    box-sizing: border-box !important;
  }
}

@media print {
  html body.printing-quality #modal-root .quality-preview-wrap > .quality-paper.print-page.has-letterhead:not(.document-attachment-page),
  html body.printing-technical-report #modal-root .technical-preview-wrap > .technical-paper.print-page.has-letterhead:not(.document-attachment-page) {
    padding-top: 34mm !important;
    padding-right: 24mm !important;
    padding-bottom: 15mm !important;
    padding-left: 14mm !important;
  }
}

/* RECEIPT-ONLY FOOTER CENTER LOCK (2026-09-21)
   The approved A4 artwork is already centered in the receipt paper.  The
   legacy 8mm compensation was shifting only the receipt footer to the right;
   remove that compensation without changing invoice or outgoing-letter
   artwork. */
@media screen, print {
  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page)::before {
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    transform: none !important;
    clip-path: inset(86% 0 0 0) !important;
  }
}

/* RECEIPT FOOTER ELEMENT LOCK (2026-09-21)
   Receipt preview/print now owns a real footer image.  Do not let the old
   paper background or pseudo-element paint a second, shifted footer. */
@media screen, print {
  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) {
    background-image: none !important;
    background-color: #fff !important;
  }

  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page)::before {
    display: none !important;
    visibility: hidden !important;
    content: none !important;
  }

  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) > .receipt-footer-artwork {
    display: block !important;
    visibility: visible !important;
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    object-fit: fill !important;
    object-position: center center !important;
    clip-path: inset(86% 0 0 0) !important;
    transform: none !important;
    opacity: 1 !important;
    z-index: 0 !important;
    pointer-events: none !important;
  }
}

/* PDF Reader gate: no non-page node may participate in pagination, and the
   last real A4 page must never carry a forced page break. This block is
   intentionally last so older document-specific rules cannot reintroduce a
   trailing blank page. */
@media print {
  html body:is(.printing-invoice, .printing-letter, .printing-letter-horizontal, .printing-receipt, .printing-check-receipt, .printing-check-receipt-a4, .printing-quality, .printing-technical-report) #modal-root .print-non-page {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
    break-before: auto !important;
    break-after: auto !important;
    page-break-before: auto !important;
    page-break-after: auto !important;
  }

  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page-last,
  html body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.print-page-last,
  html body.printing-letter-horizontal #modal-root .letter-preview-wrap > .letter-paper.print-page-last,
  html body.printing-receipt #modal-root .receipt-preview-wrap > .receipt-paper.print-page-last,
  html body.printing-check-receipt #modal-root .check-receipt-print-wrap > .check-receipt-paper.print-page-last,
  html body.printing-check-receipt-a4 #modal-root .check-receipt-print-wrap > .check-receipt-paper.print-page-last,
  html body.printing-quality #modal-root .quality-preview-wrap > .quality-paper.print-page-last,
  html body.printing-technical-report #modal-root .technical-preview-wrap > .technical-paper.print-page-last,
  html body.printing-invoice #modal-root .invoice-preview > .document-attachment-print-page.print-page-last,
  html body.printing-receipt #modal-root .receipt-preview-wrap > .document-attachment-print-page.print-page-last,
  html body.printing-check-receipt #modal-root .check-receipt-print-wrap > .document-attachment-print-page.print-page-last,
  html body.printing-quality #modal-root .quality-preview-wrap > .document-attachment-print-page.print-page-last,
  html body.printing-technical-report #modal-root .technical-preview-wrap > .document-attachment-print-page.print-page-last,
  html body.printing-letter #modal-root .letter-preview-wrap > .document-attachment-print-page.print-page-last {
    break-after: auto !important;
    page-break-after: auto !important;
  }
}

/* Absolute final letter pagination lock. */
@media print {
  html body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.print-page,
  html body.printing-letter-horizontal #modal-root .letter-preview-wrap > .letter-paper.print-page {
    break-before: auto !important;
    page-break-before: auto !important;
    break-after: auto !important;
    page-break-after: auto !important;
  }

  html body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.print-page + .letter-paper.print-page,
  html body.printing-letter-horizontal #modal-root .letter-preview-wrap > .letter-paper.print-page + .letter-paper.print-page {
    break-before: page !important;
    page-break-before: always !important;
  }

  html body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.print-page-last,
  html body.printing-letter-horizontal #modal-root .letter-preview-wrap > .letter-paper.print-page-last {
    break-after: auto !important;
    page-break-after: auto !important;
  }

  html body.printing-letter #modal-root .letter-preview-wrap .letter-attachment-pdf-canvas,
  html body.printing-letter-horizontal #modal-root .letter-preview-wrap .letter-attachment-pdf-canvas,
  html body.printing-letter #modal-root .letter-preview-wrap .letter-attachment-pdf-image,
  html body.printing-letter-horizontal #modal-root .letter-preview-wrap .letter-attachment-pdf-image,
  html body.printing-letter #modal-root .letter-preview-wrap .letter-attachment-visual,
  html body.printing-letter-horizontal #modal-root .letter-preview-wrap .letter-attachment-visual {
    width: auto !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
  }
}

/* Exact invoice footer geometry for outgoing letters. The artwork is a full
   A4 reference image; only its centered lower band is visible. */
@media screen, print {
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) > .letter-invoice-footer-artwork {
    inset: 0 !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    min-height: 100% !important;
    max-height: 100% !important;
    object-fit: fill !important;
    object-position: center center !important;
    clip-path: inset(84% 15% 0 0) !important;
    transform: translateX(14mm) !important;
    bottom: auto !important;
    left: auto !important;
    z-index: 0 !important;
  }
}

/* UNIFIED FOOTER CENTER LOCK — cheque receipt, quality and technical forms.
   This block is intentionally last so the older 8mm compensation rules above
   cannot move the footer artwork away from the A4 center. */
@media screen, print {
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page),
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page),
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) {
    background-image: none !important;
    background-color: #fff !important;
    background-position: 50% 0 !important;
  }

  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page)::before,
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page)::before {
    content: "" !important;
    position: absolute !important;
    inset: 0 !important;
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: url("/assets/afv-letterhead-main-clean-20260920.png?v=20260920-header-clean-01") 0 0 / 100% 100% no-repeat !important;
    clip-path: inset(86% 0 0 0) !important;
    transform: none !important;
    pointer-events: none !important;
    z-index: 1 !important;
  }

  /* DELIVERY RECEIPT HEADER — restore the shared invoice header image while
     keeping the receipt's approved footer artwork as the only footer layer. */
  html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) > .official-letterhead-image {
    display: block !important;
    visibility: visible !important;
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    object-fit: fill !important;
    object-position: center center !important;
    clip-path: inset(0 0 14% 0) !important;
    transform: none !important;
    opacity: 1 !important;
    z-index: 0 !important;
    pointer-events: none !important;
  }
}

/* INVOICE-ONLY PAGE META ALIGNMENT — keep «current از total» on the same
   value axis as شماره، تاریخ and پیوست in both preview and print. */
html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-document-meta > div > .official-page-count-fixed,
html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-document-meta > div > .official-page-count-fixed.invoice-page-count-value {
  display: inline-flex !important;
  align-items: baseline !important;
  justify-content: flex-start !important;
  flex-direction: row !important;
  width: 34mm !important;
  min-width: 34mm !important;
  max-width: 34mm !important;
  direction: ltr !important;
  unicode-bidi: isolate !important;
  gap: 0 !important;
  white-space: nowrap !important;
  text-align: left !important;
}

html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-document-meta > div > .official-page-count-fixed > .page-count-current,
html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-document-meta > div > .official-page-count-fixed > .page-count-separator,
html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-document-meta > div > .official-page-count-fixed > .page-count-total,
html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-document-meta > div > .official-page-count-fixed > .official-page-current,
html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-document-meta > div > .official-page-count-fixed > .official-page-separator,
html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-document-meta > div > .official-page-count-fixed > .official-page-total {
  display: inline-block !important;
  position: static !important;
  order: initial !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  direction: ltr !important;
  unicode-bidi: isolate !important;
  white-space: nowrap !important;
  font-family: "BNazanin", "B Nazanin", "Vazirmatn", Tahoma, Arial, sans-serif !important;
  font-variant-numeric: normal !important;
}

html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-document-meta > div > .official-page-count-fixed > .page-count-separator,
html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .official-document-meta > div > .official-page-count-fixed > .official-page-separator {
  padding-inline: .28em !important;
  direction: rtl !important;
}

/* RECEIPT-ONLY REFERENCE FOOTER — use the exact approved invoice/letter
   footer crop and offset; do not alter the other document templates. */
html body #modal-root .receipt-preview-wrap > .receipt-paper.receipt-redesigned.has-letterhead:not(.document-attachment-page) > .receipt-footer-artwork {
  inset: 0 !important;
  width: 100% !important;
  min-width: 100% !important;
  max-width: 100% !important;
  height: 100% !important;
  min-height: 100% !important;
  max-height: 100% !important;
  object-fit: fill !important;
  object-position: center center !important;
  clip-path: inset(84% 15% 0 0) !important;
  transform: translateX(14mm) !important;
  bottom: auto !important;
  left: auto !important;
  z-index: 0 !important;
}

/* CHECK-RECEIPT-ONLY HEADER RESTORE — the reference sheet is split into a
   visible header layer and the independent footer layer. */
html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page) > .official-letterhead-image {
  display: block !important;
  visibility: visible !important;
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  margin: 0 !important;
  object-fit: fill !important;
  object-position: center center !important;
  clip-path: inset(0 0 14% 0) !important;
  transform: none !important;
  opacity: 1 !important;
  z-index: 0 !important;
  pointer-events: none !important;
}

/* QUALITY-ONLY HEADER RESTORE — match the invoice header layer while the
   existing quality footer remains independently cropped below it. */
html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image {
  display: block !important;
  visibility: visible !important;
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  margin: 0 !important;
  object-fit: fill !important;
  object-position: center center !important;
  clip-path: inset(0 0 14% 0) !important;
  transform: none !important;
  opacity: 1 !important;
  z-index: 0 !important;
  pointer-events: none !important;
}

/* TECHNICAL-REPORT-ONLY HEADER RESTORE — match the invoice header layer;
   leave the technical footer crop and content layout unchanged. */
html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image {
  display: block !important;
  visibility: visible !important;
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  margin: 0 !important;
  object-fit: fill !important;
  object-position: center center !important;
  clip-path: inset(0 0 14% 0) !important;
  transform: none !important;
  opacity: 1 !important;
  z-index: 0 !important;
  pointer-events: none !important;
}

/* CHECK RECEIPT TITLE + FOOTER FINAL LOCK — keep this fix scoped to the
   cheque-delivery receipt.  The title must be centered on the A4 sheet (not
   the right edge of the flex header), and the footer must remain visible in
   both preview and browser print. */
@media screen, print {
  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page) > .check-receipt-v3-content > .check-receipt-paper-head {
    display: block !important;
    position: relative !important;
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    text-align: center !important;
  }

  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page) > .check-receipt-v3-content > .check-receipt-paper-head > .check-receipt-title-block {
    display: block !important;
    position: relative !important;
    left: 5mm !important;
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    text-align: center !important;
  }

  html body #modal-root .check-receipt-print-wrap > .check-receipt-paper.check-receipt-v3.has-letterhead:not(.document-attachment-page)::before {
    visibility: visible !important;
    opacity: 1 !important;
    display: block !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    clip-path: inset(86% 0 0 0) !important;
    transform: translateX(14mm) !important;
    z-index: 1 !important;
  }
}

/* QUALITY HEADER ALIGNMENT — use the same A4 header geometry as the
   approved invoice.  The quality report keeps its own English report title,
   but the header grid, safe zone and paper center must be identical. */
@media screen, print {
  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-paper-head {
    display: grid !important;
    grid-template-columns: 43mm minmax(0, 1fr) 43mm !important;
    align-items: center !important;
    width: 100% !important;
    position: relative !important;
    left: 5mm !important;
    height: 34mm !important;
    min-height: 34mm !important;
    max-height: 34mm !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-sizing: border-box !important;
  }

  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .quality-paper-head > div:first-child {
    grid-column: 2 !important;
    grid-row: 1 !important;
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    align-items: center !important;
    justify-content: center !important;
    flex-direction: column !important;
    margin: 0 !important;
    padding: 0 !important;
    text-align: center !important;
  }

  html body #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page)::before {
    visibility: visible !important;
    opacity: 1 !important;
    display: block !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    clip-path: inset(86% 0 0 0) !important;
    transform: translateX(14mm) !important;
    z-index: 1 !important;
  }

  /* TECHNICAL REPORT FOOTER — the official letterhead image owns the footer;
     keep the legacy internal coding footer hidden to avoid a duplicate. */
  html body #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page)::before {
    visibility: visible !important;
    opacity: 1 !important;
    display: block !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    clip-path: inset(86% 0 0 0) !important;
    transform: translateX(14mm) !important;
    z-index: 1 !important;
  }
}

/* FINAL PAGE-FLOW LOCK — page breaks belong before following sheets, never
   after the last sheet.  This is deliberately the final print rule so it
   cannot be overridden by legacy document-specific pagination. */
@media print {
  html body:is(.printing-invoice, .printing-letter, .printing-letter-horizontal, .printing-receipt, .printing-check-receipt, .printing-check-receipt-a4, .printing-quality, .printing-technical-report) #modal-root .print-page {
    break-after: auto !important;
    page-break-after: auto !important;
  }

  html body:is(.printing-invoice, .printing-letter, .printing-letter-horizontal, .printing-receipt, .printing-check-receipt, .printing-check-receipt-a4, .printing-quality, .printing-technical-report) #modal-root .print-page:not(.print-page-first) {
    break-before: page !important;
    page-break-before: always !important;
  }

  html body:is(.printing-invoice, .printing-letter, .printing-letter-horizontal, .printing-receipt, .printing-check-receipt, .printing-check-receipt-a4, .printing-quality, .printing-technical-report) #modal-root .print-page-first {
    break-before: auto !important;
    page-break-before: auto !important;
  }

  html body:is(.printing-invoice, .printing-letter, .printing-letter-horizontal, .printing-receipt, .printing-check-receipt, .printing-check-receipt-a4, .printing-quality, .printing-technical-report) #modal-root .print-page-last {
    break-after: avoid-page !important;
    page-break-after: avoid !important;
  }
}

/* Invoice pagination compositor: each generated A4 sheet already owns the
   break after the previous sheet. A second forced break-before on every
   non-first sheet makes Chromium print the table continuation as a separate
   fragment without the sheet artwork. Keep one break direction only. */
@media print {
  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page {
    break-before: auto !important;
    page-break-before: auto !important;
    break-after: page !important;
    page-break-after: always !important;
  }

  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page.print-page-first {
    break-before: auto !important;
    page-break-before: auto !important;
  }

  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page.print-page-last {
    break-after: auto !important;
    page-break-after: auto !important;
  }
}

/* Final multi-page invoice flow: the preview uses a flex column, but Chromium
   can paint only alternating flex items when each item is an exact A4 page.
   Browser print must use a normal block flow so every cloned paper owns one
   physical sheet and its letterhead is painted consistently. */
@media print {
  html body.printing-invoice #modal-root .invoice-preview {
    display: block !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
  }

  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page {
    display: block !important;
    flex: none !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
  }
}

/* Apply the same non-flex print flow to every A4 document family. The screen
   layouts may be flex/grid based, but exact-height flex items can make
   Chromium omit page-owned letterhead artwork on alternating pages. */
@media print {
  html body.printing-receipt #modal-root .receipt-preview-wrap,
  html body.printing-check-receipt #modal-root .check-receipt-print-wrap,
  html body.printing-check-receipt-a4 #modal-root .check-receipt-print-wrap,
  html body.printing-quality #modal-root .quality-preview-wrap,
  html body.printing-technical-report #modal-root .technical-preview-wrap,
  html body.printing-letter #modal-root .letter-preview-wrap {
    display: block !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
  }

  html body.printing-receipt #modal-root .receipt-preview-wrap > .print-page,
  html body.printing-check-receipt #modal-root .check-receipt-print-wrap > .print-page,
  html body.printing-check-receipt-a4 #modal-root .check-receipt-print-wrap > .print-page,
  html body.printing-quality #modal-root .quality-preview-wrap > .print-page,
  html body.printing-technical-report #modal-root .technical-preview-wrap > .print-page,
  html body.printing-letter #modal-root .letter-preview-wrap > .print-page {
    display: block !important;
    flex: none !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
  }
}

/* Paint the approved letterhead as the page background of every materialized
   invoice sheet. Chromium can intermittently omit an absolutely positioned
   image on an intermediate sheet; a page-owned CSS background is repeated
   deterministically while the content remains above it. */
@media print {
  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page {
    background: #fff url("/assets/afv-letterhead-main-clean-20260920.png?v=20260920-header-clean-01") center top / 100% 100% no-repeat !important;
    print-color-adjust: exact !important;
    -webkit-print-color-adjust: exact !important;
  }

  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page > .official-letterhead-image,
  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page > .invoice-footer-artwork {
    visibility: hidden !important;
    opacity: 0 !important;
  }
}

/* Final shared artwork fallback for every non-invoice A4 form. The clean
   letterhead is a complete page-owned image, so it remains present on every
   cloned sheet (including middle pages) instead of depending on an absolutely
   positioned image or pseudo-element surviving print fragmentation. */
@media print {
  html body.printing-receipt #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page),
  html body.printing-check-receipt #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page),
  html body.printing-check-receipt-a4 #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page),
  html body.printing-quality #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page),
  html body.printing-technical-report #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page),
  html body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page),
  html body.printing-letter-horizontal #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) {
    background: #fff url("/assets/afv-letterhead-main-clean-20260920.png?v=20260920-header-clean-01") center top / 100% 100% no-repeat !important;
    print-color-adjust: exact !important;
    -webkit-print-color-adjust: exact !important;
  }

  html body.printing-receipt #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body.printing-receipt #modal-root .receipt-preview-wrap > .receipt-paper.has-letterhead:not(.document-attachment-page) > .invoice-footer-artwork,
  html body.printing-check-receipt #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body.printing-check-receipt-a4 #modal-root .check-receipt-print-wrap > .check-receipt-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body.printing-quality #modal-root .quality-preview-wrap > .quality-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body.printing-technical-report #modal-root .technical-preview-wrap > .technical-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body.printing-letter-horizontal #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) > .official-letterhead-image,
  html body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) > .invoice-footer-artwork,
  html body.printing-letter-horizontal #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) > .invoice-footer-artwork {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
  }
}

/* FINAL LETTER READABILITY PRECEDENCE (2026-09-27 / v1.2.1). */
@media screen, print {
  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) > .letter-document {
    top: 34mm !important;
    right: 24mm !important;
    bottom: 34mm !important;
    left: 14mm !important;
    padding: 0 !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) .letter-basmala {
    font-size: 22pt !important;
    line-height: 1.35 !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) .letter-recipient {
    margin-top: 20mm !important;
    font-size: 16pt !important;
    line-height: 1.8 !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) .letter-subject {
    margin-top: 10mm !important;
    font-size: 14pt !important;
    line-height: 1.8 !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) .letter-body-content {
    margin-top: 10mm !important;
    font-size: 14pt !important;
    line-height: 2.15 !important;
    text-align: justify !important;
    text-align-last: right !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) .letter-body-content p {
    margin-bottom: 6mm !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) .letter-attachment-detail {
    margin-top: 7mm !important;
    padding: 4mm 5mm !important;
    font-size: 10.5pt !important;
    line-height: 1.8 !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) .letter-signature-area {
    width: 70mm !important;
    margin-top: 13mm !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) .letter-closing,
  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) .letter-signature-area > strong {
    font-size: 13pt !important;
    line-height: 1.7 !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) .letter-signature-area > span {
    margin-top: 2mm !important;
    font-size: 11.5pt !important;
    line-height: 1.6 !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) .letter-meta > div > strong,
  html body #modal-root .letter-preview-wrap > .letter-paper.afv-unified-document-theme.has-letterhead:not(.document-attachment-page) .letter-meta > div > span {
    font-size: 10.5pt !important;
    line-height: 1.45 !important;
  }
}

/* FINAL LETTER FOOTER BALANCED MARGINS (2026-09-27 / v1.2.3).
   The QR-free artwork has an intentionally blank right source area.  Paint
   only its footer band on top of a white mask and shift that band by the
   measured 14mm so the visible left/right margins are equal. */
@media screen, print {
  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) {
    background: #fff url("/assets/afv-letterhead-main-clean-20260920.png?v=20260920-header-clean-01") center top / 100% 100% no-repeat !important;
    print-color-adjust: exact !important;
    -webkit-print-color-adjust: exact !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page)::after {
    content: "" !important;
    position: absolute !important;
    inset: 84% 0 0 0 !important;
    display: block !important;
    width: 100% !important;
    height: 16% !important;
    border: 0 !important;
    background: #fff !important;
    pointer-events: none !important;
    z-index: 1 !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) > .letter-invoice-footer-artwork,
  html body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) > .letter-invoice-footer-artwork,
  html body.printing-letter-horizontal #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) > .letter-invoice-footer-artwork {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    min-height: 100% !important;
    max-height: 100% !important;
    margin: 0 !important;
    object-fit: fill !important;
    object-position: center center !important;
    clip-path: inset(84% 0 0 0) !important;
    transform: translateX(14mm) !important;
    z-index: 2 !important;
    pointer-events: none !important;
  }

  html body #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) > .letter-document,
  html body.printing-letter #modal-root .letter-preview-wrap > .letter-paper.has-letterhead:not(.document-attachment-page) > .letter-document {
    z-index: 3 !important;
  }
}

/* INVOICE PRINT/PREVIEW PARITY (2026-09-28).
   The preview centers the QR-free footer strip, while the final print
   fallback previously painted the complete letterhead as an unshifted page
   background. Keep the header in the page background and repaint only the
   lower footer band from the QR-free artwork at the same measured center as
   the preview. */
@media print {
  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) {
    position: relative !important;
    overflow: hidden !important;
  }

  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page)::after {
    content: "" !important;
    display: block !important;
    position: absolute !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 16% !important;
    margin: 0 !important;
    border: 0 !important;
    background-color: #fff !important;
    background-image: url("/assets/afv-letterhead-main-clean-20260920.png?v=20260928-invoice-footer-center-01") !important;
    background-repeat: no-repeat !important;
    background-position: calc(50% + 14mm) bottom !important;
    background-size: 100% auto !important;
    print-color-adjust: exact !important;
    -webkit-print-color-adjust: exact !important;
    pointer-events: none !important;
    z-index: 2 !important;
  }

  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) > .invoice-footer-artwork {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
  }
}

/* INVOICE PDF RELEASE PATCH 03 (2026-09-28).
   Keep the approved preview unchanged, but make the browser print compositor
   own the same footer and signature geometry. The footer is repainted from
   the QR-free artwork with the measured 14mm correction; the last generated
   A4 sheet never requests a trailing break. */
@media print {
  @page afv-final-document-a4 { size: A4 portrait; margin: 0; }

  html body.printing-invoice #modal-root,
  html body.printing-invoice #modal-root .modal-body,
  html body.printing-invoice #modal-root .invoice-preview {
    margin: 0 !important;
    padding: 0 !important;
    min-height: 0 !important;
    height: auto !important;
    overflow: visible !important;
  }

  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page {
    page: afv-final-document-a4 !important;
    display: block !important;
    position: relative !important;
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    break-before: auto !important;
    page-break-before: auto !important;
    break-after: auto !important;
    page-break-after: auto !important;
  }

  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page + .invoice-paper.print-page {
    break-before: page !important;
    page-break-before: always !important;
  }

  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page.print-page-last {
    break-after: auto !important;
    page-break-after: auto !important;
  }

  html body.printing-invoice #modal-root .invoice-preview > .print-non-page {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    break-before: auto !important;
    break-after: auto !important;
    page-break-before: auto !important;
    page-break-after: auto !important;
  }

  /* Keep the page-owned header background; repaint only the lower strip so
     the source artwork's intentionally asymmetric empty area is corrected. */
  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page.has-letterhead {
    background: #fff url("/assets/afv-letterhead-main-clean-20260920.png?v=20260928-invoice-footer-print-02") center top / 100% 100% no-repeat !important;
    print-color-adjust: exact !important;
    -webkit-print-color-adjust: exact !important;
  }

  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page.has-letterhead::after {
    content: "" !important;
    display: block !important;
    position: absolute !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 16% !important;
    margin: 0 !important;
    border: 0 !important;
    background: #fff url("/assets/afv-letterhead-main-clean-20260920.png?v=20260928-invoice-footer-print-02") no-repeat !important;
    background-position: calc(50% + 14mm) bottom !important;
    background-size: 100% auto !important;
    print-color-adjust: exact !important;
    -webkit-print-color-adjust: exact !important;
    pointer-events: none !important;
    z-index: 20 !important;
  }

  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page.has-letterhead > .invoice-footer-artwork,
  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page.has-letterhead > .official-letterhead-image {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
  }

  /* Use the full supplied Dadseresht raster and let the print compositor
     scale it once. No filter, opacity or interpolation override is allowed. */
  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page .invoice-signature-image {
    display: block !important;
    width: 50mm !important;
    max-width: 50mm !important;
    height: 25mm !important;
    max-height: 25mm !important;
    margin: 0 auto !important;
    object-fit: contain !important;
    object-position: center !important;
    opacity: 1 !important;
    filter: none !important;
    image-rendering: auto !important;
  }
}

/* FINAL INVOICE FOOTER CENTER LOCK (2026-09-28).
   The source letterhead artwork has unequal empty space around its footer.
   Use the pre-centered raster for invoice pages so preview/PDF share the
   same page-owned artwork; do not rely on a pseudo-element background offset
   that Chromium may ignore during print composition. */
@media screen, print {
  html body #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page) {
    background-image: url("/assets/afv-letterhead-main-centered-20260928.png?v=20260928-invoice-footer-centered-01") !important;
    background-repeat: no-repeat !important;
    background-position: center center !important;
    background-size: 100% 100% !important;
    background-color: #fff !important;
  }
}

@media print {
  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.has-letterhead:not(.document-attachment-page)::after {
    display: none !important;
    visibility: hidden !important;
    content: none !important;
  }
}

/* FINAL INVOICE SIGNATURE PARITY LOCK.
   The preview keeps the seller signature visible. The PDF must use the same
   signature band, without the legacy hide rule, dashed box, or blend/filter
   pass that softens the raster in Chromium's print compositor. */
@media print {
  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page.has-letterhead:not(.document-attachment-page) > .invoice-paper-content > .print-flow-signature-band,
  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page.has-letterhead:not(.document-attachment-page) > .invoice-paper-content > .invoice-paper-signature-band {
    display: flex !important;
    visibility: visible !important;
    position: static !important;
    width: 88mm !important;
    min-width: 88mm !important;
    max-width: 88mm !important;
    height: 42mm !important;
    min-height: 42mm !important;
    max-height: 42mm !important;
    margin: 8mm auto 0 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    border: 0 !important;
    background: transparent !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page.has-letterhead:not(.document-attachment-page) .invoice-seller-signature {
    display: flex !important;
    visibility: visible !important;
    width: 88mm !important;
    min-width: 88mm !important;
    max-width: 88mm !important;
    height: 42mm !important;
    min-height: 42mm !important;
    max-height: 42mm !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow: visible !important;
  }

  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page.has-letterhead:not(.document-attachment-page) .invoice-seller-signature .invoice-signature-assets {
    display: flex !important;
    visibility: visible !important;
    align-items: center !important;
    justify-content: center !important;
    width: 88mm !important;
    height: 29mm !important;
    min-height: 29mm !important;
    margin: 0 !important;
    border: 0 !important;
    background: transparent !important;
  }

  html body.printing-invoice #modal-root .invoice-preview > .invoice-paper.print-page.has-letterhead:not(.document-attachment-page) .invoice-seller-signature .invoice-signature-image {
    display: block !important;
    visibility: visible !important;
    width: 50mm !important;
    max-width: 50mm !important;
    height: 24mm !important;
    max-height: 24mm !important;
    margin: 0 auto !important;
    object-fit: contain !important;
    object-position: center !important;
    image-rendering: auto !important;
    mix-blend-mode: normal !important;
    filter: none !important;
    opacity: 1 !important;
    border: 0 !important;
    outline: 0 !important;
  }
}
