@page {
  size: A4 portrait;
  margin: 12mm;
}

 
@page invoice58 {
  size: 58mm auto;
  margin: 0;
}
@page invoice80 {
  size: 80mm auto;
  margin: 0;
}

@media print {
  html, body { width: auto !important; min-width: 0 !important; height: auto !important; }
  body {
    margin: 0 !important; padding: 0 !important;
    color: #111 !important; background: #fff !important;
    font: 10pt/1.35 Arial, Helvetica, sans-serif;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  *, *::before, *::after { box-sizing: border-box !important; box-shadow: none !important; text-shadow: none !important; }

   
  .site-header, .site-footer, .sidebar, .topbar, .bottomnav,
  .app-sidebar, .app-header, .app-topbar, .btn, .toast-stack,
  .backdrop, .scroll-progress, .no-print, .print-btn { display: none !important; }

  a[href^="http"] { overflow-wrap: anywhere; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .8em; color: #555; overflow-wrap: anywhere; }

  .page-break { break-before: page; page-break-before: always; }
  .keep-together, .document-print__signature, .document-print__meta-row,
  .invoice-print__item, .invoice-print__payment-row { break-inside: avoid; page-break-inside: avoid; }
  h1, h2, h3, .document-print__title, .invoice-print__title { break-after: avoid; page-break-after: avoid; }
}

 
@media print {
  .invoice-print {
    page: invoice58;
    width: 58mm; max-width: 100%; margin: 0 auto; padding: 4mm;
    font: 9pt/1.3 "Courier New", Courier, monospace;
    color: #000; background: #fff;
    overflow-wrap: anywhere; word-break: normal;
  }
  .invoice-print--80mm { page: invoice80; width: 80mm; }
  .invoice-print__header { text-align: center; border-bottom: 1px dashed #000; padding-bottom: 3mm; margin-bottom: 3mm; }
  .invoice-print__logo { display: block; max-width: 40mm; max-height: 15mm; margin: 0 auto 2mm; object-fit: contain; }
  .invoice-print__institution { font-weight: 700; font-size: 11pt; margin-bottom: 1mm; }
  .invoice-print__address { font-size: 8pt; color: #222; overflow-wrap: anywhere; }
  .invoice-print__title { text-align: center; font-weight: 700; font-size: 10pt; margin: 3mm 0; text-transform: uppercase; overflow-wrap: anywhere; }
  .invoice-print__meta { font-size: 8.5pt; margin-bottom: 3mm; }
  .invoice-print__meta-row, .invoice-print__payment-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 2mm; margin-bottom: 1mm; }
  .invoice-print__meta-label { min-width: 0; font-weight: 700; overflow-wrap: anywhere; }
  .invoice-print__meta-value { min-width: 0; text-align: right; overflow-wrap: anywhere; }
  .invoice-print__items { border-top: 1px dashed #000; border-bottom: 1px dashed #000; padding: 2mm 0; margin: 3mm 0; }
  .invoice-print__item { margin-bottom: 2mm; overflow-wrap: anywhere; }
  .invoice-print__item-name { font-weight: 700; }
  .invoice-print__item-detail { margin-left: 3mm; font-size: 8pt; color: #222; }
  .invoice-print__total { margin-top: 2mm; padding-top: 2mm; border-top: 1px solid #000; font-weight: 700; font-size: 10pt; text-align: right; }
  .invoice-print__payment { margin-top: 3mm; padding-top: 2mm; border-top: 1px dashed #000; font-size: 8pt; }
  .invoice-print__footer { text-align: center; margin-top: 4mm; padding-top: 3mm; border-top: 1px dashed #000; font-size: 7.5pt; color: #333; overflow-wrap: anywhere; }
  .invoice-print__signature { display: grid; grid-template-columns: 1fr; gap: 4mm; margin-top: 6mm; font-size: 8pt; }
  .invoice-print__signature-box { width: 100%; text-align: center; }
  .invoice-print__signature-line { margin-top: 10mm; border-top: 1px solid #000; padding-top: 1mm; }
}

 
@media print {
  .document-print {
    page: auto;
    width: 100%; max-width: 100%; min-width: 0; min-height: 0;
    margin: 0; padding: 0;
    font: 10pt/1.45 Arial, Helvetica, sans-serif;
    color: #111; background: #fff;
    overflow: visible; overflow-wrap: anywhere;
  }
  .document-print__header { display: block; text-align: center; border-bottom: 2px solid #111; padding-bottom: 4mm; margin-bottom: 6mm; }
  .document-print__logo { display: block; max-width: 50mm; max-height: 18mm; margin: 0 auto 2mm; object-fit: contain; }
  .document-print__institution { font-weight: 700; font-size: 15pt; margin-bottom: 1mm; }
  .document-print__address { font-size: 8.5pt; color: #333; overflow-wrap: anywhere; }
  .document-print__title { margin: 6mm 0; text-align: center; font-size: 13pt; font-weight: 700; text-transform: uppercase; text-decoration: underline; overflow-wrap: anywhere; }
  .document-print__meta { display: grid; gap: 1.5mm; margin-bottom: 5mm; font-size: 9.5pt; }
  .document-print__meta-row { display: grid; grid-template-columns: minmax(32mm, 38mm) minmax(0, 1fr); gap: 3mm; align-items: start; }
  .document-print__meta-label { font-weight: 700; overflow-wrap: anywhere; }
  .document-print__meta-value { min-width: 0; overflow-wrap: anywhere; }
  .document-print__body { margin: 5mm 0; text-align: left; overflow-wrap: anywhere; }
  .document-print__table { width: 100%; max-width: 100%; table-layout: fixed; border-collapse: collapse; margin: 4mm 0; font-size: 9pt; }
  .document-print__table thead { display: table-header-group; }
  .document-print__table tfoot { display: table-footer-group; }
  .document-print__table tr { break-inside: avoid; page-break-inside: avoid; }
  .document-print__table th, .document-print__table td {
    min-width: 0; border: 1px solid #333; padding: 1.5mm 1.8mm;
    text-align: left; vertical-align: top; white-space: normal;
    overflow-wrap: anywhere; word-break: normal;
  }
  .document-print__table th { background: #eee !important; font-weight: 700; }
  .document-print__footer { margin-top: 8mm; padding-top: 3mm; border-top: 1px solid #777; font-size: 8pt; color: #444; text-align: center; }
  .document-print__signature { display: flex; justify-content: space-between; gap: 8mm; margin-top: 12mm; }
  .document-print__signature-box { width: 45%; min-width: 0; text-align: center; overflow-wrap: anywhere; }
  .document-print__signature-line { margin-top: 18mm; border-top: 1px solid #111; padding-top: 2mm; font-weight: 700; }
}

 
@media screen {
  .print-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; background: var(--c-primary); color: #fff; border: 0; border-radius: var(--r-md); cursor: pointer; font-weight: 600; transition: background-color var(--t-fast) var(--ease); }
  .print-btn:hover { background: var(--c-primary-dark); }
  .print-btn::before { content: '🖨️'; }
}
