/* Print and PDF: the paper shows the same layout as the platform, scaled to A4.
   - Documents (report, summary, letters, public pages) print in A4 portrait, application pages in A4 landscape.
   - A first page without top and bottom margins switches off the date and URL that browsers add
     in the margins, on every page. The body's cloned padding keeps the white space on page 1.
   - From page 2, the margins carry both logos, the document reference and the page number. */
@page {
  size: A4 landscape;
  margin: 16mm 13mm 9mm;
  @top-left { content: url("../assets/print/sps-carbon.svg"); vertical-align: bottom; }
  @top-right { content: url("../assets/print/safeperform.svg"); vertical-align: bottom; }
  @bottom-left { content: "SPS-CARBON · SAFEPERFORM SOLUTIONS"; font: 7.5pt "Mona Sans", "Segoe UI", sans-serif; color: #5f7378; }
  @bottom-right { content: "Page " counter(page) " sur " counter(pages); font: 7.5pt "Mona Sans", "Segoe UI", sans-serif; color: #5f7378; }
}
@page :first {
  margin-top: 0; margin-bottom: 0;
  @top-left { content: none; } @top-center { content: none; } @top-right { content: none; }
  @bottom-left { content: none; } @bottom-center { content: none; } @bottom-right { content: none; }
}
@page document { size: A4 portrait; margin-left: 14mm; margin-right: 14mm; }

@media print {
  *, *::before, *::after { -webkit-print-color-adjust: exact; print-color-adjust: exact; animation: none !important; transition: none !important; }
  html, body { background: #fff !important; min-height: 0 !important; }
  body { padding: 8mm 0 7mm; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
  body:has(.report), body:has(.public) { page: document; }

  /* Safety net if the theme could not be switched before printing. */
  html[data-theme="dark"] .logo-on-light { display: block !important; }
  html[data-theme="dark"] .logo-on-dark { display: none !important; }

  .sidebar, .toolbar, .scrim, #toasts, #tooltip, .skip-link, .since, .report-hint, .detail, dialog, .popover,
  #page .btn, #page .action-tools, .page-head .btn, .page-head [data-action], .card-head .btn, .action-tools, .gel-head-tools,
  .pz-nav, .pz-progress, .pz-top .btn, .fig-ic { display: none !important; }
  #page button, .pill-tag { box-shadow: none !important; }
  .window { min-height: 0; }
  .table-scroll { overflow: visible; }
  /* Soft shadows print as grey smudges: a hairline replaces them. */
  .summary, .sheet-block, .card, .panel, .window-card { box-shadow: none !important; outline: 0.5px solid #d5dcde; outline-offset: -0.5px; break-inside: avoid; }

  /* ---------- Application pages: the screen layout, A4 landscape ---------- */
  body:not(:has(.report)) .content { margin: 0; zoom: 0.92; }
  body:not(:has(.report)) .page { width: 1113px; max-width: none; padding: 0; }
  body:not(:has(.report)) .print-head { display: flex; align-items: center; justify-content: space-between; gap: 2rem; margin: 0 0 1.1rem; padding-bottom: 0.7rem; border-bottom: 1px solid #062129; font-size: 0.72rem; color: #4d6166; }
  body:not(:has(.report)) .print-head span:last-child { text-align: right; }
  body:not(:has(.report)) .print-head b { color: #062129; }
  .print-head .cobrand { flex: none; }
  .card-head, .panel-head, .page-head { break-after: avoid; }

  /* ---------- Documents: the width of the sheet on screen, scaled to A4 portrait ---------- */
  body:has(.report) .content { margin: 0; }
  body:has(.report) .page { padding: 0; max-width: none; }
  .report-wrap { position: static; }
  .report { width: 816px; max-width: none; margin: 0; padding: 0; zoom: 0.843; overflow: visible; background: none; border-radius: 0; box-shadow: none; outline: 0; }
  .report.exec { width: 796px; zoom: 0.864; }
  .report.letter { width: 716px; zoom: 0.96; }
  .report-watermark { position: fixed; opacity: 0.06; font-size: 10rem; }

  .report-cover { break-after: page; border-bottom: 0; min-height: 329mm; display: flex; flex-direction: column; }
  .report-photo { height: 64mm; margin: 0.5rem 0 0; }
  .report-cover .report-kicker { margin-top: 2rem; }
  .report-cover h1 { font-size: 2.6rem; }
  .report-hero b { font-size: 3.6rem; }
  .report-parties { margin-top: auto; }
  .report-doc { margin-top: 1rem; }
  .report-front { break-after: page; border-bottom: 0; }
  .exec-head h1 { font-size: 2.1rem; }
  .decl-title { font-size: 1.7rem; }

  /* Page breaks: pages stay full, nothing is cut in a bad place. */
  .report h2, .report h3, .report-h3, .report .card-sub { break-after: avoid; }
  .report p:has(+ table), .report p:has(+ .table-scroll) { break-after: avoid; }
  .report p, .report li { orphans: 3; widows: 3; }
  .report table tr, .findings > li, .report-sign, .report-annex, .report-quote, .report-doc, .exec-grid > section, .legend, .stackbar { break-inside: avoid; }
  .report thead { display: table-header-group; }
  .report tfoot { display: table-row-group; }
  .report tbody tr:nth-child(-n + 2), .report tbody tr:last-child { break-before: avoid; }
  .report tfoot tr { break-before: avoid; }

  /* ---------- Public pages (attestation, verification) ---------- */
  .public { min-height: 0; padding: 0; background: #fff; display: block; }
  .public .auth-backdrop, .public .auth-grain { display: none !important; }
  .public .public-window, html[data-theme="dark"] .public .public-window { width: 100%; max-width: none; margin: 0; padding: 0; border-radius: 0; box-shadow: none !important; background: #fff; color: #062129; }
  .public-actions, .verify-search, .verify-print button { display: none !important; }
  .public-seal { break-inside: avoid; }
}
