/* ═══════════════ Dokument A4 – ekran i wydruk ═══════════════ */

.paper-wrap { padding: 4px 0 40px; }
.paper-wrap-modal { padding: 0; background: #e9edf3; border-radius: 8px; padding: 16px; max-height: 70vh; overflow-y: auto; }

.paper {
  position: relative;
  width: 210mm;
  max-width: 100%;
  min-height: 297mm;
  margin: 0 auto;
  padding: 15mm 16mm 12mm;
  background: #fff;
  color: #141a24;
  font: 10.5pt/1.45 Arial, "Helvetica Neue", Helvetica, sans-serif;
  box-shadow: 0 1px 3px rgba(15, 27, 45, 0.12), 0 12px 40px rgba(15, 27, 45, 0.14);
  border-radius: 2px;
  overflow: hidden;
  color-scheme: light;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.paper-wrap-modal .paper { min-height: 0; box-shadow: 0 2px 10px rgba(15, 27, 45, 0.15); }

.paper h1, .paper h2, .paper h3 { letter-spacing: 0; color: #0d1830; }
.paper p { margin: 0 0 6px; }

.doc-muted { color: #5d6878; font-size: 8.5pt; }

.doc-header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding-bottom: 10px; border-bottom: 2px solid #1d4fa3; position: relative;
}
.doc-header::after { content: ""; position: absolute; left: 0; right: 0; bottom: -5px; height: 1px; background: #c41d3a; }
.doc-brand { display: flex; gap: 12px; align-items: center; font-size: 9pt; line-height: 1.35; }
.doc-facility { font-size: 11.5pt; font-weight: 700; color: #0d1830; text-transform: uppercase; letter-spacing: 0.02em; }
.doc-place { font-size: 9.5pt; white-space: nowrap; padding-top: 4px; }

.doc-recipient {
  margin: 16px 0 0 auto; width: 48%; padding: 8px 12px; font-size: 9.5pt;
  border-left: 3px solid #1d4fa3; background: #f3f6fb;
}
.doc-recipient-label { font-size: 8pt; text-transform: uppercase; letter-spacing: 0.06em; color: #5d6878; }
.doc-recipient-name { font-weight: 700; font-size: 10.5pt; margin-bottom: 2px; }

.doc-title { text-align: center; margin: 22px 0 18px; }
.doc-title h1 { font-size: 14pt; text-transform: uppercase; margin: 0; line-height: 1.3; }
.doc-subtitle { font-size: 10pt; margin-top: 2px; }
.doc-number { margin-top: 6px; font-weight: 700; font-family: "Courier New", Courier, monospace; font-size: 11pt; letter-spacing: 0.04em; }
.doc-legal { margin-top: 3px; font-size: 8.5pt; font-style: italic; color: #5d6878; }

.doc-section { margin-top: 14px; break-inside: auto; }
.doc-section h2 {
  font-size: 9.5pt; text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 7px;
  padding-bottom: 3px; border-bottom: 1px solid #cfd7e3; color: #1d4fa3; break-after: avoid;
}
.doc-patient { background: #f7f9fc; border: 1px solid #dfe5ee; padding: 9px 12px 7px; border-radius: 3px; }
.doc-patient h2 { border: 0; padding: 0; margin-bottom: 5px; }

.doc-kv { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; margin: 0 0 6px; }
.doc-kv .kv { grid-column: span 2; display: flex; flex-wrap: wrap; column-gap: 6px; break-inside: avoid; }
.doc-kv .kv-half { grid-column: span 1; }
.doc-kv dt { color: #5d6878; white-space: nowrap; }
.doc-kv dt::after { content: ":"; }
.doc-kv dd { margin: 0; font-weight: 600; flex: 1 1 150px; min-width: 0; }
.doc-kv dd em { font-weight: 400; }

.doc-block { margin: 6px 0 8px; break-inside: avoid; }
.doc-block h3 { font-size: 9.5pt; margin: 0 0 3px; color: #2c3747; }
.doc-pre { white-space: pre-wrap; margin: 0; text-align: justify; }
.doc-list { margin: 0; padding-left: 18px; }
.doc-list li { margin: 1px 0; }

.doc-table { width: 100%; border-collapse: collapse; font-size: 9.5pt; }
.doc-table th, .doc-table td { border: 1px solid #c9d2df; padding: 4px 7px; text-align: left; vertical-align: top; }
.doc-table thead th { background: #eef2f8; font-size: 8.5pt; text-transform: uppercase; letter-spacing: 0.03em; }
.doc-table .num { width: 34px; text-align: center; }
.doc-matrix th { width: 55%; font-weight: 400; background: #f7f9fc; }
.doc-alert { color: #b0122d !important; font-weight: 700; }

.doc-statement { text-align: justify; }
.doc-emphasis {
  margin: 10px 0; padding: 9px 13px; border: 1.5px solid #1d4fa3; border-radius: 3px;
  background: #f1f5fc; break-inside: avoid;
}
.doc-emphasis-label { font-size: 8pt; text-transform: uppercase; letter-spacing: 0.06em; color: #1d4fa3; font-weight: 700; margin-bottom: 2px; }
.doc-emphasis p { margin: 0; font-weight: 600; text-align: justify; }

.doc-end { break-inside: avoid; page-break-inside: avoid; }
.doc-sign { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; padding-top: 30px; }
.doc-sign-left { flex: 1; }
.doc-sign-right { width: 62mm; max-width: 50%; text-align: center; position: relative; }
.doc-stamp {
  display: inline-block; padding: 5px 12px; border: 2px solid #2747a3; border-radius: 4px;
  color: #2747a3; font-size: 8.5pt; line-height: 1.3; text-align: center; transform: rotate(-2.5deg);
  font-family: Arial, Helvetica, sans-serif; background: transparent; opacity: 0.92;
}
.doc-stamp-name { font-weight: 700; font-size: 9.5pt; }
.doc-stamp-facility { font-size: 7.5pt; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 1px; }
.doc-signature {
  font-family: "Segoe Script", "Brush Script MT", "Lucida Handwriting", "Apple Chancery", cursive;
  font-size: 17pt; color: #1b2f80; margin: -6px 0 -4px; min-height: 26px; transform: rotate(-3deg);
}
.doc-sign-line { border-top: 1px dotted #5d6878; padding-top: 3px; font-size: 8pt; color: #5d6878; }

.doc-verify {
  display: flex; align-items: center; gap: 12px; margin-top: 24px; padding-top: 10px;
  border-top: 1px solid #dfe5ee; font-size: 9pt; break-inside: avoid;
}
.doc-qr { width: 64px; height: 64px; flex: none; }
.doc-qr svg { width: 100%; height: 100%; display: block; }
.doc-code { font-family: "Courier New", Courier, monospace; font-size: 11pt; letter-spacing: 0.08em; }
.doc-url { font-family: "Courier New", Courier, monospace; word-break: break-all; color: #1d4fa3; }
.doc-disclaimer { margin-top: 8px; font-size: 7.2pt; color: #8a94a3; text-align: center; line-height: 1.35; }

.doc-watermark {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) rotate(-28deg);
  font-size: 68pt; font-weight: 900; letter-spacing: 0.08em; color: rgba(196, 29, 58, 0.14);
  border: 7px solid rgba(196, 29, 58, 0.14); padding: 4px 24px; border-radius: 12px;
  pointer-events: none; white-space: nowrap; z-index: 2;
}
.doc-watermark-preview { color: rgba(29, 79, 163, 0.1); border-color: rgba(29, 79, 163, 0.1); }

@media (max-width: 820px) {
  .paper { min-height: 0; padding: 18px 16px; font-size: 10pt; border-radius: 0; }
  .doc-header { flex-direction: column; }
  .doc-recipient { width: 100%; }
  .doc-kv { grid-template-columns: 1fr; }
  .doc-kv .kv, .doc-kv .kv-half { grid-column: span 1; flex-wrap: wrap; }
  .doc-sign { flex-direction: column-reverse; align-items: stretch; }
  .doc-sign-right { width: 100%; max-width: none; }
  .doc-watermark { font-size: 40pt; }
}

/* ─────────── Wydruk / zapis do PDF ─────────── */

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

  html, body { background: #fff !important; }
  body { font-size: 10.5pt; }

  /* Drukujemy wyłącznie dokument – reszta interfejsu znika. */
  .sidebar, .sidebar-backdrop, .topbar, .public-header, .public-footer, .toast-host, .no-print,
  .doc-toolbar, .page-head, .verdict, .note-box, .verify-form, .modal-backdrop {
    display: none !important;
  }
  #app :not(:has(.paper)):not(.paper):not(.paper *) { display: none !important; }

  .panel-main { margin: 0 !important; }
  .panel-content, .public-main, .paper-wrap, .container, .page-narrow {
    padding: 0 !important; margin: 0 !important; max-width: none !important; width: auto !important;
  }

  .paper {
    width: auto; max-width: none; min-height: 0; margin: 0; padding: 0;
    box-shadow: none; border-radius: 0; overflow: visible; font-size: 10.5pt;
  }
  .doc-watermark { position: fixed; top: 45%; }
  .doc-kv { grid-template-columns: 1fr 1fr; }
  .doc-header { flex-direction: row; }
  .doc-sign { flex-direction: row; align-items: flex-end; padding-top: 18px; }
  .doc-sign-right { width: 62mm; padding-right: 2mm; }
  .doc-verify { margin-top: 14px; }
}
