/* Printable A4 report — shared by the in-app preview, the browser print and the PDF export */
.pdoc {
  --pg: #076b37; --pgd: #0b3b24; --pgl: #e9f3ec; --pgold: #b8901c; --pline: #c9d6cd; --pink: #18261e;
  position: relative; width: 100%; max-width: 794px; margin: 0 auto; background: #fff; color: var(--pink);
  font-family: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif; font-size: 9pt; line-height: 1.45; padding: 26px 26px 18px;
}
.sheet-wrap { overflow-x: auto; padding: 4px 0 20px; }
.sheet-wrap .pdoc { box-shadow: 0 10px 40px rgba(11, 59, 36, .14); border-radius: 6px; border: 1px solid #e3e9e5; }
.pdoc * { box-sizing: border-box; }
.pdoc .p-watermark { position: absolute; inset: 180px 0 auto; text-align: center; font-size: 120pt; font-weight: 700; color: rgba(179, 38, 30, .06); transform: rotate(-24deg); pointer-events: none; z-index: 0; }
.pdoc > * { position: relative; z-index: 1; }

.p-head { display: grid; grid-template-columns: 112px 1fr 272px; gap: 14px; align-items: center; padding-bottom: 10px; border-bottom: 3px solid var(--pg); }
.p-head::after { content: ''; position: absolute; inset-inline: 0; bottom: -6px; height: 1px; background: var(--pgold); }
.p-logo { width: 110px; height: auto; display: block; }
.p-title h1 { margin: 0 0 3px; font-size: 14.5pt; color: var(--pgd); line-height: 1.3; }
.p-title div { color: var(--pgold); font-weight: 600; font-size: 9pt; }
.p-title small { display: block; color: #6b7a71; font-size: 7.5pt; margin-top: 2px; }
.p-id { border: 1.5px solid var(--pg); border-radius: 8px; padding: 6px 8px 4px; text-align: center; background: #fff; }
.p-id span { display: block; font-size: 7.5pt; color: #6b7a71; font-weight: 600; }
.p-id b { display: block; font-size: 10pt; color: var(--pgd); }
.p-id small { color: #b3261e; font-size: 7.5pt; }
.p-id.draft { border-style: dashed; border-color: #b3261e; }
.p-barcode { display: block; width: 258px; max-width: 100%; height: auto; margin: 2px auto 0; }

.p-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 0; margin: 14px 0 10px; border: 1px solid var(--pline); border-radius: 6px; overflow: hidden; }
.p-meta div { padding: 5px 8px; border-inline-start: 1px solid var(--pline); background: #fbfcfb; }
.p-meta div:first-child { border-inline-start: 0; }
.p-meta span { display: block; font-size: 7pt; color: #6b7a71; }
.p-meta b { font-size: 8.5pt; color: var(--pgd); }

.p-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }
.p-kpi { border: 1px solid var(--pline); border-top: 3px solid var(--pgold); border-radius: 6px; padding: 5px 8px; break-inside: avoid; }
.p-kpi span { display: block; font-size: 7pt; color: #6b7a71; font-weight: 600; }
.p-kpi b { display: block; font-size: 12.5pt; color: var(--pgd); line-height: 1.25; }
.p-kpi small { display: block; font-size: 6.6pt; color: #6b7a71; }
.p-kpi.t-bad b { color: #b3261e; } .p-kpi.t-warn b { color: #a35f00; } .p-kpi.t-ok b { color: #1f7a3a; }

.p-sec { margin-bottom: 10px; break-inside: auto; }
.p-sec-head { margin: 0 0 4px; font-size: 9pt; color: #fff; background: linear-gradient(90deg, var(--pgd), var(--pg)); padding: 4px 9px; border-radius: 5px; break-after: avoid; }
.p-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
.p-pair .p-sec { margin-bottom: 10px; }

table.pt { width: 100%; border-collapse: collapse; font-size: 7.3pt; table-layout: auto; }
table.pt th { background: var(--pgl); color: var(--pgd); font-weight: 600; border: 1px solid var(--pline); padding: 3px 3px; line-height: 1.25; vertical-align: bottom; }
table.pt td { border: 1px solid var(--pline); padding: 2.5px 4px; text-align: center; vertical-align: middle; line-height: 1.3; }
table.pt td.p-lab { text-align: start; font-weight: 600; background: #fbfcfb; color: var(--pgd); }
table.pt td.p-txt { text-align: start; }
table.pt td.b { font-weight: 700; }
table.pt tbody tr:nth-child(even) td:not(.p-lab) { background: #fcfdfc; }
table.pt tfoot td { background: var(--pgl); font-weight: 700; color: var(--pgd); }
table.pt tr { break-inside: avoid; }
table.pt thead { display: table-header-group; }
table.pt.pt-dense { font-size: 6.6pt; }
table.pt.pt-dense th, table.pt.pt-dense td { padding: 2px 2px; }
table.pt .p-mark { width: 26px; font-size: 8pt; }
td.p-empty, div.p-empty { color: #8a968f; text-align: center; padding: 6px; font-size: 7.5pt; }
.t-bad { color: #b3261e !important; } .t-warn { color: #a35f00 !important; } .t-ok { color: #1f7a3a !important; } .t-muted { color: #8a968f !important; }

.p-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.p-pair .p-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.p-fld { border: 1px solid var(--pline); border-radius: 5px; padding: 4px 7px; break-inside: avoid; }
.p-fld span { display: block; font-size: 6.8pt; color: #6b7a71; }
.p-fld b { font-size: 8.5pt; font-weight: 600; white-space: pre-wrap; }
.p-fld.p-wide { grid-column: 1 / -1; }
.p-lines { margin: 0; padding: 0 18px 0 0; font-size: 8pt; }
.p-lines li { padding: 2px 0; border-bottom: 1px dotted var(--pline); }
.p-checks ul { margin: 0; padding: 0 18px 0 0; columns: 2; font-size: 7.6pt; }
.p-checks p { margin: 0; font-size: 8pt; }
.p-comments { margin: 0; padding: 0 18px 0 0; font-size: 7.8pt; }

.p-review { display: flex; gap: 12px; align-items: center; border: 1.5px solid #1f7a3a; border-radius: 8px; padding: 8px 12px; margin: 6px 0 10px; font-size: 8.5pt; break-inside: avoid; }
.p-review.warn { border-color: #a35f00; }
.p-review p { margin: 3px 0 0; }
.p-stamp { flex: none; border: 2.5px solid currentColor; color: #1f7a3a; border-radius: 8px; padding: 3px 12px; font-weight: 700; font-size: 12pt; transform: rotate(-4deg); }
.p-review.warn .p-stamp { color: #a35f00; }

.p-signs { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-top: 12px; break-inside: avoid; }
.p-sign { border: 1px solid var(--pline); border-radius: 6px; padding: 6px 8px; min-height: 86px; font-size: 7.6pt; display: grid; gap: 5px; align-content: start; }
.p-sign > span { font-weight: 700; color: var(--pgd); font-size: 8pt; border-bottom: 1px solid var(--pline); padding-bottom: 3px; }
.p-sign div { border-bottom: 1px dotted #b9c6bd; padding-bottom: 3px; min-height: 16px; }
.p-foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 12px; padding-top: 6px; border-top: 1px solid var(--pline); font-size: 6.8pt; color: #6b7a71; }

/* offscreen host used for PDF rendering */
.pdf-host { position: fixed; top: 0; left: 0; z-index: -50; width: 794px; pointer-events: none; }
.pdf-host .pdoc { max-width: none; width: 794px; padding: 0 30px 4px; box-shadow: none; border: 0; border-radius: 0; }

@media (max-width: 720px) {
  .sheet-wrap .pdoc { min-width: 720px; }
}

@page { size: A4 portrait; margin: 10mm 9mm 12mm; }
@media print {
  html, body { background: #fff !important; }
  body.print-mode .shell, body.print-mode .toasts, body.print-mode .backdrop, body.print-mode .no-print { display: none !important; }
  body.print-mode #print-root { display: block !important; }
  #print-root .pdoc { max-width: none; width: 100%; padding: 0; box-shadow: none; border: 0; border-radius: 0; }
  .pdoc { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .p-sec-head, .p-kpi, .p-sign, .p-fld, .p-review { break-inside: avoid; }
}
#print-root { display: none; }
