/* Shared document portal: paper is outside the application stacking contexts. */
body > .modal-overlay[data-celda-document-preview] {
  position: fixed !important;
  inset: 0 !important;
  z-index: 240000 !important;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: auto !important;
  overscroll-behavior: contain;
  padding: 16px !important;
  height: 100dvh;
  box-sizing: border-box;
}
body > [data-celda-document-preview] > div {
  width: 210mm;
  max-width: 100% !important;
  min-width: 0;
  flex: 0 0 auto;
}
body > [data-celda-document-preview] > .solicitud-print-wrap { width: 297mm; }
[data-celda-document-preview] .quote-sheet {
  width: 100% !important;
  max-width: none !important;
  box-sizing: border-box;
  height: auto !important;
  overflow: visible !important;
  padding: 10mm !important;
}
[data-celda-document-preview] .modal-toolbar {
  width: 100%;
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 8px;
  box-sizing: border-box;
  background: #fff;
  border-radius: 6px;
  flex-wrap: wrap;
}
[data-celda-document-preview] :is(.quote-table,.doc-info-table) { width: 100%; }
[data-celda-document-preview] :is(td,th) { overflow-wrap: anywhere; }
[data-celda-document-preview] .quote-table :is(td,th):first-child { white-space: nowrap; overflow-wrap: normal; }
[data-celda-document-preview] .doc-footer > div { white-space: normal; }
.document-config-notice { margin: 0 0 8px; color: #695126; font-size: 8pt; }
@media (max-width: 600px) {
  body > .modal-overlay[data-celda-document-preview] { padding: 8px !important; }
  [data-celda-document-preview] .quote-sheet { padding: 5mm !important; }
  [data-celda-document-preview] .quote-table :is(td,th) { padding: 4px 3px; font-size: 8pt; }
}
@media print {
  @page {
    size: A4; margin: 10mm 10mm 20mm;
    @bottom-right { content: "Página " counter(page) " de " counter(pages); font: 8pt Arial, sans-serif; }
  }
  @page solicitud-landscape { size: A4 landscape; margin: 10mm; }
  html[data-celda-design]:has([data-celda-document-preview]),
  html[data-celda-design] body:has([data-celda-document-preview]) {
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
    background: white !important;
  }
  body:has([data-celda-document-preview]) > :not([data-celda-document-preview]) { display: none !important; }
  /* Match the theme's ID specificity: visibility:hidden alone still consumes a page. */
  html[data-celda-design] body:has([data-celda-document-preview]) > #erp-root { display: none !important; }
  body > .modal-overlay[data-celda-document-preview] {
    display: block !important;
    position: static !important;
    inset: auto !important;
    height: auto !important;
    padding: 0 !important;
    overflow: visible !important;
    background: none !important;
    backdrop-filter: none !important;
  }
  [data-celda-document-preview], [data-celda-document-preview] * { visibility: visible !important; }
  [data-celda-document-preview] > div,
  [data-celda-document-preview] .quote-sheet { width: 100% !important; max-width: none !important; padding: 0 !important; box-shadow: none !important; }
  [data-celda-document-preview] :is(.modal-toolbar,button,.btn,.btn-ghost,.celda-print-hint) { display: none !important; }
  [data-celda-document-preview] thead { display: table-header-group; }
  [data-celda-document-preview] tr { break-inside: avoid; page-break-inside: avoid; }
  [data-celda-document-preview] .doc-page { break-inside: auto; }
  [data-celda-document-preview] .doc-page-topline { display: none !important; }
  [data-celda-document-preview] .doc-page + .doc-page { break-before: page; }
}

.celda-work-summary { display:grid; grid-template-columns:repeat(auto-fit,minmax(170px,1fr)); gap:12px; margin:16px 0; }
.celda-work-summary .card { display:flex; flex-direction:column; gap:8px; margin:0; }
.celda-work-summary b { font-size:1.7rem; }
.celda-report-card { margin-top:16px; }
.celda-report-result { border-top:1px solid #d9e1eb; margin-top:12px; padding:12px 0; }
.celda-report-result p { white-space:pre-wrap; overflow-wrap:anywhere; }
.celda-document-history { padding-left:18px; }
.celda-document-history li { margin:10px 0; overflow-wrap:anywhere; }
.celda-document-history small { display:block; margin-top:5px; }
.celda-expedient-card { min-width:0; margin-top:16px; overflow-wrap:anywhere; }
.celda-expedient-card .section-head { flex-wrap:wrap; gap:12px; }
.celda-expedient-card h2 { min-width:0; }
.celda-expedient-fields { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(180px,100%),1fr)); gap:12px; }
.celda-expedient-fields dt { font-weight:600; }
.celda-expedient-fields dd { margin:4px 0 0; }
.celda-expedient-events { padding-left:22px; }
.celda-expedient-events li { margin:10px 0; }
.celda-expedient-events p { margin:4px 0; }

/* Calibration only: do not let responsive/table theme rules change paper geometry. */
body > [data-celda-document-preview]:has(.calibration-paged){overflow:auto!important;}
body > [data-celda-document-preview] > .solicitud-print-wrap:has(.calibration-paged){width:min(297mm,calc(100vw - 32px))!important;max-width:100%!important;}
html[data-celda-design] body [data-celda-document-preview] #solicitud-sheet-print.calibration-paged{width:297mm!important;max-width:none!important;min-height:0!important;padding:0!important;background:transparent!important;}
.calibration-page{box-sizing:border-box!important;width:297mm!important;height:210mm!important;padding:10mm!important;display:flex!important;flex-direction:column;gap:3mm;overflow:hidden;background:#fff;margin:0 0 16px;border:1px solid #aeb8c4;color:#111;box-shadow:0 2px 8px #0002;}
.calibration-page>.ficha-header-table{flex:none;margin:0;width:100%;}
.calibration-page-body{flex:1;min-height:0;overflow:hidden;}
.calibration-page-body>.solicitud-table{table-layout:fixed;width:100%;}
html[data-celda-design] #solicitud-sheet-print.calibration-paged .solicitud-table :is(td,th){font:7.5pt/1.25 Arial,sans-serif!important;padding:3px!important;}
.calibration-page .ficha-header-table .title-cell[rowspan]{color:#006db6!important;}
html[data-celda-design] #solicitud-sheet-print.calibration-paged .solicitud-table th{background:#5b9bd5!important;color:#000!important;font-weight:700!important;}
html[data-celda-design] #solicitud-sheet-print.calibration-paged .solicitud-table :is(td,th){border-color:#26384d!important;}
.calibration-page-body .solicitud-signatures{margin:8px 0!important;gap:10px;}
.calibration-page-body .solicitud-signature-slot{width:180px;}
.calibration-page-footer{flex:none;display:block!important;font:8pt Arial,sans-serif;text-align:right;border-top:1px solid #c7d1de;padding-top:2mm;}
.calibration-equipment-label{font:700 9pt Arial,sans-serif;margin:6px 0;}
.calibration-preview-status{font:12px Arial,sans-serif;background:#f4f7fb;padding:8px;color:#29435d;}
.calibration-page-overflow{outline:2px solid #b24e3a;}
@media print{
 @page solicitud-landscape{size:A4 landscape;margin:0;@bottom-right{content:none;}}
 html[data-celda-design] body [data-celda-document-preview] #solicitud-sheet-print.calibration-paged{width:297mm!important;padding:0!important;}
 .calibration-page{page:solicitud-landscape;break-inside:avoid;break-after:page;page-break-after:always;margin:0!important;border:0!important;box-shadow:none!important;padding:10mm!important;}
 .calibration-page:last-child{break-after:auto;page-break-after:auto;}
 .calibration-preview-status{display:none!important;}
}

.calibration-page .ficha-header-table .logo-cell img{width:85px;height:32px;object-fit:contain;}
@media print{
 html[data-celda-design] body > [data-celda-document-preview] > .solicitud-print-wrap:has(.calibration-paged){width:297mm!important;max-width:none!important;}
 html[data-celda-design] body [data-celda-document-preview] #solicitud-sheet-print.calibration-paged{zoom:1!important;}
}

@media screen{.calibration-page-overflow .calibration-page-body{overflow:auto;}}

.calibration-zoom-controls{display:inline-flex;gap:4px;align-items:center;}
@media print{.calibration-zoom-controls{display:none!important;}}
.calibration-scale-stage{position:relative;flex:none;margin:0 auto;}
@media screen{.calibration-scale-stage>.calibration-paged{position:absolute;left:0;top:0;transform-origin:top left;}}
@media print{
 .calibration-scale-stage{display:contents!important;width:auto!important;height:auto!important;margin:0!important;}
 html[data-celda-design] #solicitud-sheet-print.calibration-paged{position:static!important;transform:none!important;}
}

/* Authenticated evidence gallery; hash details remain accessible on demand. */
.celda-report-evidence{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr));gap:14px}
.celda-evidence-photo{margin:0;min-width:0;max-width:320px;border:1px solid #d7e2ee;border-radius:4px;overflow:hidden;background:#fff}
.celda-evidence-image{display:block;padding:8px;text-align:center}.celda-evidence-image img{max-width:100%;height:180px;object-fit:contain}
.celda-evidence-photo figcaption{padding:8px;font-size:12px;overflow-wrap:anywhere}.celda-evidence-integrity{margin-top:8px;font-size:11px}.celda-evidence-integrity code{display:block;overflow-wrap:anywhere;margin-top:6px}
