@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

[hidden] { display: none !important; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: #F9FAFB;
    color: #111827;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ─── Top Navbar ─────────────────────────────────────────────── */
.app-navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 58px;
    background: #111827;
    box-shadow: 0 1px 0 rgba(255,255,255,0.08), 0 2px 12px rgba(0,0,0,0.25);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.navbar-home-link {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    text-decoration: none;
}

.navbar-icon {
    font-size: 1.3rem;
    color: #60a5fa;
    line-height: 1;
}

.navbar-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.3px;
}

.navbar-badge {
    font-size: 0.7rem;
    font-weight: 600;
    color: #93c5fd;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    padding: 0.18rem 0.65rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* ─── Page Wrapper ───────────────────────────────────────────── */
.page-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: calc(100vh - 56px);
    padding: 2rem 1.25rem 2.5rem;
}

/* ─── App Layout ─────────────────────────────────────────────── */
.app-layout {
    width: 100%;
    max-width: 880px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ─── Panels (Input + Output) ────────────────────────────────── */
.input-panel,
.output-panel {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.07);
    padding: 2rem 2.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    border: 1px solid #e2e8f0;
}

/* ─── Panel Header ───────────────────────────────────────────── */
.panel-header {
    padding-bottom: 1rem;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 0.1rem;
}

.panel-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.3px;
}

.panel-desc {
    font-size: 0.84rem;
    color: #6B7280;
    margin-top: 0.25rem;
    line-height: 1.4;
}

/* ─── Form Group ─────────────────────────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
}

.form-group input {
    border: 1.5px solid #d1d5db;
    border-radius: 10px;
    padding: 0.7rem 1rem;
    font-size: 0.97rem;
    color: #111827;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #ffffff;
    width: 100%;
}

.form-group input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
    background: #fff;
}

.form-group input::placeholder {
    color: #9ca3af;
}

/* Subtle hint below a label */
.field-hint {
    font-size: 0.77rem;
    color: #94a3b8;
    margin-top: -0.05rem;
}

/* Textarea — same visual language as inputs */
.form-group textarea {
    border: 1.5px solid #d1d5db;
    border-radius: 10px;
    padding: 0.7rem 1rem;
    font-size: 0.93rem;
    font-family: inherit;
    color: #111827;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #ffffff;
    width: 100%;
    resize: vertical;
    min-height: 70px;
    max-height: 180px;
    line-height: 1.55;
}

.form-group textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
    background: #fff;
}

.form-group textarea::placeholder {
    color: #9ca3af;
}

/* ─── Condition + Patient Name Row ──────────────────────────── */
.condition-patient-row {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 0.75rem;
    align-items: end;
}

.field-optional {
    font-size: 0.78rem;
    font-weight: 400;
    color: #9ca3af;
    margin-left: 0.2rem;
}

/* ─── Preset Buttons ─────────────────────────────────────────── */
.preset-section {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.preset-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.preset-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.preset-btn {
    background: #eff6ff;
    color: #2563eb;
    border: 1.5px solid #bfdbfe;
    border-radius: 999px;
    padding: 0.32rem 0.9rem;
    font-size: 0.86rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.preset-btn:hover {
    background: #dbeafe;
    border-color: #3b82f6;
}

.preset-btn.active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

/* ─── Quick Conditions (built-in library) ────────────────────── */
.quick-conditions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 10px;
}

.quick-conditions-hint {
    font-size: 0.75rem;
    font-weight: 400;
    color: #6b7280;
    margin-left: 0.4rem;
    text-transform: none;
    letter-spacing: 0;
}

.quick-conditions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.42rem;
}

.lib-btn {
    background: #ffffff;
    border: 1.5px solid #86efac;
    color: #166534;
    border-radius: 999px;
    padding: 0.28rem 0.95rem;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.lib-btn:hover {
    background: #dcfce7;
    border-color: #4ade80;
}

.lib-btn.active {
    background: #16a34a;
    border-color: #15803d;
    color: #ffffff;
}

/* ─── Smart Shortcuts ─────────────────────────────────────────── */
.smart-shortcuts {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.shortcut-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.shortcut-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #6b7280;
    white-space: nowrap;
    flex-shrink: 0;
}

.shortcut-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.shortcut-pill {
    background: #eff6ff;
    border: 1.5px solid #bfdbfe;
    color: #1d4ed8;
    border-radius: 999px;
    padding: 0.22rem 0.82rem;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.shortcut-pill:hover {
    background: #dbeafe;
    border-color: #93c5fd;
}

/* ─── Browse by System ────────────────────────────────────────── */
.browse-system-wrap {
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
}

.browse-toggle-btn {
    width: 100%;
    background: #f9fafb;
    border: none;
    padding: 0.65rem 1rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: #374151;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.15s;
}

.browse-toggle-btn:hover {
    background: #f3f4f6;
}

.browse-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2em;
    height: 1.2em;
    font-size: 1.1rem;
    font-weight: 700;
    color: #2563eb;
    transition: transform 0.2s;
}

.browse-system-body {
    padding: 0.6rem 0.75rem 0.85rem;
    border-top: 1.5px solid #e5e7eb;
    background: #fff;
}

/* ── A–Z search input ──────────────────────────────── */
.alpha-search-wrap {
    margin-bottom: 0.65rem;
}

.alpha-search-input {
    width: 100%;
    padding: 0.45rem 0.75rem;
    border: 1.5px solid #d1d5db;
    border-radius: 7px;
    font-size: 0.85rem;
    font-family: inherit;
    color: #111827;
    background: #f9fafb;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.alpha-search-input:focus {
    border-color: #2563eb;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ── Flat alphabetical pill grid ─────────────────── */
.alpha-pills-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.38rem;
}

/* ── Empty search state ──────────────────────────── */
.alpha-no-results {
    font-size: 0.83rem;
    color: #9ca3af;
    margin: 0.5rem 0 0.25rem;
    text-align: center;
}

/* Legacy accordion classes kept for graceful fallback */
.sys-section {
    margin-bottom: 0.15rem;
}

.sys-header {
    width: 100%;
    background: none;
    border: none;
    padding: 0.45rem 0.25rem;
    font-size: 0.84rem;
    font-weight: 600;
    color: #374151;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    border-radius: 6px;
    transition: background 0.12s;
}

.sys-header:hover {
    background: #f3f4f6;
}

.sys-chevron {
    margin-left: auto;
    font-size: 1.15rem;
    color: #9ca3af;
    transition: transform 0.2s;
}

.sys-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.38rem;
    padding: 0.3rem 0.25rem 0.5rem 1.4rem;
}

/* ─── NSP Language Selector & Translate ──────────────────────── */
.nsp-lang-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
    margin-bottom: 0.25rem;
}

.nsp-lang-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}

.nsp-lang-select {
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    padding: 0.45rem 1.8rem 0.45rem 0.7rem;
    font-size: 0.875rem;
    color: #111827;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    background-size: 0.65rem;
    -webkit-appearance: none;
    cursor: pointer;
}

.nsp-translate-btn {
    font-size: 0.83rem;
    padding: 0.42rem 0.9rem;
}

.nsp-translate-status {
    font-size: 0.82rem;
    color: #6b7280;
    font-style: italic;
}

.nsp-translated-preview {
    margin-top: 1.25rem;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    padding: 1rem 1.25rem;
}

.nsp-translated-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #0369a1;
    margin-bottom: 0.6rem;
    letter-spacing: 0.01em;
}

.nsp-translated-list {
    margin: 0;
    padding-left: 1.4rem;
    color: #1e293b;
    font-size: 0.95rem;
    line-height: 1.7;
}

.nsp-translated-list li {
    margin-bottom: 0.25rem;
}

@media print {
    .nsp-translated-preview { display: none; }
}

/* ─── Controls Grid ──────────────────────────────────────────── */
.controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

.select-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.select-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
}

.select-group select {
    border: 1.5px solid #d1d5db;
    border-radius: 10px;
    padding: 0.7rem 2.2rem 0.7rem 0.9rem;
    font-size: 0.93rem;
    color: #111827;
    background-color: #ffffff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
    background-size: 0.72rem;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    cursor: pointer;
    width: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.select-group select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
    background-color: #fff;
}

/* ─── Advanced Options Panel ─────────────────────────────────── */
.advanced-panel {
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
}

.advanced-panel[open] {
    background: #fafbfc;
}

.advanced-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.78rem 1.1rem;
    cursor: pointer;
    list-style: none;
    user-select: none;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    background: #f8fafc;
    transition: background 0.15s;
}

.advanced-toggle:hover {
    background: #f1f5f9;
}

.advanced-toggle::-webkit-details-marker {
    display: none;
}

.advanced-toggle::after {
    content: '\25B8';
    font-size: 0.8rem;
    color: #94a3b8;
    transition: transform 0.2s;
    margin-left: auto;
}

details[open] .advanced-toggle::after {
    transform: rotate(90deg);
}

.advanced-hint {
    font-size: 0.75rem;
    font-weight: 400;
    color: #94a3b8;
    flex: 1;
}

.advanced-content {
    padding: 1.1rem 1.25rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-top: 1px solid #e2e8f0;
}

/* ─── Doctor Branding Section ────────────────────────────────── */
.doctor-branding-section {
    background: #f5f3ff;
    border-color: #ddd6fe;
}

.doctor-branding-section .branding-section-title {
    color: #4c1d95;
}

.doctor-branding-section .form-group label,
.doctor-branding-section .select-group label {
    color: #5b21b6;
}

.doctor-branding-section .form-group input,
.doctor-branding-section .form-group textarea,
.doctor-branding-section .select-group select {
    border-color: #c4b5fd;
    background: #faf9ff;
}

.doctor-branding-section .form-group input:focus,
.doctor-branding-section .form-group textarea:focus,
.doctor-branding-section .select-group select:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
    background: #fff;
}

/* ─── Clinic Branding Section ────────────────────────────────── */
.branding-section {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    padding: 1rem 1.15rem;
}

.branding-section-header {
    display: flex;
    align-items: baseline;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.branding-section-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: #111827;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.branding-section-hint {
    font-size: 0.77rem;
    color: #94a3b8;
}

.branding-fields {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.branding-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.branding-section .form-group label {
    font-size: 0.84rem;
}

.branding-section .form-group input {
    font-size: 0.91rem;
    padding: 0.58rem 0.9rem;
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: none;
    border-radius: 10px;
    padding: 0.68rem 1.3rem;
    font-size: 0.93rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s, box-shadow 0.18s, transform 0.1s, opacity 0.18s;
    white-space: nowrap;
}

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

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover:not(:disabled) {
    background: #1d4ed8;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.btn-secondary {
    background: #f1f5f9;
    color: #374151;
    border: 1.5px solid #e2e8f0;
    font-size: 0.87rem;
    padding: 0.5rem 0.95rem;
}

.btn-secondary:hover:not(:disabled) {
    background: #e2e8f0;
}

/* ─── Action Row ─────────────────────────────────────────────── */
.action-row {
    display: flex;
    align-items: stretch;
    gap: 0.6rem;
}

.action-row .btn-primary {
    flex: 1;
    font-size: 1rem;
    padding: 0.82rem;
}

/* ─── Loading ─────────────────────────────────────────────────── */
.loading-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    padding: 0.85rem 1.1rem;
    color: #1d4ed8;
    font-size: 0.93rem;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid #bfdbfe;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ─── Error ───────────────────────────────────────────────────── */
.error-area {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    background: #fff5f5;
    border: 1px solid #fca5a5;
    border-radius: 10px;
    padding: 0.85rem 1.1rem;
    color: #b91c1c;
    font-size: 0.92rem;
}

.error-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* ─── Empty State ─────────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    background: #f8fafc;
    border: 1.5px dashed #cbd5e1;
    border-radius: 12px;
    padding: 3rem 1.5rem;
    text-align: center;
}

.empty-state-icon {
    font-size: 2.2rem;
    line-height: 1;
    opacity: 0.4;
    margin-bottom: 0.2rem;
}

.empty-state-message {
    font-size: 0.97rem;
    font-weight: 600;
    color: #64748b;
}

.empty-state-hint {
    font-size: 0.87rem;
    color: #94a3b8;
    line-height: 1.5;
}

.empty-state-hint em {
    font-style: normal;
    color: #64748b;
    font-weight: 500;
}

/* ─── Result Card ─────────────────────────────────────────────── */
.result-card {
    background: #ffffff;
    border: 1.5px solid #d1d5db;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Toolbar strip: condition label + action buttons */
.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.8rem 1.25rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.result-title-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.result-icon {
    font-size: 1rem;
    opacity: 0.65;
}

.result-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #374151;
}

.result-actions {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
}

/* ─── Handout Document Area ───────────────────────────────────── */
.handout-document {
    padding: 1.75rem 2rem 2rem;
    display: flex;
    flex-direction: column;
    background: #ffffff;
}

/* Clinic letterhead: name left, phone right */
.handout-letterhead {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    padding-bottom: 0.8rem;
    margin-bottom: 1.1rem;
    border-bottom: 2px solid #2563EB;
}

.handout-clinic-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #111827;
    line-height: 1.3;
}

.handout-clinic-phone {
    font-size: 0.88rem;
    color: #475569;
    white-space: nowrap;
}

/* Condition name — document title */
.handout-condition-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #111827;
    line-height: 1.3;
    padding-bottom: 0.5rem;
    margin-bottom: 1.2rem;
    border-bottom: 2px solid #2563EB;
}

/* ─── Handout Meta Summary ────────────────────────────────────── */
.handout-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.2rem 0.45rem;
    margin-top: -0.75rem;
    margin-bottom: 1.25rem;
    font-size: 0.82rem;
    color: #64748b;
    line-height: 1.4;
}

.handout-meta-item {
    color: #475569;
    font-weight: 500;
}

.handout-meta-sep {
    color: #cbd5e1;
    font-size: 0.7rem;
    user-select: none;
}

/* ─── Handout Body ────────────────────────────────────────────── */
.result-body {
    font-size: 1rem;
    line-height: 1.8;
    color: #111827;
    word-break: break-word;
}

/* Section heading */
.result-body .section-heading {
    font-size: 0.95rem;
    font-weight: 700;
    color: #111827;
    padding-bottom: 0.3rem;
    margin-top: 1.6rem;
    margin-bottom: 0.6rem;
    border-bottom: 1.5px solid #bfdbfe;
}

.result-body .section-heading:first-child {
    margin-top: 0;
}

/* Bullet list */
.result-body .section-list {
    margin: 0 0 0.65rem 1.4rem;
    padding: 0;
}

.result-body .section-list li {
    margin-bottom: 0.4rem;
    line-height: 1.7;
}

.result-body .section-list li:last-child {
    margin-bottom: 0;
}

/* Plain paragraph */
.result-body .section-para {
    margin-bottom: 0.55rem;
}

.result-body .section-para:last-child {
    margin-bottom: 0;
}

/* ─── Urgent Section ──────────────────────────────────────────── */
.urgent-section {
    margin-top: 1.6rem;
    padding: 0.9rem 1rem 1rem 1.1rem;
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    border-top: 1px solid #fde68a;
    border-bottom: 1px solid #fde68a;
    border-radius: 0 8px 8px 0;
}

.urgent-section .section-heading {
    margin-top: 0;
    color: #78350f;
    border-bottom-color: #fcd34d;
}

.urgent-section .section-heading::before {
    content: '\26A0\00A0';
    color: #d97706;
    font-style: normal;
}

.urgent-section .section-list {
    margin-left: 1.2rem;
}

.urgent-section .section-list li {
    color: #422006;
}

/* ─── Patient Name (handout) ──────────────────────────────────── */
.handout-patient-name {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
    margin-bottom: 1rem;
    padding: 0.4rem 0.75rem;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    font-size: 0.87rem;
    line-height: 1.4;
}

.handout-patient-label {
    font-weight: 600;
    color: #1e40af;
}

.handout-patient-value {
    color: #374151;
    font-weight: 500;
}

/* ─── Doctor Byline (handout) ─────────────────────────────────── */
.handout-doctor-byline {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.15rem 0.6rem;
    margin-bottom: 0.85rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid #e2e8f0;
}

.handout-doctor-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #111827;
}

.handout-doctor-role {
    font-size: 0.83rem;
    color: #6b7280;
}

.handout-doctor-role:not(:empty)::before {
    content: '\2014\00A0';
}

/* ─── Doctor Closing Message (handout) ───────────────────────── */
.doctor-closing-msg {
    margin-top: 1.1rem;
    padding: 0.65rem 0.85rem;
    background: #f5f3ff;
    border-left: 3px solid #7c3aed;
    border-radius: 0 6px 6px 0;
    font-size: 0.88rem;
    color: #3b3b6e;
    line-height: 1.55;
}

/* ─── Clinic Footer Message ───────────────────────────────────── */
.clinic-footer-msg {
    margin-top: 1.25rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e2e8f0;
    font-size: 0.87rem;
    color: #64748b;
    font-style: italic;
    line-height: 1.55;
}

/* ─── My Custom Conditions Library ───────────────────────────── */
.custom-library {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 0.85rem;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
}

.custom-conditions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.custom-condition-card {
    display: inline-flex;
    align-items: center;
    background: #fff;
    border: 1px solid #86efac;
    border-radius: 20px;
    overflow: hidden;
    transition: border-color 0.15s;
}

.custom-condition-card:hover {
    border-color: #16a34a;
}

.custom-condition-name-btn {
    padding: 0.3rem 0.7rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: #15803d;
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1.4;
    white-space: nowrap;
}

.custom-condition-name-btn:hover {
    color: #14532d;
    text-decoration: underline;
}

.custom-condition-delete {
    padding: 0.3rem 0.55rem 0.3rem 0.25rem;
    font-size: 0.72rem;
    color: #86efac;
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
    transition: color 0.15s;
}

.custom-condition-delete:hover {
    color: #dc2626;
}

/* ─── Saved Version Suggestion Banner ────────────────────────── */
.saved-suggestion {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 6px;
    font-size: 0.83rem;
    color: #78350f;
}

.btn-link {
    background: none;
    border: none;
    padding: 0;
    font-size: inherit;
    font-weight: 600;
    color: #d97706;
    cursor: pointer;
    text-decoration: underline;
    line-height: inherit;
}

.btn-link:hover {
    color: #92400e;
}

/* ─── Edit Textarea ───────────────────────────────────────────── */
.edit-textarea {
    width: 100%;
    min-height: 300px;
    padding: 0.9rem 1rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.88rem;
    line-height: 1.7;
    color: #111827;
    background: #f8fafc;
    border: 1.5px solid #94a3b8;
    border-radius: 6px;
    resize: none;
    overflow: hidden;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.15s;
}

.edit-textarea:focus {
    border-color: #3b82f6;
    background: #fff;
}

.edit-mode-active {
    background: #eff6ff !important;
    border-color: #3b82f6 !important;
    color: #1d4ed8 !important;
}

/* ─── Save as Custom Condition Area ──────────────────────────── */
.save-area {
    padding: 0.9rem 1.1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.save-area-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem 1rem;
    margin-bottom: 0.65rem;
}

.save-area-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #334155;
}

.save-area-hint {
    font-size: 0.78rem;
    color: #94a3b8;
}

.save-area-row {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
}

.save-condition-name-input {
    flex: 1;
    min-width: 160px;
    padding: 0.45rem 0.75rem;
    font-size: 0.88rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.15s;
    background: #fff;
    color: #111827;
}

.save-condition-name-input:focus {
    border-color: #3b82f6;
}

/* ─── Next Steps Plan ─────────────────────────────────────────── */
.nsp-section {
    margin-top: 1.5rem;
    padding: 1rem 1.2rem 1.2rem;
    background: #f0fdf4;
    border: 1.5px solid #bbf7d0;
    border-left: 4px solid #16a34a;
    border-radius: 10px;
    page-break-inside: avoid;
    break-inside: avoid;
}

.nsp-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid #bbf7d0;
    flex-wrap: wrap;
}

.nsp-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: #15803d;
    letter-spacing: -0.01em;
}

.nsp-badge {
    margin-left: auto;
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
    border-radius: 999px;
    padding: 0.15rem 0.55rem;
    white-space: nowrap;
}

.nsp-step { margin-bottom: 0.85rem; }
.nsp-step:last-child { margin-bottom: 0; }
.nsp-step-label { display: block; font-size: 0.88rem; font-weight: 700; color: #111827; margin-bottom: 0.45rem; }

/* ─── NSP Selectable Item Rows ────────────────────────────────── */
.nsp-items-ui {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-top: 0.55rem;
}

.nsp-item-row {
    background: #f8fafc;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.15s, background 0.15s;
}

.nsp-item-row:has(.nsp-item-cb:checked) {
    border-color: #2563eb;
    background: #fff;
}

.nsp-item-toggle {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.6rem 0.85rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.1s;
}

.nsp-item-toggle:hover {
    background: rgba(37,99,235,0.04);
}

.nsp-item-cb {
    width: 16px;
    height: 16px;
    accent-color: #2563eb;
    cursor: pointer;
    flex-shrink: 0;
}

.nsp-item-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #111827;
    line-height: 1.3;
}

.nsp-item-body {
    padding: 0.5rem 0.85rem 0.7rem 2.3rem;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

/* Other test row */
.nsp-other-test-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.5rem;
    padding-top: 0.35rem;
    border-top: 1px dashed #e5e7eb;
}

.nsp-other-cb {
    width: 15px;
    height: 15px;
    accent-color: #2563eb;
    cursor: pointer;
    flex-shrink: 0;
}

.nsp-other-label {
    font-size: 0.83rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    white-space: nowrap;
}

.nsp-other-test-input,
.nsp-other-step-input {
    flex: 1;
    min-width: 0;
    padding: 0.28rem 0.6rem;
    font-family: inherit;
    font-size: 0.83rem;
    border: 1.5px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #111827;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.nsp-other-test-input:focus,
.nsp-other-step-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37,99,235,0.1);
}

.nsp-other-step-input {
    width: 100%;
    margin-top: 0;
}

/* NSP print output text */
#nsp-print-output,
#nsp-sa-print-output {
    font-size: 0.875rem;
    color: #374151;
    line-height: 1.85;
}
/* ─────────────────────────────────────────────────────────────── */

.nsp-checklist {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.25rem 0.65rem;
}

.nsp-check-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.86rem;
    color: #374151;
    cursor: pointer;
    padding: 0.15rem 0;
    user-select: none;
}

.nsp-check {
    width: 15px;
    height: 15px;
    accent-color: #16a34a;
    cursor: pointer;
    flex-shrink: 0;
}

.nsp-followup-list {
    list-style: disc;
    margin: 0 0 0 1.3rem;
    padding: 0;
}

.nsp-followup-list li {
    font-size: 0.86rem;
    color: #374151;
    margin-bottom: 0.3rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.nsp-followup-list li:last-child {
    margin-bottom: 0;
}

.nsp-days-input {
    width: 52px;
    padding: 0.15rem 0.4rem;
    font-size: 0.86rem;
    border: 1.5px solid #bbf7d0;
    border-radius: 5px;
    text-align: center;
    background: #fff;
    color: #111827;
    outline: none;
    -moz-appearance: textfield;
}

.nsp-days-input::-webkit-inner-spin-button,
.nsp-days-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.nsp-days-input:focus {
    border-color: #16a34a;
    box-shadow: 0 0 0 2px rgba(22,163,74,0.12);
}

@media (max-width: 560px) {
    .nsp-checklist {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ─── Site Footer ─────────────────────────────────────────────── */
.site-footer {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.78rem;
    color: #94a3b8;
    max-width: 600px;
    line-height: 1.5;
}

.handout-disclaimer {
    margin-top: 1.25rem;
    padding-top: 0.75rem;
    border-top: 1px solid #f1f5f9;
    font-size: 0.74rem;
    color: #94a3b8;
    font-weight: 400;
    font-style: italic;
    text-align: center;
    line-height: 1.5;
}

/* ─── Mobile Responsive ───────────────────────────────────────── */
@media (max-width: 640px) {
    .app-navbar {
        padding: 0 1.1rem;
    }

    .navbar-badge {
        display: none;
    }

    .page-wrapper {
        padding: 1.25rem 0.85rem 2rem;
    }

    .input-panel,
    .output-panel {
        padding: 1.5rem 1.2rem;
        gap: 1rem;
    }

    .quick-conditions-hint {
        display: none;
    }

    .condition-patient-row {
        grid-template-columns: 1fr;
    }

    .controls-grid {
        grid-template-columns: 1fr;
    }

    .branding-row {
        grid-template-columns: 1fr;
    }

    .preset-section {
        flex-direction: column;
        align-items: flex-start;
    }

    .result-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .result-actions {
        width: 100%;
    }

    .result-actions .btn {
        flex: 1;
        justify-content: center;
    }

    .handout-document {
        padding: 1.25rem 1.1rem 1.5rem;
    }

    .handout-letterhead {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.1rem;
    }

    .action-row {
        flex-wrap: wrap;
    }

    .action-row .btn-primary {
        flex: 1;
    }

    .btn-clear {
        flex: 1;
        justify-content: center;
    }
}

/* ═══════════════════════════════════════════════════════════════
   PRINT / PDF EXPORT
   ═══════════════════════════════════════════════════════════════ */

/* ─── NSP: Screen vs Print separation ─────────────────────── */
.nsp-ui-only    { /* visible on screen, hidden when printing */ }
.nsp-print-only { display: none; /* hidden on screen, shown when printing */ }

/* ─── NSP Follow-up options (radio UI) ────────────────────── */
.nsp-followup-options {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-top: 0.5rem;
}

.nsp-followup-option {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.875rem;
    color: #374151;
    cursor: pointer;
    padding: 0.1rem 0;
    flex-wrap: wrap;
}

.nsp-followup-radio {
    accent-color: #2563eb;
    cursor: pointer;
    flex-shrink: 0;
}

.nsp-followup-in {
    font-weight: 600;
    color: #374151;
}

.nsp-unit-group {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
}

.nsp-unit-option {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.875rem;
    color: #374151;
    cursor: pointer;
}

.nsp-unit-radio {
    accent-color: #2563eb;
    cursor: pointer;
}

.nsp-or-sep {
    font-size: 0.78rem;
    color: #9ca3af;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-left: 0.1rem;
}

/* ─── NSP Print-only text (clean output) ──────────────────── */
.nsp-tests-print,
.nsp-followup-print,
[id$="-tests-print"],
[id$="-followup-print"] {
    font-size: 0.875rem;
    color: #374151;
    margin-top: 0.25rem;
}

/* ─── Tool Mode Tabs ───────────────────────────────────────── */
.tool-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e5e7eb;
}

.tool-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1.1rem;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    color: #6B7280;
    background: none;
    border: 1.5px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
    white-space: nowrap;
    line-height: 1;
}

.tool-tab:hover {
    color: #111827;
    background: #f3f4f6;
}

.tool-tab.active {
    color: #2563eb;
    background: #eff6ff;
    border-color: #bfdbfe;
}

/* ─── NSP Standalone Tool ──────────────────────────────────── */
.nsp-standalone {
    max-width: 720px;
    margin: 0 auto;
}

.nsp-sa-panel {
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.75rem 2rem 2rem;
    box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}

.nsp-sa-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.nsp-sa-title-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nsp-sa-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.nsp-sa-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: #111827;
    letter-spacing: -0.02em;
}

.nsp-sa-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.nsp-sa-patient-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.nsp-sa-patient-row label {
    font-size: 0.84rem;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}

.nsp-sa-patient-input {
    flex: 1;
    max-width: 260px;
    padding: 0.38rem 0.7rem;
    font-family: inherit;
    font-size: 0.87rem;
    border: 1.5px solid #d1d5db;
    border-radius: 7px;
    background: #fff;
    color: #111827;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.nsp-sa-patient-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.nsp-sa-hint {
    font-size: 0.77rem;
    color: #9ca3af;
}

.nsp-sa-divider {
    border: none;
    border-top: 1.5px solid #e5e7eb;
    margin: 0.25rem 0 1.25rem;
}

.nsp-sa-step {
    padding: 1rem 1.25rem 1rem 1rem;
    background: #f8fafc;
    border: 1.5px solid #e5e7eb;
    border-left: 4px solid #2563eb;
    border-radius: 0 10px 10px 0;
    margin-bottom: 0.75rem;
}

.nsp-sa-step:nth-child(1) { border-left-color: #2563eb; }
.nsp-sa-step:nth-child(2) { border-left-color: #7c3aed; }
.nsp-sa-step:last-child   { border-left-color: #16a34a; margin-bottom: 0; }

.nsp-sa-step-heading {
    display: flex;
    align-items: baseline;
    gap: 0.55rem;
    margin-bottom: 0.65rem;
}

.nsp-sa-step:nth-child(2) .nsp-sa-step-heading,
.nsp-sa-step-last .nsp-sa-step-heading {
    margin-bottom: 0;
}

.nsp-sa-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    min-width: 22px;
    border-radius: 50%;
    background: #2563eb;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    flex-shrink: 0;
}

.nsp-sa-step:nth-child(2) .nsp-sa-step-num { background: #7c3aed; }
.nsp-sa-step-last .nsp-sa-step-num         { background: #16a34a; }

.nsp-sa-step-label {
    font-size: 0.92rem;
    font-weight: 700;
    color: #111827;
}

.nsp-sa-checklist {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.25rem 0.75rem;
}

.nsp-sa-check-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
    color: #374151;
    cursor: pointer;
    padding: 0.15rem 0;
    user-select: none;
}

.nsp-sa-check {
    width: 15px;
    height: 15px;
    accent-color: #2563eb;
    cursor: pointer;
    flex-shrink: 0;
}

.nsp-sa-followup-list {
    list-style: disc;
    margin: 0.5rem 0 0 1.4rem;
    padding: 0;
}

.nsp-sa-followup-list li {
    font-size: 0.875rem;
    color: #374151;
    margin-bottom: 0.3rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.nsp-sa-followup-list li:last-child { margin-bottom: 0; }

.nsp-sa-days-input {
    width: 52px;
    padding: 0.15rem 0.4rem;
    font-family: inherit;
    font-size: 0.875rem;
    border: 1.5px solid #d1d5db;
    border-radius: 6px;
    text-align: center;
    background: #fff;
    color: #111827;
    outline: none;
    -moz-appearance: textfield;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.nsp-sa-days-input::-webkit-inner-spin-button,
.nsp-sa-days-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.nsp-sa-days-input:focus {
    border-color: #16a34a;
    box-shadow: 0 0 0 3px rgba(22,163,74,0.1);
}

@media (max-width: 640px) {
    .nsp-sa-checklist {
        grid-template-columns: repeat(2, 1fr);
    }
    .nsp-sa-panel {
        padding: 1.25rem 1rem 1.5rem;
    }
    .nsp-sa-patient-input {
        max-width: 100%;
    }
}

/* ─── Print Setup ──────────────────────────────────────────── */
@page {
    size: A4;
    margin: 20mm 25mm 22mm 25mm;
}

@media print {

    /* ── Base reset ─────────────────────────────────────────────── */
    *,
    *::before,
    *::after {
        color: #000 !important;
        background: transparent !important;
        box-shadow: none !important;
        text-shadow: none !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    body {
        font-family: Georgia, 'Times New Roman', serif;
        font-size: 11pt;
        line-height: 1.65;
        background: #fff;
    }

    /* ── Hide everything that is not the handout document ───────── */
    .app-navbar,
    .input-panel,
    .panel-header,
    .save-area,
    .site-footer,
    .result-header,
    .empty-state {
        display: none !important;
    }

    #edit-textarea {
        display: none !important;
    }

    #result-body {
        display: block !important;
    }

    .page-wrapper {
        display: block;
        padding: 0;
        min-height: 0;
    }

    .app-layout {
        display: block;
    }

    /* ── Output panel strips chrome ─────────────────────────────── */
    .output-panel {
        border: none;
        border-radius: 0;
        box-shadow: none;
        padding: 0;
        gap: 0;
    }

    .result-card {
        border: none;
        border-radius: 0;
        overflow: visible;
    }

    .handout-document {
        padding: 0;
        display: block;
    }

    /* ── Patient name ─────────────────────────────────────────────── */
    .handout-patient-name {
        display: flex;
        align-items: baseline;
        gap: 2pt 5pt;
        margin-bottom: 8pt;
        padding: 2pt 5pt;
        background: transparent !important;
        border: 0.5pt solid #bbb;
        border-color: #bbb !important;
        border-radius: 2pt;
        font-size: 9pt;
        line-height: 1.4;
    }

    .handout-patient-label {
        font-weight: 700;
        color: #000 !important;
    }

    .handout-patient-value {
        color: #000 !important;
        font-weight: 500;
    }

    /* ── Doctor byline ─────────────────────────────────────────────── */
    .handout-doctor-byline {
        display: flex;
        align-items: baseline;
        flex-wrap: wrap;
        gap: 1pt 6pt;
        margin-bottom: 7pt;
        padding-bottom: 4pt;
        border-bottom: 0.5pt solid #bbb;
        border-bottom-color: #bbb !important;
    }

    .handout-doctor-name {
        font-family: 'Segoe UI', Arial, sans-serif;
        font-size: 9.5pt;
        font-weight: 700;
        color: #000 !important;
    }

    .handout-doctor-role {
        font-family: 'Segoe UI', Arial, sans-serif;
        font-size: 9pt;
        color: #000 !important;
    }

    /* ── Doctor closing message ──────────────────────────────────── */
    .doctor-closing-msg {
        margin-top: 10pt;
        padding: 3pt 0 3pt 7pt;
        border-left: 1.5pt solid #000;
        border-left-color: #000 !important;
        background: transparent !important;
        font-size: 9.5pt;
        color: #000 !important;
        line-height: 1.5;
        border-radius: 0;
    }

    /* ── Clinic letterhead ───────────────────────────────────────── */
    .handout-letterhead {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        flex-wrap: nowrap;
        gap: 0 8pt;
        padding-bottom: 7pt;
        margin-bottom: 12pt;
        border-bottom: 2pt solid #000;
        border-bottom-color: #000 !important;
    }

    .handout-clinic-name {
        font-family: 'Segoe UI', Arial, sans-serif;
        font-size: 13pt;
        font-weight: 700;
        color: #000 !important;
        line-height: 1.2;
    }

    .handout-clinic-phone {
        font-family: 'Segoe UI', Arial, sans-serif;
        font-size: 10pt;
        color: #000 !important;
        white-space: nowrap;
    }

    /* ── Condition title ─────────────────────────────────────────── */
    .handout-condition-title {
        font-family: 'Segoe UI', Arial, sans-serif;
        font-size: 16pt;
        font-weight: 700;
        color: #000 !important;
        line-height: 1.25;
        padding-bottom: 5pt;
        margin-bottom: 10pt;
        border-bottom: 0.75pt solid #888;
        border-bottom-color: #888 !important;
        page-break-after: avoid;
        break-after: avoid;
    }

    /* ── Meta summary ────────────────────────────────────────────── */
    .handout-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 2pt 5pt;
        margin-top: -3pt;
        margin-bottom: 8pt;
        font-size: 8.5pt;
        color: #555 !important;
        line-height: 1.3;
    }

    .handout-meta-item {
        color: #333 !important;
        font-weight: 600;
    }

    .handout-meta-sep {
        color: #aaa !important;
        font-size: 7.5pt;
    }

    /* ── Handout body ────────────────────────────────────────────── */
    .result-body {
        font-size: 11pt;
        line-height: 1.65;
        color: #000;
        word-break: break-word;
    }

    .result-body .section-heading {
        font-family: 'Segoe UI', Arial, sans-serif;
        font-size: 10.5pt;
        font-weight: 700;
        color: #000 !important;
        border-bottom: 0.5pt solid #bbb;
        border-bottom-color: #bbb !important;
        padding-bottom: 2pt;
        margin-top: 11pt;
        margin-bottom: 4pt;
        background: transparent !important;
        page-break-after: avoid;
        break-after: avoid;
    }

    .result-body .section-heading:first-child {
        margin-top: 0;
    }

    .result-body .section-list {
        margin: 0 0 4pt 18pt;
        padding: 0;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .result-body .section-list li {
        font-size: 11pt;
        line-height: 1.55;
        margin-bottom: 2.5pt;
        color: #000;
    }

    .result-body .section-list li:last-child {
        margin-bottom: 0;
    }

    .result-body .section-para {
        font-size: 11pt;
        line-height: 1.65;
        margin-bottom: 4pt;
        color: #000;
    }

    .result-body .section-para:last-child {
        margin-bottom: 0;
    }

    /* ── Urgent section ────────────────────────────────────────────
       Left border and ⚠ icon ensure it stands out in B&W print.     */
    .urgent-section {
        border-left: 2pt solid #000;
        border-left-color: #000 !important;
        border-top: none !important;
        border-bottom: none !important;
        background: transparent !important;
        padding: 3pt 0 3pt 7pt;
        margin-top: 11pt;
        border-radius: 0;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .urgent-section .section-heading {
        margin-top: 0;
        color: #000 !important;
        border-bottom-color: #bbb !important;
    }

    .urgent-section .section-heading::before {
        color: #000 !important;
    }

    .urgent-section .section-list {
        margin-left: 16pt;
    }

    .urgent-section .section-list li {
        color: #000 !important;
    }

    /* ── Clinic footer message ───────────────────────────────────── */
    .clinic-footer-msg {
        margin-top: 14pt;
        padding-top: 6pt;
        border-top: 0.75pt solid #aaa;
        border-top-color: #aaa !important;
        font-size: 9.5pt;
        font-style: italic;
        color: #000 !important;
        line-height: 1.5;
    }

    /* ── NSP: hide interactive UI, show clean text ─────────────── */
    .nsp-ui-only {
        display: none !important;
    }

    .nsp-print-only {
        display: block !important;
        font-size: 9.5pt;
        color: #000 !important;
        margin-top: 3pt;
    }

    /* ── Next Steps Plan ─────────────────────────────────────────── */
    .nsp-section {
        background: transparent !important;
        border: 0.75pt solid #aaa !important;
        border-left: 3pt solid #000 !important;
        margin-top: 14pt;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .nsp-header {
        border-bottom: 0.5pt solid #aaa !important;
    }

    .nsp-title {
        color: #000 !important;
    }

    .nsp-badge {
        display: none !important;
    }

    .nsp-step-label,
    .nsp-check-item,
    .nsp-followup-list li {
        color: #000 !important;
    }

    .nsp-days-input {
        border: 0.5pt solid #aaa !important;
        background: transparent !important;
        color: #000 !important;
    }

    /* ── Standalone NSP print mode (body.nsp-mode) ───────────────── */
    body.nsp-mode .app-navbar,
    body.nsp-mode .ea-banner,
    body.nsp-mode .site-footer,
    body.nsp-mode .tool-tabs,
    body.nsp-mode #tab-content-explanation {
        display: none !important;
    }

    body.nsp-mode #tab-content-nsp {
        display: block !important;
    }

    body.nsp-mode .nsp-standalone {
        max-width: 100%;
        margin: 0;
    }

    body.nsp-mode .nsp-sa-panel {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
    }

    body.nsp-mode .nsp-sa-actions {
        display: none !important;
    }

    body.nsp-mode .nsp-sa-hint {
        display: none !important;
    }

    body.nsp-mode .nsp-sa-header {
        border-bottom: 1.5pt solid #2563eb;
        padding-bottom: 6pt;
        margin-bottom: 10pt;
    }

    body.nsp-mode .nsp-sa-title {
        font-size: 16pt;
        color: #000 !important;
    }

    body.nsp-mode .nsp-sa-divider {
        display: none !important;
    }

    body.nsp-mode .nsp-sa-step {
        background: transparent !important;
        border: 0.75pt solid #aaa !important;
        border-left: 3pt solid #000 !important;
        margin-bottom: 8pt;
        page-break-inside: avoid;
        break-inside: avoid;
        padding: 6pt 10pt;
    }

    body.nsp-mode .nsp-sa-step-num {
        background: #000 !important;
        color: #fff !important;
        width: 16pt;
        height: 16pt;
        font-size: 8pt;
    }

    body.nsp-mode .nsp-sa-step-label {
        color: #000 !important;
        font-size: 9.5pt;
    }

    body.nsp-mode .nsp-print-only {
        font-size: 9.5pt;
        color: #000 !important;
    }

    body.nsp-mode .nsp-sa-patient-row label {
        color: #000 !important;
        font-size: 9pt;
    }

    body.nsp-mode .nsp-sa-patient-input {
        border: 0.5pt solid #aaa !important;
        background: transparent !important;
        color: #000 !important;
        font-size: 9pt;
    }

    /* ── Handout disclaimer ────────────────────────────────────────── */
    .handout-disclaimer {
        display: block !important;
        margin-top: 14pt;
        padding-top: 6pt;
        border-top: 0.5pt solid #ccc;
        border-top-color: #ccc !important;
        font-size: 7.5pt;
        color: #888 !important;
        font-style: italic;
        font-weight: 400 !important;
        text-align: center;
    }
}
