/* Document preview is independent of checkout CTA and form styles. */
html.sfm-pdf-open { overflow: hidden; }
dialog.sfm-pdf-viewer { box-sizing: border-box; position: fixed; inset: 0; display: flex; flex-direction: column; width: min(100% - 32px, 1000px); max-width: none; height: min(94dvh, 1150px); max-height: none; padding: 0; margin: auto; overflow: hidden; border: 1px solid #d8d4cc; border-radius: 16px; background: #f4f3ef; color: #233a33; box-shadow: 0 24px 80px #0a201b44; font: 14px/1.45 system-ui, -apple-system, sans-serif; }
dialog.sfm-pdf-viewer:not([open]) { display: none; }
dialog.sfm-pdf-viewer::backdrop { background: #0a201b99; }
.sfm-pdf-header { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; border-bottom: 1px solid #dedbd4; background: #fff; }
.sfm-pdf-header h2 { flex: 1; min-width: 0; margin: 0; padding: 0; font: 650 19px/1.3 system-ui, -apple-system, sans-serif; overflow-wrap: anywhere; color: #233a33; }
.sfm-pdf-tools { display: flex; flex: none; align-items: center; gap: 8px; padding: 10px 20px; border-bottom: 1px solid #dedbd4; background: #fff; }
dialog.sfm-pdf-viewer .sfm-pdf-button, dialog.sfm-pdf-viewer .sfm-pdf-close, dialog.sfm-pdf-viewer .sfm-pdf-zoom { box-sizing: border-box; display: inline-flex; flex: none; align-items: center; justify-content: center; width: auto; min-width: 0; max-width: none; min-height: 40px; margin: 0; padding: 8px 13px; border: 1px solid #d2cec4; border-radius: 8px; background: #fff; color: #233a33; box-shadow: none; font: 600 14px/1.3 system-ui, -apple-system, sans-serif; text-transform: none; text-decoration: none; white-space: nowrap; cursor: pointer; }
dialog.sfm-pdf-viewer .sfm-pdf-button:hover:not(:disabled), dialog.sfm-pdf-viewer .sfm-pdf-close:hover { border-color: #98845c; background: #f6f4ed; }
dialog.sfm-pdf-viewer .sfm-pdf-close { border-color: transparent; }
dialog.sfm-pdf-viewer .sfm-pdf-zoom { margin-left: auto; padding-right: 24px; }
dialog.sfm-pdf-viewer :is(button, select, a, .sfm-pdf-viewport):focus-visible { outline: 3px solid #9b8345; outline-offset: 2px; }
dialog.sfm-pdf-viewer button:disabled, dialog.sfm-pdf-viewer select:disabled { opacity: .48; cursor: default; }
.sfm-pdf-counter { min-width: 37px; text-align: right; font: 600 13px/1.3 system-ui, -apple-system, sans-serif; color: #5c6761; white-space: nowrap; }
.sfm-pdf-message { flex: none; margin: 0; padding: 9px 20px; background: #f8f7f3; color: #5c6761; font: 12px/1.45 system-ui, -apple-system, sans-serif; }
.sfm-pdf-message.is-error { background: #fff4df; color: #744b18; }
.sfm-pdf-viewport { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; background: #e9e8e3; }
.sfm-pdf-pages { box-sizing: border-box; width: 100%; min-height: 100%; padding: 20px 16px 8px; --sfm-pdf-scale: 1; }
.sfm-pdf-pages[data-zoom="125"] { width: 125%; --sfm-pdf-scale: 1.25; }
.sfm-pdf-pages[data-zoom="150"] { width: 150%; --sfm-pdf-scale: 1.5; }
.sfm-pdf-pages[data-zoom="200"] { width: 200%; --sfm-pdf-scale: 2; }
.sfm-pdf-sheet { display: block; width: 100%; max-width: calc(780px * var(--sfm-pdf-scale)); margin: 0 auto 14px; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: transparent; }
.sfm-pdf-paper { position: relative; width: 100%; overflow: hidden; background: #fff; box-shadow: 0 1px 5px #152d2526; }
.sfm-pdf-page-size { display: block; width: 100%; height: auto; }
.sfm-pdf-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; margin: 0; }
.sfm-pdf-canvas[hidden] { display: none; }
.sfm-pdf-placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; color: #738078; text-align: center; font: 13px/1.5 system-ui, -apple-system, sans-serif; }
.sfm-pdf-placeholder[hidden] { display: none; }
.sfm-pdf-page-label { margin: 7px 0 0; color: #6c746d; text-align: center; font: 11px/1.4 system-ui, -apple-system, sans-serif; }
.sfm-pdf-accessible-text { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: pre-wrap; border: 0; }
.sfm-pdf-fallback { flex: none; margin: 0; padding: 12px 20px; background: #fff; border-top: 1px solid #dedbd4; text-align: center; font: 13px/1.4 system-ui, -apple-system, sans-serif; }
.sfm-pdf-fallback[hidden] { display: none; }
.sfm-pdf-fallback a { color: #263d34; text-underline-offset: 3px; }
.sfm-pdf-print-root { display: none; }
@media (max-width: 600px) {
  dialog.sfm-pdf-viewer { width: 100vw; height: 100dvh; border: 0; border-radius: 0; }
  .sfm-pdf-header { gap: 8px; padding: max(10px, env(safe-area-inset-top)) 12px 10px; }
  .sfm-pdf-header h2 { font-size: 16px; }
  .sfm-pdf-tools { gap: 6px; padding: 8px 12px; }
  dialog.sfm-pdf-viewer .sfm-pdf-button, dialog.sfm-pdf-viewer .sfm-pdf-close, dialog.sfm-pdf-viewer .sfm-pdf-zoom { min-height: 40px; padding: 8px 10px; font-size: 12px; }
  dialog.sfm-pdf-viewer .sfm-pdf-zoom { padding-right: 18px; }
  .sfm-pdf-counter { font-size: 11px; min-width: 30px; }
  .sfm-pdf-message { padding: 8px 12px; font-size: 11px; }
  .sfm-pdf-pages { padding: 12px 8px max(8px, env(safe-area-inset-bottom)); }
}
@media print {
  html.sfm-pdf-printing { overflow: visible !important; }
  html.sfm-pdf-printing body { display: block !important; width: auto !important; height: auto !important; min-height: 0 !important; margin: 0 !important; padding: 0 !important; background: #fff !important; overflow: visible !important; }
  html.sfm-pdf-printing body > * { display: none !important; }
  html.sfm-pdf-printing body > .sfm-pdf-print-root { display: block !important; position: static !important; width: 100%; padding: 0; margin: 0; }
  .sfm-pdf-print-page { display: block; box-sizing: border-box; width: 100%; height: auto; padding: 0; margin: 0; page: sfm-document; break-inside: avoid; break-after: page; page-break-after: always; }
  .sfm-pdf-print-page:last-child { break-after: auto; page-break-after: auto; }
  .sfm-pdf-print-page canvas { display: block; width: 100%; height: auto; margin: 0; padding: 0; }
  @page sfm-document { size: A4 portrait; margin: 0; }
}

/* V281: a retained, fully rasterized print job isolates PDF pages from the app. */
@media print {
 html.sfm-pdf-printing,html.sfm-pdf-printing body{height:auto!important;overflow:visible!important;max-height:none!important;}
 html.sfm-pdf-printing dialog,html.sfm-pdf-printing dialog::backdrop{display:none!important;visibility:hidden!important;}
 html.sfm-pdf-printing body>*:not(.sfm-pdf-print-root){display:none!important;}
 html.sfm-pdf-printing .sfm-pdf-print-root{visibility:visible!important;}
 .sfm-pdf-print-page img{display:block;width:100%;height:auto;max-height:297mm;object-fit:contain;margin:0;padding:0;}
 .sfm-pdf-print-page{break-inside:avoid;page-break-inside:avoid;}
 @page{size:A4 portrait;margin:0;}
}
