
/* FIVO Cutting Center V1.7 - print layout only.
   Requires the existing printDocument()/printMeta() from Scripts.html V1.7.
   A4 landscape, safe multi-page tables, no fixed page height. */
#print-root { display: none; }
@page { size: A4 landscape; margin: 9mm 10mm 10mm 10mm; }

@media print {
  html, body {
    margin: 0 !important;
    padding: 0 !important;
    min-width: 0 !important;
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
    background: #fff !important;
    color: #18263b !important;
  }
  #app, #modal, #toast, #authGate { display: none !important; }
  #print-root {
    display: block !important;
    position: static !important;
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    background: white !important;
  }
  #print-root, #print-root * { box-sizing: border-box; }

  .print-document {
    font: 8.7pt/1.32 Arial, Helvetica, sans-serif;
    color: #18263b;
    background: #fff;
    width: 100%;
    margin: 0;
    padding: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .print-document + .print-document { break-before: page; page-break-before: always; }

  /* PHAN DAU - tuong dong form cu: tieu de, thong tin, tong phieu */
  .print-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 9mm;
    padding: 0 0 3.5mm;
    border-bottom: 1.25pt solid #b52d37;
    margin-bottom: 3mm;
  }
  .print-heading-main { min-width: 0; flex: 1; }
  .print-overline {
    display: block;
    color: #657489;
    font-size: 7pt;
    font-weight: 700;
    letter-spacing: .7px;
    margin-bottom: 1.3mm;
  }
  .print-document h1 {
    font-size: 14.5pt;
    line-height: 1.16;
    font-weight: 800;
    margin: 0;
    color: #102641;
    letter-spacing: .05px;
  }
  .print-heading-caption { color: #637287; font-size: 7.5pt; margin-top: 1.5mm; }
  .print-document-label {
    border: 1px solid #c4ceda;
    border-left: 2.5pt solid #b52d37;
    padding: 2mm 3.2mm;
    text-align: right;
    max-width: 34%;
    overflow-wrap: anywhere;
  }
  .print-document-label span { display: block; font-size: 7.1pt; color: #657489; }
  .print-document-label strong { display: block; font-size: 9.7pt; color: #122c4b; margin-top: 1mm; }

  .print-meta {
    display: grid;
    grid-template-columns: 29% 47% 24%;
    width: 100%;
    border: .65pt solid #bac5d3;
    border-bottom: 1.3pt solid #b52d37;
    margin: 0;
  }
  .print-meta-col { min-width: 0; }
  .print-meta-col + .print-meta-col { border-left: .55pt solid #bac5d3; }
  .print-meta-col--totals { background: #f6f8fb; }
  .print-field {
    display: grid;
    grid-template-columns: 36% minmax(0, 1fr);
    gap: 2mm;
    min-height: 8.5mm;
    padding: 1.35mm 2mm;
    align-items: center;
  }
  .print-meta-col--middle .print-field { grid-template-columns: 23% minmax(0, 1fr); }
  .print-meta-col--totals .print-field { grid-template-columns: 72% minmax(0, 1fr); }
  .print-field + .print-field { border-top: .45pt solid #e0e5ec; }
  .print-field-label { color: #526178; font-weight: 600; font-size: 7.2pt; line-height: 1.2; }
  .print-field-value { min-width: 0; font-size: 8.8pt; font-weight: 700; line-height: 1.28; overflow-wrap: anywhere; }
  .print-field-value--muted { font-size: 7.8pt; font-weight: 500; }
  .print-meta-col--totals .print-field-value { text-align: right; font-size: 11pt; font-weight: 800; font-variant-numeric: tabular-nums; }

  .print-summary {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 6mm;
    margin: 2.8mm 0 4.3mm;
    padding: 0 1mm 2.4mm;
    border-bottom: .85pt solid #b52d37;
  }
  .print-summary-left { font-size: 7.8pt; color: #54647b; font-weight: 700; text-transform: uppercase; }
  .print-summary-right { display: flex; gap: 2.5mm; align-items: baseline; }
  .print-summary-total { font-size: 15.5pt; color: #a52330; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
  .print-summary-unit { font-size: 8pt; font-weight: 700; color: #4b5a71; }

  .print-table-heading {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 7mm;
    margin: 0 0 1.5mm;
    color: #263b58;
    font-size: 8.2pt;
    font-weight: 750;
    break-after: avoid;
    page-break-after: avoid;
  }
  .print-table-heading .print-rowcount { font-weight: 500; color: #657489; font-size: 7.3pt; }

  /* BANG CHI TIET - co chu de lap lai khi nhieu trang */
  .print-document table.lines {
    border-collapse: collapse;
    border-spacing: 0;
    table-layout: fixed;
    width: 100%;
    margin: 0;
    border: .8pt solid #526071;
  }
  .print-document table.lines thead { display: table-header-group; }
  .print-document table.lines tfoot { display: table-footer-group; }
  .print-document table.lines tr { break-inside: avoid; page-break-inside: avoid; }
  .print-document table.lines th {
    background: #e7edf3;
    color: #1b2d45;
    font-weight: 750;
    font-size: 8pt;
    line-height: 1.18;
    text-align: center;
    vertical-align: middle;
    padding: 2mm 1.1mm;
    border: .45pt solid #8795a7;
    border-bottom: .85pt solid #526071;
    overflow-wrap: anywhere;
  }
  .print-document table.lines td {
    font-size: 8.15pt;
    line-height: 1.34;
    padding: 1.6mm 1.2mm;
    border: .45pt solid #a9b3c0;
    vertical-align: middle;
    color: #13253e;
    overflow-wrap: anywhere;
    word-break: normal;
    hyphens: none;
  }
  .print-document table.lines tr:nth-child(even) td { background: #f9fafc; }
  .print-document table.lines td.cell-center { text-align: center; }
  .print-document table.lines td.cell-strong { font-weight: 750; }
  .print-document table.lines td.cell-code { font-size: 7.9pt; }
  .print-document table.lines td.cell-note { font-size: 7.8pt; line-height: 1.32; }
  .print-document table.lines td.cell-fill { background: #fff !important; }
  .print-document table.lines td.cell-check { text-align: center; font-size: 12pt; }

  .print-aftertable {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8mm;
    margin-top: 2.2mm;
    font-size: 7.6pt;
    color: #53637b;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .print-aftertable strong { font-size: 8.6pt; color: #172c48; }

  /* CHU KY - giu cho trong viet tay, khong gay che dong du lieu */
  .print-signatures {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6mm;
    border-top: .7pt solid #c8d0da;
    margin-top: 4.5mm;
    padding-top: 2.5mm;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .print-signatures .sign-block { text-align: center; min-height: 25mm; }
  .print-signatures .sign-block strong { display: block; color: #132741; font-size: 8.8pt; margin-bottom: 1mm; }
  .print-signatures .sign-block em { display: block; color: #6b7788; font-size: 7.5pt; font-style: normal; }
  .print-signatures .sign-space { height: 11mm; }
  .print-signatures .sign-name { color: #6b7788; font-size: 7pt; margin: 0 auto; width: 75%; padding-top: 1mm; border-top: .5pt dashed #b2bcc8; }

  .print-foot {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 6mm;
    margin-top: 1.5mm;
    padding-top: 1.8mm;
    border-top: .55pt solid #b6c1ce;
    color: #647287;
    font-size: 7.1pt;
    line-height: 1.25;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .print-foot span:last-child { text-align: right; }
}
