/* =============================================================================
   Patient Wellness Report — Design System v6
   Inter (UI) · JetBrains Mono (values) · Light-blue gradient background
============================================================================= */

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

/* ─── Tokens ──────────────────────────────────────────────────────────────── */
:root {
    --blue-800: #1E40AF; --blue-700: #1D4ED8; --blue-600: #2563EB;
    --blue-500: #3B82F6; --blue-200: #BFDBFE; --blue-100: #DBEAFE;
    --blue-50:  #EFF6FF;

    --slate-900: #0F172A; --slate-800: #1E293B; --slate-700: #334155;
    --slate-600: #475569; --slate-500: #64748B; --slate-400: #94A3B8;
    --slate-300: #CBD5E1; --slate-200: #E2E8F0; --slate-100: #F1F5F9;
    --slate-50:  #F8FAFC; --white: #FFFFFF;

    --green-700: #15803D; --green-600: #16A34A; --green-100: #DCFCE7;
    --amber-600: #D97706; --amber-100: #FEF3C7;
    --red-600:   #DC2626; --red-100:   #FEE2E2;

    /* Section accent pills */
    --accent-complaint:  #7C3AED;
    --accent-vitals:     #2563EB;
    --accent-labs:       #0891B2;
    --accent-diagnosis:  #D97706;
    --accent-medication: #16A34A;
    --accent-procedure:  #DC2626;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

    --page-pad:  32px;
    --card-pad:  20px;

    --r-card: 20px;
    --r-inner: 12px;
    --r-pill:  100px;

    --shadow-card:  0 2px 12px rgba(15,23,42,.06);
    --shadow-hover: 0 8px 32px rgba(15,23,42,.10);
    --shadow-modal: 0 24px 64px rgba(15,23,42,.22);

    --ease: 130ms ease;
    --border-xs: var(--slate-100);
    --border:    var(--slate-200);
}

/* ─── Base ────────────────────────────────────────────────────────────────── */
html, body {
    height: 100%;
    overflow: auto;
}

body {
    font-family: var(--font-sans);
    font-size: 13px;
    background: linear-gradient(180deg, #EFF6FF 0%, #F0F7FF 25%, #FFFFFF 100%);
    background-attachment: fixed;
    color: var(--slate-900);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ─── Patient Identity Header ────────────────────────────────────────────── */
.patient-header {
    background: var(--white);
    box-shadow: var(--shadow-card);
    border-bottom: 1px solid var(--border-xs);
    position: sticky;
    top: 0;
    z-index: 100;
    margin-bottom: 24px;
}

/* Inner wrapper — matches dashboard grid width and padding exactly */
.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 14px var(--page-pad) 10px;
}

/* Left-aligned name + date */
.patient-header-main {
    text-align: left;
    margin-bottom: 8px;
}

.patient-name {
    font-size: 22px;
    font-weight: 800;
    color: var(--slate-900);
    letter-spacing: -0.4px;
    line-height: 1.2;
}

.patient-datetime {
    font-size: 12px;
    font-weight: 500;
    color: var(--slate-400);
    margin-top: 3px;
}

/* Left-aligned info bar — flush with content above and grid below */
.patient-info-bar {
    display: flex;
    justify-content: flex-start;
}

.info-bar-inner {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 2px 0;
    gap: 0;
}

.info-chip {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 16px 4px 12px;
    border-right: 1px solid var(--blue-200);
}

.info-chip:first-child { padding-left: 0; }
.info-chip:last-child  { border-right: none; padding-right: 0; }

/* Hide the old separator spans — dividers now come from chip border-right */
.info-bar-sep { display: none; }

.info-chip-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--slate-400);
}

.info-chip-value {
    font-size: 12px;
    font-weight: 700;
    color: var(--slate-700);
}

.info-chip-value.mono { font-family: var(--font-mono); font-size: 11px; }

.info-bar-sep {
    width: 1px;
    height: 16px;
    background: var(--slate-300);
    flex-shrink: 0;
}

/* ─── Dashboard ──────────────────────────────────────────────────────────── */
.dashboard {
    max-width: 1400px;
    margin: 20px auto var(--page-pad);
    padding: 0 var(--page-pad);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1px;
    background: #E5E7EB;  /* 1px gaps show as seamless section dividers */
    border-radius: var(--r-card);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

/* ─── Category Section ───────────────────────────────────────────────────── */
.category-section {
    background: var(--white);
    border: none;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 220px;
    max-height: 380px;
}

.category-section:hover { background: #FAFCFF; }

/* ─── Section Tab Header ─────────────────────────────────────────────────── */
.section-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-bottom: 1px solid var(--border-xs);
    flex-shrink: 0;
    background: var(--white);
}

.section-pill {
    display: block;
    width: 4px;
    height: 20px;
    border-radius: 2px;
    flex-shrink: 0;
    background: var(--blue-600);
}

[data-category="CHIEF_COMPLAINT"]       .section-pill { background: var(--accent-complaint);  }
[data-category="VITALS_SUMMARY"]        .section-pill { background: var(--accent-vitals);     }
[data-category="INVESTIGATION_SUMMARY"] .section-pill { background: var(--accent-labs);       }
[data-category="DIAGNOSIS"]             .section-pill { background: var(--accent-diagnosis);  }
[data-category="MEDICATION"]            .section-pill { background: var(--accent-medication); }
[data-category="PROCEDURE"]             .section-pill { background: var(--accent-procedure);  }

.section-tab-icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    color: var(--slate-400);
}

.section-tab-title {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.9px;
    color: var(--slate-600);
    flex: 1;
}

.section-tab-count {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--r-pill);
    background: var(--slate-100);
    color: var(--slate-500);
}

/* Remove section-tab border-bottom for table sections — blue header is flush */
[data-category="VITALS_SUMMARY"]        .section-tab,
[data-category="INVESTIGATION_SUMMARY"] .section-tab,
[data-category="MEDICATION"]            .section-tab,
[data-category="PROCEDURE"]             .section-tab { border-bottom: none; }

/* ─── Blue Table Column Header ───────────────────────────────────────────── */
.table-col-header {
    display: flex;
    align-items: center;
    padding: 6px 16px;
    background: var(--blue-600);
    flex-shrink: 0;
}

.table-col-header span {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: rgba(255,255,255,.88);
    flex: 1;
}

.table-col-header .col-trend {
    flex: 0 0 68px;
    text-align: right;
}

/* ─── Card Container + Scrollbar ─────────────────────────────────────────── */
.card-container {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}

.card-container:hover { scrollbar-color: var(--slate-300) transparent; }
.card-container::-webkit-scrollbar         { width: 4px; }
.card-container::-webkit-scrollbar-track  { background: transparent; }
.card-container::-webkit-scrollbar-thumb  { background: transparent; border-radius: 2px; }
.card-container:hover::-webkit-scrollbar-thumb { background: var(--slate-300); }

/* ─── Generic Data Row (Chief Complaint / fallback) ──────────────────────── */
.data-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 14px;
    border-bottom: 1px solid var(--border-xs);
    gap: 10px;
    min-height: 36px;
    transition: background var(--ease);
    cursor: pointer;
}

.data-row:last-child  { border-bottom: none; }
.data-row:hover       { background: var(--blue-50); }

.data-row-content     { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }

.data-row-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--slate-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-row-subtitle {
    font-size: 10px;
    color: var(--slate-400);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-row-value { display: flex; align-items: baseline; gap: 4px; flex-shrink: 0; }

.data-row-number {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 700;
    color: var(--slate-900);
}

.data-row-number.abnormal {
    text-decoration: underline;
    text-decoration-color: var(--slate-900);
    text-underline-offset: 3px;
}

.data-row-unit  { font-size: 10px; color: var(--slate-400); }

/* Ref-range — significantly muted, right-aligned, never competes with measured value */
.data-row-range {
    font-family: var(--font-mono);
    font-size: 10px;
    color: #94A3B8;
    flex: 0 0 72px;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.75;
}

/* ─── Vital Row — Dense inline: dot · label · pill · sparkline ───────────── */
.vital-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-bottom: 1px solid var(--border-xs);
    transition: background var(--ease);
    cursor: pointer;
}

.vital-row:last-child { border-bottom: none; }
.vital-row:hover      { background: var(--blue-50); }

.vital-row-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.vital-row-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--slate-600);
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vital-row-pill {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 700;
    color: var(--slate-900);
    background: var(--slate-100);
    border-radius: 20px;
    padding: 2px 9px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Sparkline: fixed 80px so all rows align consistently */
.vital-row-sparkline {
    width: 80px;
    height: 20px;
    flex-shrink: 0;
}

.vital-row-sparkline svg { width: 100%; height: 100%; }

/* ─── Table Data Row (Labs / Meds / Procedures) ──────────────────────────── */
.table-data-row {
    display: flex;
    align-items: center;
    padding: 7px 14px;
    border-bottom: 1px solid var(--border-xs);
    gap: 10px;
    min-height: 36px;
    transition: background var(--ease);
    cursor: pointer;
}

.table-data-row:last-child { border-bottom: none; }
.table-data-row:hover      { background: var(--blue-50); }

.table-row-trend {
    width: 80px;           /* matches vital-row-sparkline for visual consistency */
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.table-row-trend .sparkline-mini { width: 76px; height: 22px; }
.table-row-trend--empty          { font-size: 11px; color: var(--slate-400); }

.table-row-status {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--green-700);
    background: var(--green-100);
    padding: 2px 7px;
    border-radius: var(--r-pill);
    white-space: nowrap;
}

/* ─── Diagnosis Cards ────────────────────────────────────────────────────── */
.dx-card {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 9px 14px;
    border-bottom: 1px solid var(--border-xs);
    transition: background var(--ease);
    cursor: pointer;
}

.dx-card:last-child { border-bottom: none; }
.dx-card:hover      { background: var(--blue-50); }

.dx-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.dx-card-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--slate-900);
    line-height: 1.3;
    flex: 1;
}

.dx-card-status {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: var(--r-pill);
    flex-shrink: 0;
    margin-top: 2px;
}

.dx-card-status--active   { background: var(--blue-100);   color: var(--blue-700);  }
.dx-card-status--resolved { background: var(--green-100);  color: var(--green-700); }
.dx-card-status--default  { background: var(--slate-100);  color: var(--slate-500); }

.dx-card-desc {
    font-size: 11px;
    color: var(--slate-500);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.dx-card-date {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--slate-400);
}

/* ─── Sparklines ─────────────────────────────────────────────────────────── */
.sparkline-mini { width: 60px; height: 22px; flex-shrink: 0; }
.sparkline-mini svg { width: 100%; height: 100%; }

.sparkline-line {
    fill: none;
    stroke: var(--blue-700);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sparkline-area  { fill: var(--blue-500); opacity: 0.07; }
.sparkline-dot   { fill: var(--slate-400); }
.sparkline-dot.latest { fill: var(--blue-600); }

/* Full-width sparkline for vitals right panel */
.sparkline {
    width: 100%;
    height: 80px;
}

/* ─── Status Indicator ───────────────────────────────────────────────────── */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--slate-400);
    padding: 2px 7px;
    border-radius: var(--r-pill);
    background: var(--slate-100);
}

.status-indicator::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--slate-400);
}

.status-indicator.active, .status-indicator.resulted, .status-indicator.completed {
    color: var(--green-700);
    background: var(--green-100);
}

.status-indicator.active::before, .status-indicator.resulted::before, .status-indicator.completed::before {
    background: var(--green-600);
}

/* ─── Empty State ────────────────────────────────────────────────────────── */
.empty-state {
    padding: 24px;
    text-align: center;
    color: var(--slate-400);
    font-size: 12px;
    font-weight: 500;
}

.empty-state::before {
    content: '—';
    display: block;
    margin-bottom: 8px;
    color: var(--slate-300);
    font-size: 18px;
}

/* ─── Entity Detail Modal ────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.52);
    backdrop-filter: blur(6px);
    display: none;                  /* toggled by JS */
    align-items: center;
    justify-content: center;
    z-index: 9000;
    padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal-panel {
    background: var(--white);
    border-radius: var(--r-card);
    box-shadow: var(--shadow-modal);
    width: 100%;
    max-width: 480px;
    max-height: 78vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modal-in 180ms ease;
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 16px;
    border-bottom: 1px solid var(--border-xs);
    flex-shrink: 0;
}

.modal-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--slate-900);
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Inline status + category badges shown just below title
.modal-title-sub {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    padding: 8px 16px 4px;
    flex-shrink: 0;
} */

.modal-badge {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: var(--r-pill);
}

.modal-badge--status { background: var(--blue-100);   color: var(--blue-700);  }
.modal-badge--cat    { background: var(--slate-100);  color: var(--slate-600); }
.modal-badge--source { background: var(--amber-100);  color: var(--amber-600); }

.modal-close {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: var(--slate-100);
    color: var(--slate-500);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 12px;
    transition: background var(--ease);
}

.modal-close:hover { background: var(--slate-200); }

.modal-body {
    overflow-y: auto;
    padding: 0 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 0;
    text-align: left; /* explicit left-align throughout modal */
}

.modal-section {
    padding-top: 14px;
}

.modal-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--blue-600);
    margin-bottom: 10px;
}

/* Meta grid */
.modal-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
}

.modal-meta-item {
    background: var(--slate-50);
    border: 1px solid var(--border-xs);
    border-radius: 10px;
    padding: 10px 12px;
}

.modal-meta-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--slate-400);
    margin-bottom: 4px;
}

.modal-meta-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--slate-900);
    word-break: break-all;
}

.modal-meta-value.mono { font-family: var(--font-mono); font-size: 12px; }

/* Confidence bar */
.modal-confidence-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.modal-confidence-track {
    flex: 1;
    height: 4px;
    background: var(--slate-200);
    border-radius: 2px;
    overflow: hidden;
}

.modal-confidence-fill {
    height: 100%;
    background: var(--blue-600);
    border-radius: 2px;
}

.modal-confidence-pct {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    color: var(--blue-700);
    flex-shrink: 0;
}

/* Source type badge */
.modal-source-badge {
    display: inline-flex;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: var(--r-pill);
    background: var(--blue-100);
    color: var(--blue-700);
}

/* Extracted text */
.modal-extracted-text {
    font-size: 12px;
    color: var(--slate-600);
    background: var(--slate-50);
    border-radius: 8px;
    border-left: 3px solid var(--blue-200);
    padding: 10px 12px;
    line-height: 1.6;
    font-style: italic;
}

/* History list */
.modal-history { display: flex; flex-direction: column; }

.modal-history-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-xs);
}

.modal-history-row:last-child { border-bottom: none; }

.modal-history-date {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--slate-400);
    flex: 0 0 110px;
}

.modal-history-value {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 700;
    color: var(--slate-900);
    flex: 1;
}

.modal-history-phase {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--slate-500);
    background: var(--slate-100);
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.modal-history-empty {
    font-size: 12px;
    color: var(--slate-400);
    padding: 8px 0;
}

/* Clinical JSON */
.modal-json {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--slate-600);
    background: var(--slate-50);
    border: 1px solid var(--border-xs);
    border-radius: 10px;
    padding: 14px;
    overflow-x: auto;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 240px;
    overflow-y: auto;
}

/* ─── Loading Overlay ────────────────────────────────────────────────────── */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(248,250,252,.92);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay.hidden { display: none; }

.loading-card {
    background: var(--white);
    border-radius: var(--r-card);
    box-shadow: var(--shadow-hover);
    padding: 40px 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 2.5px solid var(--slate-200);
    border-top-color: var(--blue-600);
    border-radius: 50%;
    animation: spin 600ms linear infinite;
}

.spinner-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--slate-400);
}

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

/* ─── Legacy support (createDataRow / createMemoryCard fallback) ─────────── */
.memory-card { border-bottom: 1px solid var(--border-xs); transition: background var(--ease); }
.memory-card:hover { background: var(--blue-50); }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; gap: 10px; }
.card-title  { font-size: 13px; font-weight: 600; color: var(--slate-900); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-status { font-size: 9px; font-weight: 700; text-transform: uppercase; padding: 2px 7px; border-radius: var(--r-pill); background: var(--slate-100); color: var(--slate-500); }
.card-status.active, .card-status.resulted, .card-status.completed { color: var(--green-700); background: var(--green-100); }
.card-content { padding: 0 14px 10px; }
.card-description { font-size: 12px; color: var(--slate-600); line-height: 1.5; margin-bottom: 6px; }
.value-display { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.value-numeric { font-family: var(--font-mono); font-size: 18px; font-weight: 700; color: var(--slate-900); }
.value-numeric.abnormal { text-decoration: underline; text-decoration-color: var(--slate-900); text-underline-offset: 3px; }
.value-unit   { font-size: 12px; color: var(--slate-400); }
.value-range  { font-size: 10px; color: var(--slate-400); margin-left: 6px; padding-left: 6px; border-left: 1px solid var(--border); }
.value-text   { font-size: 13px; color: var(--slate-600); line-height: 1.5; }
.badges-container { padding: 0 14px 6px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-mono); font-size: 9px; font-weight: 500; background: var(--slate-100); color: var(--slate-600); padding: 3px 8px; border-radius: 4px; border: 1px solid var(--border); }
.card-metadata { padding: 6px 14px 10px; display: flex; gap: 16px; border-top: 1px solid var(--border-xs); }
.metadata-item { display: flex; flex-direction: column; gap: 1px; }
.metadata-label { font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--slate-400); }
.metadata-value { font-size: 11px; color: var(--slate-600); }
.code-pill { font-family: var(--font-mono); font-size: 9px; padding: 2px 6px; border-radius: 4px; background: var(--slate-100); color: var(--slate-600); border: 1px solid var(--border); }
.phase-filter, .footer-grid, .combined-section { display: none; }

/* ─── Responsive — single column on mobile / Flutter WebView ─────────────── */
@media (max-width: 768px) {
    :root { --page-pad: 0px; }

    .patient-header   { position: static; }
    .header-inner     { padding: 16px 16px 14px; }
    .patient-name     { font-size: 22px; }
    .info-bar-inner   { border-radius: 12px; }

    .dashboard        { margin: 0; padding: 0; }
    .dashboard-grid   {
        border-radius: 0;
        grid-template-columns: 1fr;
        row-gap: 20px;
        padding: 0 16px;
        background: transparent;
    }
    .category-section {
        max-height: none;
        border: 1px solid var(--slate-200);
        border-radius: 16px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }

    /* Left-align header on mobile — prevent any centering regression */
    .patient-header-main { text-align: left; }
    .patient-info-bar     { justify-content: flex-start; }
    .info-bar-inner       { justify-content: flex-start; }

    .vitals-split { grid-template-columns: 1fr; }
    .vitals-chart-panel { border-top: 1px solid var(--border-xs); border-right: none; min-height: 120px; }

    .modal-panel  { max-height: 90vh; }
}

/* ─── Print ──────────────────────────────────────────────────────────────── */
@media print {
    body            { background: white; }
    .patient-header { position: static; box-shadow: none; }
    .loading-overlay, .modal-overlay { display: none !important; }
    .dashboard      { margin: 8px; padding: 0; }
    .dashboard-grid { grid-template-columns: repeat(2, 1fr); border-radius: 0; }
    .category-section { max-height: none; }
    .card-container { overflow: visible; }
}
