/* --- A4 page setup --- */
@page {
  size: A4 portrait;                 /* switch to landscape if you need: size: A4 landscape */
  margin: 12mm 12mm 16mm;            /* top/right/bottom/left */
}

/* --- Print rules --- */
@media print {
  /* Crisp, high-contrast text */
  html, body {
    background: #fff !important;
    color: #000 !important;
    font-size: 11pt;
    line-height: 1.35;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;       /* keep colors if you have charts/branding */
  }

  /* Remove “screen-only” chrome & effects */
  .d-print-none,
  nav, .navbar, .breadcrumb,
  .btn, .btn-group,
  .dropdown-menu, .pagination,
  .alert, .toast, .badge,
  .modal, .offcanvas, .carousel,
  .sticky-top, .fixed-top, .fixed-bottom,
  [role="dialog"], [role="alert"] {
    display: none !important;
  }

  /* Let you force print-only visibility via Bootstrap utility */
  .d-print-block { display: block !important; }

  /* Simplify layout: full-width, no gutters/shadows */
  .container, .container-fluid { max-width: none !important; width: auto !important; padding: 0 !important; }
  .row, [class*="col-"] { display: block !important; float: none !important; width: 100% !important; max-width: 100% !important; padding: 0 !important; }
  .shadow, .shadow-sm, .shadow-lg, .card, .img-thumbnail { box-shadow: none !important; }
  .card, .border, .border-0 { border: 0 !important; }

  /* De-emphasize backgrounds; keep text dark */
  [class*="bg-"] { background: transparent !important; }
  .text-muted { color: #444 !important; }
  .lead { font-size: 12pt !important; }

  /* Links: optionally show URLs in print (comment out if you don’t want it) */
  a[href^="http"]:after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    word-break: break-all;
  }

  /* Images & figures */
  img, svg, figure { max-width: 100% !important; height: auto !important; page-break-inside: avoid; }

  /* Headings should stay with following content */
  h1, h2, h3, h4 { break-after: avoid-page; /* avoid page break right after a heading */ }

  /* Tables: repeat header row on each page & add light borders */
  table { border-collapse: collapse !important; }
  .table { width: 100% !important; }
  .table th, .table td { border: 1px solid #ccc !important; padding: 4pt 6pt !important; }
  .table thead { display: table-header-group !important; }
  .table tfoot { display: table-footer-group !important; }
  .table tr, .table td, .table th { break-inside: avoid; }

  /* Code/pre blocks & quotes */
  pre, blockquote { white-space: pre-wrap; break-inside: avoid; }

  /* Better typography */
  * { orphans: 3; widows: 3; }

  /* Helpers you can add to elements in your HTML */
  .print-page-break { break-before: page; }   /* <div class="print-page-break"></div> */
  .avoid-break      { break-inside: avoid; }

  /* Optional header/footer repeated on each page (best-effort in browsers) */
  .print-header, .print-footer { position: fixed; left: 0; right: 0; }
  .print-header { top: 0; }
  .print-footer { bottom: 0; text-align: right; font-size: 10pt; opacity: 0.8; }

  /* Reserve space for the fixed header/footer so content doesn’t overlap */
  body { margin-top: 20mm; margin-bottom: 14mm; }

  /* Page numbers: works in some engines; Chrome may not support total pages */
  .print-footer .page-number:after { content: "Page " counter(page); }
  /* .print-footer .total-pages:after { content: " of " counter(pages); } */ /* not in all browsers */
}