/* ==========================================================================
   ThaDigital Enterprise - A4 document renderer
   Used for every "Export PDF" action in the demos. The browser's own
   print-to-PDF gives vector text, selectable content and real page breaks,
   so exported documents are genuinely print-quality rather than screenshots.
   ========================================================================== */

.pdoc{
  width:210mm;
  min-height:297mm;
  padding:16mm 15mm 20mm;
  background:#fff;
  color:#14171B;
  font-family:'Inter',-apple-system,'Segoe UI',sans-serif;
  font-size:10pt;
  line-height:1.5;
  box-sizing:border-box;
}

.pdoc-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16mm;
  padding-bottom:6mm;
  border-bottom:2px solid #14171B;
}
.pdoc-org{display:flex;align-items:center;gap:5mm;}
.pdoc-org img{width:15mm;height:15mm;}
.pdoc-org .nm{
  font-family:'Space Grotesk','Segoe UI',sans-serif;
  font-size:15pt;font-weight:700;letter-spacing:-.02em;line-height:1.1;
}
.pdoc-org .sub{
  font-family:'JetBrains Mono',Consolas,monospace;
  font-size:6.5pt;letter-spacing:.22em;text-transform:uppercase;color:#6B737C;margin-top:1.4mm;
}
.pdoc-org .meta{font-size:8pt;color:#6B737C;margin-top:2mm;line-height:1.45;}

.pdoc-doc{text-align:right;flex:none;}
.pdoc-doc .type{
  font-family:'Space Grotesk','Segoe UI',sans-serif;
  font-size:14pt;font-weight:700;letter-spacing:-.01em;text-transform:uppercase;
}
.pdoc-doc .no{
  font-family:'JetBrains Mono',Consolas,monospace;
  font-size:9.5pt;color:#B87F25;margin-top:1.5mm;font-weight:600;
}
.pdoc-doc .dt{font-size:8pt;color:#6B737C;margin-top:1.5mm;}

.pdoc-strip{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:4mm;
  margin-top:6mm;
  padding:4mm 5mm;
  background:#F4F5F3;
  border:.3mm solid #E0E2DE;
  border-radius:1.2mm;
}
.pdoc-strip .c .k{
  font-family:'JetBrains Mono',Consolas,monospace;
  font-size:6.4pt;letter-spacing:.14em;text-transform:uppercase;color:#7A828B;margin-bottom:1.2mm;
}
.pdoc-strip .c .v{font-size:9.5pt;font-weight:600;line-height:1.3;}

.pdoc h2{
  font-family:'Space Grotesk','Segoe UI',sans-serif;
  font-size:11pt;font-weight:700;margin:8mm 0 3mm;
  padding-bottom:1.6mm;border-bottom:.4mm solid #14171B;
  letter-spacing:-.01em;
}
.pdoc h2:first-of-type{margin-top:7mm;}

.pdoc table{width:100%;border-collapse:collapse;font-size:9pt;margin-bottom:4mm;}
.pdoc thead th{
  text-align:left;padding:2.2mm 2.5mm;
  background:#14171B;color:#fff;
  font-size:7.2pt;letter-spacing:.08em;text-transform:uppercase;font-weight:600;
}
.pdoc tbody td{padding:2.2mm 2.5mm;border-bottom:.25mm solid #E0E2DE;vertical-align:top;}
.pdoc tbody tr:nth-child(even) td{background:#FAFBF9;}
.pdoc tfoot td{
  padding:2.6mm 2.5mm;border-top:.5mm solid #14171B;font-weight:700;background:#F4F5F3;
}
.pdoc .n{
  text-align:right;
  font-family:'JetBrains Mono',Consolas,monospace;
  font-variant-numeric:tabular-nums;white-space:nowrap;
}
.pdoc .muted{color:#6B737C;}
.pdoc .sm{font-size:7.6pt;}

.pdoc-totals{
  display:flex;justify-content:flex-end;margin-top:4mm;
}
.pdoc-totals table{width:78mm;margin:0;}
.pdoc-totals td{padding:2mm 2.5mm;border-bottom:.25mm solid #E0E2DE;}
.pdoc-totals tr:last-child td{
  border-bottom:none;border-top:.5mm solid #14171B;
  font-size:12pt;font-weight:700;padding-top:2.6mm;
}
.pdoc-totals tr:last-child .n{color:#B87F25;}

.pdoc-cols{display:grid;grid-template-columns:1fr 1fr;gap:8mm;}
.pdoc-cols-3{display:grid;grid-template-columns:repeat(3,1fr);gap:6mm;}

.pdoc-box{
  border:.3mm solid #E0E2DE;border-radius:1.2mm;padding:4mm;background:#FAFBF9;
}
.pdoc-box .t{
  font-family:'JetBrains Mono',Consolas,monospace;
  font-size:6.5pt;letter-spacing:.14em;text-transform:uppercase;color:#7A828B;margin-bottom:2mm;
}
.pdoc-box .big{
  font-family:'Space Grotesk','Segoe UI',sans-serif;
  font-size:16pt;font-weight:700;letter-spacing:-.02em;
}

.pdoc-kv{display:grid;grid-template-columns:auto 1fr;gap:1.8mm 4mm;font-size:8.6pt;}
.pdoc-kv dt{color:#7A828B;}
.pdoc-kv dd{margin:0;font-weight:500;}

.pdoc-sign{
  display:grid;grid-template-columns:repeat(3,1fr);gap:10mm;margin-top:14mm;
}
.pdoc-sign .s{border-top:.35mm solid #9AA1A9;padding-top:2mm;font-size:8pt;color:#6B737C;}

.pdoc-foot{
  margin-top:10mm;padding-top:3mm;
  border-top:.3mm solid #E0E2DE;
  display:flex;justify-content:space-between;gap:8mm;
  font-size:7.4pt;color:#8A9199;line-height:1.5;
}

.pdoc-watermark{
  margin-top:5mm;padding:3mm 4mm;
  border-left:1mm solid #B87F25;background:#FDF6E9;
  font-size:7.8pt;color:#6B5426;line-height:1.5;border-radius:0 1.2mm 1.2mm 0;
}

.pdoc-bar{display:flex;align-items:center;gap:2mm;}
.pdoc-bar .track{flex:1;height:2.2mm;background:#E4E6E2;border-radius:2mm;overflow:hidden;}
.pdoc-bar .fill{height:100%;background:#B87F25;}

/* --------------------------------------------------------------------------
   Print mode - hide the whole site, show only the generated document.

   The page margins live on @page, NOT as padding on .pdoc. That distinction
   is the whole ballgame for multi-page documents: padding only applies at the
   start and end of the element, so a two-page report laid out with padding
   gets a proper top margin on page one and then runs edge-to-edge on page
   two. Moving the margins to @page gives every page the same frame.
   -------------------------------------------------------------------------- */

@media print{
  @page{
    size:A4 portrait;
    margin:13mm 13mm 13mm;
  }

  html,body{
    background:#fff !important;
    margin:0 !important;
    padding:0 !important;
    height:auto !important;
    overflow:visible !important;
  }

  body.is-printing > *{display:none !important;}
  body.is-printing .printdoc-host{
    display:block !important;
    position:static !important;
    left:auto !important;
    width:auto !important;
  }

  /* the page box now supplies the frame, so the document itself is flush */
  body.is-printing .pdoc{
    width:auto;
    min-height:0;
    padding:0;
    box-shadow:none;
    break-after:page;
    page-break-after:always;
  }
  body.is-printing .pdoc:last-child{break-after:auto;page-break-after:auto;}

  /* ---- keep tables readable when they span pages ---- */
  .pdoc thead{display:table-header-group;}   /* header repeats on every page */
  .pdoc tfoot{display:table-footer-group;}
  .pdoc tr{break-inside:avoid;page-break-inside:avoid;}
  .pdoc thead th{break-after:avoid;page-break-after:avoid;}

  /* ---- blocks that must never be sliced in half ---- */
  .pdoc-head,
  .pdoc-strip,
  .pdoc-box,
  .pdoc-totals,
  .pdoc-sign,
  .pdoc-watermark,
  .pdoc-foot,
  .pdoc-kv,
  .receipt{
    break-inside:avoid;
    page-break-inside:avoid;
  }

  /* the letterhead and the summary strip belong with what follows them */
  .pdoc-head,.pdoc-strip{break-after:avoid;page-break-after:avoid;}

  /* a heading must never be the last thing on a page */
  .pdoc h2{
    break-after:avoid;page-break-after:avoid;
    break-inside:avoid;page-break-inside:avoid;
  }

  /* the closing blocks travel together with the content above them */
  .pdoc-sign,.pdoc-watermark,.pdoc-foot{break-before:avoid;page-break-before:avoid;}

  /* no single stranded line at a page boundary */
  .pdoc p,.pdoc li,.pdoc td{orphans:3;widows:3;}

  /* two-column blocks stay side by side rather than splitting mid-column */
  .pdoc-cols,.pdoc-cols-3{break-inside:avoid;page-break-inside:avoid;}

  /* ---- tighten the vertical rhythm for print ----
     On screen the document is generous; on paper a few spare millimetres per
     block is what decides whether a report lands on one page or strands its
     footer alone on a second. Inline margins in the generators are overridden
     here deliberately. */
  .pdoc-head{padding-bottom:5mm;}
  .pdoc-strip{margin-top:4.5mm !important;padding:3.5mm 4.5mm;}
  .pdoc h2{margin:5.5mm 0 2.5mm;}
  .pdoc h2:first-of-type{margin-top:5mm;}
  .pdoc table{margin-bottom:3mm;}
  /* a third of a millimetre per row is invisible on paper and decides whether
     a 40-row sheet needs a third page for nothing but its footer */
  .pdoc tbody td{padding:1.85mm 2.5mm;}
  .pdoc thead th{padding:1.9mm 2.5mm;}
  .pdoc tfoot td{padding:2.2mm 2.5mm;}
  .pdoc-cols,.pdoc-cols-3{margin-top:4.5mm !important;}
  .pdoc-totals{margin-top:3mm;}
  .pdoc-sign{margin-top:7mm !important;}
  .pdoc-watermark{margin-top:3.5mm !important;}
  .pdoc-foot{margin-top:5mm;padding-top:2.5mm;}
  .pdoc > *:last-child{margin-bottom:0;}

  *{-webkit-print-color-adjust:exact !important;print-color-adjust:exact !important;}
}
