/* ============================================================
   PRINT — isolate the document, repeat header/footer, paginate
   @page size itself is injected by app.js (#pagesize style) so it
   matches the active format at export time.
   ============================================================ */
@media print{
  html,body{ background:#fff !important; height:auto !important; overflow:visible !important; }

  /* hide tool chrome */
  .panel, .toolbar, .canvas > .zoomhint, .no-print{ display:none !important; }

  .app{ display:block !important; height:auto !important; }
  .stage{ display:block !important; background:#fff !important; }
  .canvas{ display:block !important; overflow:visible !important; padding:0 !important; background:#fff !important; }
  .canvas__inner{ transform:none !important; zoom:1 !important; width:auto !important; }

  .doc{
    box-shadow:none !important; margin:0 !important; width:auto !important;
    /* @page margin is 0, so the sheet's top/bottom breathing room lives here —
       this is what keeps the cover logo off the paper edge */
    padding-top:9mm !important; padding-bottom:7mm !important;
  }

  /* header rides in the frame table's thead and footer in its tfoot — the
     browser reserves BOTH heights on every printed page, so flowing content
     can never slide behind the running header or footer. */
  .frame{ width:100%; }
  .frame thead{ display:table-header-group; }
  .frame tfoot{ display:table-footer-group; }
  /* page margins live INSIDE the document (@page margin is 0) so no page-margin
     band exists for a canvas background to paint black */
  .frame thead .frame__cell{ padding-top:7mm; padding-bottom:5mm; }
  .frame tfoot .frame__cell{ padding-top:8mm; padding-bottom:6mm; }  /* safe zone above the footer */
  .run-head{ background:#fff; }
  .run-foot{ background:#fff; margin:0 !important; }

  /* footer: the in-flow copies reserve their height on every page but stay
     invisible; the pinned clone paints at the bottom edge of every sheet, so on
     the last page the footer sits on the bottom of the paper, not after the text */
  .frame tfoot .run-foot, .cover-page > .run-foot{ visibility:hidden; }
  .run-foot--pinned{
    display:flex !important; visibility:visible !important;
    position:fixed; bottom:7mm; inset-inline:16mm; background:#fff;
  }
  .doc--landscape .run-foot--pinned{ inset-inline:18mm; }

  .cover-page{ break-after:page; break-inside:avoid; }
  .doc--portrait .cover-page{ min-height:276mm; max-height:283mm; overflow:hidden; }
  .doc--landscape .cover-page{ min-height:189mm; max-height:196mm; overflow:hidden; }

  .body{ display:block !important; }   /* block flow paginates correctly */
  /* sections flow continuously — a section never jumps to a new page just
     because it doesn't fit whole; only its small units stay atomic, so the
     remaining space after the price table is always filled */
  .sec{ break-inside:auto; margin-top:19px; }
  .sec:first-child{ margin-top:0; }
  .scope__card, .ptable tbody tr, .tcol, .sign,
  .about-wrap .k, .tlist li, .bank-row, .bank-grid > *{ break-inside:avoid; }
  /* each block is independent: none of them forces a new page, and none of them
     drags the others along — they simply flow into whatever space is left */
  .bank-details-table, .bank-wa, .capprv, .pay{ break-inside:avoid; page-break-inside:avoid; }
  .bank-section, .client-approval, .electronic-verification{ break-inside:auto; }
  .bank-section, .client-approval, .electronic-verification{ break-before:auto; break-after:auto; }
  .sec--bank{ break-inside:auto; }               /* the section flows; its table stays whole */
  .sec__h, .tcol__t{ break-after:avoid; page-break-after:avoid; }
  p, .lead, .tlist li{ orphans:3; widows:3; }
  tr{ break-inside:avoid; page-break-inside:avoid; }
  .ptable thead{ display:table-header-group; }    /* repeat header row on every page the table spans */
  .ptable tfoot{ display:table-row-group; break-inside:avoid; }  /* totals flow once at the end — never repeated */
  .ptable tfoot tr{ break-inside:avoid; }

  /* force exact colors ONLY inside the document — never for the app chrome,
     whose dark backgrounds otherwise print as black bands in the page margins */
  .doc, .doc *{ -webkit-print-color-adjust:exact !important; print-color-adjust:exact !important; }

  /* every ancestor of the document paints white so no dark UI background can
     propagate to the page canvas (the source of black strips top/bottom) */
  html, body, .screen, .app, .stage, .canvas, .canvas__inner, #paper, .doc{
    background:#fff !important; background-image:none !important;
    box-shadow:none !important; border:0 !important;
  }
  body{ -webkit-print-color-adjust:economy; print-color-adjust:economy; }
  #paper{ margin:0 !important; padding:0 !important; }
}
