/* ============================================================
   doc-preview.css  —  Document preview modal
   Shared across all download-journey pages.

   DEV NOTE:
   This viewer renders HTML "pages" that mirror the final PDF layout.
   In production, replace buildPreviewPages() in doc-preview.js with
   a fetch() call to your API returning rendered HTML per page, OR
   swap the inner <iframe> src with a PDF.js viewer URL pointing to
   the generated Blob / pre-signed S3 URL.
   ============================================================ */

/* ── Overlay ── */
.dp-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  padding: 24px;
  background: rgba(15, 23, 42, 0.68);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  font-family: "Lato", system-ui, sans-serif;
}

.dp-overlay.dp-open {
  opacity: 1;
  pointer-events: all;
}

/* ── Viewer panel ── */
.dp-main-col {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-width: 1180px;
  background: #f1f4f9;
  border-radius: 16px;
  overflow: hidden;
  box-shadow:
    0 24px 80px rgba(15, 23, 42, 0.3),
    0 2px 8px rgba(15, 23, 42, 0.12);
  transform: translateY(16px) scale(0.99);
  transition: transform 0.26s cubic-bezier(0.16, 1, 0.3, 1);
}

.dp-overlay.dp-open .dp-main-col {
  transform: translateY(0) scale(1);
}

@media (min-width: 900px) {
  .dp-overlay {
    flex-direction: row;
  }

  .dp-main-col {
    width: min(1076px, calc(100vw - 152px));
    height: min(900px, 100%);
    border-radius: 0 16px 16px 0;
  }
}

/* ── Toolbar ── */
.dp-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px;
  min-height: 68px;
  background: #ffffff;
  color: #172033;
  border-bottom: 1px solid #e3e8f0;
  flex-shrink: 0;
}

.dp-toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.dp-doc-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #fff1f0;
  display: grid;
  place-items: center;
  font-size: 16px;
  flex-shrink: 0;
  color: #c83f45;
}

.dp-doc-title {
  font-size: 14px;
  font-weight: 700;
  color: #172033;
  letter-spacing: -0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

.dp-toolbar-center {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.dp-pager-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid #dfe5ee;
  background: #ffffff;
  color: #344054;
  font-size: 12px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.dp-pager-btn:hover:not(:disabled) {
  background: #f4f6fa;
  border-color: #c9d2e0;
  color: #291f75;
}

.dp-pager-btn:disabled {
  color: #aab3c2;
  background: #f8f9fb;
  border-color: #e8ecf2;
  cursor: not-allowed;
}

.dp-page-label {
  font-size: 12px;
  font-weight: 600;
  color: #667085;
  min-width: 82px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.dp-toolbar-right {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}

.dp-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 15px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.1s ease;
}

.dp-action-btn:active {
  transform: translateY(1px);
}

.dp-btn-download {
  background: #291f75;
  color: #fff;
}

.dp-btn-download:hover {
  background: #21185f;
}

.dp-btn-mail {
  background: #ffffff;
  color: #344054;
  border-color: #dfe5ee;
}

.dp-btn-mail:hover {
  background: #f4f6fa;
  border-color: #c9d2e0;
}

.dp-close-btn {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  border: none;
  background: #f2f4f7;
  color: #667085;
  font-size: 16px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition:
    background 0.15s ease,
    color 0.15s ease;
  flex-shrink: 0;
}

.dp-close-btn:hover {
  background: #e9edf3;
  color: #172033;
}

/* Keep the toolbar usable without forcing horizontal scrolling on phones. */
@media (max-width: 680px) {
  .dp-overlay {
    padding: 0;
  }

  .dp-main-col {
    border-radius: 0;
  }

  .dp-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "left right"
      "center center";
    gap: 12px;
    padding: 12px 14px;
    min-height: 0;
  }

  .dp-toolbar-left {
    grid-area: left;
  }

  .dp-toolbar-center {
    grid-area: center;
    justify-content: center;
  }

  .dp-toolbar-right {
    grid-area: right;
  }

  .dp-action-btn .dp-btn-label {
    display: none;
  }

  .dp-doc-title {
    max-width: 220px;
    font-size: 13px;
  }

  .dp-action-btn {
    width: 38px;
    padding: 0;
    justify-content: center;
  }
}

@media (max-width: 360px) {
  .dp-doc-title {
    max-width: 150px;
  }

  .dp-toolbar {
    padding-right: 10px;
    padding-left: 10px;
  }
}

/* ── Page progress bar ── */
.dp-progress-track {
  height: 2px;
  background: #e8eaf1;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.dp-progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: #6658c8;
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Viewport (scrollable page area) ── */
.dp-viewport {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 30px 24px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  background: #f1f4f9;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 600px) {
  .dp-viewport {
    padding: 36px 32px 48px;
  }
}

/* ── A4 Paper page ── */
.dp-page {
  width: 100%;
  max-width: 720px;
  min-height: 960px;
  background: #ffffff;
  border-radius: 3px;
  box-shadow:
    0 3px 8px rgba(16, 24, 40, 0.06),
    0 16px 40px rgba(16, 24, 40, 0.1),
    0 0 0 1px rgba(16, 24, 40, 0.08);
  padding: 56px 54px;
  flex-shrink: 0;
  display: none;
  flex-direction: column;
}

.dp-page.dp-page-active {
  display: flex;
}

@media (max-width: 599px) {
  .dp-page {
    padding: 30px 22px;
    min-height: auto;
    border-radius: 3px;
  }

  .dp-viewport {
    padding: 18px 12px 28px;
    gap: 16px;
  }
}

/* ── Page header (letterhead) ── */
.dp-letterhead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 2px solid #291f75;
  margin-bottom: 24px;
  flex-shrink: 0;
}

.dp-lh-brand {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.dp-lh-company {
  font-size: 15px;
  font-weight: 700;
  color: #291f75;
  letter-spacing: -0.01em;
}

.dp-lh-tagline {
  font-size: 10px;
  color: #667085;
  letter-spacing: 0.02em;
}

.dp-lh-doc-meta {
  text-align: right;
  flex-shrink: 0;
}

.dp-lh-doc-type {
  font-size: 10px;
  font-weight: 700;
  color: #291f75;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dp-lh-ref {
  margin-top: 2px;
  font-size: 9px;
  color: #667085;
}

/* ── Page body content ── */
.dp-page-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.dp-section-title {
  font-size: 10px;
  font-weight: 700;
  color: #667085;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.dp-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 20px;
}

.dp-field-grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dp-field-grid.cols-1 {
  grid-template-columns: minmax(0, 1fr);
}

@media (max-width: 479px) {
  .dp-field-grid,
  .dp-field-grid.cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.dp-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.dp-field.span-2 {
  grid-column: span 2;
}

.dp-field.span-all {
  grid-column: 1 / -1;
}

.dp-field-label {
  font-size: 9px;
  font-weight: 700;
  color: #667085;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dp-field-value {
  font-size: 13px;
  font-weight: 600;
  color: #172033;
  line-height: 1.4;
  word-break: break-word;
}

.dp-field-value.highlight {
  font-size: 16px;
  color: #291f75;
  font-weight: 700;
}

.dp-divider {
  height: 1px;
  background: #e8e8f0;
  margin: 4px 0;
}

.dp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

.dp-table thead th {
  text-align: left;
  padding: 9px 10px;
  background: #f5f6fa;
  font-size: 9px;
  font-weight: 700;
  color: #667085;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  border-bottom: 1px solid #e2e2ec;
}

.dp-table tbody td {
  padding: 10px;
  color: #344054;
  font-weight: 500;
  border-bottom: 1px solid #eaecf0;
  vertical-align: top;
}

.dp-table tbody tr:last-child td {
  border-bottom: none;
}

.dp-table .td-amount {
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.dp-table .td-total td {
  background: #f7f6ff;
  font-weight: 700;
  border-top: 1.5px solid #291f75;
  padding-top: 10px;
}

/* Stamp / watermark badge */
.dp-stamp {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 2px solid #1a7f4e;
  border-radius: 8px;
  padding: 6px 12px;
  color: #1a7f4e;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  width: fit-content;
  margin-top: 8px;
}

.dp-stamp i {
  font-size: 11px;
}

/* Notice / callout box inside doc */
.dp-notice {
  background: #f7f6ff;
  border-left: 3px solid #291f75;
  border-radius: 0 6px 6px 0;
  padding: 12px 15px;
  font-size: 11px;
  color: #344054;
  line-height: 1.65;
}

/* Signature block */
.dp-sig-block {
  margin-top: auto;
  padding-top: 28px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-shrink: 0;
}

.dp-sig-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.dp-sig-item.right {
  align-items: flex-end;
}

.dp-sig-line {
  width: 110px;
  border-bottom: 1px solid #9898b2;
}

.dp-sig-caption {
  font-size: 9px;
  color: #9898b2;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ── Page footer strip ── */
.dp-page-foot {
  margin-top: 24px;
  padding-top: 10px;
  border-top: 1px solid #eaecf0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.dp-page-foot-copy {
  font-size: 8px;
  color: #98a2b3;
  letter-spacing: 0.03em;
}

.dp-page-foot-num {
  font-size: 8px;
  color: #98a2b3;
  letter-spacing: 0.03em;
}

/* ── Between pages gap ── */
.dp-page + .dp-page {
  margin-top: 0;
}

/* ── Thumbnail strip (optional, shown on desktop) ── */
.dp-thumbstrip {
  display: none;
}

@media (min-width: 900px) {
  .dp-thumbstrip {
    display: flex;
    flex-direction: column;
    width: 104px;
    height: min(900px, 100%);
    box-sizing: border-box;
    background: #f8f9fb;
    border-right: 1px solid #e3e8f0;
    border-radius: 16px 0 0 16px;
    overflow-x: hidden;
    overflow-y: auto;
    align-items: center;
    padding: 16px 10px;
    gap: 12px;
    flex-shrink: 0;
  }

  .dp-thumb {
    width: 80px;
    max-width: 100%;
    min-height: 108px;
    box-sizing: border-box;
    background: #fff;
    border-radius: 5px;
    border: 1px solid #e3e8f0;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    padding: 8px 7px;
    gap: 4px;
    transition:
      border-color 0.15s ease,
      box-shadow 0.15s ease;
    overflow: hidden;
    flex-shrink: 0;
  }

  .dp-thumb:hover {
    border-color: #a9a0e5;
  }

  .dp-thumb.dp-thumb-active {
    border-color: #6658c8;
    box-shadow: 0 0 0 2px rgba(102, 88, 200, 0.16);
  }

  .dp-thumb-line {
    height: 4px;
    border-radius: 2px;
    background: #e0e0ec;
    flex-shrink: 0;
  }

  .dp-thumb-line.dark {
    background: #291f75;
    height: 5px;
  }

  .dp-thumb-line.short {
    width: 55%;
  }

  .dp-thumb-num {
    margin-top: auto;
    font-size: 9px;
    color: #667085;
    text-align: center;
    font-weight: 600;
  }
}

/* ── Loading skeleton (while pages build) ── */
.dp-skeleton {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px 0;
  width: 100%;
  max-width: 660px;
}

.dp-skel-block {
  height: 14px;
  border-radius: 5px;
  background: linear-gradient(90deg, #e3e8f0 25%, #f8f9fb 50%, #e3e8f0 75%);
  background-size: 200% 100%;
  animation: dpSkelShimmer 1.4s infinite linear;
}

.dp-skel-block.tall {
  height: 22px;
}

.dp-skel-block.short {
  width: 45%;
}

.dp-skel-block.shorter {
  width: 65%;
}

@keyframes dpSkelShimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ── View button (added alongside Download/Mail) ── */
.btn-view {
  background: var(--white, #ffffff);
  border: 1.5px solid var(--fk-line-strong, rgba(20, 20, 43, 0.2));
  color: var(--fk-ink, #0d0d1a);
}

.btn-view:hover {
  border-color: var(--fk-accent, #291f75);
  background: var(--fk-accent-soft, #f0f1fa);
  color: var(--fk-accent, #291f75);
}

.dp-pager-btn:focus-visible,
.dp-action-btn:focus-visible,
.dp-close-btn:focus-visible,
.dp-thumb:focus-visible {
  outline: 3px solid rgba(102, 88, 200, 0.4);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .dp-overlay,
  .dp-shell,
  .dp-pager-btn,
  .dp-action-btn,
  .dp-close-btn,
  .dp-thumb,
  .dp-progress-fill {
    transition: none;
  }

  .dp-viewport {
    scroll-behavior: auto;
  }

  .dp-skel-block {
    animation: none;
  }
}

.dp-main-col,
.dp-page,
.dp-thumb {
  box-shadow: #0003 0 6px 5px;
}

.dp-thumb.dp-thumb-active {
  box-shadow: #0003 0 6px 5px, 0 0 0 2px rgba(102, 88, 200, 0.16);
}

/* Printing (and Save as PDF) outputs the open document only */
@media print {
  body:has(.dp-overlay.dp-open) > *:not(.dp-overlay) {
    display: none !important;
  }
  .dp-overlay.dp-open,
  .dp-overlay.dp-open .dp-main-col,
  .dp-overlay.dp-open .dp-viewport {
    position: static !important;
    display: block !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    background: #fff !important;
    padding: 0 !important;
    margin: 0 !important;
    transform: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
  .dp-overlay .dp-thumbstrip,
  .dp-overlay .dp-toolbar,
  .dp-overlay .dp-progress-track {
    display: none !important;
  }
  .dp-overlay .dp-page {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    box-shadow: none !important;
    break-after: page;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .dp-overlay .dp-page::before {
    content: "Prototype sample - not a valid document";
    display: block;
    padding: 0 0 8px;
    font-size: 12px;
    color: #66668a;
    text-align: center;
  }
  .dp-overlay .dp-page:last-child {
    break-after: auto;
  }
}

/* ============================================================
   SHEET VIEWER  —  DocPreview.open({ layout: "sheet" })
   Continuous A4 pages, live page thumbnails and zoom.
   ============================================================ */
.dp-overlay.dp-sheet {
  flex-direction: column;
  padding: 24px;
  background: rgba(13, 13, 26, 0.62);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  font-family: "Lato", system-ui, sans-serif;
}

.dp-sheet .dp-main-col {
  width: 100%;
  height: 100%;
  max-width: 1120px;
  max-height: 960px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 16px 48px rgba(13, 13, 26, 0.28);
}

.dp-sheet .dp-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-areas: none;
  gap: 20px;
  min-height: 0;
  padding: 14px 16px 14px 24px;
  border-color: #e4e8f0;
}

.dp-sheet .dp-doc-title {
  max-width: none;
  margin: 0;
  color: #0d0d1a;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.3;
}

.dp-doc-sub {
  overflow: hidden;
  color: #4a4a6a;
  font-size: 13px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dp-sheet .dp-toolbar-right {
  gap: 8px;
}

.dp-sheet .dp-action-btn {
  height: 42px;
  padding: 0 16px;
  gap: 8px;
  border: 1.5px solid #291f75;
  border-radius: 10px;
  background: #fff;
  color: #291f75;
  font-size: 14px;
  font-weight: 700;
}

.dp-sheet .dp-action-btn:hover {
  background: #f6f5fc;
}

.dp-sheet .dp-close-btn {
  width: 42px;
  height: 42px;
  background: none;
  color: #4a4a6a;
  font-size: 19px;
}

.dp-sheet .dp-close-btn:hover {
  background: #f6f7fb;
  color: #0d0d1a;
}

.dp-zoom {
  display: flex;
  align-items: center;
}

.dp-zoom button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: #291f75;
  font-size: 14px;
  cursor: pointer;
}

.dp-zoom button:hover:not(:disabled) {
  background: #f6f7fb;
}

.dp-zoom button:disabled {
  color: #b8b8cc;
  cursor: not-allowed;
}

.dp-zoom output {
  min-width: 46px;
  color: #4a4a6a;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.dp-sheet button:focus-visible,
.dp-sheet .dp-viewport:focus-visible {
  outline: 2px solid #291f75;
  outline-offset: -2px;
}

.dp-body {
  position: relative;
  display: flex;
  min-height: 0;
  flex: 1;
}

/* ── Thumbnails: the real pages, scaled down ── */
.dp-sheet .dp-thumbstrip {
  display: none;
}

.dp-sheet .dp-thumb {
  display: block;
  width: 112px;
  min-height: 0;
  padding: 0;
  overflow: visible;
  border: 0;
  background: none;
  box-shadow: none;
  color: #4a4a6a;
  font: inherit;
  font-size: 13px;
  line-height: 28px;
  cursor: pointer;
}

.dp-thumb-frame {
  display: block;
  width: 112px;
  height: 158px;
  overflow: hidden;
  border: 1px solid #d8dce8;
  background: #fff;
}

.dp-thumb:hover .dp-thumb-frame {
  border-color: #8f86cf;
}

.dp-sheet .dp-thumb-active {
  color: #291f75;
  font-weight: 700;
}

.dp-thumb-active .dp-thumb-frame {
  outline: 2px solid #291f75;
  outline-offset: 2px;
}

.dp-thumb-frame .dp-paper {
  width: 720px;
  transform: scale(0.1528);
  transform-origin: 0 0;
  text-align: left;
  pointer-events: none;
}

.dp-sheet .dp-viewport {
  display: block;
  min-width: 0;
  overflow: auto;
  padding: 28px;
  background: #e9ebf3;
  text-align: center;
}

.dp-sheet .dp-skeleton {
  max-width: 600px;
  margin: 0 auto;
}

/* Page counter floats over the pages, as in a PDF reader */
.dp-sheet .dp-page-label {
  position: absolute;
  right: 24px;
  bottom: 16px;
  padding: 7px 14px;
  border-radius: 999px;
  background: #0d0d1a;
  color: #fff;
  font-size: 13px;
  pointer-events: none;
}

/* ── Paper ── */
.dp-sheet .dp-paper {
  display: flex;
  width: 720px;
  max-width: none;
  min-height: 1018px;
  flex-direction: column;
  padding: 0;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
  text-align: left;
}

.dp-sheet .dp-viewport .dp-paper {
  margin: 0 auto 24px;
  box-shadow: 0 2px 10px rgba(13, 13, 26, 0.16);
  zoom: var(--dp-zoom, 1);
}

.dp-sheet .dp-viewport .dp-paper:last-child {
  margin-bottom: 0;
}

.dp-sheet .dp-letterhead {
  align-items: center;
  margin: 0;
  padding: 24px 56px;
  border-bottom: 1px solid #e4e8f0;
}

.dp-sheet .dp-lh-company {
  font-size: 17px;
  letter-spacing: 0;
}

.dp-sheet .dp-lh-tagline,
.dp-sheet .dp-lh-ref {
  color: #4a4a6a;
  font-size: 12px;
  letter-spacing: 0;
}

.dp-sheet .dp-lh-doc-type {
  font-size: 14px;
  letter-spacing: 0;
  text-transform: none;
}

/* First page carries the cover band */
.dp-sheet .dp-paper--first .dp-letterhead {
  flex-direction: column;
  align-items: stretch;
  gap: 36px;
  padding: 36px 56px 32px;
  border: 0;
  background: #291f75;
}

.dp-sheet .dp-paper--first .dp-letterhead * {
  color: #fff;
}

.dp-sheet .dp-paper--first .dp-lh-tagline,
.dp-sheet .dp-paper--first .dp-lh-ref {
  color: #c9c4ee;
}

.dp-sheet .dp-paper--first .dp-lh-doc-meta {
  text-align: left;
}

.dp-sheet .dp-paper--first .dp-lh-doc-type {
  font-size: 34px;
  line-height: 1.2;
}

.dp-sheet .dp-paper--first .dp-lh-ref {
  margin-top: 8px;
  font-size: 14px;
}

.dp-sheet .dp-page-body {
  gap: 0;
  padding: 40px 56px 0;
}

.dp-sheet .dp-section-title {
  margin: 0 0 10px;
  color: #291f75;
  font-size: 20px;
  letter-spacing: 0;
  text-transform: none;
}

.dp-sheet .dp-divider {
  height: 0;
  margin: 20px 0;
  background: none;
}

.dp-sheet .dp-field-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  margin: 0 !important;
}

.dp-sheet .dp-field,
.dp-sheet .dp-field.span-2 {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  grid-column: auto;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid #e4e8f0;
}

.dp-sheet .dp-field-label {
  color: #4a4a6a;
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.5;
  text-transform: none;
}

.dp-sheet .dp-field-value {
  color: #0d0d1a;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.5;
}

.dp-sheet .dp-field-grid.cols-1 .dp-field:not(.span-all) .dp-field-value {
  font-weight: 400;
}

.dp-sheet .dp-field-grid.cols-1 .dp-field:not(.span-all) .dp-field-label {
  color: #291f75;
  font-weight: 700;
}

.dp-sheet .dp-notice {
  padding: 16px 18px;
  border: 0;
  border-radius: 10px;
  background: #f1f0fa;
  color: #2f2f4a;
  font-size: 15px;
}

.dp-sheet .dp-table {
  font-size: 15px;
}

.dp-sheet .dp-table thead th {
  padding: 10px 0;
  border-color: #291f75;
  background: none;
  color: #4a4a6a;
  font-size: 14px;
  letter-spacing: 0;
  text-transform: none;
}

.dp-sheet .dp-table thead th:last-child {
  text-align: right;
}

.dp-sheet .dp-table tbody td {
  padding: 12px 0;
  color: #0d0d1a;
}

.dp-sheet .dp-table .td-total td {
  padding: 14px 0;
  border-top: 1.5px solid #291f75;
  background: none;
  color: #291f75;
  font-size: 18px;
}

.dp-sheet .dp-sig-line {
  width: 200px;
}

.dp-sheet .dp-sig-caption {
  color: #4a4a6a;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
}

.dp-sheet .dp-page-foot {
  margin: 32px 56px 0;
  padding: 14px 0 24px;
}

.dp-sheet .dp-page-foot span {
  color: #4a4a6a;
  font-size: 12px;
  letter-spacing: 0;
}

@media (min-width: 1024px) {
  .dp-sheet .dp-thumbstrip {
    display: flex;
    width: 168px;
    height: auto;
    padding: 24px 0;
    gap: 14px;
    border-right: 1px solid #e4e8f0;
    border-radius: 0;
    background: #fff;
  }
}

@media screen and (max-width: 767px) {
  .dp-overlay.dp-sheet {
    padding: 0;
  }

  .dp-sheet .dp-main-col {
    max-height: none;
    border-radius: 0;
  }

  /* Title on top; actions move to a bar under the pages. */
  .dp-sheet .dp-toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: calc(8px + env(safe-area-inset-top)) 6px 8px 16px;
  }

  .dp-sheet .dp-zoom {
    display: none;
  }

  .dp-sheet .dp-toolbar-left {
    grid-area: 1 / 1;
  }

  .dp-sheet .dp-toolbar-right {
    grid-area: 1 / 2;
  }

  .dp-sheet .dp-doc-title {
    font-size: 17px;
  }

  .dp-sheet .dp-action-btn {
    position: absolute;
    z-index: 1;
    bottom: calc(10px + env(safe-area-inset-bottom));
    width: calc(50% - 21px);
    height: 46px;
  }

  .dp-sheet .dp-action-btn .dp-btn-label {
    display: inline;
  }

  .dp-sheet .dp-btn-download {
    left: 16px;
  }

  .dp-sheet .dp-btn-mail {
    right: 16px;
  }

  .dp-sheet .dp-main-col {
    position: relative;
    padding-bottom: calc(66px + env(safe-area-inset-bottom));
  }

  /* Pages reflow so the text stays readable without zooming. */
  .dp-sheet .dp-viewport {
    padding: 12px;
  }

  .dp-sheet .dp-viewport .dp-paper {
    width: 100%;
    min-height: 0;
    margin-bottom: 12px;
    zoom: 1;
  }

  .dp-sheet .dp-viewport .dp-letterhead,
  .dp-sheet .dp-viewport .dp-paper--first .dp-letterhead {
    padding: 20px;
  }

  .dp-sheet .dp-paper--first .dp-letterhead {
    gap: 20px;
  }

  .dp-sheet .dp-viewport .dp-paper--first .dp-lh-doc-type {
    font-size: 26px;
  }

  .dp-sheet .dp-paper:not(.dp-paper--first) .dp-letterhead {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .dp-sheet .dp-paper:not(.dp-paper--first) .dp-lh-doc-meta {
    text-align: left;
  }

  .dp-sheet .dp-page-body {
    padding: 24px 20px 0;
  }

  .dp-sheet .dp-field,
  .dp-sheet .dp-field.span-2 {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding: 9px 0;
  }

  .dp-sheet .dp-page-foot {
    margin: 24px 20px 0;
    padding-bottom: 16px;
  }

  .dp-sheet .dp-sig-block {
    gap: 24px;
  }

  .dp-sheet .dp-sig-item {
    min-width: 0;
    flex: 1;
  }

  .dp-sheet .dp-sig-line {
    width: 100%;
  }

  .dp-sheet .dp-page-label {
    right: 16px;
    bottom: 12px;
  }
}

@media print {
  .dp-overlay.dp-sheet .dp-body {
    display: block !important;
    overflow: visible !important;
  }
  .dp-overlay.dp-sheet .dp-page-label {
    display: none !important;
  }
  .dp-overlay.dp-sheet .dp-viewport .dp-paper {
    page: dp-sheet;
    display: flex !important;
    min-height: 290mm;
    margin: 0 !important;
    zoom: 1;
  }
  .dp-overlay.dp-sheet .dp-paper::before {
    padding: 6px 0;
  }
  body:has(.dp-sheet.dp-open) {
    background: #fff !important;
  }
  .dp-overlay.dp-sheet .dp-letterhead,
  .dp-overlay.dp-sheet .dp-field,
  .dp-overlay.dp-sheet .dp-notice,
  .dp-overlay.dp-sheet .dp-table tr,
  .dp-overlay.dp-sheet .dp-sig-block {
    break-inside: avoid;
  }
}

/* Named page, so only the sheet layout prints edge to edge on A4 */
@page dp-sheet {
  size: A4;
  margin: 0;
}

/* ── Real PDF pages (DocPreview.open({ pdf })) ── */
.dp-sheet .dp-viewport .dp-paper--pdf {
  position: relative;
  display: block;
  width: 720px;
  min-height: 0;
  overflow: hidden;
  zoom: 1;
}

.dp-paper--pdf canvas,
.dp-thumb-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.dp-text {
  position: absolute;
  inset: 0;
  overflow: hidden;
  line-height: 1;
  text-align: left;
  text-size-adjust: none;
  forced-color-adjust: none;
}

.dp-text span,
.dp-text br {
  position: absolute;
  color: transparent;
  white-space: pre;
  cursor: text;
  transform-origin: 0 0;
}

.dp-text span.markedContent {
  top: 0;
  height: 0;
}

.dp-text ::selection {
  background: rgba(41, 31, 117, 0.25);
}

.dp-error {
  max-width: 420px;
  margin: 48px auto;
  text-align: center;
}

.dp-error h3 {
  color: #0d0d1a;
  font-size: 20px;
}

.dp-error p {
  margin: 8px 0 20px;
  color: #2f2f4a;
  font-size: 15px;
  line-height: 1.5;
}

.dp-error div {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.dp-sheet .dp-error .dp-action-btn {
  position: static;
  width: auto;
  text-decoration: none;
}

/* Real pages can't reflow on a phone, so zoom stays available there. */
@media screen and (max-width: 767px) {
  .dp-sheet.dp-pdf .dp-zoom {
    position: absolute;
    z-index: 1;
    bottom: calc(76px + env(safe-area-inset-bottom));
    left: 12px;
    display: flex;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(13, 13, 26, 0.24);
  }

  .dp-sheet.dp-pdf .dp-viewport {
    padding-bottom: 64px;
  }
}

/* Page jumps and zoom are measured, so they must land at once */
.dp-sheet .dp-viewport {
  scroll-behavior: auto;
}

/* Tables with more than two columns: headers and cells share an edge */
.dp-sheet .dp-table th:not(:last-child),
.dp-sheet .dp-table td:not(:last-child) {
  padding-right: 14px;
}

.dp-sheet .dp-table .td-amount:not(:last-child) {
  text-align: left;
}

.dp-sheet .dp-table td:last-child {
  text-align: right;
}

.dp-sheet .dp-stamp {
  margin-top: 24px;
  border-width: 1.5px;
  border-radius: 10px;
  font-size: 14px;
  letter-spacing: 0;
  text-transform: none;
}

/* Tighter rows on paper: the fullest page (COI, page 1) must fit one A4 */
@media print {
  .dp-overlay.dp-sheet .dp-field,
  .dp-overlay.dp-sheet .dp-field.span-2 {
    padding: 6px 0;
  }
  .dp-overlay.dp-sheet .dp-page-body {
    padding-top: 28px;
  }
}
