@page { size: A4 portrait; margin: 12mm 8mm 9mm; }
@media print {
  html,body{width:210mm!important;min-height:297mm!important;background:#fff!important;margin:0!important;padding:0!important;}
  body{-webkit-print-color-adjust: exact;print-color-adjust: exact;color-adjust:exact;}
  .no-print{display:none!important;}
  .page-shell{padding:0!important;margin:0!important;}
  .page.a4{
    width:auto!important;
    max-width:none!important;
    min-height:auto!important;
    margin:0!important;
    border:none!important;
    box-shadow:none!important;
    border-radius:0!important;
    padding:0!important;
    overflow:visible!important;
    background:#fff!important;
  }
  .page-content{position:relative;z-index:1;padding:4mm 8mm 7mm!important;}
  .print-header,.print-body,.print-footer{position:relative;z-index:1;}
.print-body{flex:1 0 auto;}
.print-footer{margin-top:auto;}
  .print-header,.hero-grid,.summary-layout,.terms-grid,.pf-signatures,.doc-table-wrap,.summary-card,.panel,.term-card,.pf-sign{break-inside:avoid;page-break-inside:avoid;}
  .table{width:100%;border-collapse:collapse;page-break-inside:auto;}
  thead{display:table-header-group;}
  tfoot{display:table-footer-group;}
  tr{page-break-inside:avoid;break-inside:avoid;}
  td,th{page-break-inside:avoid;break-inside:avoid;}
  .print-footer{margin-top:5mm;break-inside:avoid;page-break-inside:avoid;}
  .summary-layout{margin-top:4mm;}
  .section-heading{break-after:avoid;page-break-after:avoid;}
}

:root{
  --brand-navy:#16324a;
  --brand-blue:#245a8d;
  --brand-dark:#1f2937;
  --brand-soft:#edf4fb;
  --brand-line:#d8e1ea;
  --brand-line-soft:#e8eef4;
  --brand-text:#10202f;
  --brand-muted:#6b7a8c;
  --brand-gold:#c9a24f;
  --brand-warn:#fff6df;
}

*{box-sizing:border-box;}
html,body{min-height:100%;}
body{font-family:"Cairo",sans-serif;font-size:12px;color:var(--brand-text);background:#eef2f6;}
a{color:inherit;}
.page-shell{max-width:210mm;margin:0 auto;padding:8px 0;}
.page-content{position:relative;z-index:1;display:flex;flex-direction:column;min-height:calc(297mm - 24px);}
.print-page-frame{display:none;}
.page{background:#fff;}
.page.a4{
  position:relative;
  width:210mm;
  min-height:297mm;
  max-width:210mm;
  margin:12px auto;
  border-radius:22px;
  overflow:hidden;
  box-shadow:0 18px 50px rgba(15,23,42,.12);
  border:1px solid #dde4ec;
  padding:0;
}
.page.a4::before{
  content:"";
  position:absolute;
  top:0;left:0;right:0;
  height:78px;
  background:
    radial-gradient(circle at 10% 0%, rgba(255,255,255,.18) 0 12%, transparent 13%),
    linear-gradient(120deg, var(--brand-blue) 0%, var(--brand-navy) 34%, var(--brand-dark) 56%, #f8fbff 56.3%, #f8fbff 100%);
  z-index:0;
}

.print-toolbar{display:flex;gap:8px;justify-content:center;align-items:center;margin:10px 0 16px;}
.print-toolbar button{padding:8px 14px;font-family:"Cairo",sans-serif;border:1px solid var(--brand-line);border-radius:10px;background:#fff;cursor:pointer;font-size:13px;font-weight:700;min-width:98px;}

.print-header,.print-body,.print-footer{position:relative;z-index:1;}
.print-body{flex:1 0 auto;}
.print-footer{margin-top:auto;}
.page-content{padding:12px 14px 10px;display:flex;flex-direction:column;min-height:calc(297mm - 24px);}
 .print-header{padding-top:0;}
 .ph-top{display:grid;grid-template-columns:1.25fr .75fr;gap:18px;align-items:start;min-height:96px;}
 .ph-left-ribbon{padding-top:12px;color:#fff;}
.ph-mini{font-size:11px;letter-spacing:.12em;font-weight:700;text-transform:uppercase;opacity:.92;}
.ph-docno{font-size:23px;font-weight:800;line-height:1.1;margin-top:8px;}
.ph-date{font-size:13px;font-weight:700;margin-top:10px;}
.ph-status{display:inline-flex;align-items:center;gap:6px;margin-top:14px;padding:6px 10px;border:1px solid rgba(255,255,255,.26);border-radius:999px;font-size:11px;font-weight:700;background:rgba(255,255,255,.08);}
.ph-status::before{content:"";width:8px;height:8px;border-radius:50%;background:#fff;display:inline-block;}
.ph-brand-card{background:rgba(255,255,255,.98);border:1px solid rgba(207,220,232,.95);border-radius:0 0 18px 18px;padding:18px 18px 14px;box-shadow:0 10px 20px rgba(15,23,42,.05);}
.ph-brand{display:flex;align-items:flex-start;gap:14px;}
.ph-logo{width:48px;height:48px;border-radius:50%;border:3px solid #ebf2f9;display:flex;align-items:center;justify-content:center;font-weight:800;color:var(--brand-blue);background:#fff;font-size:22px;flex:0 0 auto;overflow:hidden;}
.ph-logo-img{width:48px;height:48px;border-radius:50%;overflow:hidden;display:flex;align-items:center;justify-content:center;border:3px solid #ebf2f9;background:#fff;flex:0 0 auto;}
.ph-logo-img img{width:100%;height:100%;object-fit:cover;}
.ph-company{min-width:0;flex:1;}
.ph-name{font-size:18px;font-weight:800;line-height:1.1;color:#12293f;}
.ph-sub{font-size:10px;color:var(--brand-muted);margin-top:2px;line-height:1.5;}
.ph-contact{display:flex;flex-wrap:wrap;gap:10px 14px;margin-top:10px;}
.ph-chip{font-size:11px;color:#405468;font-weight:700;}
.ph-chip strong{color:#12293f;}
 .ph-titleband{display:block;margin:18px 0 10px;}
.ph-title-stack{padding-right:2px;}
.ph-kicker{font-size:11px;font-weight:700;letter-spacing:.16em;text-transform:uppercase;color:var(--brand-blue);}
 .ph-title{font-size:22px;font-weight:800;line-height:1.1;color:#111827;margin-top:0;}
.ph-title-en{font-size:11px;font-weight:800;color:#48596b;letter-spacing:.08em;text-transform:uppercase;}
.ph-note-card{border-right:4px solid var(--brand-blue);padding:10px 14px;background:linear-gradient(180deg,#fbfdff 0%,#f5f9fd 100%);border-radius:14px;border:1px solid var(--brand-line-soft);}
.ph-title-note{font-size:12px;color:#314457;line-height:1.8;}
.ph-note-muted{font-size:11px;color:var(--brand-muted);margin-top:4px;}

.print-body{padding-top:4px;}
.print-section{margin-bottom:14px;}
.hero-grid{display:grid;grid-template-columns:1.35fr .65fr;gap:10px;align-items:start;}
.panel{border:1px solid var(--brand-line);border-radius:18px;background:#fff;overflow:hidden;}
.panel-head{padding:8px 12px;background:#f7fafc;border-bottom:1px solid var(--brand-line);font-size:12px;font-weight:800;color:#17324a;display:flex;justify-content:space-between;gap:10px;align-items:center;}
.panel-head small{font-size:10px;color:var(--brand-muted);font-weight:700;text-transform:uppercase;letter-spacing:.08em;}
.panel-body{padding:10px 12px;}
.detail-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px 12px;}
.detail-item{min-width:0;}
.detail-label{font-size:10px;color:var(--brand-muted);margin-bottom:4px;font-weight:700;letter-spacing:.03em;}
.detail-value{font-size:12px;font-weight:800;color:#111827;line-height:1.45;word-break:break-word;}
.detail-sub{font-size:11px;color:#506173;line-height:1.75;margin-top:4px;}
.hero-summary{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;}
.stat-box{border:1px solid var(--brand-line);border-radius:14px;background:#fbfdff;padding:10px 10px 8px;min-height:70px;position:relative;overflow:hidden;}
.stat-box::before{content:"";position:absolute;top:0;right:0;width:56px;height:56px;background:radial-gradient(circle at top right, rgba(36,90,141,.15), transparent 70%);}
.stat-label{font-size:10px;color:var(--brand-muted);font-weight:700;letter-spacing:.08em;text-transform:uppercase;}
.stat-value{font-size:18px;font-weight:800;color:var(--brand-navy);line-height:1.1;margin-top:4px;}
.stat-note{font-size:11px;color:#506173;margin-top:6px;line-height:1.6;}
.status-strip{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px;}
.badge{display:inline-flex;align-items:center;padding:5px 10px;border-radius:999px;font-size:11px;font-weight:800;border:1px solid var(--brand-line);background:#fff;color:#16324a;}
.badge.alt{background:var(--brand-soft);}
.badge.warn{background:var(--brand-warn);border-color:#f2d29b;color:#84570d;}

.doc-warning{margin-bottom:12px;border:1px solid #f1d49a;background:linear-gradient(180deg,#fff8e7 0%,#fffdf6 100%);color:#8a5a00;border-radius:16px;padding:12px 14px;font-size:12px;font-weight:700;}
.doc-warning strong{font-size:13px;display:block;margin-bottom:4px;}
.section-heading{font-size:13px;font-weight:800;color:var(--brand-navy);margin-bottom:8px;display:flex;align-items:center;gap:8px;}
.section-heading:before{content:"";display:inline-block;width:24px;height:3px;border-radius:999px;background:linear-gradient(90deg,var(--brand-blue),var(--brand-navy));}

.doc-table-wrap{border:1px solid var(--brand-line);border-radius:14px;overflow:hidden;background:#fff;}
.table{width:100%;border-collapse:collapse;}
.table thead th{background:linear-gradient(180deg,var(--brand-dark) 0%,var(--brand-navy) 100%);color:#fff;font-weight:800;padding:8px 6px;border-left:1px solid rgba(255,255,255,.08);font-size:11px;vertical-align:middle;}
.table thead th small{display:block;font-size:9px;opacity:.76;font-weight:700;letter-spacing:.06em;line-height:1.4;}
.table td{padding:8px 6px;border-bottom:1px solid var(--brand-line-soft);font-size:11px;vertical-align:top;line-height:1.55;}
.table tbody tr:nth-child(even) td{background:#fbfdff;}
.table tbody tr:last-child td{border-bottom:none;}
.table .text-center{text-align:center;}
.table .text-left{text-align:left;}
.table .text-right{text-align:right;}
.table .strong{font-weight:800;color:var(--brand-navy);}
.table .muted{display:block;color:var(--brand-muted);font-size:10.5px;line-height:1.5;margin-top:2px;}
.table .desc-main{font-size:13px;font-weight:800;color:#0f2233;}
.table .line-index{display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:50%;background:var(--brand-soft);color:var(--brand-navy);font-weight:800;}

.summary-layout{display:grid;grid-template-columns:1fr .72fr;gap:10px;align-items:start;}
.note-box{border:1px dashed #b8c7d7;border-radius:16px;padding:12px 14px;background:#fcfdff;font-size:12px;color:var(--brand-text);line-height:1.9;min-height:96px;white-space:pre-line;}
.summary-card{border:1px solid var(--brand-line);border-radius:14px;background:#fff;padding:0;overflow:hidden;}
.summary-card .summary-head{padding:8px 10px;background:#f7fafc;font-size:12px;font-weight:800;color:var(--brand-navy);border-bottom:1px solid var(--brand-line);}
.summary-card table{width:100%;border-collapse:collapse;}
.summary-card td{padding:7px 10px;border-bottom:1px solid var(--brand-line-soft);font-size:11px;}
.summary-card tr:last-child td{border-bottom:none;}
.summary-card .label{color:var(--brand-muted);font-weight:700;}
.summary-card .val{font-weight:800;text-align:left;color:var(--brand-text);}
.summary-card .grand td{background:linear-gradient(180deg,var(--brand-dark) 0%,var(--brand-navy) 100%);color:#fff;font-size:15px;font-weight:800;}
.summary-card .grand .label,.summary-card .grand .val{color:#fff;}
.summary-inline{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px;}
.summary-pill{border-radius:999px;background:var(--brand-soft);border:1px solid var(--brand-line);padding:6px 10px;font-size:11px;font-weight:700;color:var(--brand-navy);}

.terms-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;}
.term-card{border:1px solid var(--brand-line);border-radius:12px;background:#fff;overflow:hidden;}
.term-title{padding:7px 9px;background:#f7fbff;border-bottom:1px solid var(--brand-line-soft);font-size:11px;font-weight:800;color:var(--brand-navy);}
.term-content{padding:8px 9px;font-size:11px;color:var(--brand-text);line-height:1.65;white-space:pre-line;min-height:0;}

.print-footer{margin-top:auto;padding-top:8px;border-top:1px solid var(--brand-line-soft);}
.pf-signatures{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;}
.pf-sign{border:none;border-top:1px solid var(--brand-line);border-radius:0;padding:4px 4px 0;background:transparent;min-height:34px;position:relative;overflow:hidden;}
.pf-sign::after{content:none;}
.pf-sign-title{font-weight:800;text-align:center;margin-bottom:4px;color:var(--brand-navy);font-size:11px;}
.pf-line{border-bottom:1px dashed #b8c7d7;margin:7px 0 4px;}
.pf-small{font-size:9px;color:var(--brand-muted);margin:1px 0;}

.pf-company-strip{margin-top:8px;padding-top:8px;border-top:1px solid var(--brand-line-soft);text-align:center;display:flex;flex-direction:column;gap:3px;align-items:center;justify-content:center;}
.pf-company-name{font-size:12px;font-weight:800;color:var(--brand-navy);line-height:1.5;}
.pf-company-address,.pf-company-contact{font-size:10px;color:var(--brand-muted);line-height:1.7;}

.pf-bottom{display:flex;justify-content:space-between;align-items:flex-end;gap:10px;color:var(--brand-muted);font-size:9px;margin-top:6px;border-top:1px solid var(--brand-line-soft);padding-top:6px;}
.pf-bottom strong{display:block;color:var(--brand-navy);font-size:10px;margin-bottom:1px;}
.pf-bottom-right{text-align:left;}

@media screen and (max-width:900px){
  .page.a4{padding:0;}
  .ph-top,.ph-titleband,.hero-grid,.summary-layout,.terms-grid,.pf-signatures,.hero-summary,.detail-grid{grid-template-columns:1fr;display:grid;}
}


.print-page-break{break-before:page;page-break-before:always;}
.keep-together{break-inside:avoid;page-break-inside:avoid;}
.table-compact td,.table-compact th{padding-top:8px;padding-bottom:8px;}


.simple-header .simple-top{grid-template-columns:.78fr 1.22fr;min-height:auto;align-items:center;gap:10px;}
.simple-brand-card{border-radius:14px;padding:12px 14px;box-shadow:none;}
.ph-doc-card{background:#f9fbfd;border:1px solid var(--brand-line);border-radius:14px;padding:10px 12px;min-height:auto;display:flex;flex-direction:column;justify-content:center;gap:6px;}
.ph-doc-row{display:flex;align-items:center;justify-content:space-between;gap:14px;}
.ph-doc-label{font-size:12px;font-weight:700;color:var(--brand-muted);}
.ph-doc-value{font-size:13px;font-weight:800;color:#16283a;text-align:left;direction:ltr;}
.simple-titleband{border-top:1px solid var(--brand-line-soft);padding-top:8px;margin-top:8px;}
.simple-title-stack{text-align:center;}
.simple-titleband .ph-title-en{margin-top:6px;}
.ph-note-card,.ph-left-ribbon,.ph-kicker,.ph-note-muted{display:none!important;}
.hero-summary{display:grid;grid-template-columns:1fr 1fr;gap:8px;}
.stat-note,.status-strip,.summary-inline,.note-box.is-muted{display:none!important;}
.summary-inline:empty,.note-box:empty{display:none!important;}
.section-heading{margin-bottom:10px;}
.term-card:empty{display:none;}
@media print{
  .simple-header .simple-top{grid-template-columns:1.2fr .8fr;}
}


.compact-summary-layout .summary-card table td{padding:8px 12px;}
.compact-summary-layout .terms-grid{gap:10px;}
.compact-summary-layout .term-card{border-radius:14px;}
.compact-summary-layout .term-title{padding:8px 10px;font-size:11px;}
.print-section{margin-bottom:8px;}
.doc-table-wrap{margin-bottom:0;}
@media print{ .print-section{margin-bottom:8px;} .page.a4{min-height:296mm;} }


.simple-header .ph-brand{align-items:center;}
.simple-header .ph-company{display:flex;flex-direction:column;justify-content:center;}
.section-heading{font-size:12px;margin-bottom:6px;}
.compact-summary-layout .summary-card table td{padding:6px 9px;}
.compact-summary-layout .terms-grid{gap:8px;}
@media print{ .page.a4{min-height:296mm;} .pf-bottom{font-size:8.5px;} }

@media print{.page-content{min-height:calc(297mm - 17mm);} .print-footer{margin-top:auto;} }


/* voucher a4 */
.voucher-hero-grid{grid-template-columns:1.25fr .75fr;}
.voucher-summary-boxes{grid-template-columns:1fr;}
.voucher-summary-layout{grid-template-columns:1.08fr .92fr;}
.voucher-grand-card{max-width:420px;margin-inline-start:auto;}
@media screen and (max-width:900px){
  .voucher-hero-grid,.voucher-summary-layout{grid-template-columns:1fr;}
  .voucher-grand-card{max-width:none;}
}


/* final stabilization: print behavior, totals alignment, voucher signatures */
.text-muted{color:var(--brand-muted)!important;}
.py-4{padding-top:14px!important;padding-bottom:14px!important;}
.table td,.table th,.summary-card td,.pf-bottom,.pf-company-contact,.pf-company-address,.pf-company-name,.detail-value,.stat-value,.ph-doc-value{
  font-variant-numeric:tabular-nums;
}
.summary-card .val,.table .text-left,.quotation-total-table td:last-child,.pi-total-table td:last-child,.purchase-doc-row strong,.qph-meta-row strong,.ph-doc-value{
  unicode-bidi:plaintext;
}
.signatures{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin-top:10px;break-inside:avoid;page-break-inside:avoid;}
.sig{border-top:1px solid var(--brand-line);padding-top:8px;min-height:34px;text-align:center;font-size:11px;font-weight:800;color:var(--brand-navy);}
@media print{
  .doc-table-wrap,.summary-card,.term-card,.panel,.note-box,.voucher-grand-card{overflow:visible!important;}
  .doc-table-wrap{border-radius:12px;}
  .table-wrap,.doc-table-wrap table{overflow:visible!important;}
  .print-body .table thead{display:table-header-group;}
  .print-body .table tbody tr{break-inside:avoid;page-break-inside:avoid;}
  .summary-card,.note-box,.signatures{break-inside:avoid;page-break-inside:avoid;}
  .print-footer{padding-bottom:0!important;}
}
@media screen and (max-width:900px){
  .signatures{grid-template-columns:repeat(2,minmax(0,1fr));}
}

/* Phase print stabilization: document consistency without changing module philosophy */
.print-body{line-height:1.55;}
.doc-table-wrap{overflow:visible;border-radius:14px;}
.table,.quotation-table{font-variant-numeric:tabular-nums;}
.table th,.table td,.quotation-table th,.quotation-table td{vertical-align:top;}
.table th small{display:block;margin-top:2px;font-size:8.5px;color:var(--brand-muted);font-weight:700;letter-spacing:.2px;}
.text-left,.val{direction:ltr;unicode-bidi:plaintext;font-variant-numeric:tabular-nums;}
.summary-card,.note-box,.panel,.stat-box,.quotation-total-box,.quotation-terms-block{break-inside:avoid;page-break-inside:avoid;}
.note-box:empty,.receipt-note-box:empty{display:none!important;}
@media print{
  .table th,.table td{padding-top:5px;padding-bottom:5px;}
  .doc-table-wrap{break-inside:auto;page-break-inside:auto;}
  .summary-card table td{padding-top:5px;padding-bottom:5px;}
  .print-body{min-height:0;}
}

.summary-card .amount-words-row td{background:#fbfdff;}
.summary-card .amount-words{font-size:12px;line-height:1.8;text-align:right!important;direction:rtl;unicode-bidi:normal;color:var(--brand-navy);font-weight:800;}


/* Voucher signature cards */
.voucher-signature-cards{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:14px;
  margin-top:12px;
  break-inside:avoid;
  page-break-inside:avoid;
}
.voucher-signature-card{
  border:1px solid var(--brand-line);
  border-radius:14px;
  background:#fff;
  min-height:92px;
  padding:12px 14px 10px;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
}
.voucher-signature-title{
  font-size:13px;
  font-weight:900;
  color:var(--brand-navy);
  text-align:center;
}
.voucher-signature-line{
  border-bottom:1px solid #9aaaba;
  height:30px;
}
@media print{
  .voucher-signature-cards,.voucher-signature-card{break-inside:avoid;page-break-inside:avoid;}
}
@media screen and (max-width:900px){
  .voucher-signature-cards{grid-template-columns:1fr;}
}


/* Bank / check print improvements */
.bank-hero-grid{grid-template-columns:1.15fr .85fr;gap:10px;}
.bank-detail-grid{grid-template-columns:repeat(2,minmax(0,1fr));}
.bank-summary-card{height:100%;}
.bank-summary-card .amount-words-row td{background:#fbfdff;}
.bank-table th,.bank-table td{font-size:10.5px;text-align:center;vertical-align:middle;}
.bank-table .text-left,.bank-table .ltr-number{direction:ltr;unicode-bidi:plaintext;text-align:center;}
.bank-opening-row td{background:#f7fafc!important;}
.bank-check-hero .summary-card .grand td{font-size:14px;}
@media print{
  .bank-hero-grid,.bank-summary-card,.bank-check-hero,.bank-opening-row{break-inside:avoid;page-break-inside:avoid;}
  .bank-table thead{display:table-header-group;}
  .bank-table tr{break-inside:avoid;page-break-inside:avoid;}
}
@media screen and (max-width:900px){
  .bank-hero-grid,.bank-detail-grid{grid-template-columns:1fr;}
}

/* inventory/warehouse print polish */
.inventory-print-table th,
.inventory-print-table td{
  text-align:center;
  vertical-align:middle;
}
.inventory-print-table .pi-item-name{
  text-align:right;
}
.inventory-print-table td.text-left{
  text-align:left;
}
.inventory-print-table .is-strong{
  font-weight:800;
  color:var(--brand-navy);
}
@media print{
  .inventory-print-table thead{display:table-header-group;}
  .inventory-print-table tr{break-inside:avoid;page-break-inside:avoid;}
  .inventory-print-table th,
  .inventory-print-table td{font-variant-numeric:tabular-nums;}
}


/* Controlled pagination for long stock reports */
.inventory-report-page{
  break-inside:auto;
  page-break-inside:auto;
}
.inventory-report-page.is-continuation-page{
  padding-top:5mm;
}
.inventory-continuation-head{
  display:grid;
  grid-template-columns:1.4fr .8fr .45fr;
  gap:10px;
  align-items:center;
  border:1px solid var(--brand-line);
  border-radius:14px;
  background:#fbfdff;
  padding:8px 12px;
  margin-bottom:9px;
}
.inventory-continuation-head div{
  min-width:0;
  border-left:1px solid var(--brand-line-soft);
  padding-left:10px;
}
.inventory-continuation-head div:last-child{border-left:none;padding-left:0;}
.inventory-continuation-head span{display:block;font-size:10px;color:var(--brand-muted);font-weight:700;line-height:1.4;}
.inventory-continuation-head strong{display:block;font-size:13px;color:var(--brand-navy);font-weight:800;line-height:1.5;}
.inventory-report-table-section{margin-top:0;}
.inventory-report-table-wrap{overflow:visible;}
.inventory-stock-table th,
.inventory-stock-table td{padding-top:7px;padding-bottom:7px;}
.inventory-report-total-section{margin-top:10px;}
@media print{
  .inventory-report-break{break-before:page!important;page-break-before:always!important;}
  .inventory-report-page{break-inside:auto!important;page-break-inside:auto!important;}
  .inventory-report-page.is-continuation-page{padding-top:5mm!important;}
  .inventory-report-table-section{break-inside:auto!important;page-break-inside:auto!important;}
  .inventory-report-page .pi-table-wrap{break-inside:auto!important;page-break-inside:auto!important;}
  .inventory-stock-table thead{display:table-header-group;}
  .inventory-stock-table th,
  .inventory-stock-table td{padding-top:5px;padding-bottom:5px;line-height:1.25;}
  .inventory-continuation-head{display:grid!important;grid-template-columns:1.4fr .8fr .45fr!important;break-after:avoid;page-break-after:avoid;margin-bottom:5px;padding:6px 10px;}
  .inventory-continuation-head div{display:block!important;white-space:normal!important;writing-mode:horizontal-tb!important;text-orientation:mixed!important;}
  .inventory-continuation-head span,.inventory-continuation-head strong{writing-mode:horizontal-tb!important;text-orientation:mixed!important;white-space:normal!important;}
  .inventory-report-page .pi-section-title{break-after:avoid;page-break-after:avoid;margin-bottom:5px;}
}

/* Safe top space for continuation pages in long inventory reports. */
.inventory-report-safe-top{height:5mm;}

/*
 * Global print safety: multipage A4 documents continue inside the printable page
 * area instead of starting too close to the physical printer edge.  We keep the
 * first-page visual position stable by moving 4mm from .page-content padding to
 * the @page top margin. This helps invoices, reports, statements, warehouse
 * documents, vouchers, and any long table that naturally spans pages.
 */
@media print{
  .pi-table thead,
  .table thead,
  .doc-table thead,
  .bank-table thead,
  .inventory-print-table thead{display:table-header-group;}
  .pi-table tr,
  .table tr,
  .doc-table tr,
  .bank-table tr,
  .inventory-print-table tr{break-inside:avoid;page-break-inside:avoid;}
  .print-page-break + section,
  .print-page-break + .print-section{padding-top:5mm;}
  .inventory-report-break + section{padding-top:5mm;}
}


/* Statement print refresh: customer/supplier account statements */
.statement-hero{margin-bottom:10px;}
.statement-title-block{display:block;padding:0 0 10px;border-bottom:2px solid var(--brand-line-soft);}
.statement-title-block .pi-title{margin:0;font-size:28px;line-height:1.15;color:var(--brand-navy);font-weight:900;}
.statement-title-block .pi-title-en{font-size:12px;color:var(--brand-muted);letter-spacing:.18em;font-weight:800;margin-top:4px;text-transform:uppercase;}
.statement-hero-grid{display:grid;grid-template-columns:1.12fr .88fr;gap:12px;align-items:start;margin-top:10px;}
.statement-party-card,.statement-summary-card{border:1px solid var(--brand-line);border-radius:14px;background:#fff;overflow:hidden;}
.statement-party-card .pi-card-head,.statement-summary-card .pi-card-head{padding:10px 12px;background:#f7fafc;border-bottom:1px solid var(--brand-line);color:var(--brand-navy);font-size:12px;font-weight:900;}
.statement-party-card .pi-party-name{padding:12px 14px 6px;font-size:18px;font-weight:900;color:#10273a;}
.statement-meta-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;padding:0 14px 14px;}
.statement-meta-grid span{display:block;font-size:10px;color:var(--brand-muted);margin-bottom:4px;font-weight:700;}
.statement-meta-grid strong{display:block;font-size:13px;color:#10273a;font-weight:900;line-height:1.35;}
.statement-summary-stats{display:grid;grid-template-columns:1fr 1fr;gap:10px;padding:12px;}
.statement-summary-stats .pi-stat-box{border:1px solid #e2eaf1;border-radius:12px;padding:10px;background:#fbfdff;min-height:78px;display:flex;flex-direction:column;justify-content:space-between;}
.statement-summary-stats .pi-stat-box span{font-size:10.5px;color:var(--brand-muted);font-weight:800;}
.statement-summary-stats .pi-stat-box strong{font-size:19px;color:#10273a;font-weight:900;line-height:1.1;}
.statement-summary-stats .pi-stat-box em{font-style:normal;color:#e5eef7;font-size:10px;font-weight:700;margin-top:4px;}
.statement-summary-stats .pi-stat-box.is-accent{background:linear-gradient(135deg,var(--brand-navy) 0%,var(--brand-blue) 100%);border-color:var(--brand-navy);}
.statement-summary-stats .pi-stat-box.is-accent span,.statement-summary-stats .pi-stat-box.is-accent strong{color:#fff;}
.statement-page{margin-bottom:10px;}
.statement-page-follow{padding-top:9mm;}
.statement-continuation-head{border:1px solid var(--brand-line);border-radius:12px;background:#fbfdff;margin-bottom:8px;padding:8px 10px;display:flex;align-items:center;justify-content:space-between;gap:10px;}
.statement-continuation-head strong{display:block;color:var(--brand-navy);font-size:13px;font-weight:900;line-height:1.3;}
.statement-continuation-head span{display:block;color:var(--brand-muted);font-size:10px;font-weight:800;margin-top:2px;}
.statement-continuation-note{font-size:11px;color:var(--brand-muted);font-weight:800;}
.statement-section-heading{margin-top:0;}
.statement-table-wrap{border-radius:14px;overflow:visible;}
.statement-table th{text-align:center!important;font-size:10.5px;}
.statement-table td{text-align:center;vertical-align:middle;font-size:10.7px;line-height:1.55;}
.statement-table .col-date{width:88px;}
.statement-table .col-type{width:104px;}
.statement-table .col-ref{width:108px;}
.statement-table .col-money{width:92px;}
.statement-table .col-balance{width:102px;}
.statement-table .statement-desc{text-align:right!important;font-weight:700;color:#10202f;}
.statement-table .statement-money{direction:ltr;unicode-bidi:plaintext;font-variant-numeric:tabular-nums;font-weight:800;}
.statement-opening-row td{background:#f8fafc!important;font-weight:900;color:var(--brand-navy);}
.statement-final-summary{max-width:430px;margin-inline-start:auto;margin-top:10px;}
.statement-total-card .summary-head{font-weight:900;}
@media print{
  .statement-hero-grid,.statement-summary-stats,.statement-meta-grid{break-inside:avoid;page-break-inside:avoid;}
  .statement-page-follow{padding-top:10mm;}
  .statement-continuation-head{break-inside:avoid;page-break-inside:avoid;}
  .statement-table thead{display:table-header-group;}
  .statement-table tr{break-inside:avoid;page-break-inside:avoid;}
  .statement-final-summary{break-inside:avoid;page-break-inside:avoid;}
}
@media screen and (max-width:900px){
  .statement-hero-grid,.statement-summary-stats,.statement-meta-grid{grid-template-columns:1fr;}
  .statement-final-summary{max-width:none;}
}


/* Statement header/layout alignment with invoice A4 style */
.statement-hero{margin-bottom:10px;}
.statement-title-block{display:block;padding:0 0 10px;border-bottom:2px solid var(--brand-line-soft);}
.statement-hero-grid{display:grid!important;grid-template-columns:1.15fr .85fr!important;gap:12px;align-items:start;margin-top:10px;}
.statement-summary-stats{display:grid!important;grid-template-columns:1fr 1fr!important;gap:10px;padding:12px;}
.statement-meta-grid{display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:10px;padding:0 14px 14px;}
.statement-party-card .pi-party-name{font-size:20px;line-height:1.35;}
.statement-table-wrap{width:100%;}
@media print{
  .statement-hero-grid{grid-template-columns:1.15fr .85fr!important;}
  .statement-summary-stats{grid-template-columns:1fr 1fr!important;}
  .statement-meta-grid{grid-template-columns:repeat(3,minmax(0,1fr))!important;}
}
@media screen and (max-width:700px){
  .statement-hero-grid,.statement-summary-stats,.statement-meta-grid{grid-template-columns:1fr!important;}
}


/* =========================================================
   Reports print mode (generic reports only)
   Unified print / PDF header-footer and A4 pagination
   ========================================================= */
body.report-print-mode{background:#eef2f6;}
.report-print-mode .page.a4::before{display:none;}
.report-print-mode .page.a4{border-radius:0;box-shadow:none;border:1px solid #dde4ec;background:#fff;}
.report-print-mode .page-content{padding:14mm 12mm 12mm;min-height:calc(297mm - 26mm);}
.report-print-mode .print-body{padding-top:0;}
.report-print-mode .print-footer{margin-top:8mm;}
.report-print-header{margin-bottom:8mm;padding-bottom:5mm;border-bottom:1px solid #d8e1ea;}
.report-header-topbar{height:8mm;border-radius:0 0 12px 12px;background:linear-gradient(120deg,var(--brand-blue) 0%, var(--brand-navy) 48%, var(--brand-dark) 72%, #eef4fa 72.2%, #eef4fa 100%);margin-bottom:6mm;}
.report-header-grid{display:grid;grid-template-columns:1.2fr .8fr;gap:12px;align-items:stretch;}
.report-brand-card,.report-doc-card{border:1px solid #d9e3ec;border-radius:14px;background:#fbfdff;}
.report-brand-card{padding:12px 16px;}
.report-brand-wrap{display:flex;align-items:center;justify-content:space-between;gap:12px;}
.report-brand-logo{width:78px;height:78px;border-radius:50%;overflow:hidden;border:1px solid #d7e2ec;background:#fff;display:flex;align-items:center;justify-content:center;padding:4px;flex:0 0 78px;}
.report-brand-logo img{width:100%;height:100%;object-fit:contain;border-radius:50%;}
.report-brand-copy{min-width:0;flex:1;}
.report-brand-name{font-size:24px;font-weight:800;color:#10273a;line-height:1.15;}
.report-brand-sub,.report-brand-meta{font-size:11px;color:#66798a;line-height:1.7;}
.report-doc-card{padding:10px 12px;}
.report-doc-row{display:flex;justify-content:space-between;gap:8px;padding:6px 0;border-bottom:1px solid #edf2f7;font-size:12px;align-items:flex-start;}
.report-doc-row:last-child{border-bottom:none;padding-bottom:0;}
.report-doc-row span{color:#6b7c8d;font-weight:700;}
.report-doc-row strong{color:#10273a;font-weight:800;text-align:left;}
.report-title-block{display:grid;grid-template-columns:1.15fr .85fr;gap:10px;align-items:start;margin-bottom:10px;}
.report-title-copy{border-right:4px solid var(--brand-blue);padding-right:12px;}
.report-main-title{font-size:24px;line-height:1.25;color:#10273a;font-weight:900;margin:0 0 4px;}
.report-subtitle{font-size:12px;color:#66798a;line-height:1.8;}
.report-meta-card{border:1px solid #d9e3ec;border-radius:14px;background:#fff;padding:10px 12px;}
.report-meta-row{display:flex;justify-content:space-between;gap:10px;padding:6px 0;border-bottom:1px solid #edf2f7;font-size:12px;}
.report-meta-row:last-child{border-bottom:none;padding-bottom:0;}
.report-meta-row span{color:#6b7c8d;font-weight:700;}
.report-meta-row strong{color:#10273a;font-weight:800;}
.report-section-caption{font-size:13px;font-weight:900;color:#16324a;margin-bottom:8px;}
.report-filter-block,.report-summary-block,.report-table-block{margin-bottom:10px;}
.report-filter-chips{display:flex;flex-wrap:wrap;gap:8px;}
.report-filter-chip{display:inline-flex;align-items:center;gap:8px;border:1px solid #d8e1ea;background:#fbfdff;border-radius:999px;padding:7px 12px;font-size:11px;}
.report-filter-chip span{color:#6b7c8d;font-weight:700;}
.report-filter-chip strong{color:#10273a;font-weight:800;}
.report-summary-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;}
.report-summary-card{border:1px solid #d9e3ec;border-radius:14px;background:linear-gradient(180deg,#fbfdff 0%,#f7fafc 100%);padding:10px 12px;min-height:82px;display:flex;flex-direction:column;justify-content:center;}
.report-summary-label{font-size:11px;color:#6b7c8d;font-weight:700;line-height:1.6;}
.report-summary-value{font-size:20px;color:#10273a;font-weight:900;line-height:1.2;margin-top:3px;font-variant-numeric:tabular-nums;unicode-bidi:plaintext;}
.report-table-wrap{overflow:visible!important;border-radius:14px;}
.report-print-table th{text-align:center;font-size:11px;padding:9px 7px;white-space:nowrap;}
.report-print-table td{text-align:center;font-size:11px;line-height:1.6;padding:8px 7px;vertical-align:middle;}
.report-print-table td:first-child,.report-print-table th:first-child{text-align:right;}
.report-print-table td{font-variant-numeric:tabular-nums;unicode-bidi:plaintext;}
.report-print-footer{padding-top:4mm;border-top:1px solid #d8e1ea;}
.report-footer-line{display:grid;grid-template-columns:1.15fr 1.15fr .7fr;gap:10px;align-items:center;font-size:10.5px;color:#66798a;}
.report-footer-note{font-weight:700;color:#4f6376;}
.report-footer-contact{display:flex;flex-wrap:wrap;gap:6px 12px;justify-content:center;}
.report-footer-contact span::after{content:"|";margin-inline-start:12px;color:#c2ccd6;}
.report-footer-contact span:last-child::after{display:none;}
.report-footer-meta{display:flex;flex-direction:column;align-items:flex-end;gap:4px;color:#4f6376;font-weight:700;}
.report-page-current::after{content:counter(page);}
.report-page-total::after{content:counter(pages);}
@media screen and (max-width:900px){
  .report-header-grid,.report-title-block,.report-footer-line,.report-summary-grid{grid-template-columns:1fr;}
  .report-brand-wrap{align-items:flex-start;}
  .report-footer-meta{align-items:flex-start;}
}
@page { size: A4 portrait; margin: 16mm 10mm 16mm; }
@media print{
  body.report-print-mode{background:#fff!important;}
  .report-print-mode .page.a4{border:none!important;box-shadow:none!important;width:auto!important;min-height:auto!important;}
  .report-print-mode .page-content{padding:0!important;min-height:auto!important;}
  .report-print-mode .print-header,.report-print-mode .print-footer{position:fixed;left:0;right:0;background:#fff;z-index:3;}
  .report-print-mode .print-header{top:0;padding:0 0 3mm;}
  .report-print-mode .print-footer{bottom:0;padding-top:3mm;}
  .report-print-mode .print-body{padding-top:46mm!important;padding-bottom:20mm!important;}
  .report-print-mode .report-print-header{margin-bottom:0;border-bottom:1px solid #d8e1ea;}
  .report-print-mode .report-print-footer{margin-top:0;}
  .report-print-mode .report-title-block,
  .report-print-mode .report-filter-block,
  .report-print-mode .report-summary-block,
  .report-print-mode .report-table-block,
  .report-print-mode .report-summary-card,
  .report-print-mode .report-meta-card,
  .report-print-mode .report-brand-card,
  .report-print-mode .report-doc-card{break-inside:avoid;page-break-inside:avoid;}
  .report-print-mode .report-print-table{width:100%;border-collapse:collapse;page-break-inside:auto;}
  .report-print-mode .report-print-table thead{display:table-header-group;}
  .report-print-mode .report-print-table tfoot{display:table-footer-group;}
  .report-print-mode .report-print-table tr{break-inside:avoid;page-break-inside:avoid;}
  .report-print-mode .report-print-table td,.report-print-mode .report-print-table th{font-size:10.5px;}
}

/* =========================================================
   Reports A4 stable print fix v2
   No fixed header/footer. Uses table header/footer groups.
   ========================================================= */
body.report-print-mode{background:#eef2f6;color:#10202f;}
body.report-print-mode .page.a4::before{display:none!important;}
body.report-print-mode .page.a4{width:210mm;max-width:210mm;min-height:297mm;margin:12px auto;border:1px solid #d7dee7;border-radius:0;box-shadow:0 6px 18px rgba(15,23,42,.12);background:#fff;padding:0;overflow:visible;}
.report-paper-table{width:100%;border-collapse:collapse;table-layout:fixed;direction:rtl;}
.report-paper-table thead{display:table-header-group;}
.report-paper-table tfoot{display:table-footer-group;}
.report-paper-header{padding:9mm 12mm 4mm;}
.report-paper-body{padding:0 12mm 6mm;vertical-align:top;}
.report-paper-footer{padding:3mm 12mm 8mm;}
.report-print-header{margin:0 0 5mm;border-bottom:1px solid #d8e1ea;padding-bottom:3mm;}
.report-header-bar{height:6mm;border-radius:0 0 8px 8px;background:linear-gradient(120deg,#245a8d 0%,#16324a 48%,#1f2937 70%,#f3f7fb 70.3%,#f3f7fb 100%);margin-bottom:4mm;}
.report-header-main{display:grid;grid-template-columns:1.18fr .82fr;gap:10px;align-items:stretch;}
.report-brand,.report-doc-meta{border:1px solid #d9e3ec;border-radius:12px;background:#fbfdff;}
.report-brand{display:flex;align-items:center;gap:12px;padding:8px 12px;min-height:24mm;}
.report-logo{width:19mm;height:19mm;border-radius:50%;border:1px solid #d7e2ec;background:#fff;display:flex;align-items:center;justify-content:center;padding:2mm;flex:0 0 19mm;overflow:hidden;}
.report-logo img{width:100%;height:100%;object-fit:contain;border-radius:50%;}
.report-company{min-width:0;flex:1;color:#66798a;font-size:9px;line-height:1.55;}
.report-company-name{font-size:17px;font-weight:900;color:#10273a;line-height:1.15;margin-bottom:1mm;}
.report-company-meta{font-size:8.5px;direction:ltr;text-align:right;}
.report-doc-meta{padding:5px 10px;}
.report-doc-meta>div{display:flex;justify-content:space-between;gap:8px;padding:3px 0;border-bottom:1px solid #edf2f7;font-size:9.5px;line-height:1.45;}
.report-doc-meta>div:last-child{border-bottom:none;}
.report-doc-meta span{color:#6b7c8d;font-weight:800;white-space:nowrap;}
.report-doc-meta strong{color:#10273a;font-weight:900;text-align:left;overflow:hidden;text-overflow:ellipsis;}
.report-print-section{margin:0;}
.report-title-line{display:grid;grid-template-columns:1.22fr .78fr;gap:9px;align-items:start;margin-bottom:5mm;break-inside:avoid;page-break-inside:avoid;}
.report-title-line h1{font-size:19px;line-height:1.25;color:#10273a;font-weight:900;margin:0 0 2mm;border-right:4px solid #245a8d;padding-right:8px;}
.report-title-line p{font-size:10px;color:#66798a;line-height:1.7;margin:0;padding-right:12px;}
.report-generated-box{border:1px solid #d9e3ec;border-radius:12px;background:#fff;padding:6px 10px;}
.report-generated-box div{display:flex;justify-content:space-between;gap:8px;padding:4px 0;border-bottom:1px solid #edf2f7;font-size:10px;}
.report-generated-box div:last-child{border-bottom:none;}
.report-generated-box span{color:#6b7c8d;font-weight:800;}
.report-generated-box strong{color:#10273a;font-weight:900;}
.report-compact-panel{margin-bottom:5mm;break-inside:avoid;page-break-inside:avoid;}
.report-compact-panel h3,.report-table-title{font-size:12px;font-weight:900;color:#16324a;margin:0 0 2mm;}
.report-mini-table,.report-summary-table{width:100%;border-collapse:collapse;border:1px solid #d9e3ec;border-radius:10px;overflow:hidden;background:#fff;}
.report-mini-table th,.report-mini-table td,.report-summary-table th,.report-summary-table td{border:1px solid #e7edf3;padding:5px 7px;font-size:9.5px;line-height:1.45;}
.report-mini-table th,.report-summary-table th{background:#f7fafc;color:#637489;font-weight:900;white-space:nowrap;width:16%;}
.report-mini-table td,.report-summary-table td{color:#10273a;font-weight:900;direction:ltr;text-align:right;}
.report-table-title{margin-top:2mm;break-after:avoid;page-break-after:avoid;}
table.report-print-table{width:100%;border-collapse:collapse;page-break-inside:auto;border:1px solid #d9e3ec;direction:rtl;}
table.report-print-table thead{display:table-header-group;}
table.report-print-table tfoot{display:table-footer-group;}
table.report-print-table th{background:#16324a;color:#fff;font-size:9.2px;font-weight:900;padding:6px 5px;border:1px solid rgba(255,255,255,.12);text-align:center;white-space:nowrap;}
table.report-print-table td{font-size:9px;line-height:1.45;padding:5px 5px;border:1px solid #e7edf3;text-align:center;vertical-align:middle;color:#10202f;}
table.report-print-table td:first-child,table.report-print-table th:first-child{text-align:right;}
table.report-print-table tbody tr:nth-child(even) td{background:#fbfdff;}
table.report-print-table tr{break-inside:avoid;page-break-inside:avoid;}
.report-print-footer{border-top:1px solid #d8e1ea;padding-top:3mm;color:#66798a;font-size:8.3px;line-height:1.65;}
.report-footer-note{font-weight:900;color:#4f6376;margin-bottom:1.5mm;}
.report-footer-line{display:flex;flex-wrap:wrap;gap:2mm 5mm;align-items:center;justify-content:center;}
.report-footer-line span{white-space:nowrap;}
@page{size:A4 portrait;margin:8mm 0 8mm;}
@media print{
  body.report-print-mode{background:#fff!important;}
  body.report-print-mode .no-print{display:none!important;}
  body.report-print-mode .page-shell{padding:0!important;margin:0!important;max-width:none!important;}
  body.report-print-mode .page.a4{width:auto!important;max-width:none!important;min-height:auto!important;margin:0!important;border:none!important;box-shadow:none!important;}
  .report-paper-header{padding:0 10mm 3mm!important;}
  .report-paper-body{padding:0 10mm 4mm!important;}
  .report-paper-footer{padding:2.5mm 10mm 0!important;}
  .report-header-main{grid-template-columns:1.18fr .82fr!important;}
  .report-title-line{grid-template-columns:1.22fr .78fr!important;}
  .report-summary-table th,.report-summary-table td,.report-mini-table th,.report-mini-table td{font-size:9px!important;padding:4px 6px!important;}
  table.report-print-table th{font-size:8.8px!important;padding:5px 4px!important;}
  table.report-print-table td{font-size:8.5px!important;padding:4px!important;}
}
@media screen and (max-width:900px){
  .report-header-main,.report-title-line{grid-template-columns:1fr;}
}

/* Reports print space fix v3: remove excessive first-page gap after report header */
body.report-print-mode .report-print-header{margin-bottom:2mm!important;padding-bottom:2mm!important;}
body.report-print-mode .report-paper-body{padding-top:0!important;}
body.report-print-mode .report-title-line{margin-top:-24mm!important;margin-bottom:3mm!important;}
body.report-print-mode .report-title-line h1{margin-bottom:1mm!important;}
body.report-print-mode .report-title-line p{line-height:1.45!important;}
body.report-print-mode .report-compact-panel{margin-bottom:3mm!important;}
body.report-print-mode .report-table-title{margin-top:1mm!important;margin-bottom:1.5mm!important;}
@media print{
  body.report-print-mode .report-print-header{margin-bottom:2mm!important;padding-bottom:2mm!important;}
  body.report-print-mode .report-paper-body{padding-top:0!important;}
  body.report-print-mode .report-title-line{margin-top:-24mm!important;margin-bottom:3mm!important;}
}

/* Document print layout lock
   Keep A4 commercial documents identical in browser preview, Ctrl+P and PDF.
   Mobile responsive rules are intentionally screen-only above; these rules protect print output. */
@media print{
  body:not(.report-print-mode) .page.a4{
    width:210mm!important;
    max-width:210mm!important;
    min-height:297mm!important;
    overflow:visible!important;
  }
  body:not(.report-print-mode) .page-content{
    padding:4mm 8mm 7mm!important;
    min-height:calc(297mm - 17mm)!important;
  }
  body:not(.report-print-mode) .purchase-header-grid{grid-template-columns:1.18fr .82fr!important;}
  body:not(.report-print-mode) .simple-header .simple-top{grid-template-columns:.78fr 1.22fr!important;}
  body:not(.report-print-mode) .pi-hero,
  body:not(.report-print-mode) .pi-party-summary-grid,
  body:not(.report-print-mode) .pi-bottom-grid,
  body:not(.report-print-mode) .summary-layout,
  body:not(.report-print-mode) .quotation-client-strip,
  body:not(.report-print-mode) .quotation-summary-area,
  body:not(.report-print-mode) .voucher-summary-layout,
  body:not(.report-print-mode) .statement-invoice-grid,
  body:not(.report-print-mode) .bank-hero-grid{
    display:grid!important;
  }
  body:not(.report-print-mode) .pi-party-summary-grid,
  body:not(.report-print-mode) .pi-bottom-grid,
  body:not(.report-print-mode) .quotation-client-strip,
  body:not(.report-print-mode) .quotation-summary-area,
  body:not(.report-print-mode) .statement-invoice-grid{
    grid-template-columns:1.15fr .85fr!important;
  }
  body:not(.report-print-mode) .pi-party-meta-grid,
  body:not(.report-print-mode) .quotation-info-grid,
  body:not(.report-print-mode) .statement-meta-grid{
    display:grid!important;
    grid-template-columns:repeat(3,minmax(0,1fr))!important;
  }
  body:not(.report-print-mode) .pi-summary-stats,
  body:not(.report-print-mode) .hero-summary,
  body:not(.report-print-mode) .statement-summary-stats{
    display:grid!important;
    grid-template-columns:1fr 1fr!important;
  }
  body:not(.report-print-mode) .terms-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important;}
  body:not(.report-print-mode) .pf-signatures{grid-template-columns:repeat(3,1fr)!important;}
  body:not(.report-print-mode) .voucher-signature-cards{grid-template-columns:repeat(2,minmax(0,1fr))!important;}
  body:not(.report-print-mode) .print-header,
  body:not(.report-print-mode) .print-footer,
  body:not(.report-print-mode) .pi-hero,
  body:not(.report-print-mode) .pi-party-summary-grid,
  body:not(.report-print-mode) .pi-bottom-grid,
  body:not(.report-print-mode) .quotation-client-strip,
  body:not(.report-print-mode) .quotation-summary-area,
  body:not(.report-print-mode) .voucher-summary-layout{
    break-inside:avoid!important;
    page-break-inside:avoid!important;
  }
  body:not(.report-print-mode) .pi-table-wrap,
  body:not(.report-print-mode) .doc-table-wrap,
  body:not(.report-print-mode) .quotation-table-section{
    overflow:visible!important;
  }
}


/* Statement compact mode: keep account statement header useful without consuming page height. */
.statement-title-hero{margin-bottom:6px!important;padding-bottom:7px!important;}
.statement-title-hero .pi-title{font-size:24px!important;line-height:1.1!important;}
.statement-title-hero .pi-title-en{font-size:10px!important;margin-top:2px!important;letter-spacing:.16em!important;}
.statement-card-section{margin-bottom:7px!important;}
.statement-party-card .pi-card-head,.statement-summary-card .pi-card-head{padding:7px 10px!important;font-size:11px!important;}
.statement-party-compact{display:grid;grid-template-columns:1.7fr repeat(5,minmax(0,1fr));gap:6px;padding:8px 10px 9px;align-items:stretch;}
.statement-party-compact > div{border:1px solid #edf2f7;border-radius:10px;background:#fbfdff;padding:6px 8px;min-width:0;}
.statement-party-compact span{display:block;font-size:9.5px;color:var(--brand-muted);font-weight:800;margin-bottom:2px;}
.statement-party-compact strong{display:block;font-size:11.5px;color:#10273a;font-weight:900;line-height:1.25;white-space:normal;overflow-wrap:anywhere;}
.statement-party-compact .statement-party-main strong{font-size:15px;line-height:1.2;}
.statement-summary-stats.statement-summary-stats--wide{grid-template-columns:repeat(4,minmax(0,1fr))!important;gap:7px!important;padding:8px 10px!important;}
.statement-summary-stats.statement-summary-stats--wide .pi-stat-box{min-height:46px!important;padding:7px 8px!important;border-radius:10px!important;}
.statement-summary-stats.statement-summary-stats--wide .pi-stat-box span{font-size:9.5px!important;line-height:1.25!important;}
.statement-summary-stats.statement-summary-stats--wide .pi-stat-box strong{font-size:16px!important;line-height:1.1!important;}
.statement-summary-stats.statement-summary-stats--wide .pi-stat-box em{font-size:9px!important;margin-top:1px!important;}
@media print{
  body:not(.report-print-mode) .statement-party-compact{display:grid!important;grid-template-columns:1.7fr repeat(5,minmax(0,1fr))!important;}
  body:not(.report-print-mode) .statement-summary-stats.statement-summary-stats--wide{display:grid!important;grid-template-columns:repeat(4,minmax(0,1fr))!important;}
}
@media screen and (max-width:900px){
  .statement-party-compact{grid-template-columns:1fr 1fr;}
  .statement-party-compact .statement-party-main{grid-column:1 / -1;}
}

/* A4 print fit fix: Chrome print preview adds @page margins outside our 210x297mm page.
   Keep commercial document pages exact A4 so a one-page statement does not create a blank page 2. */
@page{size:A4 portrait;margin:0;}
@media print{
  html,body{width:210mm!important;min-height:0!important;height:auto!important;margin:0!important;padding:0!important;background:#fff!important;overflow:visible!important;}
  body:not(.report-print-mode) .page-shell{width:210mm!important;max-width:210mm!important;margin:0!important;padding:0!important;overflow:visible!important;}
  body:not(.report-print-mode) .page.a4{width:210mm!important;max-width:210mm!important;min-height:297mm!important;margin:0!important;border:none!important;box-shadow:none!important;border-radius:0!important;overflow:visible!important;break-after:auto!important;page-break-after:auto!important;}
  body:not(.report-print-mode) .page-content{width:210mm!important;min-height:297mm!important;padding:4mm 8mm 6mm!important;display:flex!important;flex-direction:column!important;box-sizing:border-box!important;overflow:visible!important;}
  body:not(.report-print-mode) .print-body{flex:0 0 auto!important;padding-top:2mm!important;overflow:visible!important;}
  body:not(.report-print-mode) .print-footer{margin-top:4mm!important;break-inside:avoid!important;page-break-inside:avoid!important;}
  body:not(.report-print-mode) .print-header{break-inside:avoid!important;page-break-inside:avoid!important;}
  body:not(.report-print-mode) .print-page-break{break-before:page!important;page-break-before:always!important;}
  body:not(.report-print-mode) .statement-page-follow{padding-top:6mm!important;}
  body:not(.report-print-mode) .statement-continuation-head{display:flex!important;break-after:avoid!important;page-break-after:avoid!important;margin-bottom:4px!important;padding:6px 10px!important;}
  body:not(.report-print-mode) .statement-table thead{display:table-header-group!important;}
  body:not(.report-print-mode) .statement-table tr{break-inside:avoid!important;page-break-inside:avoid!important;}
}

/* Multipage A4 safe area v2
   Use real @page vertical margins so repeated table headers on page 2+ do not
   touch the physical printer edge.  The printable height is reduced to avoid
   the blank extra page that happened when the page content stayed 297mm high. */
@page{size:A4 portrait;margin:7mm 0 8mm;}
@media print{
  html,body{width:210mm!important;min-height:0!important;height:auto!important;margin:0!important;padding:0!important;background:#fff!important;overflow:visible!important;}
  body:not(.report-print-mode) .page-shell{width:210mm!important;max-width:210mm!important;margin:0!important;padding:0!important;overflow:visible!important;}
  body:not(.report-print-mode) .page.a4{width:210mm!important;max-width:210mm!important;min-height:282mm!important;margin:0!important;border:none!important;box-shadow:none!important;border-radius:0!important;overflow:visible!important;break-after:auto!important;page-break-after:auto!important;}
  body:not(.report-print-mode) .page-content{width:210mm!important;min-height:282mm!important;padding:0 8mm!important;display:flex!important;flex-direction:column!important;box-sizing:border-box!important;overflow:visible!important;}
  body:not(.report-print-mode) .print-body{flex:0 0 auto!important;padding-top:2mm!important;overflow:visible!important;}
  body:not(.report-print-mode) .print-footer{margin-top:4mm!important;break-inside:avoid!important;page-break-inside:avoid!important;}
  body:not(.report-print-mode) .print-header{break-inside:avoid!important;page-break-inside:avoid!important;}
  body:not(.report-print-mode) table thead{display:table-header-group!important;}
  body:not(.report-print-mode) table tfoot{display:table-footer-group!important;}
  body:not(.report-print-mode) table tr{break-inside:avoid!important;page-break-inside:avoid!important;}
  body:not(.report-print-mode) .doc-table-wrap,
  body:not(.report-print-mode) .pi-table-wrap,
  body:not(.report-print-mode) .quotation-table-section,
  body:not(.report-print-mode) .statement-table-wrap,
  body:not(.report-print-mode) .bank-table-wrap{overflow:visible!important;}
  body:not(.report-print-mode) .print-page-break{break-before:page!important;page-break-before:always!important;}
  body:not(.report-print-mode) .print-page-break + section,
  body:not(.report-print-mode) .print-page-break + .print-section{padding-top:0!important;}
  body:not(.report-print-mode) .statement-page-follow{padding-top:0!important;}
  body:not(.report-print-mode) .statement-continuation-head{display:flex!important;break-after:avoid!important;page-break-after:avoid!important;margin-bottom:4px!important;padding:6px 10px!important;}
}
