/* ═══════════════════════════════════════════════════════════════════
   Repix / Synapse — Liquid Glass Design System
   Inspired by Apple Intelligence (apple.com/apple-intelligence)
   ═══════════════════════════════════════════════════════════════════ */

/* ── Design Tokens ──────────────────────────────────────────────── */
:root {
    /* Surface (pure white) */
    --bg-body: #ffffff;

    /* Subtle iridescent tints for ambient depth */
    --iris-pink: rgba(255, 182, 193, 0.18);
    --iris-blue: rgba(186, 220, 255, 0.20);
    --iris-mint: rgba(190, 245, 220, 0.16);
    --iris-violet: rgba(220, 200, 255, 0.18);

    /* Glass */
    --glass-bg: rgba(255, 255, 255, 0.55);
    --glass-bg-solid: rgba(255, 255, 255, 0.74);
    --glass-border: rgba(255, 255, 255, 0.55);
    --glass-border-soft: rgba(15, 23, 42, 0.08);
    --glass-shadow:
        0 20px 50px rgba(15, 23, 42, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.75);
    --glass-blur: blur(30px) saturate(1.8);

    /* Apple-style text greys */
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-muted: #86868b;

    /* Status colors (clinical semantics — DO NOT remove) */
    --status-high: #7c3aed;
    --status-low: #dc2626;
    --status-normal: #059669;
    --status-abnormal: #d97706;
    --status-info: #2563eb;
    --status-critical: #dc2626;
    --status-warning: #d97706;

    /* Radii */
    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 24px;
    --radius-card: 28px;
    --radius-pill: 999px;

    /* Shadows */
    --shadow-sm: 0 2px 10px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.10);

    /* Motion */
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display",
        "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "ss01", "cv11";
    letter-spacing: -0.01em;
}

/* Faint iridescent drift behind glass */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 50% at 18% 25%, var(--iris-pink), transparent 70%),
        radial-gradient(ellipse 55% 55% at 82% 18%, var(--iris-blue), transparent 70%),
        radial-gradient(ellipse 50% 50% at 78% 82%, var(--iris-mint), transparent 70%),
        radial-gradient(ellipse 45% 40% at 22% 78%, var(--iris-violet), transparent 70%);
    z-index: -1;
    animation: irisDrift 32s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes irisDrift {
    0% {
        transform: translate(0, 0) scale(1);
    }
    50% {
        transform: translate(-20px, 14px) scale(1.05);
    }
    100% {
        transform: translate(14px, -10px) scale(1.02);
    }
}

/* ── Glass Card ─────────────────────────────────────────────────── */
.glass {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border-soft);
    border-radius: var(--radius-card);
    box-shadow: var(--glass-shadow);
    position: relative;
    overflow: hidden;
}

.glass::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.85),
        transparent
    );
    pointer-events: none;
}

/* ── Layout ─────────────────────────────────────────────────────── */
.container {
    max-width: 1040px;
    margin: 0 auto;
    padding: 16px 24px 80px;
}

/* ── 2×2 Form Grid (iPad optimized) ─────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.form-grid > .glass.form-card {
    margin-bottom: 0;
}

.form-grid textarea {
    min-height: 160px;
}

.form-grid .dropzone {
    padding: 24px 16px;
}

/* ── Header Bar ─────────────────────────────────────────────────── */
.header {
    margin-bottom: 40px;
}

.header-info-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 18px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border-soft);
    border-radius: var(--radius-card);
    box-shadow: var(--glass-shadow);
    position: relative;
    z-index: 1001;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.header-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 8px;
}

.header-right {
    justify-content: flex-end;
}

.header-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ── Site Logo (uses the high-res PNG) ────────────────────────── */
.site-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
}

.site-logo img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.12));
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.12));
    }
    50% {
        transform: scale(1.06);
        filter: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.18));
    }
}

/* ── Pill Controls (monochrome glass) ──────────────────────────── */
.header-pill,
.header-files-btn,
.header-submit-btn,
.btn-icon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--radius-pill);
    font-family: inherit;
    font-weight: 500;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    color: var(--text-primary);
    background: var(--glass-bg-solid);
    backdrop-filter: blur(16px) saturate(1.5);
    -webkit-backdrop-filter: blur(16px) saturate(1.5);
    border: 1px solid var(--glass-border-soft);
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.header-pill svg,
.header-files-btn svg,
.header-submit-btn svg,
.btn-icon svg {
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    width: 16px;
    height: 16px;
}

.header-pill {
    height: 38px;
    padding: 0 20px;
    font-size: 0.85rem;
}

.header-files-btn {
    padding: 8px 16px;
    font-size: 0.82rem;
    font-weight: 500;
}

.header-submit-btn {
    padding: 8px 20px;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.header-files-btn:hover,
.header-pill:hover,
.header-submit-btn:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.header-submit-btn:active {
    transform: scale(0.97);
}

.header-submit-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

.header-submit-btn.loading .btn-label {
    opacity: 0.5;
}

.header-submit-btn.loading .spinner {
    display: block;
}

.header-submit-btn .spinner {
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(29, 29, 31, 0.18);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

.btn-icon {
    padding: 6px 12px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.btn-icon:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.85);
    transform: translateY(-1px);
}

.btn-icon--icon-only {
    padding: 6px 8px;
}

/* ── Container Navigation (monochrome segmented) ───────────────── */
.container-nav {
    display: flex;
    gap: 6px;
    margin: 22px 0;
    padding: 6px;
    flex-wrap: wrap;
    justify-content: center;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border-soft);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.container-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: none;
    cursor: pointer;
    transition: all var(--transition);
    flex: 1;
    min-width: 130px;
    max-width: 220px;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid transparent;
    box-shadow: none;
    text-decoration: none;
}

.container-nav-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.container-nav-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.55);
}

.container-nav-btn.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.85);
    border-color: var(--glass-border-soft);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

/* Form section */
.form-section {
    margin-bottom: 20px;
}

.header-divider {
    width: 1px;
    height: 24px;
    background: var(--glass-border-soft);
    margin: 0 12px;
    flex-shrink: 0;
}

/* ── Form Card ──────────────────────────────────────────────────── */
.form-card {
    padding: 36px 32px;
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 28px;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: 0.01em;
}

.form-group .hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    line-height: 1.5;
}

textarea {
    width: 100%;
    min-height: 200px;
    padding: 16px 18px;
    background: var(--glass-bg-solid);
    backdrop-filter: blur(12px) saturate(1.4);
    -webkit-backdrop-filter: blur(12px) saturate(1.4);
    border: 1px solid var(--glass-border-soft);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.65;
    resize: vertical;
    transition: border-color var(--transition), box-shadow var(--transition),
        background var(--transition);
}

textarea:focus {
    outline: none;
    border-color: rgba(29, 29, 31, 0.18);
    box-shadow: 0 0 0 4px rgba(29, 29, 31, 0.06);
    background: rgba(255, 255, 255, 0.92);
}

textarea::placeholder {
    color: var(--text-muted);
}

/* ── Field Grid (demographics & vitals) ─────────────────────────── */
.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}

.field label {
    display: block;
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.field input[type="text"],
.field select {
    width: 100%;
    padding: 12px 14px;
    background: var(--glass-bg-solid);
    backdrop-filter: blur(12px) saturate(1.4);
    -webkit-backdrop-filter: blur(12px) saturate(1.4);
    border: 1px solid var(--glass-border-soft);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.92rem;
    transition: border-color var(--transition), box-shadow var(--transition),
        background var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
}

.field input[type="text"]:focus,
.field select:focus {
    outline: none;
    border-color: rgba(29, 29, 31, 0.2);
    box-shadow: 0 0 0 4px rgba(29, 29, 31, 0.06);
    background: rgba(255, 255, 255, 0.94);
}

.field input[type="text"]::placeholder {
    color: var(--text-muted);
}

/* ── Info Grid (report demographics) ────────────────────────────── */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0 24px;
}

/* ── Patient Demographics Grid (3-column) ───────────────────────── */
.patient-demo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0 24px;
}

.patient-demo-grid .kv-row {
    border-bottom: 1px solid rgba(15, 23, 42, 0.05);
}

.patient-diagnosis-row {
    margin-top: 10px;
    border-top: 1px solid var(--glass-border-soft);
    padding-top: 14px;
    border-bottom: none !important;
}

@media (max-width: 600px) {
    .patient-demo-grid {
        grid-template-columns: 1fr;
    }
}

/* ── HPI Two-Column Grid ────────────────────────────────────────── */
.hpi-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 24px;
}

@media (max-width: 600px) {
    .hpi-two-col {
        grid-template-columns: 1fr;
    }
}

/* ── Dropzone ───────────────────────────────────────────────────── */
.dropzone {
    border: 1.5px dashed rgba(15, 23, 42, 0.18);
    border-radius: var(--radius-lg);
    padding: 36px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    background: var(--glass-bg-solid);
    backdrop-filter: blur(12px) saturate(1.4);
    -webkit-backdrop-filter: blur(12px) saturate(1.4);
    position: relative;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.dropzone:hover,
.dropzone.dragover {
    border-color: rgba(15, 23, 42, 0.32);
    background: rgba(255, 255, 255, 0.85);
}

.dropzone__icon {
    font-size: 2.2rem;
    margin-bottom: 10px;
    opacity: 0.5;
    color: var(--text-secondary);
}

.dropzone__text {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.dropzone__text span {
    color: var(--text-primary);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* File chips — monochrome (per design) */
.file-list {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--glass-border-soft);
    border-radius: 8px;
    font-size: 0.78rem;
    color: var(--text-primary);
    animation: chipIn 0.3s ease;
    transition: all 0.2s ease;
}

.file-chip:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: translateY(-1px);
}

.file-chip--pdf {
    background: rgba(255, 255, 255, 0.7);
    border-color: var(--glass-border-soft);
    color: var(--text-primary);
}

.file-chip__icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.file-chip__name {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.file-chip__size {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-left: 2px;
}

.file-chip__remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 4px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.08);
    color: inherit;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.file-chip__remove:hover {
    background: rgba(15, 23, 42, 0.18);
    color: var(--text-primary);
    transform: scale(1.1);
}

.file-count {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.05);
    width: 100%;
}

@keyframes chipIn {
    from {
        opacity: 0;
        transform: scale(0.85);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ── Primary Buttons ────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 32px;
    border: 1px solid var(--glass-border-soft);
    border-radius: var(--radius-pill);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition),
        background var(--transition);
    letter-spacing: 0.01em;
    text-decoration: none;
    color: var(--text-primary);
    background: var(--glass-bg-solid);
    backdrop-filter: blur(16px) saturate(1.5);
    -webkit-backdrop-filter: blur(16px) saturate(1.5);
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: rgba(29, 29, 31, 0.92);
    color: #fff;
    border-color: rgba(29, 29, 31, 0.92);
    box-shadow: 0 4px 20px rgba(29, 29, 31, 0.18);
    width: 100%;
}

.btn-primary:hover {
    background: #000;
    box-shadow: 0 6px 24px rgba(29, 29, 31, 0.25);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.9);
}

.btn-primary .spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.65s linear infinite;
}

.btn-primary.loading .spinner {
    display: block;
}

.btn-primary.loading .btn-label {
    opacity: 0.5;
}

/* ── Flash Message ──────────────────────────────────────────────── */
.flash {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    background: rgba(220, 38, 38, 0.08);
    backdrop-filter: blur(10px) saturate(1.4);
    -webkit-backdrop-filter: blur(10px) saturate(1.4);
    border: 1px solid rgba(220, 38, 38, 0.2);
    color: var(--status-low);
    font-size: 0.88rem;
    margin-bottom: 24px;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ═══════════════════════════════════════════════════════════════════
   REPORT PAGE
   ═══════════════════════════════════════════════════════════════════ */

.report-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 48px 24px 80px;
}

/* ── Report Hero Header ────────────────────────────────────────── */
.report-hero {
    text-align: center;
    padding: 32px 28px 24px;
    margin-bottom: 28px;
    position: relative;
    overflow: hidden;
}

.report-hero::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(15, 23, 42, 0.18),
        transparent
    );
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.report-hero__logo {
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
}

.report-hero__logo img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.12));
}

.report-hero__pills {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Monochrome hero pills */
.hero-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    backdrop-filter: blur(14px) saturate(1.4);
    -webkit-backdrop-filter: blur(14px) saturate(1.4);
    border: 1px solid var(--glass-border-soft);
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
    background: var(--glass-bg-solid);
    color: var(--text-secondary);
}

.hero-pill svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.hero-pill--gold,
.hero-pill--sky,
.hero-pill--muted {
    background: var(--glass-bg-solid);
    border-color: var(--glass-border-soft);
    color: var(--text-secondary);
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

/* ── Section Panels ─────────────────────────────────────────────── */
.section-panel {
    padding: 28px 28px 24px;
    margin-bottom: 24px;
    transition: box-shadow var(--transition);
}

.section-panel:hover {
    box-shadow: var(--shadow-lg);
}

/* ── Section body text ──────────────────────────────────────────── */
.section-panel .kv-key,
.section-panel .kv-value,
.section-panel .bullet-list li,
.section-panel .sub-label,
.section-panel .med-table td,
.section-panel .lab-table td,
.section-panel p,
.section-panel .empty {
    color: var(--text-secondary);
}

.section-panel .kv-key {
    color: var(--text-muted);
}

/* ── Pill-shaped Glassmorphic Section Title (monochrome) ────────── */
.section-title {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 9px 18px;
    border-radius: var(--radius-pill);
    margin-bottom: 22px;
    background: var(--glass-bg-solid);
    backdrop-filter: blur(14px) saturate(1.4);
    -webkit-backdrop-filter: blur(14px) saturate(1.4);
    border: 1px solid var(--glass-border-soft);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
    color: var(--text-primary);
    transition: box-shadow var(--transition), transform var(--transition);
}

.section-title:hover {
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.85);
    transform: translateY(-1px);
}

/* Per-section title variations all collapse to monochrome */
.section-title--patient,
.section-title--vitals,
.section-title--hpi,
.section-title--meds,
.section-title--history,
.section-title--labs,
.section-title--patient-header {
    color: var(--text-primary);
    background: var(--glass-bg-solid);
    border-color: var(--glass-border-soft);
}

/* ── Patient Info Header Pills ──────────────────────────────────── */
.patient-section-header {
    display: flex;
    align-items: center;
    margin-bottom: 22px;
    flex-wrap: wrap;
}

.section-title--patient-header {
    margin-bottom: 0 !important;
}

.mrn-text {
    font-weight: 400;
    font-size: 0.75rem;
    opacity: 0.8;
    margin-left: 8px;
}

.patient-header-pills {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.info-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    backdrop-filter: blur(12px) saturate(1.3);
    -webkit-backdrop-filter: blur(12px) saturate(1.3);
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
    text-transform: none;
    background: var(--glass-bg-solid);
    border: 1px solid var(--glass-border-soft);
    color: var(--text-secondary);
}

.info-pill svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.info-pill--sky,
.info-pill--gold,
.info-pill--muted {
    background: var(--glass-bg-solid);
    border-color: var(--glass-border-soft);
    color: var(--text-secondary);
}

.patient-mrn {
    font-weight: 500;
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-left: 12px;
    background: var(--glass-bg-solid);
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--glass-border-soft);
}

.gender-value {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.gender-value svg {
    width: 16px;
    height: 16px;
}

/* ── Section Logo inside pill (monochrome) ──────────────────────── */
.section-logo {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.06);
    border: 1px solid var(--glass-border-soft);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
    flex-shrink: 0;
}

.section-logo svg {
    width: 12px;
    height: 12px;
    stroke: var(--text-secondary);
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── Vitals Inline Row ──────────────────────────────────────────── */
.vitals-inline-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.vital-inline {
    display: flex;
    align-items: flex-start;
    gap: 5px;
    padding: 0 10px;
    border-left: 1px solid var(--glass-border-soft);
    white-space: nowrap;
}

.vital-inline:first-of-type,
.section-title + .vital-inline {
    border-left: none;
    padding-left: 0;
}

.vital-inline-icon {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}

.vital-inline-icon svg {
    width: 22px;
    height: 22px;
}

.vital-label {
    font-size: 0.66rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.vital-value {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text-primary);
    line-height: 1.1;
    letter-spacing: -0.01em;
}

.vital-value small {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-muted);
}

.vital-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.05;
}

.vital-data {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.vital-unit {
    font-size: 0.58rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

/* ── Key-Value Rows ─────────────────────────────────────────────── */
.kv-row {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(15, 23, 42, 0.05);
}

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

.kv-key {
    flex: 0 0 180px;
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.kv-value {
    flex: 1;
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* ── Bullet Lists ───────────────────────────────────────────────── */
.bullet-list {
    list-style: none;
    padding: 0;
}

.bullet-list li {
    position: relative;
    padding-left: 20px;
    margin-bottom: 6px;
    font-size: 0.92rem;
    color: var(--text-primary);
}

.bullet-list li::before {
    content: '•';
    position: absolute;
    left: 4px;
    color: var(--text-muted);
    font-weight: 700;
}

/* ── Tables ─────────────────────────────────────────────────────── */
.med-table,
.lab-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.med-table thead,
.lab-table thead {
    position: sticky;
    top: 0;
}

.med-table th,
.lab-table th {
    text-align: left;
    padding: 12px 14px;
    font-weight: 600;
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 1px solid var(--glass-border-soft);
    background: var(--glass-bg);
}

.med-table td,
.lab-table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.04);
    color: var(--text-primary);
    vertical-align: top;
}

.med-table tbody tr:hover,
.lab-table tbody tr:hover {
    background: rgba(15, 23, 42, 0.02);
}

/* Status-colored lab row tints (KEEP — clinical semantics) */
.lab-table tbody tr.lab-row--high {
    background: rgba(124, 58, 237, 0.05);
}

.lab-table tbody tr.lab-row--low {
    background: rgba(220, 38, 38, 0.05);
}

/* ── Compact Lab Table ─────────────────────────────────────────── */
.lab-table--compact {
    font-size: 0.82rem;
}

.lab-table--compact th {
    padding: 10px 12px;
    font-size: 0.7rem;
}

.lab-table--compact td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.05);
}

.lab-table--compact td.lab-cell--high {
    background: rgba(124, 58, 237, 0.07);
    color: var(--status-high);
}

.lab-table--compact td.lab-cell--low {
    background: rgba(220, 38, 38, 0.07);
    color: var(--status-low);
}

.lab-table td.lab-cell--high {
    background: rgba(124, 58, 237, 0.06);
}

.lab-table td.lab-cell--low {
    background: rgba(220, 38, 38, 0.06);
}

.lab-table--compact .lab-arrow {
    font-size: 0.75rem;
    margin-right: 2px;
}

/* ── Lab Status Badges (KEEP status colors) ─────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.status-badge--high {
    background: rgba(124, 58, 237, 0.1);
    color: var(--status-high);
}

.status-badge--low {
    background: rgba(220, 38, 38, 0.1);
    color: var(--status-low);
}

.status-badge--normal {
    background: rgba(5, 150, 105, 0.1);
    color: var(--status-normal);
}

.status-badge--abnormal {
    background: rgba(217, 119, 6, 0.1);
    color: var(--status-abnormal);
}

.status-badge--unknown {
    background: rgba(15, 23, 42, 0.06);
    color: var(--text-muted);
}

/* ── Lab Value Arrows ───────────────────────────────────────────── */
.lab-arrow {
    display: inline-block;
    margin-left: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    vertical-align: middle;
}

.lab-arrow--high {
    color: var(--status-high);
}

.lab-arrow--low {
    color: var(--status-low);
}

/* ── Lab Results Grid (2-column cards) ──────────────────────────── */
.lab-results-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px 16px;
}

.lab-result-card {
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: var(--glass-bg-solid);
    border: 1px solid var(--glass-border-soft);
    transition: box-shadow var(--transition);
    backdrop-filter: blur(10px) saturate(1.3);
    -webkit-backdrop-filter: blur(10px) saturate(1.3);
}

.lab-result-card:hover {
    box-shadow: var(--shadow-sm);
}

.lab-result-card__name {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.lab-result-card__value {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.lab-result-card__value small {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

.lab-result-card__range {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
}

@media (max-width: 600px) {
    .lab-results-grid {
        grid-template-columns: 1fr;
    }
}

/* Status card variants (KEEP — clinical semantics) */
.lab-result-card--high {
    background: rgba(124, 58, 237, 0.07);
    border-color: rgba(124, 58, 237, 0.2);
}

.lab-result-card--high .lab-result-card__name {
    color: var(--status-high);
}

.lab-result-card--low {
    background: rgba(220, 38, 38, 0.07);
    border-color: rgba(220, 38, 38, 0.2);
}

.lab-result-card--low .lab-result-card__name {
    color: var(--status-low);
}

/* ── Abnormal Summary ───────────────────────────────────────────── */
.abnormal-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 16px 20px;
    border-radius: var(--radius-md);
    background: rgba(220, 38, 38, 0.05);
    border: 1px solid rgba(220, 38, 38, 0.14);
    margin-top: 16px;
    backdrop-filter: blur(10px) saturate(1.3);
    -webkit-backdrop-filter: blur(10px) saturate(1.3);
}

.abnormal-strip__item {
    font-size: 0.84rem;
    color: var(--status-low);
    font-weight: 500;
}

.all-normal-strip {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    background: rgba(5, 150, 105, 0.06);
    border: 1px solid rgba(5, 150, 105, 0.16);
    margin-top: 16px;
    font-size: 0.88rem;
    color: var(--status-normal);
    font-weight: 500;
    text-align: center;
    backdrop-filter: blur(10px) saturate(1.3);
    -webkit-backdrop-filter: blur(10px) saturate(1.3);
}

/* ── Lab Meta Row (date + stats inline) ─────────────────────────── */
.lab-meta-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    padding: 10px 0;
    border-bottom: 1px solid var(--glass-border-soft);
}

.lab-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 14px;
    border-radius: var(--radius-pill);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--glass-bg-solid);
    border: 1px solid var(--glass-border-soft);
    letter-spacing: 0.01em;
    backdrop-filter: blur(10px) saturate(1.3);
    -webkit-backdrop-filter: blur(10px) saturate(1.3);
}

.lab-meta--normal {
    color: var(--status-normal);
    background: rgba(5, 150, 105, 0.06);
    border-color: rgba(5, 150, 105, 0.18);
}

.lab-meta--abnormal {
    color: var(--status-low);
    background: rgba(220, 38, 38, 0.06);
    border-color: rgba(220, 38, 38, 0.18);
}

.lab-meta--high {
    color: var(--status-high);
    background: rgba(124, 58, 237, 0.06);
    border-color: rgba(124, 58, 237, 0.18);
}

.lab-meta--low {
    color: var(--status-low);
    background: rgba(220, 38, 38, 0.06);
    border-color: rgba(220, 38, 38, 0.18);
}

/* ── Stats Bar ──────────────────────────────────────────────────── */
.stats-bar {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.stat {
    text-align: center;
    padding: 14px 22px;
    border-radius: var(--radius-md);
    background: var(--glass-bg-solid);
    border: 1px solid var(--glass-border-soft);
    min-width: 100px;
    backdrop-filter: blur(10px) saturate(1.3);
    -webkit-backdrop-filter: blur(10px) saturate(1.3);
}

.stat__num {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.stat__label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 4px;
}

/* ── Action Bar ─────────────────────────────────────────────────── */
.action-bar {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 32px;
    flex-wrap: wrap;
}

/* ── Sub-section labels ─────────────────────────────────────────── */
.sub-label {
    font-weight: 600;
    font-size: 0.74rem;
    color: var(--text-muted);
    margin-top: 18px;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ── Allergy Chip (KEEP red — clinical semantics) ───────────────── */
.allergy-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    background: rgba(220, 38, 38, 0.07);
    border: 1px solid rgba(220, 38, 38, 0.2);
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
    color: var(--status-low);
    margin-right: 6px;
    margin-bottom: 6px;
}

/* ── Empty State ────────────────────────────────────────────────── */
.empty {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.88rem;
}

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .container,
    .report-container {
        padding: 28px 14px 60px;
    }

    .form-card,
    .section-panel {
        padding: 22px 18px;
    }

    .kv-row {
        flex-direction: column;
        gap: 2px;
    }

    .kv-key {
        flex: unset;
    }

    .header__logo {
        font-size: 1.5rem;
    }

    .report-header__title {
        font-size: 1.25rem;
    }

    .med-table,
    .lab-table {
        font-size: 0.8rem;
    }

    .med-table th,
    .lab-table th,
    .med-table td,
    .lab-table td {
        padding: 8px 6px;
    }
}

/* ── Print / A4 ───────────────────────────────────────────────── */
@page {
    size: A4;
    margin: 15mm 18mm;
}

@media print {
    body::before {
        display: none;
    }
    body {
        background: #fff !important;
    }

    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;

    .glass,
    .report-hero {
        background: #fff !important;
        backdrop-filter: none !important;
        box-shadow: none !important;
        border: 1px solid #e5e7eb !important;
        border-radius: 8px;
    }

    .report-hero {
        overflow: visible;
    }
    .report-hero::after {
        border-radius: 8px 8px 0 0;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .section-title {
        background: transparent !important;
        backdrop-filter: none !important;
        box-shadow: none !important;
        border: none !important;
        border-left: 3px solid var(--text-primary) !important;
        border-radius: 4px;
        padding: 8px 16px;
        color: var(--text-primary) !important;
    }
    .section-title:hover {
        transform: none;
    }

    .report-hero__logo img {
        print-color-adjust: exact;
    }

    .hero-pill,
    .info-pill {
        print-color-adjust: exact;
    }

    .section-panel {
        page-break-inside: avoid;
        break-inside: avoid;
        margin-bottom: 16px;
    }

    .action-bar,
    .flash {
        display: none !important;
    }

    .report-container {
        padding: 16px 16px 40px;
    }
    .section-panel {
        padding: 18px 20px;
    }
    .report-hero {
        padding: 20px 20px 16px;
        margin-bottom: 18px;
    }
}

/* ── Vital Signs Highlighting (KEEP status colors) ─────────────── */
.vital-inline--high {
    background: rgba(124, 58, 237, 0.08);
    color: var(--status-high);
    border-radius: 8px;
    padding: 4px 8px;
    margin: 2px;
}

.vital-inline--low {
    background: rgba(220, 38, 38, 0.08);
    color: var(--status-low);
    border-radius: 8px;
    padding: 4px 8px;
    margin: 2px;
}

.vital-range {
    display: block;
    font-size: 0.6rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 1px;
    white-space: nowrap;
}

.vital-inline--high .vital-range {
    color: var(--status-high);
    opacity: 0.75;
}

.vital-inline--low .vital-range {
    color: var(--status-low);
    opacity: 0.75;
}

/* ── Form Card Variant (used in summary/section panels) ────────── */
.form-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border-soft);
    border-radius: var(--radius-card);
    box-shadow: var(--glass-shadow);
}
