body .page.a4{padding:12mm 11mm 10mm;background:#fff;box-shadow:none;border-radius:0;border:1px solid #e5e7eb;}
body .page-content{min-height:calc(297mm - 22mm);display:flex;flex-direction:column;}
body .print-page-frame{display:none!important;}

.pi-print-body{display:flex;flex-direction:column;gap:12px;}
.pi-hero{display:block;padding:0 0 10px;border-bottom:2px solid #e7edf3;}
.pi-title{margin:0;font-size:28px;line-height:1.15;color:#0f2b40;font-weight:800;}
.pi-title-en{font-size:12px;color:#6f8293;letter-spacing:.18em;font-weight:700;margin-top:4px;text-transform:uppercase;}
.pi-meta-card,.pi-party-card,.pi-summary-card,.pi-total-card,.pi-terms-card{border:1px solid #d9e3ec;border-radius:14px;background:#fff;overflow:hidden;}
.pi-meta-card{padding:10px 12px;background:#fbfdff;}
.pi-meta-row{display:flex;justify-content:space-between;gap:10px;padding:7px 0;border-bottom:1px solid #edf2f7;font-size:12px;}
.pi-meta-row:last-child{border-bottom:none;padding-bottom:0;}
.pi-meta-row span{color:#6b7c8d;font-weight:700;}
.pi-meta-row strong{color:#10273a;font-weight:800;direction:ltr;text-align:left;}
.pi-party-summary-grid{display:grid;grid-template-columns:1.15fr .85fr;gap:12px;align-items:start;}
.pi-card-head{padding:10px 12px;background:#f7fafc;border-bottom:1px solid #d9e3ec;color:#16324a;font-size:12px;font-weight:800;}
.pi-party-card,.pi-summary-card,.pi-total-card,.pi-terms-card{padding-bottom:0;}
.pi-party-name{padding:12px 14px 6px;font-size:18px;font-weight:800;color:#10273a;}
.pi-party-meta-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;padding:0 14px 14px;}
.pi-party-meta-grid span{display:block;font-size:10px;color:#728496;margin-bottom:4px;}
.pi-party-meta-grid strong{display:block;font-size:13px;color:#10273a;font-weight:800;}
.pi-summary-stats{display:grid;grid-template-columns:1fr 1fr;gap:10px;padding:12px;}
.pi-stat-box{border:1px solid #e2eaf1;border-radius:12px;padding:12px;background:#fbfdff;min-height:88px;display:flex;flex-direction:column;justify-content:space-between;}
.pi-stat-box span{font-size:11px;color:#708293;font-weight:700;}
.pi-stat-box strong{font-size:22px;color:#10273a;font-weight:800;line-height:1.1;}
.pi-stat-box.is-accent{background:linear-gradient(135deg,#16324a 0%,#245a8d 100%);border-color:#16324a;}
.pi-stat-box.is-accent span,.pi-stat-box.is-accent strong{color:#fff;}
.pi-section-title{font-size:13px;font-weight:800;color:#16324a;margin-bottom:7px;}
.pi-table-wrap{border:1px solid #d9e3ec;border-radius:14px;overflow:hidden;}
.pi-table{width:100%;border-collapse:collapse;}
.pi-table th{background:#16324a;color:#fff;font-size:11px;font-weight:800;padding:9px 8px;border-left:1px solid rgba(255,255,255,.08);}
.pi-table td{padding:9px 8px;border-bottom:1px solid #eaf0f5;font-size:11px;line-height:1.6;}
.pi-table tbody tr:nth-child(even) td{background:#fbfdff;}
.pi-table tbody tr:last-child td{border-bottom:none;}
.pi-table .col-no{width:42px;}.pi-table .col-unit{width:92px;}.pi-table .col-qty,.pi-table .col-price,.pi-table .col-total{width:110px;}
.pi-item-name{font-size:13px;font-weight:800;color:#10273a;}
.pi-table .text-center{text-align:center;}.pi-table .text-left{text-align:left;}.pi-table .is-strong{font-weight:800;color:#0f2b40;}
.pi-bottom-grid{display:grid;grid-template-columns:1fr .86fr;gap:12px;align-items:start;}
.pi-notes-box{padding:12px 14px;font-size:12px;color:#304355;line-height:1.9;white-space:pre-line;min-height:134px;}
.pi-total-table{width:100%;border-collapse:collapse;}
.pi-total-table td{padding:8px 12px;border-bottom:1px solid #edf2f7;font-size:12px;}
.pi-total-table td:last-child{text-align:left;font-weight:800;color:#10273a;direction:ltr;}
.pi-total-table tr:last-child td{border-bottom:none;}
.pi-total-table tr.is-grand td{background:#16324a;color:#fff;font-size:15px;font-weight:800;padding-top:12px;padding-bottom:12px;}
.pi-total-table tr.is-grand td:last-child{color:#fff;}
@media print{
  body .page.a4{width:auto;min-height:auto;padding:0;border:none;}
  body .page-content{min-height:calc(297mm - 16mm);}
  .pi-hero,.pi-party-summary-grid,.pi-bottom-grid{break-inside:avoid;page-break-inside:avoid;}
  .pi-table thead{display:table-header-group;}
  .pi-table tr{break-inside:avoid;page-break-inside:avoid;}
}
@media screen and (max-width:900px){
  .pi-hero,.pi-party-summary-grid,.pi-bottom-grid,.pi-party-meta-grid,.pi-summary-stats{grid-template-columns:1fr;}
}
.purchase-header{margin-bottom:12px;padding-bottom:10px;border-bottom:1px solid #e7edf3;}
.purchase-header-grid{display:grid;grid-template-columns:1.18fr .82fr;gap:14px;align-items:stretch;}
.purchase-doc-card,.purchase-brand-card{border:1px solid #d9e3ec;border-radius:14px;background:#fbfdff;}
.purchase-doc-card{padding:10px 12px;}
.purchase-doc-card--invoice{padding:7px 10px;}
.purchase-doc-row{display:flex;justify-content:space-between;gap:10px;padding:4px 0;border-bottom:1px solid #edf2f7;font-size:12px;}
.purchase-doc-row:last-child{border-bottom:none;padding-bottom:0;}
.purchase-doc-row span{color:#6b7c8d;font-weight:700;}
.purchase-doc-row strong{color:#10273a;font-weight:800;direction:ltr;text-align:left;}
.purchase-brand-card{padding:11px 18px;}
.purchase-brand-wrap{display:flex;align-items:center;justify-content:space-between;gap:14px;}
.purchase-company-copy{min-width:0;}
.purchase-company-name{font-size:25px;font-weight:800;color:#10273a;line-height:1.15;}
.purchase-company-sub,.purchase-company-meta{font-size:12px;color:#66798a;line-height:1.58;}
.purchase-logo{width:96px;height:96px;border-radius:50%;border:1px solid #d7e2ec;display:flex;align-items:center;justify-content:center;padding:4px;background:#fff;flex:0 0 96px;}
.purchase-logo img{width:100%;height:100%;max-width:none;max-height:none;object-fit:contain;border-radius:50%;}
@media screen and (max-width:900px){.purchase-header-grid{grid-template-columns:1fr;}}


@media print{
  .pi-table-wrap,.pi-meta-card,.pi-party-card,.pi-summary-card,.pi-total-card,.pi-terms-card{overflow:visible!important;}
  .pi-total-table td:last-child,.pi-meta-row strong,.purchase-doc-row strong{font-variant-numeric:tabular-nums;unicode-bidi:plaintext;}
}

.purchase-doc-card--invoice{background:#fff;}
.purchase-doc-card--invoice .purchase-doc-row strong{font-size:14px;}

/* Statement body: force invoice-style proportions and spacing */
.statement-invoice-grid{display:grid;grid-template-columns:1.15fr .85fr;gap:12px;align-items:start;margin-bottom:12px;}
.statement-summary-stats{display:grid;grid-template-columns:1fr 1fr;gap:10px;padding:12px;}
.statement-summary-stats .pi-stat-box{min-height:76px;padding:10px;}
.statement-summary-stats .pi-stat-box strong{font-size:18px;}
.statement-summary-stats .pi-stat-box em{font-style:normal;color:#e5eef7;font-size:10px;font-weight:700;margin-top:4px;}
.statement-meta-grid{grid-template-columns:repeat(3,minmax(0,1fr));}
.statement-page{margin-bottom:10px;}
.statement-page-follow{padding-top:10mm;}
.statement-continuation-head{border:1px solid #d9e3ec;border-radius:12px;background:#fbfdff;margin-bottom:8px;padding:8px 10px;display:flex;align-items:center;justify-content:space-between;gap:10px;break-inside:avoid;page-break-inside:avoid;}
.statement-continuation-head strong{display:block;color:#16324a;font-size:13px;font-weight:900;line-height:1.3;}
.statement-continuation-head span{display:block;color:#708293;font-size:10px;font-weight:800;margin-top:2px;}
.statement-continuation-note{font-size:11px;color:#708293;font-weight:800;}
.statement-table-wrap{width:100%;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:#16324a;}
.statement-bottom-grid{margin-top:10px;}
@media print{
  .statement-invoice-grid{grid-template-columns:1.15fr .85fr;break-inside:avoid;page-break-inside:avoid;}
  .statement-summary-stats{grid-template-columns:1fr 1fr;}
  .statement-meta-grid{grid-template-columns:repeat(3,minmax(0,1fr));}
  .statement-table thead{display:table-header-group;}
  .statement-table tr{break-inside:avoid;page-break-inside:avoid;}
}


/* Statement: match invoice card heights and support totals visibility */
.statement-invoice-grid{align-items:stretch!important;}
.statement-invoice-grid .statement-party-card,
.statement-invoice-grid .statement-summary-card{height:100%;display:flex;flex-direction:column;}
.statement-invoice-grid .statement-party-card .statement-meta-grid,
.statement-invoice-grid .statement-summary-card .statement-summary-stats{flex:1;}
.statement-invoice-grid .statement-party-card .statement-meta-grid{align-content:center;}
.statement-invoice-grid .statement-summary-card .statement-summary-stats{align-content:stretch;}
.statement-invoice-grid .statement-summary-card .pi-stat-box{min-height:0;justify-content:center;gap:6px;}
.statement-invoice-grid .statement-party-card .pi-party-name{padding-top:14px;padding-bottom:8px;}
.statement-bottom-grid:empty{display:none;}
@media print{
  .statement-invoice-grid{align-items:stretch!important;}
  .statement-invoice-grid .statement-party-card,
  .statement-invoice-grid .statement-summary-card{height:100%;}
}

/* Final A4 document lock: do not let browser print preview switch commercial docs to mobile/stacked layout. */
@media print{
  body:not(.report-print-mode) .page.a4{width:210mm!important;max-width:210mm!important;min-height:297mm!important;padding:0!important;}
  body:not(.report-print-mode) .page-content{min-height:calc(297mm - 17mm)!important;padding:4mm 8mm 7mm!important;}
  body:not(.report-print-mode) .purchase-header-grid{grid-template-columns:1.18fr .82fr!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{display:grid!important;grid-template-columns:1.15fr .85fr!important;}
  body:not(.report-print-mode) .pi-party-meta-grid{display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr))!important;}
  body:not(.report-print-mode) .pi-summary-stats{display:grid!important;grid-template-columns:1fr 1fr!important;}
}

/* Statement print settings lock: sections are independent, so admin ordering cannot break the grid. */
.statement-title-hero{display:block!important;margin-bottom:10px;}
.statement-card-section{margin-bottom:12px;break-inside:avoid;page-break-inside:avoid;}
.statement-wide-card{width:100%;border:1px solid #d9e3ec;border-radius:14px;background:#fff;overflow:hidden;}
.statement-meta-grid--wide{grid-template-columns:repeat(3,minmax(0,1fr));}
.statement-summary-stats--wide{grid-template-columns:repeat(4,minmax(0,1fr));}
.statement-summary-stats--wide .pi-stat-box{min-height:72px;}
.statement-period-summary-card,.statement-notes-card{border:1px solid #d9e3ec;border-radius:14px;background:#fff;overflow:hidden;}
.statement-period-summary-table td:last-child{text-align:left;direction:rtl;unicode-bidi:plaintext;}
.statement-notes-card .pi-notes-box{min-height:0;white-space:pre-line;}
@media screen and (max-width:900px){
  .statement-meta-grid--wide,.statement-summary-stats--wide{grid-template-columns:1fr;}
}
@media print{
  .statement-card-section{break-inside:avoid!important;page-break-inside:avoid!important;}
  body:not(.report-print-mode) .statement-meta-grid--wide{display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr))!important;}
  body:not(.report-print-mode) .statement-summary-stats--wide{display:grid!important;grid-template-columns:repeat(4,minmax(0,1fr))!important;}
  body:not(.report-print-mode) .statement-title-hero{display:block!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;}
}
