/* ---------- Printable Patient Care Report (.prt-) ---------- */
.prt-loading { padding: 60px; text-align: center; color: var(--muted); }
.prt-page { background: #e9ecef; min-height: 100vh; }
.prt-toolbar { position: sticky; top: 0; z-index: 5; align-items: center; background: var(--navy); color: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .2); }
.prt-toolbar-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.prt-toolbar-spacer { flex: 1; }
.prt-report { position: relative; background: #fff; margin: 24px auto 40px; box-shadow: 0 2px 14px rgba(0, 0, 0, .12); font-family: Arial, Helvetica, sans-serif; line-height: 1.35; overflow: hidden; }
.prt-report h2 { break-after: avoid; page-break-after: avoid; }
.prt-report h3 { font-size: 12px; color: #111; margin: 10px 0 4px; text-transform: uppercase; letter-spacing: .3px; border-bottom: 1px solid #ccc; padding-bottom: 2px; }
.prt-sub:first-of-type h3 { margin-top: 4px; }

.prt-watermark { position: absolute; top: 360px; left: 0; right: 0; text-align: center; font-size: 160px; font-weight: 900; color: rgba(200, 30, 30, .08); transform: rotate(-28deg); pointer-events: none; letter-spacing: 20px; z-index: 0; user-select: none; }
.prt-report > *:not(.prt-watermark) { position: relative; z-index: 1; }

/* header */
.prt-header { border-bottom: 3px solid #111; padding-bottom: 10px; margin-bottom: 4px; }
.prt-head-top { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.prt-agency { display: flex; align-items: center; gap: 12px; }
.prt-logo { height: 56px; width: auto; max-width: 140px; object-fit: contain; }
.prt-agency-name { font-size: 18px; font-weight: 700; }
.prt-agency-city { color: #555; }
.prt-title { text-align: right; }
.prt-title h1 { font-size: 22px; text-transform: uppercase; letter-spacing: .5px; }
.prt-status { margin-top: 4px; }
.prt-badge { display: inline-block; padding: 2px 10px; border: 2px solid currentColor; font-weight: 800; letter-spacing: 1px; font-size: 12px; }
.prt-badge-locked { color: #1b5e20; }
.prt-badge-draft { color: #b71c1c; }
.prt-small { font-size: 11px; color: #555; }
.prt-head-grid { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid #c9d0d6; margin-top: 10px; }
.prt-cell { padding: 4px 8px; border-right: 1px solid #c9d0d6; border-bottom: 1px solid #c9d0d6; }
.prt-cell:nth-child(4n) { border-right: 0; }
.prt-cell:nth-last-child(-n+4) { border-bottom: 0; }
.prt-cell b { display: block; font-size: 9.5px; text-transform: uppercase; color: #666; font-weight: 600; }
.prt-cell span { font-size: 13px; }
.prt-strong { font-weight: 700; }

/* key/value grids */
.prt-kv { gap: 5px 16px; }
.prt-kv-2 { grid-template-columns: repeat(2, 1fr); }
.prt-kv-3 { grid-template-columns: repeat(3, 1fr); }
.prt-kv-4 { grid-template-columns: repeat(4, 1fr); }
.prt-kv > div { min-width: 0; overflow-wrap: anywhere; }
.prt-none { color: #777; font-style: italic; padding: 2px 0 4px; }
.prt-uto { color: #8a5a00; font-style: italic; }
.prt-list { overflow-wrap: anywhere; }

/* tables */
.prt-table { font-size: 12px; }
.prt-table tr { break-inside: avoid; page-break-inside: avoid; }
.prt-table th { font-size: 10.5px; text-transform: uppercase; white-space: nowrap; }
.prt-two { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; }
.prt-vitals { font-size: 11px; }
.prt-vitals th, .prt-vitals td { padding: 3px 4px; }
.prt-vitals td:last-child { min-width: 110px; }
.prt-tx td:first-child, .prt-vitals td:first-child { white-space: nowrap; }
.prt-narrow { max-width: 420px; }
.prt-tag { display: inline-block; font-size: 9px; font-weight: 700; border: 1px solid #555; padding: 0 3px; margin-left: 4px; vertical-align: middle; }
.prt-note { margin-top: 3px; color: #333; font-style: italic; white-space: pre-wrap; }

.prt-exam { margin-bottom: 8px; break-inside: avoid; page-break-inside: avoid; }
.prt-exam-head { font-weight: 700; margin: 6px 0 3px; }
.prt-narrative { border: 1px solid #c9d0d6; padding: 8px 10px; margin-bottom: 8px; }
.prt-narr-meta { font-size: 11px; color: #555; margin-bottom: 4px; }
.prt-narr-text { white-space: pre-wrap; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.prt-form { margin-bottom: 6px; }
.prt-nested { margin: 6px 0 0 0; padding-left: 10px; border-left: 2px solid #e1e5e8; }
.prt-nested-title { font-weight: 700; font-size: 11px; text-transform: uppercase; color: #444; margin-bottom: 2px; }

/* signatures */
.prt-sigs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.prt-sig { border: 1px solid #c9d0d6; padding: 8px 10px; break-inside: avoid; page-break-inside: avoid; }
.prt-sig-title { font-weight: 700; font-size: 12px; text-transform: uppercase; margin-bottom: 4px; }
.prt-sig-box { min-height: 60px; border-bottom: 1px solid #333; display: flex; align-items: flex-end; padding-bottom: 2px; }
.prt-sig-img { max-height: 70px; max-width: 100%; }
.prt-sig-missing { color: #999; font-style: italic; }
.prt-sig-meta { font-size: 11px; margin: 4px 0; color: #333; }

.prt-footer { display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid #999; margin-top: 24px; padding-top: 6px; font-size: 10px; color: #666; }

@media (max-width: 800px) {
  .prt-head-grid, .prt-kv-4, .prt-kv-3 { grid-template-columns: repeat(2, 1fr); }
  .prt-two, .prt-sigs { grid-template-columns: 1fr; }
  .prt-report { overflow-x: auto; }
}

@media print {
  @page { margin: 12mm 10mm; }
  html, body { background: #fff !important; }
  #toasts, .modal-backdrop, .pop-menu { display: none !important; }
  .prt-page { background: #fff; min-height: 0; }
  .prt-report { margin: 0; box-shadow: none; max-width: none; font-size: 10.5px; overflow: visible; }
  .prt-report * { color: #000; }
  .prt-report h2 { background: #2d3e50 !important; color: #fff !important; }
  .prt-report th { background: #eef1f3 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .prt-table { font-size: 10px; }
  .prt-table, .prt-sig, .prt-exam, .prt-narrative, .prt-kv { break-inside: avoid; page-break-inside: avoid; }
  .prt-section { break-inside: auto; }
  .prt-watermark { position: fixed; top: 40%; color: rgba(200, 30, 30, .08) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .prt-badge-draft { color: #b71c1c !important; }
  .prt-footer { color: #444; }
  a { color: #000; text-decoration: none; }
}
.prt-report h3 { break-after: avoid; page-break-after: avoid; }
@media print { .prt-sub { break-inside: avoid; page-break-inside: avoid; } }
