/* ═══════════════════════════════════════════════════════════════
   Rural Clinic Network — Production CSS
   Optimized for: Tablets (720p-1080p), Mobile, and Desktop
   Design: Clean ERP system with healthcare color coding
   ═══════════════════════════════════════════════════════════════ */

/* CSS Variables */
:root {
    /* Brand */
    --primary: #1a56db;
    --primary-dark: #1344b0;
    --primary-light: #e8eefb;
    --primary-50: #eff4ff;

    /* Healthcare Risk Colors */
    --red: #dc2626;
    --red-bg: #fef2f2;
    --red-border: #fca5a5;
    --yellow: #d97706;
    --yellow-bg: #fffbeb;
    --yellow-border: #fcd34d;
    --green: #16a34a;
    --green-bg: #f0fdf4;
    --green-border: #86efac;

    /* Semantic */
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #2563eb;

    /* Neutrals */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Layout */
    --sidebar-width: 232px;
    --topbar-height: 60px;

    /* Radius scale */
    --radius-xs: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-pill: 999px;

    /* Elevation — soft, layered, premium (low-contrast ambient + key light) */
    --shadow-sm: 0 1px 2px rgba(16,24,40,0.05);
    --shadow: 0 1px 3px rgba(16,24,40,0.08), 0 1px 2px rgba(16,24,40,0.04);
    --shadow-md: 0 4px 12px -2px rgba(16,24,40,0.10), 0 2px 6px -2px rgba(16,24,40,0.06);
    --shadow-lg: 0 12px 28px -6px rgba(16,24,40,0.14), 0 6px 12px -6px rgba(16,24,40,0.08);
    --shadow-xl: 0 24px 48px -12px rgba(16,24,40,0.20);
    --ring: 0 0 0 3px rgba(26,86,219,0.20);
    --ring-danger: 0 0 0 3px rgba(220,38,38,0.18);

    /* Spacing scale (4px base) */
    --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
    --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;

    /* Type scale */
    --text-xs: 0.75rem; --text-sm: 0.85rem; --text-base: 0.95rem;
    --text-md: 1.05rem; --text-lg: 1.2rem; --text-xl: 1.45rem; --text-2xl: 1.8rem;

    --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    --surface: #ffffff;
    --canvas: #f5f7fa;
    --hairline: #eceef2;
}

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
    /* Devanagari-capable stack. First try Google Fonts (loaded when
       reachable). Then fall back to fonts that already ship with each OS:
       Nirmala UI (Windows 8+), Kohinoor Devanagari (macOS/iOS), Mangal
       (older Windows), Roboto (Android). This guarantees Hindi renders
       even when corporate IT blocks Google Fonts. */
    font-family: 'Noto Sans Devanagari', -apple-system, BlinkMacSystemFont,
                 'Segoe UI', 'Nirmala UI', 'Kohinoor Devanagari', 'Mangal',
                 Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--gray-800);
    background: var(--canvas);
    line-height: 1.55;
    overflow: hidden;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    letter-spacing: -0.006em;
}
#app { height: 100vh; display: flex; flex-direction: column; }
a { color: var(--primary); text-decoration: none; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
/* Premium, accessible keyboard focus on every interactive element */
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-xs); }
button:focus:not(:focus-visible) { box-shadow: none; }

/* ═══════════ SCREENS ═══════════ */
.screen { display: none; height: 100vh; }
.screen.active { display: flex; flex-direction: column; }
#screen-main { flex-direction: column; }

/* ═══════════ LOGIN ═══════════ */
.login-wrapper {
    display: flex; align-items: center; justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, #1a56db 0%, #1e3a8a 50%, #172554 100%);
    padding: 1rem;
}
.login-card {
    background: white; border-radius: var(--radius-lg);
    padding: 2.5rem 2rem; width: 100%; max-width: 420px;
    box-shadow: var(--shadow-lg);
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.logo-icon { font-size: 3rem; margin-bottom: 0.5rem; }
.login-logo h1 { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); margin-bottom: 0.25rem; }
.login-subtitle { color: var(--gray-500); font-size: 0.9rem; }
.login-district { color: var(--primary); font-size: 0.8rem; font-weight: 600; margin-top: 0.25rem; }

.login-quick-fill { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--gray-200); text-align: center; }
.login-quick-fill p { font-size: 0.75rem; color: var(--gray-400); margin-bottom: 0.5rem; }
.quick-btn-row { display: flex; gap: 0.5rem; justify-content: center; }

/* ═══════════ TOPBAR ═══════════ */
.topbar {
    height: var(--topbar-height); display: flex; align-items: center;
    justify-content: space-between; padding: 0 1rem;
    background: white; border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm); z-index: 100;
    flex-shrink: 0;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 0.75rem; }
.topbar-center { flex: 1; text-align: center; }
.topbar-brand { display: flex; align-items: center; gap: 0.5rem; }
.brand-icon { font-size: 1.3rem; }
.brand-text { font-weight: 700; font-size: 1rem; color: var(--primary-dark); }
.topbar-page-title { font-size: 1.1rem; font-weight: 600; color: var(--gray-700); }

/* Language Toggle Button */
.btn-lang {
    padding: 4px 12px; border-radius: 6px; border: 2px solid var(--primary);
    background: white; color: var(--primary); font-weight: 700; font-size: 0.85rem;
    cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.btn-lang:hover { background: var(--primary); color: white; }

/* Treatment Rx Button */
.btn-rx {
    background: linear-gradient(135deg, #059669, #10B981); color: white;
    padding: 10px 28px; border-radius: 8px; border: none; font-size: 1rem;
    font-weight: 700; cursor: pointer; transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.3);
}
.btn-rx:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(5, 150, 105, 0.4); }

/* Treatment Section (legacy — can remove later) */
.treatment-section { border: 2px solid var(--primary); border-radius: 12px; }
.treatment-warning {
    background: #FFF3CD; border: 1px solid #FFD93D; border-radius: 8px;
    padding: 10px 14px; margin-bottom: 16px; font-weight: 600; font-size: 0.85rem; color: #664D03;
}
.treatment-condition { font-size: 1.1rem; font-weight: 700; margin-bottom: 12px; color: var(--gray-800); }
.treatment-medicines { margin-bottom: 16px; }
.med-card {
    background: #F0F7FF; border: 1px solid #BFDBFE; border-radius: 8px;
    padding: 12px 14px; margin-bottom: 8px;
}
.med-name { font-weight: 700; font-size: 1rem; color: var(--primary-dark); }
.med-detail { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; font-size: 0.85rem; }
.med-detail span { background: white; padding: 2px 8px; border-radius: 4px; border: 1px solid #e2e8f0; }
.med-dose { color: #059669; font-weight: 600; }
.med-duration { color: #7C3AED; }
.med-route { color: #0891B2; }
.med-when { color: #D97706; font-style: italic; }

.treatment-advice { margin-bottom: 12px; }
.treatment-advice li { padding: 4px 0; font-size: 0.9rem; color: var(--gray-600); line-height: 1.5; }
.treatment-advice li::marker { color: #059669; }

.treatment-refer { background: #FEF2F2; border: 1px solid #FECACA; border-radius: 8px; padding: 10px 14px; }
.treatment-refer h4 { color: #DC2626; margin-bottom: 6px; font-size: 0.9rem; }
.treatment-refer li { color: #991B1B; font-size: 0.85rem; padding: 2px 0; }
.treatment-refer li::marker { content: '🚨 '; }

.treatment-pediatric { background: #FFF7ED; border: 1px solid #FDBA74; border-radius: 8px; padding: 10px 14px; margin-top: 12px; font-size: 0.85rem; }
.treatment-pediatric strong { color: #9A3412; }

.treatment-firstaid { background: #ECFDF5; border: 2px solid #10B981; border-radius: 8px; padding: 12px 14px; margin-top: 12px; }
.treatment-firstaid h4 { color: #065F46; margin-bottom: 8px; }
.treatment-firstaid .fa-item { padding: 4px 0; font-size: 0.9rem; }

.sync-indicator { display: flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; color: var(--gray-500); }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; }
.sync-dot.online { background: var(--green); box-shadow: 0 0 4px var(--green); }
.sync-dot.offline { background: var(--red); }
.user-info { display: flex; align-items: center; gap: 0.5rem; }
.user-name-text { font-weight: 600; font-size: 0.85rem; color: var(--gray-700); }
.user-role-badge {
    font-size: 0.7rem; padding: 2px 8px; border-radius: 12px;
    background: var(--primary-light); color: var(--primary-dark); font-weight: 600;
}

/* ═══════════ SIDEBAR ═══════════ */
.sidebar {
    position: fixed; left: 0; top: var(--topbar-height);
    width: var(--sidebar-width); height: calc(100vh - var(--topbar-height));
    background: #FFFFFF; border-right: 1px solid var(--gray-200);
    display: flex; flex-direction: column; z-index: 90;
    transition: transform var(--transition);
    box-shadow: 2px 0 8px rgba(0,0,0,0.03);
}
.sidebar.collapsed { transform: translateX(-100%); }
.sidebar-nav { flex: 1; padding: 0.75rem 0.5rem; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 0.75rem;
    width: 100%; padding: 0.7rem 0.85rem; border: none;
    background: transparent; border-radius: var(--radius);
    cursor: pointer; color: var(--gray-600); font-size: 0.88rem;
    transition: all 0.15s ease; text-align: left;
    border-left: 3px solid transparent; margin-bottom: 2px;
}
.nav-item:hover { background: var(--gray-50); color: var(--gray-800); border-left-color: var(--gray-300); }
.nav-item.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 700; border-left-color: var(--primary); }
.nav-icon { font-size: 1.1rem; width: 1.5rem; text-align: center; }
.nav-divider { height: 1px; background: var(--gray-200); margin: 0.5rem 0.75rem; }
.sidebar-footer { padding: 0.75rem; border-top: 1px solid var(--gray-200); }
.clinic-info { display: flex; flex-direction: column; }
.clinic-name { font-size: 0.8rem; font-weight: 600; color: var(--gray-700); }
.clinic-id { font-size: 0.7rem; color: var(--gray-400); }

/* ═══════════ MAIN CONTENT ═══════════ */
.main-content {
    margin-left: var(--sidebar-width);
    height: calc(100vh - var(--topbar-height));
    overflow-y: auto; padding: 1.5rem 2rem;
    transition: margin-left var(--transition);
    background: #F8FAFC;
}
.sidebar.collapsed ~ .main-content { margin-left: 0; }
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* Page header with breadcrumb feel */
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.25rem; padding-bottom: 0.75rem; border-bottom: 1px solid #E2E8F0;
}
.page-header h2 {
    font-size: 1.25rem; font-weight: 700; color: #1E293B;
    display: flex; align-items: center; gap: 8px;
}

/* ═══════════ CARDS & SECTIONS ═══════════ */
.section-card {
    background: white; border-radius: var(--radius-lg);
    padding: 1.25rem; margin-bottom: 1rem;
    box-shadow: var(--shadow-sm); border: 1px solid var(--gray-200);
}
.section-title { font-size: 1rem; font-weight: 600; color: var(--gray-700); margin-bottom: 0.75rem; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.stat-card {
    background: white; border-radius: var(--radius-lg); padding: 1rem;
    display: flex; align-items: center; gap: 1rem;
    box-shadow: var(--shadow-sm); border: 1px solid var(--gray-200);
}
.stat-icon { font-size: 2rem; }
.stat-number { font-size: 1.8rem; font-weight: 800; color: var(--gray-900); line-height: 1; }
.stat-label { font-size: 0.75rem; color: var(--gray-500); margin-top: 0.15rem; }
.stat-red .stat-number { color: var(--red); }
.stat-yellow .stat-number { color: var(--yellow); }
.stat-green .stat-number { color: var(--green); }

/* Quick Actions */
.quick-actions-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; }
.action-card {
    display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
    padding: 1.25rem 1rem; border: 2px solid var(--gray-200); border-radius: var(--radius-lg);
    background: white; cursor: pointer; transition: all var(--transition);
}
.action-card:hover { border-color: var(--primary); background: var(--primary-50); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.action-icon { font-size: 1.8rem; }
.action-text { font-size: 0.85rem; font-weight: 600; color: var(--gray-700); }

.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.item-list { max-height: 200px; overflow-y: auto; }
.empty-state { text-align: center; padding: 2rem 1rem; color: var(--gray-400); }
.empty-icon { font-size: 2.5rem; display: block; margin-bottom: 0.75rem; }

/* ═══════════ FORMS ═══════════ */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--gray-700); margin-bottom: 0.3rem; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 0.6rem 0.75rem; border: 1px solid var(--gray-300);
    border-radius: var(--radius); font-size: 0.95rem; color: var(--gray-800);
    background: white; transition: all var(--transition);
}
.form-group textarea { resize: vertical; }
.form-group-sm { max-width: 140px; }

.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 140px; }

.input-with-icon { position: relative; }
.input-with-icon .input-icon { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); font-size: 1.1rem; }
.input-with-icon input { padding-left: 2.5rem; }

.search-bar { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.search-input-wrap { flex: 1; }

.checkbox-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-weight: 400 !important; }
.checkbox-label input { width: auto; }

.radio-group { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.radio-card { cursor: pointer; }
.radio-card input { display: none; }
.radio-card-content {
    display: flex; align-items: center; gap: 0.5rem; padding: 0.75rem 1.25rem;
    border: 2px solid var(--gray-200); border-radius: var(--radius); transition: all var(--transition);
    font-weight: 500;
}
.radio-card input:checked + .radio-card-content { border-color: var(--primary); background: var(--primary-50); color: var(--primary-dark); }
.radio-icon { font-size: 1.2rem; }

/* ═══════════ BUTTONS ═══════════ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.6rem 1.3rem; border: none; border-radius: var(--radius);
    font-weight: 600; font-size: 0.88rem; cursor: pointer;
    transition: all var(--transition); white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #2563EB, #1D4ED8); color: white; }
.btn-primary:hover:not(:disabled) { background: linear-gradient(135deg, #1D4ED8, #1E40AF); box-shadow: 0 4px 12px rgba(37,99,235,0.3); transform: translateY(-1px); }
.btn-secondary { background: white; color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-success { background: linear-gradient(135deg, #10B981, #059669); color: white; }
.btn-success:hover { box-shadow: 0 4px 12px rgba(16,185,129,0.3); transform: translateY(-1px); }
.btn-warning { background: linear-gradient(135deg, #F59E0B, #D97706); color: white; }
.btn-warning:hover { box-shadow: 0 4px 12px rgba(245,158,11,0.3); }
.btn-danger { background: linear-gradient(135deg, #EF4444, #DC2626); color: white; }
.btn-danger:hover { box-shadow: 0 4px 12px rgba(239,68,68,0.3); }
.btn-outline { background: transparent; border: 1.5px solid var(--gray-300); color: var(--gray-600); }
.btn-outline:hover { background: var(--gray-50); border-color: var(--primary); color: var(--primary); }
.btn-block { width: 100%; }
.btn-sm { padding: 0.35rem 0.85rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-xl { padding: 1rem 2rem; font-size: 1.15rem; }
.btn-icon { background: none; border: none; cursor: pointer; font-size: 1.3rem; padding: 0.25rem; color: var(--gray-500); transition: color 0.15s; }
.btn-icon:hover { color: var(--primary); }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 0.8rem; padding: 0; margin-top: 0.25rem; }

/* ═══════════ PATIENT CARDS ═══════════ */
.patient-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0.75rem; }
.patient-card {
    background: white; border: 1px solid var(--gray-200); border-radius: var(--radius-lg);
    padding: 1rem; cursor: pointer; transition: all var(--transition);
}
.patient-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.patient-card-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 0.5rem; }
.patient-card-name { font-weight: 700; font-size: 1rem; color: var(--gray-900); }
.patient-card-id { font-size: 0.75rem; color: var(--primary); font-weight: 600; font-family: monospace; }
.patient-card-meta { display: flex; gap: 1rem; font-size: 0.8rem; color: var(--gray-500); flex-wrap: wrap; }
.patient-card-tags { display: flex; gap: 0.35rem; margin-top: 0.5rem; flex-wrap: wrap; }
.tag { font-size: 0.7rem; padding: 2px 8px; border-radius: 12px; font-weight: 500; }
.tag-condition { background: #fef3c7; color: #92400e; }
.tag-pregnant { background: #fce7f3; color: #9d174d; }
.tag-pediatric { background: #e0e7ff; color: #3730a3; }

.patient-select-list .patient-card { cursor: pointer; }
.patient-select-list .patient-card.selected { border-color: var(--primary); background: var(--primary-50); }

.selected-patient {
    background: var(--primary-50); border: 2px solid var(--primary);
    border-radius: var(--radius-lg); padding: 1rem; margin-top: 0.75rem;
}
.selected-patient .label { font-size: 0.75rem; color: var(--primary); font-weight: 600; text-transform: uppercase; }

/* ═══════════ VITALS ═══════════ */
.vitals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.vital-card {
    background: white; border: 2px solid var(--gray-200); border-radius: var(--radius-lg);
    padding: 1rem; transition: all var(--transition);
}
.vital-card-wide { grid-column: span 2; }
.vital-card.normal { border-color: var(--green-border); background: var(--green-bg); }
.vital-card.borderline { border-color: var(--yellow-border); background: var(--yellow-bg); }
.vital-card.critical { border-color: var(--red-border); background: var(--red-bg); }
.vital-card.has-value { border-color: var(--primary); }

.vital-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.vital-icon { font-size: 1.3rem; }
.vital-title { font-weight: 600; font-size: 0.9rem; color: var(--gray-700); flex: 1; }
.vital-source { font-size: 0.7rem; padding: 2px 8px; border-radius: 12px; background: var(--gray-100); color: var(--gray-500); }
.vital-source.ble { background: #dbeafe; color: #1d4ed8; }

.vital-inputs { display: flex; align-items: center; gap: 0.5rem; }
.vital-input { border: 1px solid var(--gray-300); border-radius: var(--radius); padding: 0.5rem; text-align: center; }
.vital-input-lg { font-size: 1.5rem; font-weight: 700; width: 90px; }
.vital-unit { font-size: 0.85rem; color: var(--gray-500); font-weight: 500; }
.vital-select { padding: 0.5rem; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: 0.85rem; }
.bp-display { display: flex; align-items: center; gap: 0.25rem; }
.bp-separator { font-size: 1.5rem; font-weight: 700; color: var(--gray-400); }
.glucose-inputs { flex-wrap: wrap; }

.vital-status { margin-top: 0.5rem; font-size: 0.8rem; font-weight: 600; min-height: 1.2em; }
.vital-status.normal { color: var(--green); }
.vital-status.borderline { color: var(--yellow); }
.vital-status.critical { color: var(--red); }

.bmi-display {
    background: var(--primary-50); border: 1px solid var(--primary-light);
    border-radius: var(--radius); padding: 0.75rem 1rem;
    display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem;
}
.bmi-label { font-weight: 600; color: var(--gray-600); }
.bmi-value { font-size: 1.3rem; font-weight: 800; color: var(--primary-dark); }
.bmi-category { font-size: 0.85rem; padding: 2px 10px; border-radius: 12px; font-weight: 600; }

/* Device Status */
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.75rem; }
.device-item {
    display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-200); border-radius: var(--radius); font-size: 0.85rem;
}
.device-icon { font-size: 1.2rem; }
.device-name { flex: 1; font-weight: 500; }
.device-status { font-size: 0.7rem; padding: 2px 8px; border-radius: 12px; font-weight: 600; }
.device-status.connected { background: var(--green-bg); color: var(--green); }
.device-status.disconnected { background: var(--gray-100); color: var(--gray-400); }

/* Confirmation Section */
.confirmation-section { background: white; border: 2px solid var(--primary); border-radius: var(--radius-lg); padding: 1.25rem; margin-bottom: 1rem; }
.confirm-checkbox-group { margin-bottom: 1rem; }
.confirm-checkbox {
    display: flex; align-items: flex-start; gap: 0.5rem; padding: 0.5rem;
    border-radius: var(--radius); cursor: pointer; margin-bottom: 0.5rem;
}
.confirm-checkbox:hover { background: var(--gray-50); }
.confirm-checkbox input { margin-top: 0.15rem; width: 18px; height: 18px; accent-color: var(--primary); }
.confirm-checkbox span { font-size: 0.9rem; color: var(--gray-700); }

/* ═══════════ SYMPTOMS ═══════════ */
.body-area-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.body-area-btn {
    padding: 0.5rem 1rem; border: 2px solid var(--gray-200); border-radius: var(--radius);
    background: white; cursor: pointer; font-size: 0.85rem; font-weight: 500;
    transition: all var(--transition);
}
.body-area-btn:hover { border-color: var(--primary-light); }
.body-area-btn.active { border-color: var(--primary); background: var(--primary-50); color: var(--primary-dark); }

.symptom-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.symptom-chip {
    padding: 0.5rem 1rem; border: 1px solid var(--gray-300); border-radius: 20px;
    background: white; cursor: pointer; font-size: 0.85rem; transition: all var(--transition);
}
.symptom-chip:hover { border-color: var(--primary); background: var(--primary-50); }
.symptom-chip.selected { background: var(--primary); color: white; border-color: var(--primary); }

.symptom-list { display: flex; flex-direction: column; gap: 0.5rem; }
.symptom-entry {
    display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem;
    border: 1px solid var(--gray-200); border-radius: var(--radius); background: white;
    flex-wrap: wrap;
}
.symptom-entry-name { font-weight: 600; min-width: 150px; font-size: 0.9rem; }
.symptom-entry select, .symptom-entry input { padding: 0.35rem 0.5rem; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: 0.8rem; }
.symptom-entry input[type="number"] { width: 60px; }
.symptom-remove { background: none; border: none; cursor: pointer; font-size: 1.2rem; color: var(--red); padding: 0.25rem; }
.badge { font-size: 0.7rem; padding: 2px 8px; border-radius: 12px; background: var(--primary); color: white; vertical-align: middle; }

/* ═══════════ TRIAGE V2 — Production UI ═══════════ */
.active-encounter-bar {
    background: var(--primary-50); border: 1px solid var(--primary-light);
    border-radius: var(--radius); padding: 0.6rem 1rem;
    font-size: 0.85rem; margin-bottom: 1rem; display: flex; gap: 1rem; flex-wrap: wrap;
}
.encounter-badge { font-size: 0.8rem; padding: 4px 12px; border-radius: 20px; background: var(--primary); color: white; font-weight: 600; }

/* ── Readiness Card (pre-triage) ── */
.triage-readiness-card {
    background: white; border-radius: 16px; padding: 0; overflow: hidden;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08); border: 1px solid var(--gray-200);
}
.triage-readiness-header {
    display: flex; align-items: center; gap: 16px; padding: 24px 28px 16px;
    background: linear-gradient(135deg, #EFF6FF 0%, #F0FDF4 100%);
    border-bottom: 1px solid var(--gray-100);
}
.triage-readiness-icon { font-size: 2.5rem; }
.triage-readiness-header h3 { font-size: 1.2rem; font-weight: 800; color: #1E293B; margin: 0; }
.triage-readiness-sub { font-size: 0.85rem; color: var(--gray-500); margin: 2px 0 0; }
.triage-readiness-patient { padding: 16px 28px; font-size: 0.9rem; }

.triage-checklist { padding: 0 28px 12px; display: flex; flex-direction: column; gap: 6px; }
.triage-check-item {
    display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: #475569;
}
.triage-check-item .check-ok { color: var(--green); font-weight: 700; }
.triage-check-item .check-miss { color: var(--gray-300); }

.triage-layers-preview {
    display: flex; gap: 8px; padding: 12px 28px; flex-wrap: wrap;
}
.triage-layer-chip {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.75rem; font-weight: 600; padding: 4px 12px;
    border-radius: 20px; background: #F1F5F9; color: #475569;
}
.layer-dot { width: 8px; height: 8px; border-radius: 50%; }
.layer-1 .layer-dot { background: #EF4444; }
.layer-2 .layer-dot { background: #3B82F6; }
.layer-3 .layer-dot { background: #8B5CF6; }
.layer-4 .layer-dot { background: #10B981; }

.btn-triage-start {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: calc(100% - 56px); margin: 16px 28px 24px;
    padding: 16px 32px; border: none; border-radius: 12px;
    background: linear-gradient(135deg, #2563EB, #7C3AED);
    color: white; font-size: 1.1rem; font-weight: 700;
    cursor: pointer; transition: all 0.3s;
    box-shadow: 0 4px 14px rgba(37,99,235,0.3);
}
.btn-triage-start:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(37,99,235,0.4); }
.btn-triage-start:active { transform: translateY(0); }
.btn-triage-icon { font-size: 1.4rem; }

/* ── Running Animation ── */
.triage-running-card {
    background: white; border-radius: 16px; overflow: hidden;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08); border: 1px solid var(--gray-200);
}
.triage-running-header {
    display: flex; align-items: center; gap: 16px; padding: 24px 28px 16px;
    background: linear-gradient(135deg, #EFF6FF 0%, #F5F3FF 100%);
}
.triage-brain-anim {
    position: relative; font-size: 2.5rem; width: 56px; height: 56px;
    display: flex; align-items: center; justify-content: center;
}
.brain-pulse {
    position: absolute; inset: 0; border-radius: 50%;
    background: rgba(99,102,241,0.15);
    animation: brainPulse 1.5s ease-in-out infinite;
}
@keyframes brainPulse {
    0%, 100% { transform: scale(0.8); opacity: 0.5; }
    50% { transform: scale(1.3); opacity: 0; }
}
.triage-running-header h3 { font-size: 1.15rem; font-weight: 800; color: #1E293B; margin: 0; }
.triage-running-sub { font-size: 0.85rem; color: var(--gray-500); margin: 2px 0 0; }

.triage-layers-stack { padding: 8px 28px 16px; display: flex; flex-direction: column; gap: 4px; }

.triage-layer {
    border-radius: 12px; padding: 14px 16px 10px; transition: all 0.4s;
    background: #F8FAFC; border: 1px solid transparent;
}
.triage-layer.active { background: white; border-color: var(--primary-light); box-shadow: 0 2px 12px rgba(37,99,235,0.08); }
.triage-layer.done { background: #F0FDF4; border-color: #BBF7D0; }
.triage-layer.error { background: #FEF2F2; border-color: #FECACA; }

.triage-layer-header { display: flex; align-items: center; gap: 12px; }

.layer-indicator {
    width: 36px; height: 36px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; color: white; font-size: 0.85rem; flex-shrink: 0;
}
.layer-1-color { background: linear-gradient(135deg, #EF4444, #DC2626); }
.layer-2-color { background: linear-gradient(135deg, #3B82F6, #2563EB); }
.layer-3-color { background: linear-gradient(135deg, #8B5CF6, #7C3AED); }
.layer-4-color { background: linear-gradient(135deg, #10B981, #059669); }

.layer-info { flex: 1; }
.layer-name { font-weight: 700; font-size: 0.9rem; color: #1E293B; }
.layer-desc { font-size: 0.78rem; color: #94A3B8; margin-top: 1px; }

.layer-status { font-size: 1.2rem; }
.layer-waiting { color: #CBD5E1; }
.layer-spinner {
    width: 24px; height: 24px; border: 3px solid #E2E8F0;
    border-top-color: var(--primary); border-radius: 50%;
    animation: layerSpin 0.8s linear infinite;
}
@keyframes layerSpin { to { transform: rotate(360deg); } }
.layer-check { color: #10B981; font-size: 1.3rem; }
.layer-error-icon { color: #EF4444; font-size: 1.3rem; }

.layer-progress-track {
    height: 3px; background: #E2E8F0; border-radius: 2px; margin-top: 8px;
    overflow: hidden;
}
.layer-progress-bar {
    height: 100%; width: 0; border-radius: 2px;
    transition: width 0.3s ease;
}
.layer-1-color-bar { background: linear-gradient(90deg, #EF4444, #F97316); }
.layer-2-color-bar { background: linear-gradient(90deg, #3B82F6, #06B6D4); }
.layer-3-color-bar { background: linear-gradient(90deg, #8B5CF6, #EC4899); }
.layer-4-color-bar { background: linear-gradient(90deg, #10B981, #34D399); }

.layer-detail {
    margin-top: 8px; padding: 8px 12px; font-size: 0.8rem; color: #64748B;
    background: rgba(255,255,255,0.7); border-radius: 8px;
}

.triage-running-footer {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 28px; background: #F8FAFC; border-top: 1px solid var(--gray-100);
    font-size: 0.75rem; color: #94A3B8;
}
.triage-elapsed { font-family: 'SF Mono', 'Cascadia Mono', monospace; font-weight: 600; color: #64748B; }
.triage-powered { font-style: italic; }

/* ── Risk Banner V2 ── */
.risk-banner-v2 {
    border-radius: 16px; overflow: hidden; margin-bottom: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}
.risk-banner-inner {
    display: flex; align-items: center; gap: 16px; padding: 20px 24px;
}
.risk-badge {
    width: 64px; height: 64px; border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; font-weight: 900; color: white; flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.risk-meta { flex: 1; }
.risk-level-text { font-size: 1.4rem; font-weight: 900; letter-spacing: 1px; }
.risk-banner-v2 .risk-description { font-size: 0.9rem; opacity: 0.9; margin-top: 4px; }
.risk-confidence {
    font-size: 0.85rem; font-weight: 700; padding: 6px 14px;
    border-radius: 20px; background: rgba(255,255,255,0.25); white-space: nowrap;
}

/* V3.2: banners de-gradiented — white cards, color only as accent
   (owner: full-bleed green/red/yellow slabs "look horrible") */
.risk-banner-v2 { background: #fff; border: 1.5px solid #e5e7eb; box-shadow: 0 1px 4px rgba(20,40,60,.06); }
.risk-banner-v2.risk-RED { border-left: 8px solid #dc2626; background: #fffbfb; }
.risk-banner-v2.risk-RED .risk-level-text { color: #b91c1c; }
.risk-banner-v2.risk-RED .risk-badge { background: #fee2e2; }
.risk-banner-v2.risk-YELLOW { border-left: 8px solid #f59e0b; background: #fffdf8; }
.risk-banner-v2.risk-YELLOW .risk-level-text { color: #b45309; }
.risk-banner-v2.risk-YELLOW .risk-badge { background: #fef3c7; }
.risk-banner-v2.risk-GREEN { border-left: 8px solid #16a34a; background: #fbfffc; }
.risk-banner-v2.risk-GREEN .risk-level-text { color: #15803d; }
.risk-banner-v2.risk-GREEN .risk-badge { background: #dcfce7; }
.risk-banner-v2 .risk-description { color: #64748b; opacity: 1; }
.risk-confidence { background: #f1f5f9; color: #475569; }

/* Verdict card family (action hero, all risks) */
.verdict-card { background: #fff; border: 1.5px solid #e5e7eb; border-left: 7px solid #94a3b8; border-radius: 14px; padding: 18px 20px; color: #1e293b; }
.verdict-card.v-red { border-left-color: #dc2626; background: #fffbfb; }
.verdict-card.v-amber { border-left-color: #f59e0b; background: #fffdf8; }
.verdict-card.v-green { border-left-color: #16a34a; background: #fbfffc; }
.v-head { display: flex; align-items: flex-start; gap: 14px; }
.v-icon { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.7rem; flex-shrink: 0; }
.v-red .v-icon { background: #fee2e2; } .v-amber .v-icon { background: #fef3c7; } .v-green .v-icon { background: #dcfce7; }
.v-main { flex: 1; min-width: 0; }
.v-title { font-size: 1.22rem; font-weight: 800; line-height: 1.25; }
.v-red .v-title { color: #b91c1c; } .v-amber .v-title { color: #b45309; } .v-green .v-title { color: #15803d; }
.v-sub { font-size: 0.9rem; color: #64748b; margin-top: 3px; }
.v-chip { display: inline-block; margin-top: 8px; font-size: 0.8rem; font-weight: 700; background: #f1f5f9; color: #334155; padding: 4px 12px; border-radius: 999px; }
.v-actions { display: flex; flex-direction: column; gap: 7px; flex-shrink: 0; }
.v-btn { border: none; padding: 10px 16px; border-radius: 10px; font-weight: 700; cursor: pointer; font-size: 0.85rem; color: #fff; }
.v-btn.red { background: #dc2626; } .v-btn.amber { background: #d97706; } .v-btn.green { background: #16a34a; } .v-btn.blue { background: #0e7490; }
.v-btn-ghost { background: #fff; border: 1.5px solid #cbd5e1; color: #334155; padding: 8px 14px; border-radius: 10px; font-weight: 600; cursor: pointer; font-size: 0.8rem; }
.v-panel { margin-top: 12px; background: #f8fafc; border: 1px solid #eef2f7; border-radius: 10px; padding: 12px 14px; font-size: 0.85rem; color: #334155; }
.v-panel-title { font-weight: 700; font-size: 0.84rem; margin-bottom: 7px; color: #475569; }
.v-panel.danger { background: #fef2f2; border-color: #fecaca; }
.v-panel.danger .v-panel-title { color: #b91c1c; }
.v-panel ol, .v-panel ul { margin: 0; padding-left: 20px; line-height: 1.65; }
.v-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.v-2col .v-panel { margin-top: 0; }
@media (max-width: 640px) { .v-2col { grid-template-columns: 1fr; } }
.v-conf { display: inline-block; margin-top: 12px; font-size: 0.74rem; font-weight: 700; padding: 4px 12px; border-radius: 12px; background: #f1f5f9; color: #475569; }
.tests-strip { margin: 12px 0; background: #fff; border: 1.5px solid #bae6fd; border-left: 6px solid #0284c7; border-radius: 12px; padding: 12px 16px; }
.tests-strip .ts-title { font-weight: 800; font-size: 0.95rem; color: #075985; margin-bottom: 8px; }
.tests-strip .ts-chip { display: inline-flex; align-items: center; gap: 5px; background: #f0f9ff; border: 1.5px solid #bae6fd; border-radius: 999px; padding: 6px 13px; font-size: 0.88rem; font-weight: 700; color: #0c4a6e; margin: 3px 6px 3px 0; }

/* ── Escalation Alert V2 ── */
.escalation-alert-v2 {
    background: linear-gradient(135deg, #FEF2F2, #FFF1F2);
    border: 2px solid #FECACA; border-left: 6px solid #EF4444;
    border-radius: 12px; padding: 16px 20px; margin-bottom: 16px;
    display: flex; align-items: start; gap: 12px;
}
.escalation-alert-v2.hidden { display: none; }
.alert-icon-v2 { font-size: 1.8rem; flex-shrink: 0; }
.alert-body { flex: 1; }
.alert-title { font-weight: 800; color: #991B1B; font-size: 0.95rem; }
.alert-body .alert-text { font-size: 0.85rem; color: #7F1D1D; margin-top: 4px; }

/* ── Triage Section Cards ── */
.triage-section-card {
    background: white; border-radius: 12px; padding: 20px;
    margin-bottom: 12px; border: 1px solid var(--gray-200);
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.triage-section-header {
    display: flex; align-items: center; gap: 8px;
    font-size: 1rem; font-weight: 800; color: #1E293B;
    margin-bottom: 14px; padding-bottom: 10px; border-bottom: 2px solid #F1F5F9;
}
.triage-section-icon { font-size: 1.2rem; }

/* ── Treatment Action Bar (click-to-reveal) ── */
.treatment-action-bar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; padding: 0;
}
.treatment-action-left {
    display: flex; align-items: center; gap: 12px; flex: 1;
}
.treatment-action-icon {
    font-size: 1.8rem; width: 44px; height: 44px; display: flex;
    align-items: center; justify-content: center;
    background: #F0FDF4; border-radius: 10px;
}
.treatment-action-title {
    font-size: 0.95rem; font-weight: 700; color: #1E293B;
}
.treatment-action-subtitle {
    font-size: 0.82rem; color: #6B7280; margin-top: 2px;
}
.treatment-reveal-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 20px; border: 2px solid #059669;
    background: white; color: #059669; border-radius: 8px;
    font-weight: 700; font-size: 0.88rem; cursor: pointer;
    transition: all 0.15s ease; white-space: nowrap;
}
.treatment-reveal-btn:hover {
    background: #059669; color: white;
}
.treatment-reveal-btn.treatment-reveal-red {
    border-color: #DC2626; color: #DC2626;
}
.treatment-reveal-btn.treatment-reveal-red:hover {
    background: #DC2626; color: white;
}
.treatment-reveal-btn.treatment-reveal-yellow {
    border-color: #D97706; color: #D97706;
}
.treatment-reveal-btn.treatment-reveal-yellow:hover {
    background: #D97706; color: white;
}
.treatment-reveal-arrow {
    font-size: 0.7rem; transition: transform 0.2s;
}
.rx-card-collapsed {
    max-height: 0; overflow: hidden; opacity: 0;
    transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.2s ease;
    padding: 0;
}
#rx-card:not(.rx-card-collapsed) {
    max-height: 3000px; opacity: 1; padding-top: 16px;
    transition: max-height 0.4s ease, opacity 0.3s ease, padding 0.2s ease;
}

.triage-summary-text {
    font-size: 0.9rem; line-height: 1.6; color: #475569;
    background: #F8FAFC; border-radius: 8px; padding: 14px 16px;
    border-left: 4px solid var(--primary);
}

.triage-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 768px) { .triage-two-col { grid-template-columns: 1fr; } }

/* ── Conditions & Tests V2 ── */
.condition-item, .test-item, .rule-item {
    padding: 12px 14px; border-radius: 10px; margin-bottom: 8px;
    border: 1px solid var(--gray-100); background: #FAFAFA;
    transition: border-color 0.2s;
}
.condition-item:hover, .test-item:hover { border-color: var(--primary-light); }
.condition-item { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.condition-name { font-weight: 700; font-size: 0.95rem; color: #1E293B; }
.condition-likelihood { font-size: 0.72rem; padding: 3px 12px; border-radius: 20px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; }
.likelihood-high { background: #FEE2E2; color: #DC2626; }
.likelihood-medium { background: #FEF3C7; color: #D97706; }
.likelihood-low { background: #DCFCE7; color: #059669; }
.condition-reasoning { font-size: 0.8rem; color: #64748B; margin-top: 4px; line-height: 1.4; }

.test-item { display: flex; align-items: center; gap: 12px; }
.test-name { font-weight: 600; flex: 1; font-size: 0.9rem; }
.test-urgency { font-size: 0.7rem; padding: 3px 12px; border-radius: 20px; font-weight: 700; text-transform: uppercase; }
.urgency-today { background: #FEE2E2; color: #DC2626; }
.urgency-this_week { background: #FEF3C7; color: #D97706; }
.urgency-routine { background: #DCFCE7; color: #059669; }

.rule-item { display: flex; align-items: center; gap: 10px; }
.rule-id { font-family: 'SF Mono', monospace; font-weight: 700; color: var(--primary); font-size: 0.8rem; min-width: 55px; background: var(--primary-50); padding: 2px 8px; border-radius: 6px; text-align: center; }
.rule-desc { flex: 1; font-size: 0.85rem; color: #475569; }

.question-item, .redflag-item {
    padding: 8px 12px; margin-bottom: 4px;
    border-radius: 8px; font-size: 0.88rem; line-height: 1.5;
}
.question-item { background: #F0F9FF; color: #0C4A6E; }
.redflag-item { background: #FEF2F2; color: #7F1D1D; }

/* ── Decision Buttons V2 ── */
.triage-decision-card { border: 2px solid var(--primary-light); }
.decision-buttons-v2 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 640px) { .decision-buttons-v2 { grid-template-columns: 1fr; } }
.decision-btn-v2 {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 16px 12px; border: 2px solid var(--gray-200); border-radius: 12px;
    background: white; cursor: pointer; transition: all 0.2s;
    text-align: center;
}
.decision-btn-v2:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.decision-btn-v2.selected { border-width: 3px; transform: scale(1.02); }
.decision-accept.selected { border-color: #10B981; background: #F0FDF4; }
.decision-modify.selected { border-color: #F59E0B; background: #FFFBEB; }
.decision-override.selected { border-color: #EF4444; background: #FEF2F2; }
.decision-btn-icon { font-size: 1.5rem; }
.decision-btn-label { font-weight: 700; font-size: 0.95rem; color: #1E293B; }
.decision-btn-sub { font-size: 0.72rem; color: #94A3B8; }
.decision-textarea {
    width: 100%; padding: 12px; border: 2px solid var(--gray-200); border-radius: 10px;
    font-size: 0.9rem; resize: vertical; font-family: inherit;
}
.decision-textarea:focus { border-color: var(--primary); outline: none; }

/* ── AI Metadata Collapsible ── */
.triage-metadata-details { margin-top: 8px; }
.triage-metadata-summary {
    cursor: pointer; font-size: 0.85rem; color: #94A3B8;
    padding: 10px 16px; border-radius: 10px; background: #F8FAFC;
    border: 1px solid var(--gray-100); user-select: none;
}
.triage-metadata-summary:hover { background: #F1F5F9; }
.triage-metadata-body {
    padding: 12px 16px; font-size: 0.8rem; color: #64748B;
    background: #FAFAFA; border-radius: 0 0 10px 10px;
}

/* ═══════════ MODALS ═══════════ */
.modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: 1rem;
    animation: modalBgIn 0.2s ease;
}
@keyframes modalBgIn { from { opacity: 0; } to { opacity: 1; } }
.modal.hidden { display: none; }
.modal-content {
    background: white; border-radius: 16px; max-height: 90vh;
    overflow-y: auto; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    animation: modalSlideIn 0.3s ease;
}
@keyframes modalSlideIn { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-lg { max-width: 700px; }
.modal-xl { max-width: 900px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--gray-200); }
.modal-header h3 { font-size: 1.15rem; font-weight: 700; }
.modal-body { padding: 1.25rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: 0.75rem; padding: 1rem 1.25rem; border-top: 1px solid var(--gray-200); }

/* ═══════════ TOAST ═══════════ */
#toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 9999; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
    padding: 0.75rem 1.25rem; border-radius: var(--radius); color: white;
    font-weight: 500; font-size: 0.9rem; box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease, fadeOut 0.5s ease 2.5s forwards;
    max-width: 380px;
}
.toast-success { background: var(--green); }
.toast-error { background: var(--red); }
.toast-warning { background: var(--yellow); }
.toast-info { background: var(--info); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(50%); } }

/* ═══════════ LOADING ═══════════ */
#loading-overlay {
    position: fixed; inset: 0; background: rgba(255,255,255,0.85);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    z-index: 5000;
}
.loading-spinner {
    width: 40px; height: 40px; border: 4px solid var(--gray-200);
    border-top-color: var(--primary); border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* ═══════════ RESPONSIVE ═══════════ */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .quick-actions-grid { grid-template-columns: repeat(2, 1fr); }
    .two-column { grid-template-columns: 1fr; }
    .vital-card-wide { grid-column: span 1; }
}
@media (max-width: 768px) {
    :root { --sidebar-width: 0px; }
    .sidebar { transform: translateX(-260px); width: 260px; }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .main-content { margin-left: 0; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .vitals-grid { grid-template-columns: 1fr; }
    .topbar-brand .brand-text { display: none; }
    .decision-buttons { flex-direction: column; }
    .patient-grid { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; }
    .form-row .form-group { min-width: auto; }
    .form-group-sm { max-width: none; }
}
@media (max-width: 480px) {
    html { font-size: 14px; }
    .quick-actions-grid { grid-template-columns: 1fr 1fr; }
    .radio-group { flex-direction: column; }
}

/* ═══════════════════════════════════════════════
   V2.0 — Hemoglobin / Urine / Pregnancy Test
   ═══════════════════════════════════════════════ */

/* Required badge on hemoglobin (and any other) card */
.vital-required-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 6px;
    background: #DC2626;
    color: #fff;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    vertical-align: middle;
}

.vital-reference {
    margin-top: 6px;
    font-size: 0.72rem;
    color: var(--gray-600, #6B7280);
    line-height: 1.3;
}

/* Hemoglobin severity banners (also reusable for any vital banner) */
.vital-banner {
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid transparent;
}
.vital-banner-severe   { background: #FEE2E2; color: #991B1B; border-color: #FCA5A5; }
.vital-banner-moderate { background: #FFEDD5; color: #9A3412; border-color: #FDBA74; }
.vital-banner-mild     { background: #FEF9C3; color: #854D0E; border-color: #FDE68A; }
.vital-banner-normal   { background: #DCFCE7; color: #166534; border-color: #86EFAC; }

/* Card highlight when severe */
.vital-card.is-severe   { border: 2px solid #DC2626; box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.08); }
.vital-card.is-moderate { border: 2px solid #EA580C; }
.vital-card.is-mild     { border: 2px solid #CA8A04; }
.vital-card.is-normal   { border: 2px solid #16A34A; }

/* Collapsible "extra" section (Urine, Pregnancy Test) */
.vitals-extra-section {
    margin: 12px 0;
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    overflow: hidden;
}
.vitals-extra-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #F9FAFB;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    text-align: left;
    transition: background 150ms;
}
.vitals-extra-toggle:hover { background: #F3F4F6; }
.vitals-extra-toggle[aria-expanded="true"] { background: #EFF6FF; border-bottom: 1px solid #DBEAFE; }
.vitals-extra-toggle[aria-expanded="true"] .vitals-extra-chev { transform: rotate(180deg); }
.vitals-extra-icon { font-size: 1.2rem; }
.vitals-extra-title { font-weight: 700; color: #111827; flex: 1; }
.vitals-extra-meta {
    font-size: 0.72rem;
    padding: 2px 8px;
    background: #E5E7EB;
    color: #4B5563;
    border-radius: 12px;
    font-weight: 600;
}
.vitals-extra-meta.is-required { background: #DC2626; color: #fff; }
.vitals-extra-chev {
    color: #9CA3AF;
    transition: transform 200ms;
    font-size: 0.8rem;
}
.vitals-extra-body { padding: 16px; }

/* Urine grid */
.urine-meta-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px dashed #E5E7EB;
}
.urine-meta-row label,
.urine-grid label,
.preg-grid label {
    display: flex;
    flex-direction: column;
    font-size: 0.78rem;
    color: #4B5563;
    font-weight: 600;
    gap: 4px;
}
.urine-meta-row select,
.urine-grid select,
.urine-grid input,
.preg-grid select,
.preg-grid input {
    padding: 8px 10px;
    border: 1px solid #D1D5DB;
    border-radius: 6px;
    background: #fff;
    font-size: 0.9rem;
    font-weight: 500;
    color: #111827;
}
.urine-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
}
.urine-flags {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.urine-flag {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 8px;
}
.urine-flag-red    { background: #FEE2E2; color: #991B1B; border-color: #FCA5A5; }
.urine-flag-yellow { background: #FEF9C3; color: #854D0E; border-color: #FDE68A; }
.urine-flag-info   { background: #DBEAFE; color: #1E40AF; border-color: #93C5FD; }

/* Pregnancy test */
.preg-help {
    margin: 0 0 12px 0;
    font-size: 0.82rem;
    color: #6B7280;
}
.preg-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
#preg-weeks-display {
    grid-column: 1 / -1;
    padding: 8px 12px;
    background: #F0F9FF;
    color: #0369A1;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

@media (max-width: 640px) {
    .urine-meta-row { grid-template-columns: 1fr; }
    .urine-grid { grid-template-columns: 1fr; }
    .preg-grid { grid-template-columns: 1fr; }
}

/* ═══════════ PATIENT RECORD VIEW ═══════════ */
.patient-record { font-size: 0.9rem; }
.pr-header {
    display: flex; align-items: center; gap: 16px; padding: 16px 20px;
    background: linear-gradient(135deg, #EFF6FF, #F0FDF4);
    border-radius: 12px; margin-bottom: 16px;
}
.pr-avatar {
    width: 52px; height: 52px; border-radius: 14px;
    background: var(--primary); color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; font-weight: 800; flex-shrink: 0;
}
.pr-name { font-size: 1.15rem; font-weight: 800; color: #1E293B; }
.pr-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.pr-meta-chip {
    font-size: 0.75rem; padding: 2px 10px; border-radius: 6px;
    background: white; color: #475569; border: 1px solid #E2E8F0;
    font-weight: 600;
}
.pr-meta-chip.chip-preg { background: #FFF1F2; color: #BE123C; border-color: #FECDD3; }
.pr-meta-chip.chip-child { background: #F0F9FF; color: #0369A1; border-color: #BAE6FD; }

.pr-info-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px;
}
@media (max-width: 640px) { .pr-info-grid { grid-template-columns: 1fr; } }
.pr-info-card {
    background: #F8FAFC; border-radius: 10px; padding: 12px 16px;
    border: 1px solid #F1F5F9;
}
.pr-info-card h4 {
    font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px;
    color: #94A3B8; margin: 0 0 8px; font-weight: 700;
}
.pr-info-card .pr-tags { display: flex; flex-wrap: wrap; gap: 6px; }

.pr-encounter {
    border: 1px solid #E2E8F0; border-radius: 12px;
    margin-bottom: 10px; overflow: hidden; transition: box-shadow 0.2s;
}
.pr-encounter:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
.pr-encounter-header {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; cursor: pointer; background: white;
}
.pr-encounter-risk {
    width: 6px; height: 40px; border-radius: 3px; flex-shrink: 0;
}
.pr-encounter-risk.risk-RED { background: #EF4444; }
.pr-encounter-risk.risk-YELLOW { background: #F59E0B; }
.pr-encounter-risk.risk-GREEN { background: #10B981; }
.pr-encounter-risk.risk-default { background: #94A3B8; }
.pr-encounter-main { flex: 1; }
.pr-encounter-date { font-weight: 700; font-size: 0.9rem; color: #1E293B; }
.pr-encounter-complaint { font-size: 0.82rem; color: #64748B; margin-top: 2px; }
.pr-encounter-badge {
    font-size: 0.68rem; font-weight: 700; padding: 3px 10px;
    border-radius: 6px; text-transform: uppercase; letter-spacing: 0.5px;
    color: white;
}
.pr-encounter-chevron { color: #CBD5E1; font-size: 1.2rem; transition: transform 0.2s; }
.pr-encounter.expanded .pr-encounter-chevron { transform: rotate(90deg); }

.pr-encounter-detail {
    display: none; padding: 0 16px 16px; background: #FAFAFA;
    border-top: 1px solid #F1F5F9;
}
.pr-encounter.expanded .pr-encounter-detail { display: block; }
.pr-detail-section {
    margin-top: 10px; padding: 10px 14px; border-radius: 8px; background: white;
    border: 1px solid #F1F5F9; font-size: 0.82rem;
}
.pr-detail-section strong { color: #1E293B; display: block; margin-bottom: 4px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.3px; }
.pr-detail-vitals { display: flex; flex-wrap: wrap; gap: 8px; }
.pr-vital-chip {
    background: #EFF6FF; color: #1E40AF; padding: 3px 10px;
    border-radius: 6px; font-size: 0.78rem; font-weight: 600;
}
.pr-detail-treatment {
    background: #F0FDF4; border-color: #BBF7D0;
}
.pr-detail-treatment strong { color: #166534; }

.btn-outline {
    border: 2px solid var(--gray-300); background: white;
    color: #475569; padding: 8px 16px; border-radius: var(--radius);
    font-weight: 600; cursor: pointer; font-size: 0.85rem;
    transition: all 0.2s;
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

/* ═══════════ PRINT STYLES ═══════════ */
/* ═══ Report View (PDF-like) ═══ */
.report-view {
    max-width: 820px; margin: 0 auto; font-family: 'Inter', system-ui, sans-serif;
    color: #1F2937; line-height: 1.6;
}
.report-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 20px 24px; border-bottom: 3px solid #1a56db; margin-bottom: 20px;
}
.report-header-left { flex: 1; }
.report-clinic-name { font-size: 1.3rem; font-weight: 700; color: #1a56db; }
.report-clinic-sub { font-size: 0.78rem; color: #6B7280; margin-top: 2px; }
.report-header-right { text-align: right; font-size: 0.78rem; color: #6B7280; }
.report-date { font-weight: 600; color: #374151; }
.report-id { margin-top: 2px; }

.report-patient-banner {
    display: flex; align-items: center; gap: 16px; padding: 16px 20px;
    background: linear-gradient(135deg, #EFF6FF 0%, #F0F9FF 100%);
    border: 1px solid #BFDBFE; border-radius: 12px; margin-bottom: 20px;
}
.report-patient-avatar {
    width: 56px; height: 56px; border-radius: 50%; background: #2563EB;
    color: white; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.2rem; flex-shrink: 0;
}
.report-patient-name { font-size: 1.15rem; font-weight: 700; color: #1E293B; }
.report-patient-meta {
    display: flex; flex-wrap: wrap; gap: 12px; font-size: 0.82rem; color: #475569; margin-top: 4px;
}
.report-patient-meta span { display: inline-flex; align-items: center; gap: 4px; }
.report-badge-preg { background: #FEE2E2; color: #DC2626; padding: 2px 8px; border-radius: 10px; font-size: 0.75rem; font-weight: 600; }
.report-patient-contact { font-size: 0.8rem; color: #64748B; margin-top: 4px; }

.report-section { margin-bottom: 20px; }
.report-section-title {
    font-size: 0.9rem; font-weight: 700; color: #1E293B; padding: 8px 0;
    border-bottom: 2px solid #E2E8F0; margin-bottom: 12px; text-transform: uppercase;
    letter-spacing: 0.5px;
}
.report-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.report-field label { display: block; font-size: 0.72rem; font-weight: 600; color: #64748B; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.report-tag {
    display: inline-block; padding: 3px 10px; background: #F1F5F9; border: 1px solid #E2E8F0;
    border-radius: 6px; font-size: 0.8rem; color: #334155; margin: 2px 4px 2px 0;
}

.report-encounter {
    border: 1px solid #E2E8F0; border-radius: 10px; padding: 16px 20px; margin-bottom: 12px;
    page-break-inside: avoid;
}
.report-encounter-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.report-encounter-num {
    width: 28px; height: 28px; border-radius: 50%; background: #F1F5F9;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.8rem; color: #64748B; flex-shrink: 0;
}
.report-encounter-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.report-encounter-date { font-weight: 600; font-size: 0.88rem; color: #1E293B; }
.report-encounter-badge { color: white; padding: 2px 10px; border-radius: 6px; font-size: 0.7rem; font-weight: 700; }
.report-encounter-type { font-size: 0.75rem; color: #94A3B8; }
.report-encounter-action { font-size: 0.72rem; color: #10B981; font-weight: 600; }
.report-encounter-complaint { font-size: 0.85rem; color: #475569; margin-bottom: 10px; padding-left: 40px; }

.report-subsection { padding: 8px 0 8px 40px; font-size: 0.82rem; color: #334155; }
.report-subsection strong { display: block; font-size: 0.72rem; color: #64748B; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 4px; }
.report-vitals-table { width: 100%; border-collapse: collapse; }
.report-vitals-table td { padding: 6px 12px; border: 1px solid #F1F5F9; text-align: center; }
.report-vitals-table td label { display: block; font-size: 0.68rem; color: #94A3B8; font-weight: 600; text-transform: uppercase; }
.report-vitals-table td span { font-weight: 600; color: #1E293B; }
.report-symptom-list { display: flex; flex-wrap: wrap; gap: 6px; }
.report-symptom-chip { padding: 3px 10px; background: #FEF3C7; border-radius: 6px; font-size: 0.78rem; color: #92400E; }
.report-treatment { background: #F0FDF4; border-radius: 8px; padding: 10px 16px !important; margin-left: 40px; }

.report-footer {
    margin-top: 30px; padding-top: 16px; border-top: 2px solid #E2E8F0; text-align: center;
}
.report-footer-line { font-size: 0.72rem; color: #94A3B8; margin-bottom: 4px; }
.report-footer-sig { display: flex; justify-content: space-between; margin-top: 30px; padding: 0 40px; }
.report-sig-box { width: 200px; border-top: 1px solid #CBD5E1; padding-top: 8px; }
.report-sig-label { font-size: 0.7rem; color: #94A3B8; text-align: center; }

@media print {
    body * { visibility: hidden; }
    #modal-patient-detail,
    #modal-patient-detail *,
    #modal-patient-record,
    #modal-patient-record * { visibility: visible; }
    #modal-patient-detail,
    #modal-patient-record {
        position: absolute; left: 0; top: 0; width: 100%;
        background: white; padding: 0;
    }
    .modal { background: white !important; padding: 0 !important; }
    .modal-content {
        max-height: none !important; box-shadow: none !important;
        border-radius: 0 !important; max-width: 100% !important;
    }
    .modal-footer, .modal-close, .btn-outline { display: none !important; }
    .modal-header { border-bottom: 2px solid #000 !important; }
    .pr-header { background: white !important; border: 1px solid #ccc; }
    .pr-encounter-detail { display: block !important; }
    .pr-encounter { break-inside: avoid; }
    .report-encounter { break-inside: avoid; }
    .report-view { max-width: 100%; }
    @page { margin: 1.5cm; }
    .print-clinic-header {
        display: block !important; text-align: center;
        padding: 12px 0 16px; border-bottom: 3px double #000;
        margin-bottom: 16px;
    }
    .print-clinic-header h2 { font-size: 1.3rem; margin: 0; }
    .print-clinic-header p { font-size: 0.8rem; color: #666; margin: 4px 0 0; }
}

/* ═══════════════════════════════════════════════
   VOICE INTERVIEW STYLES
   ═══════════════════════════════════════════════ */

/* Status Banner */
.vi-status-banner {
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 12px;
    transition: all 0.3s;
}
.vi-status-idle { background: #f0f4f8; color: #475569; }
.vi-status-starting { background: #fef3c7; color: #92400e; }
.vi-status-active { background: #dcfce7; color: #166534; border: 2px solid #22c55e; }
.vi-status-completed { background: #dbeafe; color: #1e40af; }
.vi-status-emergency { background: #fef2f2; color: #991b1b; border: 2px solid #ef4444; font-size: 1.1rem; }
.vi-status-failed { background: #fef2f2; color: #991b1b; }

/* Health Warning */
.vi-health-warning {
    background: #fffbeb;
    border: 2px solid #f59e0b;
    border-radius: 8px;
}
.vi-health-warning h3 { margin: 0 0 6px; }
.vi-health-warning p { margin: 0 0 10px; color: #92400e; }

/* Mode & Language Controls */
.vi-controls { padding: 12px !important; }
.vi-controls-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.vi-mode-toggle {
    display: flex;
    gap: 4px;
    background: #f1f5f9;
    border-radius: 8px;
    padding: 3px;
}
.vi-mode-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    background: transparent;
    color: #64748b;
    transition: all 0.2s;
}
.vi-mode-btn.active {
    background: #1a56db;
    color: white;
    font-weight: 600;
}
.vi-lang-select select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
}

/* Conversation Panel */
.vi-conversation-card { padding-bottom: 8px !important; }
.vi-conversation {
    max-height: 450px;
    min-height: 200px;
    overflow-y: auto;
    padding: 12px;
    background: #f8fafc;
    border-radius: 8px;
    margin-bottom: 8px;
    scroll-behavior: smooth;
}
.vi-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #94a3b8;
}
.vi-empty-state .vi-hint { font-size: 0.85rem; margin-top: 8px; }

/* Messages */
.vi-message {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    max-width: 88%;
}
.vi-message-ai {
    background: #e0e7ff;
    border-left: 3px solid #4f46e5;
    margin-right: auto;
}
.vi-message-patient {
    background: #dcfce7;
    border-right: 3px solid #22c55e;
    margin-left: auto;
}
.vi-message-system {
    background: #fef3c7;
    border-left: 3px solid #f59e0b;
    margin: 0 auto;
    max-width: 95%;
    text-align: center;
    font-size: 0.9rem;
}
.vi-message-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 4px;
}
.vi-message-icon { font-size: 1rem; }
.vi-message-label { font-weight: 600; }
.vi-message-time { margin-left: auto; }
.vi-message-text {
    font-size: 0.95rem;
    line-height: 1.5;
    color: #1e293b;
    white-space: pre-wrap;
}

/* Input Areas */
.vi-input-area {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid #e2e8f0;
}
.vi-text-input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}
.vi-text-input:focus { border-color: #4f46e5; }
.vi-text-input:disabled { background: #f1f5f9; }

/* Voice Record Button */
.vi-record-btn {
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
    border: 2px dashed #94a3b8;
    border-radius: 12px;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.3s;
}
.vi-record-btn:hover { border-color: #4f46e5; background: #eef2ff; }
.vi-record-btn.recording {
    background: #fef2f2;
    border-color: #ef4444;
    border-style: solid;
    animation: vi-pulse 1.5s ease-in-out infinite;
}

@keyframes vi-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
}

/* Processing Indicator */
.vi-processing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    color: #64748b;
    font-size: 0.9rem;
    border-top: 1px solid #e2e8f0;
}
.loading-spinner-sm {
    width: 18px;
    height: 18px;
    border: 2px solid #e2e8f0;
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Live Insights */
.vi-insights { padding: 12px !important; }
.vi-insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}
.vi-insight-item {
    text-align: center;
    padding: 8px;
    background: #f8fafc;
    border-radius: 6px;
}
.vi-insight-label {
    display: block;
    font-size: 0.75rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}
.vi-insight-value {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: #1e293b;
}

/* Action Bar */
.vi-action-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}
.vi-action-bar .btn { flex: 1; min-width: 140px; }

.btn-danger {
    background: #ef4444;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}
.btn-danger:hover { background: #dc2626; }

/* Extraction Results */
.vi-extraction-section { margin-bottom: 16px; }
.vi-extraction-section h4 {
    font-size: 0.95rem;
    color: #374151;
    margin: 0 0 8px;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 4px;
}
.vi-extraction-item {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
    align-items: flex-start;
}
.vi-extract-label {
    font-size: 0.8rem;
    color: #6b7280;
    min-width: 110px;
    flex-shrink: 0;
}
.vi-extract-value {
    font-size: 0.9rem;
    color: #1f2937;
}
.vi-hindi {
    font-style: italic;
    color: #4338ca;
}

/* Symptom chips in extraction */
.vi-symptom-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.vi-symptom-chip {
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.85rem;
    flex: 1 1 200px;
    max-width: 300px;
}
.vi-symptom-code {
    font-weight: 700;
    color: #166534;
    display: block;
}
.vi-symptom-area {
    color: #6b7280;
    font-size: 0.78rem;
}
.vi-symptom-dur, .vi-symptom-sev {
    font-size: 0.78rem;
    color: #64748b;
    margin-left: 6px;
}
.vi-symptom-quote {
    font-size: 0.8rem;
    color: #4338ca;
    font-style: italic;
    margin-top: 4px;
}
.vi-extraction-actions { margin-top: 16px; }

/* Source badge for auto-populated symptoms */
.symptom-source-badge,
.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.72rem;
    padding: 2px 6px;
    background: #ede9fe;
    color: #6d28d9;
    border-radius: 4px;
    margin-left: 6px;
}
.source-badge.source-voice {
    background: #dbeafe;
    color: #1d4ed8;
}
.vi-patient-quote {
    font-size: 0.78rem;
    color: #6b7280;
    font-style: italic;
    margin-top: 2px;
    padding-left: 4px;
    width: 100%;
}



/* ---------------------------------------------------------------
   V2.1 � Physical observation checklist
   --------------------------------------------------------------- */
.physobs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.5rem 1rem;
    margin-top: 0.5rem;
}
.physobs-item {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    background: #fafafa;
    border: 1px solid #eee;
    user-select: none;
    font-size: 0.9rem;
}
.physobs-item:hover { background: #f0f4ff; border-color: #cfd7ff; }
.physobs-item input[type=checkbox] { transform: scale(1.15); }
.physobs-item input:checked + span { color: #b23a00; font-weight: 600; }

/* ---------------------------------------------------------------
   V2.1 � Referral / Encounter Print
   Only visible when the print action is triggered.
   --------------------------------------------------------------- */
.print-area { display: none; }
@media print {
    body * { visibility: hidden; }
    .print-area, .print-area * { visibility: visible; }
    .print-area {
        display: block !important;
        position: absolute;
        left: 0; top: 0;
        width: 100%;
        padding: 24px;
        /* System Devanagari fallbacks — Google Fonts is often blocked by
           corporate firewalls in the field, so we lean on fonts that ship
           with each OS: Nirmala UI (Windows 8+), Kohinoor Devanagari
           (macOS/iOS), Roboto (Android). */
        font-family: 'Noto Sans Devanagari', 'Nirmala UI', 'Kohinoor Devanagari',
                     'Mangal', 'Aparajita', 'Segoe UI', 'Roboto', Arial, sans-serif;
        color: #111;
        background: white;
    }
    .print-area h1, .print-area h2, .print-area h3 { color: #000; }
    .print-area .print-section { margin-bottom: 12px; page-break-inside: avoid; }
    .print-area .print-hindi { font-size: 1.05rem; line-height: 1.6; }
    .print-area .print-two-col { display: flex; gap: 20px; }
    .print-area .print-two-col > div { flex: 1; }
    .print-area table { width: 100%; border-collapse: collapse; }
    .print-area td, .print-area th { border: 1px solid #333; padding: 4px 8px; text-align: left; font-size: 0.9rem; }
    @page { size: A4; margin: 12mm; }
}

/* ---------------------------------------------------------------
   V2.1 � Attachments (photos of prior reports)
   --------------------------------------------------------------- */
.attachments-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 8px;
}
.attachment-thumb {
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    background: #fafafa;
    display: flex;
    flex-direction: column;
    text-align: center;
    position: relative;
}
.attachment-thumb img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    background: #eee;
}
.attachment-thumb .caption {
    padding: 4px 6px;
    font-size: 0.75rem;
    color: #333;
    max-height: 40px;
    overflow: hidden;
}
.attachment-thumb .del {
    position: absolute;
    top: 4px; right: 4px;
    background: rgba(220, 40, 40, 0.9);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.7rem;
    cursor: pointer;
}
.attachment-thumb .del:hover { background: #c00; }

/* ---------------------------------------------------------------
   V2.1 � Outcomes dashboard
   --------------------------------------------------------------- */
.outcomes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin: 12px 0;
}
.outcomes-card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    padding: 12px 16px;
}
.outcomes-card .val { font-size: 1.8rem; font-weight: 700; color: #123; }
.outcomes-card .label { font-size: 0.85rem; color: #666; text-transform: uppercase; letter-spacing: 0.5px; }
.outcomes-table { width: 100%; margin-top: 10px; border-collapse: collapse; }
.outcomes-table th, .outcomes-table td { padding: 6px 8px; border-bottom: 1px solid #eee; font-size: 0.9rem; text-align: left; }
.outcomes-table th { background: #f5f5f5; }

/* ═══════════════════════════════════════════════════════════════
   PREMIUM POLISH LAYER  (appended last — wins the cascade)
   Unifies the shell, controls, surfaces and adds motion + skeletons
   ═══════════════════════════════════════════════════════════════ */

/* Refined scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--gray-300) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--gray-400); background-clip: content-box; }

/* ---- App shell ---- */
.topbar {
    height: var(--topbar-height);
    background: rgba(255,255,255,0.85);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--hairline);
    box-shadow: 0 1px 0 rgba(16,24,40,0.02);
}
.brand-text { color: var(--primary-dark); letter-spacing: -0.02em; }
.topbar-page-title { color: var(--gray-800); font-weight: 650; text-transform: capitalize; letter-spacing: -0.01em; }

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--hairline);
    width: var(--sidebar-width);
    padding: var(--space-3) var(--space-3);
}
.nav-item {
    display: flex; align-items: center; gap: var(--space-3);
    padding: 10px 12px; margin: 2px 0;
    border-radius: var(--radius);
    color: var(--gray-600); font-weight: 550; font-size: var(--text-base);
    cursor: pointer; border: none; background: transparent; width: 100%; text-align: left;
    transition: background var(--transition), color var(--transition);
    position: relative;
}
.nav-item:hover { background: var(--gray-50); color: var(--gray-900); }
.nav-item.active {
    background: var(--primary-50);
    color: var(--primary-dark);
    font-weight: 650;
}
.nav-item.active::before {
    content: ''; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
    width: 3px; height: 20px; border-radius: 999px; background: var(--primary);
}
.nav-icon, .nav-item .icon { font-size: 1.05rem; width: 20px; text-align: center; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 16px; border-radius: var(--radius);
    font-weight: 600; font-size: var(--text-base); line-height: 1;
    cursor: pointer; border: 1px solid transparent;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition), border-color var(--transition);
    white-space: nowrap;
}
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary {
    background: linear-gradient(180deg, #2563eb 0%, var(--primary) 100%);
    color: #fff; box-shadow: 0 1px 2px rgba(16,24,40,0.10), inset 0 1px 0 rgba(255,255,255,0.18);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 4px 12px -2px rgba(26,86,219,0.40); }
.btn-secondary, .btn-outline {
    background: var(--surface); color: var(--gray-700);
    border: 1px solid var(--gray-300); box-shadow: var(--shadow-sm);
}
.btn-secondary:hover:not(:disabled), .btn-outline:hover:not(:disabled) { background: var(--gray-50); border-color: var(--gray-400); }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover:not(:disabled) { background: var(--gray-100); }
.btn-danger { background: var(--danger); color: #fff; box-shadow: 0 1px 2px rgba(220,38,38,0.25); }
.btn-danger:hover:not(:disabled) { background: #b91c1c; box-shadow: 0 4px 12px -2px rgba(220,38,38,0.40); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803d; }
.btn-lg { padding: 14px 22px; font-size: var(--text-md); border-radius: var(--radius-lg); }
.btn-block { width: 100%; }

/* ---- Surfaces / cards ---- */
.card, .panel, .section-card {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.card:hover { box-shadow: var(--shadow-md); }

/* ---- Inputs ---- */
input, select, textarea {
    border-radius: var(--radius) !important;
    border: 1px solid var(--gray-300);
    transition: border-color var(--transition), box-shadow var(--transition);
}
input::placeholder, textarea::placeholder { color: var(--gray-400); }

/* ---- Tables (premium density + hover) ---- */
.data-table, .outcomes-table {
    border-collapse: separate; border-spacing: 0;
    background: var(--surface); border-radius: var(--radius-lg); overflow: hidden;
    border: 1px solid var(--hairline);
}
.data-table th, .outcomes-table th {
    background: var(--gray-50); color: var(--gray-500);
    font-size: var(--text-xs); font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em;
    padding: 12px 16px; border-bottom: 1px solid var(--hairline); text-align: left;
}
.data-table td, .outcomes-table td { padding: 13px 16px; border-bottom: 1px solid var(--hairline); font-size: var(--text-base); }
.data-table tr:last-child td, .outcomes-table tr:last-child td { border-bottom: none; }
.data-table tbody tr, .outcomes-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover, .outcomes-table tbody tr:hover { background: var(--gray-50); }

/* ---- Status pill ---- */
.pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: var(--radius-pill);
    font-size: var(--text-xs); font-weight: 650; letter-spacing: 0.01em; line-height: 1.5;
}
.pill-red { background: var(--red-bg); color: var(--red); box-shadow: inset 0 0 0 1px var(--red-border); }
.pill-yellow { background: var(--yellow-bg); color: var(--yellow); box-shadow: inset 0 0 0 1px var(--yellow-border); }
.pill-green { background: var(--green-bg); color: var(--green); box-shadow: inset 0 0 0 1px var(--green-border); }
.pill-gray { background: var(--gray-100); color: var(--gray-600); box-shadow: inset 0 0 0 1px var(--gray-200); }

/* ---- Skeleton shimmer ---- */
.skeleton {
    position: relative; overflow: hidden;
    background: var(--gray-200); border-radius: var(--radius-xs);
}
.skeleton::after {
    content: ''; position: absolute; inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.65), transparent);
    animation: skeleton-shimmer 1.4s infinite;
}
@keyframes skeleton-shimmer { 100% { transform: translateX(100%); } }

/* ---- Motion primitives ---- */
@keyframes rcn-fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes rcn-spin { to { transform: rotate(360deg); } }
.fade-up { animation: rcn-fade-up 0.35s cubic-bezier(0.22,1,0.36,1) both; }

/* ═══════════ MEDICAL DIAGNOSTIC SCANNER OVERLAY ═══════════ */
.rcn-analysis {
    --rcn-accent: #2563eb;
    position: fixed; inset: 0; z-index: 4000;
    display: flex; align-items: center; justify-content: center;
    background:
        radial-gradient(1000px 560px at 50% 34%, rgba(37,99,235,0.16), transparent 62%),
        rgba(15,23,42,0.55);
    backdrop-filter: saturate(170%) blur(14px);
    -webkit-backdrop-filter: saturate(170%) blur(14px);
    animation: rcn-fade-up 0.3s ease both;
}
.rcn-analysis-card {
    position: relative; overflow: hidden;
    background: var(--surface); border: 1px solid rgba(255,255,255,0.7);
    border-radius: 24px;
    box-shadow: 0 44px 90px -22px rgba(2,6,23,0.6), inset 0 1px 0 rgba(255,255,255,0.8);
    width: min(500px, 94vw); padding: 34px 30px 0;
    text-align: center;
    animation: rcn-card-in 0.5s cubic-bezier(0.22,1,0.36,1) both;
}
@keyframes rcn-card-in { from { opacity: 0; transform: translateY(16px) scale(0.96); } to { opacity: 1; transform: none; } }
/* faint moving vitals-grid behind the content */
.rcn-analysis-card::before {
    content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0.6;
    background-image: linear-gradient(color-mix(in srgb, var(--rcn-accent) 7%, transparent) 1px, transparent 1px),
                      linear-gradient(90deg, color-mix(in srgb, var(--rcn-accent) 7%, transparent) 1px, transparent 1px);
    background-size: 24px 24px;
    -webkit-mask-image: radial-gradient(circle at 50% 26%, #000 0%, transparent 70%);
    mask-image: radial-gradient(circle at 50% 26%, #000 0%, transparent 70%);
    transition: background-image 0.4s;
}
.rcn-analysis-card > * { position: relative; }

/* ---- Scanner hero ---- */
.rcn-scanner { position: relative; width: 138px; height: 138px; margin: 6px auto 22px; }
.rcn-ring-svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.rcn-ring-svg circle { fill: none; stroke-width: 7; stroke-linecap: round; }
.rcn-ring-svg .track { stroke: var(--gray-200); }
.rcn-ring-svg .prog {
    stroke: var(--rcn-accent);
    filter: drop-shadow(0 0 7px color-mix(in srgb, var(--rcn-accent) 60%, transparent));
    transition: stroke-dashoffset 0.45s cubic-bezier(0.4,0,0.2,1), stroke 0.45s;
}
/* rotating radar sweep */
.rcn-radar {
    position: absolute; inset: 14px; border-radius: 999px;
    background: conic-gradient(from 0deg, transparent 0deg, color-mix(in srgb, var(--rcn-accent) 30%, transparent) 46deg, transparent 96deg);
    animation: rcn-spin 2.6s linear infinite; opacity: 0.85;
    -webkit-mask: radial-gradient(circle, transparent 33%, #000 35%);
    mask: radial-gradient(circle, transparent 33%, #000 35%);
    transition: background 0.45s;
}
/* emanating pulse rings */
.rcn-pulse-ring {
    position: absolute; inset: 0; margin: auto; width: 74px; height: 74px; border-radius: 999px;
    border: 2px solid color-mix(in srgb, var(--rcn-accent) 50%, transparent);
    animation: rcn-pulse-out 2.4s ease-out infinite;
}
.rcn-pulse-ring.r2 { animation-delay: 1.2s; }
@keyframes rcn-pulse-out { 0% { transform: scale(0.55); opacity: 0.75; } 100% { transform: scale(1.95); opacity: 0; } }
/* glowing core with the % */
.rcn-scanner-core {
    position: absolute; inset: 0; margin: auto; width: 74px; height: 74px; border-radius: 999px;
    background: radial-gradient(circle at 50% 32%, #fff, color-mix(in srgb, var(--rcn-accent) 9%, #fff));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--rcn-accent) 18%, transparent),
                0 8px 18px -8px color-mix(in srgb, var(--rcn-accent) 45%, transparent);
    display: flex; align-items: center; justify-content: center;
    animation: rcn-core-breathe 2.2s ease-in-out infinite;
}
@keyframes rcn-core-breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.rcn-analysis-pct { font-weight: 800; font-size: 1.35rem; color: var(--gray-900); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

.rcn-analysis-title { font-size: 1.4rem; font-weight: 750; color: var(--gray-900); letter-spacing: -0.02em; }
.rcn-analysis-sub { color: var(--gray-500); font-size: var(--text-sm); margin-top: 5px; min-height: 1.2em; }

/* ---- Live EKG monitor strip ---- */
.rcn-ekg {
    margin: 24px -30px 0; height: 62px; position: relative; overflow: hidden;
    border-top: 1px solid var(--hairline);
    background: color-mix(in srgb, var(--rcn-accent) 4%, #fff);
}
.rcn-ekg svg { width: 100%; height: 100%; display: block; }
.rcn-ekg-scroll { animation: rcn-ekg-scroll 2.2s linear infinite; }
@keyframes rcn-ekg-scroll { to { transform: translateX(-120px); } }
.rcn-ekg-line {
    fill: none; stroke: var(--rcn-accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
    filter: drop-shadow(0 0 3px color-mix(in srgb, var(--rcn-accent) 65%, transparent));
    transition: stroke 0.45s;
}
/* soft leading glow at the right edge of the monitor */
.rcn-ekg::after {
    content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 60px;
    background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--rcn-accent) 4%, #fff));
    pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
    .rcn-radar, .rcn-pulse-ring, .rcn-scanner-core, .rcn-ekg-scroll { animation: none; }
}
.rcn-analysis-steps { margin-top: 22px; text-align: left; display: flex; flex-direction: column; gap: 12px; }
.rcn-astep {
    display: flex; align-items: center; gap: 12px;
    font-size: var(--text-base); color: var(--gray-400); font-weight: 500;
    transition: color var(--transition), opacity var(--transition);
    opacity: 0.55;
}
/* colorful medical-icon chip; --c is the step's accent colour */
.rcn-astep .dot {
    --c: var(--primary);
    width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; position: relative;
    background: var(--gray-100);  /* fallback if color-mix unsupported */
    background: color-mix(in srgb, var(--c) 12%, #fff);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 22%, transparent);
    font-size: 19px; line-height: 1;
    filter: grayscale(0.7); transition: filter var(--transition), transform var(--transition), box-shadow var(--transition);
}
.rcn-astep.active {
    color: var(--gray-900); font-weight: 650; opacity: 1;
}
.rcn-astep.active .dot {
    filter: none; transform: scale(1.06);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 40%, transparent),
                0 0 0 4px color-mix(in srgb, var(--c) 16%, transparent);
    animation: rcn-astep-pulse 1.3s ease-in-out infinite;
}
@keyframes rcn-astep-pulse {
    0%,100% { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 40%, transparent), 0 0 0 3px color-mix(in srgb, var(--c) 20%, transparent); }
    50%     { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 55%, transparent), 0 0 0 8px color-mix(in srgb, var(--c) 6%, transparent); }
}
.rcn-astep.done { color: var(--gray-600); opacity: 1; }
.rcn-astep.done .dot { filter: none; }
/* green check badge on completed steps */
.rcn-astep.done .dot::after {
    content: '✓'; position: absolute; right: -4px; bottom: -4px;
    width: 17px; height: 17px; border-radius: 999px;
    background: var(--green); color: #fff; font-size: 11px; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 0 2px var(--surface);
    animation: rcn-fade-up 0.25s ease both;
}

/* ═══════════ ENCOUNTER CONTEXT BAR + STEPPER ═══════════ */
.enc-contextbar {
    display: flex; align-items: center; gap: 16px;
    padding: 10px 20px; background: var(--surface);
    border-bottom: 1px solid var(--hairline);
    flex-shrink: 0; flex-wrap: wrap;
}
.enc-context-patient { display: flex; align-items: center; gap: 10px; min-width: 0; }
.enc-context-avatar {
    width: 34px; height: 34px; border-radius: 999px; flex-shrink: 0;
    background: linear-gradient(180deg, #2563eb, var(--primary)); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.enc-context-name { font-weight: 650; color: var(--gray-900); font-size: var(--text-base); }
.enc-context-meta { color: var(--gray-500); font-size: var(--text-xs); }
.enc-stepper { display: flex; align-items: center; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.enc-step {
    display: flex; align-items: center; gap: 7px;
    padding: 5px 11px; border-radius: var(--radius-pill);
    font-size: var(--text-xs); font-weight: 600; color: var(--gray-400);
    background: transparent; cursor: pointer; transition: all var(--transition);
    border: 1px solid transparent;
}
.enc-step .idx {
    width: 18px; height: 18px; border-radius: 999px; display: flex; align-items: center; justify-content: center;
    background: var(--gray-200); color: var(--gray-500); font-size: 11px; font-weight: 700;
}
.enc-step:hover { background: var(--gray-50); }
.enc-step.active { color: var(--primary-dark); background: var(--primary-50); }
.enc-step.active .idx { background: var(--primary); color: #fff; }
.enc-step.done { color: var(--green); }
.enc-step.done .idx { background: var(--green); color: #fff; }
.enc-step.done .idx::after { content: '✓'; }
.enc-step.done .idx .n { display: none; }
.enc-step-sep { width: 14px; height: 1px; background: var(--gray-200); }

/* ═══════════ DECISION CARD ADDITIONS (doctor diagnosis + AI verdict) ═══════════ */
.decision-field { margin-top: 16px; }
.decision-field label { display: block; font-size: var(--text-sm); font-weight: 650; color: var(--gray-700); margin-bottom: 6px; }
.decision-field input[type=text], .decision-field textarea, .decision-field select {
    width: 100%; padding: 10px 12px; border: 1px solid var(--gray-300); border-radius: var(--radius);
    font-size: var(--text-base);
}
.seg-control { display: inline-flex; background: var(--gray-100); border-radius: var(--radius); padding: 3px; gap: 3px; }
.seg-control button {
    padding: 7px 16px; border: none; background: transparent; border-radius: var(--radius-xs);
    font-weight: 600; font-size: var(--text-sm); color: var(--gray-600); cursor: pointer; transition: all var(--transition);
}
.seg-control button.on-yes { background: var(--green); color: #fff; box-shadow: var(--shadow-sm); }
.seg-control button.on-no { background: var(--danger); color: #fff; box-shadow: var(--shadow-sm); }

/* Outcomes: AI-OK status chips (fix mojibake) */
.ai-ok-chip { display: inline-flex; align-items: center; justify-content: center; font-size: 1rem; }
.ai-ok-chip.correct { color: var(--green); }
.ai-ok-chip.wrong { color: var(--danger); }
.ai-ok-chip.pending { color: var(--gray-400); }
.audit-row-btn {
    padding: 5px 12px; font-size: var(--text-xs); font-weight: 650;
    border: 1px solid var(--primary); color: var(--primary); background: var(--primary-50);
    border-radius: var(--radius-pill); cursor: pointer; transition: all var(--transition);
}
.audit-row-btn:hover { background: var(--primary); color: #fff; }


/* ═══════ V3 medicine cards + action lanes (mockup style, 2026-09-06) ═══════
   Owner: the medicine tables "look garbage" for semi-literate operators.
   Replaced with big per-medicine cards + icon timing chips + colored lanes. */
.lane3 { border-radius: 14px; overflow: hidden; margin: 10px 16px; border: 2px solid #e5e7eb; background: #fff; }
.lane3-head { padding: 11px 14px; font-size: 1.02rem; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.lane3-g .lane3-head { background: #ecfdf3; color: #15803d; }
.lane3-y .lane3-head { background: #fefce8; color: #92680a; }
.lane3-r .lane3-head { background: #fef2f2; color: #b91c1c; }
.lane3-g { border-color: #86efac; } .lane3-y { border-color: #fde047; } .lane3-r { border-color: #fca5a5; }
.lane3-body { padding: 6px 12px 12px; }
.med3-card { display: flex; gap: 12px; align-items: flex-start; background: #f8fafc; border: 1.5px solid #e2e8f0; border-radius: 12px; padding: 12px 14px; margin: 8px 0; }
.med3-num { flex: 0 0 34px; height: 34px; border-radius: 50%; background: #0e7490; color: #fff; font-weight: 800; font-size: 1.05rem; display: flex; align-items: center; justify-content: center; margin-top: 2px; }
.med3-main { flex: 1; min-width: 0; }
.med3-name { font-size: 1.08rem; font-weight: 800; color: #0f172a; line-height: 1.25; }
.med3-form { font-size: 0.8rem; color: #64748b; font-weight: 500; }
.med3-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.med3-chip { display: inline-flex; align-items: center; gap: 5px; background: #fff; border: 1.5px solid #cbd5e1; border-radius: 999px; padding: 5px 12px; font-size: 0.92rem; font-weight: 700; color: #334155; }
.med3-chip.dose { background: #eff6ff; border-color: #93c5fd; color: #1d4ed8; }
.med3-chip.days { background: #f0fdf4; border-color: #86efac; color: #15803d; }
.med3-chip.maxcap { background: #fef2f2; border-color: #fca5a5; color: #b91c1c; font-size: 0.8rem; }
.med3-note { margin-top: 7px; font-size: 0.87rem; color: #475569; background: #fffbeb; border-left: 3px solid #f59e0b; padding: 5px 9px; border-radius: 0 8px 8px 0; }
.med3-empty { font-size: 0.95rem; color: #475569; padding: 8px 2px; }
.lane3 ul.lane3-list { margin: 4px 0 2px; padding-left: 22px; font-size: 0.95rem; color: #334155; line-height: 1.65; }
.fu3-chip { margin: 4px 16px 12px; padding: 11px 14px; background: #f0f9ff; border: 1.5px solid #7dd3fc; border-radius: 12px; font-size: 0.95rem; font-weight: 700; color: #0c4a6e; }
/* V3.1 result-page declutter */
.triage-fold { margin: 12px 0; border: 1.5px solid #e2e8f0; border-radius: 12px; background: #fff; }
.triage-fold > summary { cursor: pointer; padding: 13px 16px; font-weight: 700; font-size: 0.95rem; color: #334155; list-style: none; display: flex; align-items: center; gap: 8px; }
.triage-fold > summary::-webkit-details-marker { display: none; }
.triage-fold > summary::after { content: '▼'; margin-left: auto; font-size: 0.75rem; color: #94a3b8; transition: transform .15s; }
.triage-fold[open] > summary::after { transform: rotate(180deg); }
.triage-fold[open] > summary { border-bottom: 1.5px solid #e2e8f0; }
.triage-fold .triage-section-card { border: none; border-top: 1px solid #f1f5f9; border-radius: 0; box-shadow: none; margin: 0; }
.triage-fold-hint { font-weight: 400; font-size: 0.75rem; color: #94a3b8; }
.med3-note { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.med3-note.open { -webkit-line-clamp: unset; }

/* ═══════════════════════════════════════════════════════════════════
   TABLET & MOBILE  (2026-09-13)
   ═══════════════════════════════════════════════════════════════════
   These rules are LAST in the file on purpose. An earlier `.sidebar`
   block further up re-declares `width: var(--sidebar-width)` outside any
   media query, and on small screens that variable is 0px — so the drawer
   opened correctly but was zero pixels wide and appeared to do nothing.
   Equal specificity means last-one-wins, so this section must stay at the
   bottom of the file.

   Breakpoint is 1024px, not 768px: the clinic runs on 11-inch tablets,
   which are ~820px CSS wide in portrait. At a 768px breakpoint those fall
   into DESKTOP layout and lose a third of the screen to a pinned sidebar.
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    /* Drawer, not a pinned column. !important is deliberate — it has to beat
       the later unconditional .sidebar rule described above. */
    .sidebar {
        width: 288px !important;
        max-width: 86vw;
        transform: translateX(-100%);
        padding: var(--space-3, 0.75rem) !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        z-index: 1000;
    }
    .sidebar.open { transform: translateX(0) !important; box-shadow: 0 0 40px rgba(0,0,0,.28); }

    /* Content must never be pushed by a drawer that floats above it. */
    .main-content,
    .sidebar.collapsed ~ .main-content { margin-left: 0 !important; padding: 1rem; }

    /* Tap-to-close backdrop. Without this the only way out of the drawer is
       picking a menu item, which is a trap on a touch screen. */
    #sidebar-backdrop {
        position: fixed; inset: var(--topbar-height, 60px) 0 0 0;
        background: rgba(15,23,42,.45);
        opacity: 0; pointer-events: none;
        transition: opacity .2s ease;
        z-index: 999;
    }
    #sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

    /* Touch targets: a gloved finger in a clinic, not a mouse. */
    .nav-item { padding: 14px 14px !important; font-size: 1rem !important; }
    .nav-icon { font-size: 1.25rem; }
    .btn-icon { min-width: 44px; min-height: 44px; font-size: 1.25rem; }
    .btn, button.btn { min-height: 44px; }

    /* Forms: 16px minimum stops iOS/Android auto-zooming on focus, which
       otherwise throws the whole layout sideways mid-consultation. */
    input, select, textarea { font-size: 16px !important; min-height: 44px; }

    /* Grids that assume a wide screen. */
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .vitals-grid { grid-template-columns: repeat(2, 1fr); }
    .quick-actions-grid { grid-template-columns: repeat(2, 1fr); }
    .two-column, .triage-two-col, .patient-grid { grid-template-columns: 1fr; }

    /* Nothing may cause a horizontal scroll on a touch device. */
    body { overflow-x: hidden; }
    table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* Phones and narrow portrait tablets */
@media (max-width: 640px) {
    .stats-grid, .vitals-grid, .quick-actions-grid { grid-template-columns: 1fr; }
    .main-content { padding: 0.75rem; }
    .topbar-page-title { font-size: 0.95rem; }
    .decision-buttons, .decision-buttons-v2 { flex-direction: column; grid-template-columns: 1fr; }
}

/* 11-inch tablet in landscape (~1194-1280px): keep the pinned sidebar, it
   fits comfortably, but tighten the content gutters so cards breathe. */
@media (min-width: 1025px) and (max-width: 1366px) {
    .main-content { padding: 1.25rem 1.5rem; }
    .vitals-grid { grid-template-columns: repeat(3, 1fr); }
}
