/* ==========================================================================
   UDPP — dedicated A4 print / PDF template
   ========================================================================== */

body.print-view {
  min-height: 100vh;
  background: #e9e6dc;
  font-size: 10.2pt;
  line-height: 1.42;
}

body.print-view ::selection {
  background: #efefef;
  color: #111;
}

/* ------------------------------------------------------------ toolbar */

.print-toolbar {
  position: sticky;
  top: 0;
  z-index: 80;
  border-bottom: 1px solid #d3d0c5;
  background: rgb(241 239 231 / 0.9);
  backdrop-filter: blur(14px) saturate(1.05);
}

.print-toolbar-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  width: min(1240px, calc(100% - 32px));
  height: 64px;
  margin: 0 auto;
}

.print-toolbar-title {
  margin-right: auto;
  color: #797d71;
  font-size: 0.74rem;
  font-weight: 600;
}

.print-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ------------------------------------------------------------ paper */

.paper-wrap {
  padding: 28px 16px 72px;
}

.sheet {
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  padding: 14mm;
  border: 1px solid #d8d4c8;
  border-radius: 2px;
  background: #fff;
  color: #151713;
  box-shadow: 0 28px 80px -38px rgb(23 25 19 / 0.5),
    0 2px 5px rgb(23 25 19 / 0.06);
}

/* ------------------------------------------------------------ document header */

.doc-header {
  display: grid;
  grid-template-columns: 36mm minmax(0, 1fr) 30mm;
  gap: 6mm;
  align-items: start;
  padding-bottom: 3.5mm;
  border-bottom: 1.5px solid #151713;
}

.doc-brand {
  display: flex;
  flex-direction: column;
  gap: 1.5mm;
}

.doc-brand-top {
  display: flex;
  align-items: center;
  gap: 2.5mm;
}

.doc-mark {
  display: grid;
  width: 8mm;
  height: 8mm;
  place-items: center;
  border-radius: 2mm;
  background: #151713;
  color: #d9ff76;
  font-size: 11pt;
  font-weight: 800;
}

.doc-brand strong {
  font-size: 12pt;
  font-weight: 760;
  letter-spacing: -0.03em;
}

.doc-brand > span {
  color: #777;
  font-size: 6.5pt;
  font-weight: 650;
  letter-spacing: 0.05em;
  line-height: 1.35;
  text-transform: uppercase;
}

.doc-title {
  min-width: 0;
}

.doc-title > span {
  display: block;
  color: #777;
  font-size: 6.5pt;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.doc-title strong {
  display: block;
  margin: 1mm 0;
  font-size: 17pt;
  font-weight: 680;
  line-height: 1.04;
  letter-spacing: -0.045em;
}

.doc-title .mono {
  color: #555;
  font-size: 7.2pt;
  letter-spacing: 0;
  text-transform: none;
}

.doc-qr {
  text-align: center;
}

.doc-qr .qr-svg {
  width: 26mm;
  height: auto;
  margin: 0 auto;
  shape-rendering: crispEdges;
}

.doc-qr span {
  display: block;
  margin-top: 1mm;
  color: #777;
  font-size: 5.8pt;
  line-height: 1.25;
}

/* ------------------------------------------------------------ meta */

.doc-meta {
  display: grid;
  grid-template-columns: 1.7fr 1fr 1fr 1fr;
  column-gap: 5mm;
  margin-top: 3mm;
  padding-bottom: 1mm;
  border-bottom: 1px solid #ddd;
}

.doc-meta > div {
  min-width: 0;
  padding: 1.6mm 0;
  border-top: 1px solid #ececec;
}

.doc-meta > div:nth-child(-n + 4) {
  border-top: 0;
}

.doc-meta-wide {
  grid-column: span 2;
}

.doc-meta span {
  display: block;
  color: #777;
  font-size: 5.7pt;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.doc-meta strong {
  display: block;
  margin-top: 0.4mm;
  overflow-wrap: anywhere;
  color: #151713;
  font-size: 7.1pt;
  font-weight: 650;
}

.doc-meta .mono {
  font-size: 6.4pt;
}

/* ------------------------------------------------------------ hero */

.doc-hero {
  display: grid;
  grid-template-columns: 42mm minmax(0, 1fr);
  gap: 6mm;
  align-items: center;
  padding: 5mm 0;
  border-bottom: 1px solid #ddd;
}

.doc-figure {
  display: flex;
  min-height: 40mm;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2mm;
  padding: 2.5mm;
  border: 1px solid #ddd;
  border-radius: 2mm;
  background: #faf9f5;
}

.doc-figure img {
  width: 88%;
  max-height: 36mm;
  object-fit: contain;
  mix-blend-mode: multiply;
  filter: grayscale(1) contrast(1.05);
}

.doc-figure-placeholder svg {
  width: 18mm;
  height: 18mm;
  color: #999;
}

.doc-credit {
  color: #999;
  font-size: 5.2pt;
  line-height: 1.25;
  text-align: center;
}

.doc-kicker {
  color: #777;
  font-size: 6.3pt;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.doc-intro h1 {
  margin: 1.5mm 0 2mm;
  font-size: 17pt;
  font-weight: 680;
  line-height: 1.05;
  letter-spacing: -0.045em;
}

.doc-intro > p {
  max-width: 130mm;
  color: #333;
  font-size: 8.1pt;
  line-height: 1.5;
}

.doc-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 3.5mm;
  overflow: hidden;
  border: 1px solid #ddd;
  border-radius: 2mm;
}

.doc-metric {
  min-width: 0;
  padding: 2mm 2.2mm;
  border-right: 1px solid #ddd;
}

.doc-metric:last-child {
  border-right: 0;
}

.doc-metric > span {
  display: block;
  overflow: hidden;
  color: #777;
  font-size: 5.6pt;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.doc-metric strong {
  display: block;
  margin-top: 0.5mm;
  font-size: 10.5pt;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  white-space: nowrap;
}

.doc-metric small {
  margin-left: 1mm;
  color: #666;
  font-size: 6.2pt;
  font-weight: 600;
  letter-spacing: 0;
}

/* ------------------------------------------------------------ sections */

.doc-section {
  padding-top: 5mm;
}

.doc-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 5mm;
  padding-bottom: 1.8mm;
  border-bottom: 1.2px solid #151713;
  break-after: avoid;
}

.doc-section-head > div {
  min-width: 0;
}

.doc-eyebrow {
  display: block;
  color: #777;
  font-size: 6.2pt;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.doc-section-head h2 {
  margin-top: 0.8mm;
  font-size: 13pt;
  font-weight: 680;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.doc-section-head > span {
  color: #666;
  font-size: 6.8pt;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.doc-status {
  display: inline-flex;
  align-items: center;
  gap: 1mm;
  color: #2d693c;
}

.doc-status svg {
  width: 3.2mm;
  height: 3.2mm;
}

/* ------------------------------------------------------------ groups */

.sheet .group-stack {
  display: flex;
  flex-direction: column;
  gap: 2.4mm;
  padding-top: 2.6mm;
}

.sheet .group {
  overflow: visible;
  border: 1px solid #ddd;
  border-radius: 2mm;
  background: #fff;
  box-shadow: none;
  break-inside: auto;
}

.sheet .group-head {
  display: flex;
  align-items: center;
  gap: 3mm;
  padding: 2.2mm 3mm;
  border-bottom: 1px solid #e8e8e8;
  background: #f7f7f4;
  cursor: default;
  break-after: avoid;
}

.sheet .group-head::-webkit-details-marker {
  display: none;
}

.sheet .group-number {
  width: 5.5mm;
  height: 5.5mm;
  border: 1px solid #ccc;
  border-radius: 1.2mm;
  background: #fff;
  color: #666;
  font-family: var(--mono);
  font-size: 5.8pt;
}

.sheet .group-title {
  font-size: 9.2pt;
  font-weight: 680;
  letter-spacing: -0.02em;
}

.sheet .group-subtitle {
  color: #777;
  font-size: 6.4pt;
  white-space: normal;
}

.sheet .group-count {
  min-width: 5mm;
  height: 4.4mm;
  border: 1px solid #ddd;
  background: #fff;
  color: #555;
  font-size: 5.8pt;
}

.sheet .group-chevron {
  display: none;
}

.sheet .group-fields {
  padding: 0 3mm;
}

.sheet .field {
  grid-template-columns: 34% minmax(0, 1fr);
  gap: 4mm;
  padding: 1.7mm 0;
  border-top: 1px solid #e8e8e8;
  break-inside: avoid;
}

.sheet .field-label {
  padding-top: 0.2mm;
  color: #666;
  font-size: 6.7pt;
  font-weight: 550;
  line-height: 1.4;
}

.sheet .field-value {
  color: #151713;
  font-size: 7.7pt;
  font-weight: 550;
  line-height: 1.45;
}

.sheet .measure-value {
  font-size: 8.6pt;
}

.sheet .measure-unit {
  font-size: 6.6pt;
}

.sheet .measure-note {
  color: #777;
  font-size: 6.2pt;
}

.sheet .copy {
  font-size: 7.5pt;
  line-height: 1.5;
}

.sheet .chip {
  padding: 0.8mm 1.5mm;
  border: 1px solid #ccc;
  background: #fff;
  color: #333;
  font-size: 6.4pt;
}

.sheet .chips {
  gap: 1.2mm;
}

.sheet .boolean {
  padding: 0.8mm 2mm;
  border: 1px solid #bbb;
  background: #fff;
  color: #151713;
  font-size: 6.8pt;
}

.sheet .doc-link {
  padding: 1.4mm 2mm;
  border: 1px solid #ccc;
  background: #faf9f5;
  font-size: 6.9pt;
}

.sheet .doc-icon {
  height: 3.4mm;
  font-size: 5.2pt;
}

.sheet .doc-note {
  font-size: 6pt;
}

.sheet .subfields {
  gap: 1.4mm;
}

.sheet .subfield {
  grid-template-columns: 38% minmax(0, 1fr);
  gap: 3mm;
}

.sheet .subfield dt {
  color: #666;
  font-size: 6.4pt;
  line-height: 1.35;
}

.sheet .subfield dd {
  font-size: 7.4pt;
  line-height: 1.4;
}

.sheet .inline-link svg {
  width: 2.6mm;
  height: 2.6mm;
}

/* ------------------------------------------------------------ timeline */

.doc-table {
  width: 100%;
  margin-top: 2.5mm;
  border-collapse: collapse;
  font-size: 7.4pt;
}

.doc-table thead {
  display: table-header-group;
}

.doc-table th {
  padding: 1.4mm 1mm;
  border-bottom: 1px solid #999;
  color: #666;
  font-size: 5.9pt;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-align: left;
  text-transform: uppercase;
}

.doc-table td {
  padding: 1.6mm 1mm;
  border-bottom: 1px solid #e8e8e8;
  vertical-align: top;
}

.doc-table tr {
  break-inside: avoid;
}

.doc-table td:first-child,
.doc-table th:first-child {
  width: 7mm;
}

.doc-table td:nth-child(2),
.doc-table th:nth-child(2) {
  width: 25mm;
  white-space: nowrap;
}

.doc-table td:nth-child(4),
.doc-table th:nth-child(4) {
  width: 32mm;
}

.doc-table td strong {
  display: block;
  font-size: 7.4pt;
  font-weight: 680;
}

.doc-table td span {
  display: block;
  margin-top: 0.3mm;
  color: #777;
  font-size: 6.3pt;
  line-height: 1.35;
}

/* ------------------------------------------------------------ integrity */

.doc-integrity-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2mm;
  margin-top: 2.8mm;
}

.doc-panel {
  min-width: 0;
  padding: 2.2mm 2.6mm;
  border: 1px solid #ddd;
  border-radius: 1.5mm;
  background: #faf9f5;
}

.doc-panel > span {
  display: block;
  margin-bottom: 1mm;
  color: #777;
  font-size: 5.8pt;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.doc-panel > code,
.doc-carrier {
  display: block;
  overflow-wrap: anywhere;
  color: #333;
  font-family: var(--mono);
  font-size: 5.8pt;
  line-height: 1.45;
}

.doc-carriers {
  display: flex;
  flex-direction: column;
  gap: 0.8mm;
}

.doc-integrity-note {
  margin-top: 2mm;
  color: #666;
  font-size: 6.6pt;
  line-height: 1.45;
}

/* ------------------------------------------------------------ footer */

.doc-footer {
  display: flex;
  justify-content: space-between;
  gap: 4mm;
  margin-top: 6mm;
  padding-top: 2.2mm;
  border-top: 1px solid #bbb;
  color: #777;
  font-size: 6pt;
}

/* ------------------------------------------------------------ responsive preview */

@media (max-width: 900px) {
  .print-toolbar-title {
    display: none;
  }

  .print-toolbar-actions .btn span {
    display: none;
  }

  .print-toolbar-actions .btn {
    width: 38px;
    padding: 0;
  }

  .paper-wrap {
    padding: 14px 10px 40px;
  }

  .sheet {
    width: 100%;
    min-height: 0;
    padding: 22px 18px;
  }

  .doc-header {
    grid-template-columns: 32mm minmax(0, 1fr) 26mm;
    gap: 4mm;
  }

  .doc-hero {
    grid-template-columns: 34mm minmax(0, 1fr);
    gap: 4mm;
  }
}

@media (max-width: 620px) {
  .print-toolbar-inner {
    gap: 8px;
  }

  .print-toolbar-actions {
    gap: 5px;
  }

  .doc-header {
    grid-template-columns: 1fr 26mm;
  }

  .doc-brand {
    grid-column: 1;
  }

  .doc-title {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .doc-qr {
    grid-column: 2;
    grid-row: 1;
  }

  .doc-meta {
    grid-template-columns: 1fr 1fr;
  }

  .doc-meta > div:nth-child(-n + 3) {
    border-top: 1px solid #ececec;
  }

  .doc-meta > div:nth-child(-n + 2) {
    border-top: 0;
  }

  .doc-meta-wide {
    grid-column: 1 / -1;
  }

  .doc-hero {
    grid-template-columns: 1fr;
  }

  .doc-figure {
    min-height: 120px;
  }

  .doc-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .doc-metric:nth-child(2) {
    border-right: 0;
  }

  .doc-metric:nth-child(-n + 2) {
    border-bottom: 1px solid #ddd;
  }

  .sheet .field {
    grid-template-columns: 1fr;
    gap: 0.6mm;
  }

  .sheet .subfield {
    grid-template-columns: 1fr;
    gap: 0.4mm;
    padding: 1mm 0;
    border-top: 1px dashed #eee;
  }

  .sheet .subfield:first-child {
    border-top: 0;
    padding-top: 0;
  }

  .doc-integrity-grid {
    grid-template-columns: 1fr;
  }

  .doc-footer {
    flex-direction: column;
    gap: 0.5mm;
  }
}

/* ------------------------------------------------------------ print */

@media print {
  @page {
    size: A4 portrait;
    margin: 12mm 12mm 16mm;
  }

  html,
  body.print-view {
    width: auto;
    min-height: 0;
    background: #fff !important;
  }

  body.print-view {
    color: #111;
    font-size: 9.6pt;
    line-height: 1.38;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .print-toolbar {
    display: none !important;
  }

  .paper-wrap {
    padding: 0;
  }

  .sheet {
    width: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #fff;
  }

  a {
    color: #111;
    text-decoration: none;
  }

  .doc-qr .qr-svg {
    width: 24mm;
  }

  .doc-header {
    break-after: avoid;
  }

  .doc-meta {
    break-after: avoid;
  }

  .doc-hero {
    break-inside: avoid;
  }

  .doc-section {
    padding-top: 3.8mm;
  }

  .doc-section-head {
    break-after: avoid;
  }

  .sheet .group-stack {
    display: block;
  }

  .sheet .group {
    margin-bottom: 2.4mm;
    break-inside: auto;
  }

  .sheet .group-head {
    break-after: avoid;
  }

  .sheet .field {
    break-inside: avoid;
  }

  .doc-table tr,
  .doc-history tr {
    break-inside: avoid;
  }

  .doc-integrity-section {
    break-inside: avoid;
  }

  .doc-footer {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    margin: 0;
    padding-top: 1.5mm;
    border-top: 1px solid #bbb;
    background: #fff;
    font-size: 5.6pt;
  }
}
