/* Print and PDF-preview styling: pages print without the app shell, always on white. The document print pages (views/document.php)
   load this file for the screen too; their sheet is styled by the .doc-* rules below. */
@media print {
  @page { size: A4; margin: 12mm 12mm 16mm; @bottom-right { content: "Page " counter(page) " of " counter(pages); font: 7pt Arial, Helvetica, sans-serif; color: #555; } }   /* page numbers on every printed page (Chrome, Edge) */
  html, body, #wrapper, #content, .terminal-container { background: #fff; color: #000; padding: 0; margin: 0; width: auto; }
  #sidebar, .top-console, .sidebar-backdrop, .mobile-menu-toggle, .no-print, .btn, .alert { display: none; }
  #content { margin: 0; width: 100%; }
  .card { border: 0; box-shadow: none; background: #fff; color: #000; }
  table { width: 100%; border-collapse: collapse; }
  th, td { border: 1px solid #999; padding: 4px 6px; }
  tr, img { page-break-inside: avoid; }
  a { color: #000; text-decoration: none; }
  .table-register.cols-compact .col-secondary { display: table-cell; }
  /* The printed register (a list's Print / PDF page): the same look as the list on screen (theme colours, header row, soft lines, status chips), always on a light page, even
     from dark mode. Portrait unless chosen otherwise in the print window; the table fits the page width and words wrap at spaces. */
  html[data-bs-theme] body, html[data-bs-theme] body.layout-modern { --bg-card: #fff !important; --bg-hover: #f3f5f8 !important; --border-color: #dfe3e8 !important; --text-primary: #1f2a37 !important;
    --text-secondary: #4b5767 !important; --text-muted: #7b8696 !important; --grey-bg: #eef0f3 !important; --grey: #5f6672 !important; --ok-bg: #e3f3ea !important; --ok: #1f7a52 !important;
    --bad-bg: #fbe5e2 !important; --bad: #b3362a !important; --info-bg: #e2eff8 !important; --info: #1d6493 !important; --warn: #8a5f28 !important; color: #1f2a37 !important; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }   /* print the colours, not just the text */
  .panel { padding: 0 !important; overflow: visible !important; }
  .table-responsive { overflow: visible !important; }
  .table-register { width: 100% !important; max-width: 100% !important; table-layout: auto !important; font-size: 7.5pt !important; }
  .table-register th, .table-register td { border: 0; border-bottom: 1px solid var(--border-color); min-width: 0 !important; max-width: none !important; padding: 5px 4px !important;
    white-space: normal !important; word-break: normal !important; overflow-wrap: normal !important; vertical-align: middle; color: var(--text-primary); }
  .table-register thead th { background: var(--bg-hover) !important; color: var(--text-muted) !important; }
  .table-register thead { display: table-header-group; }
  .table-register td:first-child, .table-register td .badge, .table-register td .stage, .table-register td .chip { white-space: nowrap !important; }
}

/* ---- Document sheet (invoice, quotation, receipt, DO, CAN, slips) */
.doc-body { margin: 0; background: #ddd; color: #111; font-family: Arial, Helvetica, sans-serif; font-size: 8.5pt; }
.doc-toolbar { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 16px; background: #222; color: #fff; }
.doc-toolbar a, .doc-toolbar button { display: inline-block; margin-left: 6px; padding: 6px 12px; border: 0; background: #fff; color: #111; font: bold 9pt Arial, sans-serif; text-decoration: none; cursor: pointer; }
.doc-toolbar > a:first-child { margin-left: 0; }
.doc-flash { width: 210mm; max-width: 100%; box-sizing: border-box; margin: 10px auto 0; padding: 8px 12px; background: #d1e7dd; color: #0f5132; }
.doc-flash-danger { background: #f8d7da; color: #842029; }
.doc-flash-warning { background: #fff3cd; color: #664d03; }
.doc-page { width: 210mm; max-width: 100%; min-height: 297mm; box-sizing: border-box; margin: 12px auto; padding: 10mm; background: #fff; }
.doc-a5 { width: 148mm; min-height: 210mm; }
.doc-head { display: flex; align-items: flex-start; gap: 4mm; }
.doc-logo { width: 38mm; height: auto; }
.doc-company { flex: 1; font-size: 7pt; line-height: 1.35; }
.doc-company-name { font-size: 11pt; font-weight: bold; }
.doc-copy { border: 1px solid #111; padding: 2px 10px; font-weight: bold; }
.doc-title { margin: 3mm 0; padding: 2mm; border-top: 2px solid #111; background: #ebebeb; text-align: center; font-size: 11pt; font-weight: bold; }
.doc-pairs { display: flex; margin-bottom: 3mm; }
.doc-pairs-col { flex: 1; padding: 1mm 1.5mm; border: 1px solid #111; }
.doc-pairs-col + .doc-pairs-col { border-left: 0; }
.doc-kv { display: flex; line-height: 1.45; }
.doc-k { flex: 0 0 34mm; }
.doc-c { flex: 0 0 3mm; text-align: center; }
.doc-v { flex: 1; overflow-wrap: anywhere; }
.doc-table { width: 100%; border-collapse: collapse; table-layout: fixed; margin-bottom: 3mm; font-size: 7.5pt; }
.doc-table th, .doc-table td { border: 1px solid #111; padding: 1mm; vertical-align: top; overflow-wrap: anywhere; }
.doc-table th { background: #ebebeb; text-align: center; font-size: 7pt; }
.doc-foot td { background: #ebebeb; font-weight: bold; }
.doc-small { font-size: 6.5pt; }
.doc-small th { font-size: 6pt; }
.doc-small td.doc-R, .doc-small td.doc-C { white-space: nowrap; }   /* amounts and rates never break in the wide charge table */
.doc-L { text-align: left; }
.doc-C { text-align: center; }
.doc-R { text-align: right; }
.doc-head-text { margin: 1mm 0; font-weight: bold; }
.doc-t-words { margin-bottom: 3mm; padding: 1mm; border: 1px solid #111; font-weight: bold; }
.doc-t-head { margin-bottom: 2mm; font-weight: bold; }
.doc-t-note { margin-bottom: 2mm; font-size: 7pt; }
.doc-t-plain { margin-bottom: 2mm; }
.doc-amount { display: flex; margin-bottom: 3mm; border: 1px solid #111; background: #ebebeb; font-size: 9pt; font-weight: bold; }
.doc-amount span { padding: 1.5mm 2mm; text-align: right; }
.doc-amount span:first-child { flex: 0 0 70%; box-sizing: border-box; border-right: 1px solid #111; }
.doc-amount span:last-child { flex: 1; }
.doc-footer { display: flex; border: 1px solid #111; font-size: 7pt; line-height: 1.4; }
.doc-footer > div { padding: 1mm 1.5mm; }
.doc-footer > div:first-child { flex: 0 0 60%; box-sizing: border-box; }
.doc-footer > div + div { flex: 1; border-left: 1px solid #111; }
.doc-footer-terms > div:first-child { flex: 1; }
.doc-terms { margin: 0; padding-left: 5mm; }
.doc-sign { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 6mm; font-weight: bold; }
.doc-sign-left { width: 33%; border-top: 1px solid #111; padding-top: 1mm; text-align: center; }
.doc-sign-right { text-align: right; }
.doc-sign-space { height: 22mm; }
.doc-stamp { display: block; width: 20mm; height: 20mm; margin: 1mm 0 1mm auto; }
.doc-ref { margin-top: 4mm; font-size: 7pt; }
@media print {
  .doc-body { background: #fff; }
  .doc-toolbar, .doc-flash { display: none; }   /* after the screen rules above, so the toolbar is never printed */
  .doc-page { width: auto; min-height: 0; margin: 0; padding: 0; }
  .doc-table th, .doc-table td { border: 1px solid #111; padding: 1mm; }
  .doc-table { page-break-inside: auto; }
  .doc-table thead { display: table-header-group; }   /* the column names repeat on every page of a long table */
  .doc-table tr, .doc-pairs, .doc-amount, .doc-footer, .doc-sign, .doc-t-words { break-inside: avoid; }
  .doc-title, .doc-head-text { break-after: avoid; }
}
