 .document-print *{box-sizing:border-box}
.document-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px}.document-wide{grid-column:1/-1}.document-notice{padding:16px 20px;background:#eaf5f3;border:1px solid #cae5df;border-radius:8px;margin-bottom:24px;color:#315c56}.document-actions{display:flex;align-items:center;justify-content:flex-end;flex-wrap:wrap;gap:12px;margin:24px 0}.document-actions>span{margin-right:auto}.medicine-card{position:relative;border:1px solid #dbe4e7;border-radius:10px;padding:22px;margin:20px 0}.medicine-card>legend,.dose-stage>legend{float:none;width:auto;padding:0 8px;font-size:16px;font-weight:600}.medicine-card>.remove-medicine{margin-bottom:20px}.dose-stage{padding:16px;background:#f6f8fa;border-radius:8px;margin:20px 0}.document-paper{background:#fff;border:1px solid #dbe4e7;border-radius:12px;max-width:850px;margin:0 auto 24px;padding:40px;color:#21333d;line-height:1.6;overflow-wrap:anywhere}.document-paper h1{font-size:25px;margin:20px 0 8px}.document-paper h2{font-size:22px}.document-paper h3{font-size:15px;margin:0 0 8px}.document-paper p{margin:0 0 8px}.document-paper section{margin:24px 0}.document-paper hr{border:0;border-top:1px solid #dbe4e7;margin:24px 0}.document-kicker{text-transform:uppercase;font-size:12px;color:#667982;letter-spacing:.08em}.document-lines{white-space:pre-wrap}.signature-line{margin-top:32px!important}.document-print{font:14px/1.6 system-ui,sans-serif;background:#f5f7f9;margin:0;padding:24px}.print-toolbar{max-width:850px;margin:0 auto 20px;display:flex;gap:20px;align-items:center}.print-toolbar button{background:#087f78;color:white;border:0;border-radius:6px;padding:12px 18px;cursor:pointer;font:inherit}
@media(max-width:650px){.document-fields{grid-template-columns:1fr}.document-paper{padding:22px}.document-actions{justify-content:stretch}.document-actions .btn{flex:1}.document-actions>span{width:100%}.medicine-card{padding:16px}.document-print{padding:12px}}
@media print{@page{size:A4;margin:16mm}.document-print{background:#fff;padding:0;font-size:10pt}.print-toolbar{display:none}.document-paper{border:0;border-radius:0;padding:0;max-width:none;margin:0}.document-paper header{break-inside:avoid}.document-paper h3{break-after:avoid}.document-medicine,.document-paper footer{break-inside:avoid}.document-paper h1{font-size:20pt}.document-paper section{margin:16px 0}}

#signature-pad{display:block;width:100%;max-width:600px;aspect-ratio:3/1;height:auto;border:2px dashed #9badb4;border-radius:8px;background:white;touch-action:none}.doctor-signature{display:block;width:240px;max-width:100%;height:auto}

.qualification-row{display:flex;align-items:flex-end;gap:12px;margin-bottom:12px}.qualification-row label{flex:1;min-width:0;margin:0}.qualification-row button{flex-shrink:0}.qualification-row button:disabled{cursor:default}

.medicine-search-group{flex-wrap:nowrap}.medicine-search-group .medicine-search{min-width:0}.medicine-search-group .search-medicine{flex-shrink:0}.medicine-search-group .form-control:focus{z-index:3}@media(max-width:650px){.medicine-search-group .search-medicine{padding:10px;font-size:12px;gap:6px}.medicine-search-group .medicine-search{font-size:13px;padding:10px}}
.prescription-delivery { max-width: 760px; }
.prescription-delivery label:not(.form-check-label) { display: block; margin-bottom: .45rem; font-weight: 600; }
.delivery-queue-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 0; border-top: 1px solid #dde5e9; }
.delivery-queue-row > div { min-width: 0; }
.delivery-destination { overflow-wrap: anywhere; }
@media(max-width: 575px) { .delivery-queue-row { align-items: flex-start; flex-direction: column; } .prescription-delivery .input-group { flex-wrap: wrap; } .prescription-delivery .input-group .form-control { min-width: 140px; } }

.document-authentication{display:flex;align-items:flex-start;justify-content:space-between;gap:28px;margin-bottom:20px;break-inside:avoid}
.document-signing{flex:1;min-width:0}
.signature-caption{border-top:1px solid #8b9ba4;padding-top:6px;max-width:240px;font-size:12px}
.signature-placeholder{border-bottom:1px dashed #8b9ba4;padding:24px 0 8px;font-size:12px}
.practice-stamp{flex:0 1 310px;min-width:0;border:2px solid #36586c;border-radius:5px;padding:16px;text-align:center;color:#29495d;font-size:12px;line-height:1.5;overflow-wrap:anywhere;break-inside:avoid}
.practice-stamp strong{display:block;font-size:15px;margin-bottom:6px}
.document-paper .practice-stamp p{margin-bottom:6px}
.practice-stamp-label{text-transform:uppercase;letter-spacing:.12em;font-size:10px;border-bottom:1px solid #8b9ba4;padding-bottom:6px}
@media screen and (max-width:650px){.document-authentication{flex-direction:column}.document-signing,.practice-stamp{width:100%;box-sizing:border-box}.practice-stamp{flex-basis:auto}}
@media print{.practice-stamp{font-size:9pt;border-color:#29495d}.practice-stamp strong{font-size:11pt}.document-authentication{gap:20px}}

.delivery-recipient{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:12px;padding:16px 0;border-bottom:1px solid var(--border)}
.delivery-recipient .delivery-destination{overflow-wrap:anywhere}
.delivery-recipient-error{grid-column:1/-1;margin:0}
@media(max-width:575px){.delivery-recipient{grid-template-columns:1fr}}

.clinical-letterhead{display:grid;grid-template-columns:minmax(0,1.8fr) minmax(0,1fr);gap:28px;align-items:start;border-bottom:2px solid #39464b;padding-bottom:20px}
.letterhead-brand{display:flex;align-items:center;gap:16px;background:#edf0f1;padding:24px 18px;min-height:135px;color:#233039}
.letterhead-cross{font-family:Arial,sans-serif;font-size:64px;font-weight:bold;line-height:1;width:65px;height:65px;flex-shrink:0;display:flex;align-items:center;justify-content:center;border-radius:50%;background:#39464b;color:white}
.letterhead-brand h2{font-family:Arial,sans-serif;font-size:25px!important;line-height:1.15;letter-spacing:.02em;text-transform:uppercase;margin:0!important;overflow-wrap:anywhere}
.letterhead-details{text-align:right;font-size:11px;line-height:1.45;overflow-wrap:anywhere}
.letterhead-details strong{font-size:14px}.letterhead-details p{white-space:pre-line;margin:5px 0!important}
.letterhead-date{text-align:right;font-size:12px;margin:20px 0!important}
.letterhead-title{text-align:center;text-transform:uppercase;letter-spacing:.06em;font-size:22px!important;margin:34px 0 24px!important}
.document-paper .document-kicker{text-align:center}
.document-authentication .practice-stamp{order:-1}
@media print{.letterhead-brand{print-color-adjust:exact;-webkit-print-color-adjust:exact}.clinical-letterhead{gap:20px}.letterhead-brand h2{font-size:20px!important}.letterhead-title{font-size:18pt!important}}
@media screen and (max-width:600px){.clinical-letterhead{grid-template-columns:1fr}.letterhead-details{text-align:left}.letterhead-brand h2{font-size:22px!important}}

.letterhead-brand.letterhead-image{padding:0;background:white;min-height:0;display:block}.letterhead-image img{display:block;width:100%;height:auto}.practice-letterhead-preview{display:block;width:100%;max-width:640px;height:auto;margin:0 0 24px}

/* Keep uploaded letterheads proportional without letting tall images displace the document. */
.letterhead-image img{width:100%;height:auto;max-height:145px;object-fit:contain;object-position:top left}

.patient-documents { margin-bottom:1.25rem; padding:.9rem 1rem .25rem; background:#fff; border:1px solid #dae4e8; border-radius:14px; }
.patient-documents h2 { font-size:1rem; margin:0 0 .45rem; font-weight:700; }
.patient-document-row { display:grid; grid-template-columns:minmax(0,1fr) auto auto; align-items:center; gap:.45rem; padding:.25rem 0; border-top:1px solid #e3ebee; }
.patient-document-name { display:flex; align-items:center; gap:.65rem; font-size:.94rem; font-weight:600; line-height:1.25; }
.patient-document-name i { color:#007771; }
.patient-document-row a { display:inline-flex; justify-content:center; align-items:center; gap:.25rem; min-height:44px; min-width:44px; text-decoration:none; font-weight:600; font-size:.9rem; }
.patient-document-view { color:#006e69; }
.patient-document-new { padding:0 .75rem; border-radius:8px; background:#e4f4f1; color:#005f59; }
.patient-document-row a:hover { text-decoration:underline; }

.page-heading > div:has(> .page-title-row) { flex:1 1 auto; min-width:0; }
.page-title-row { display:flex; align-items:center; gap:.65rem; }
.page-title-row h1 { flex:1; text-align:right; margin:0; min-width:0; }
a.page-back { display:inline-flex; align-items:center; justify-content:center; flex:0 0 44px; width:44px; height:44px; border:1px solid #c9ddda; border-radius:50%; background:white; color:#006d68; text-decoration:none; font:1.45rem/1 system-ui,sans-serif; }
a.page-back:hover, a.page-back:focus-visible { background:#e6f4f2; color:#004f4c; }

@media (max-width: 768px), (any-pointer: coarse) {
  .mobile-action-pair.document-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: .75rem;
  }

  .mobile-action-pair > .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 0;
    margin: 0;
    white-space: normal;
    text-align: center;
  }
}
