/* CSS Variables for consistent theming - Light Mode */
:root {
    /* 1.1 Surfaces - The "Clinical Slate" Foundation */
    --bg-main: #f1f5f9;        /* Slate-100 Softest slate background */
    --bg-card: #ffffff;        /* Pure white for cards */
    --bg-sidebar: #0f172a;     /* Slate-900 Dark anchor */
    --border-subtle: #e2e8f0;  /* Slate-200 */
    --border-focus: #4f46e5;   /* Indigo-600 */
    
    /* 1.2 Primary Brand - The "Indigo Diagnostic" Palette */
    --brand-primary: #4f46e5;    /* Indigo-600 */
    --brand-primary-hover: #4338ca;
    --brand-accent: #6366f1;     /* Indigo-500 */
    --brand-soft: #eef2ff;       /* Indigo-50 */
    
    /* 1.3 Semantic Colors - Consistent meaning */
    --success: #10b981;        /* Emerald-500 */
    --warning: #f59e0b;        /* Amber-500 */
    --danger: #ef4444;         /* Red-500 */
    --info: #3b82f6;           /* Blue-500 */

    /* 1.4 Typography - Slate scale for depth */
    --text-heading: #0f172a;   /* Slate-900 */
    --text-body: #334155;      /* Slate-700 */
    --text-muted: #64748b;     /* Slate-500 */
    --text-on-brand: #ffffff;

    /* 1.5 Geometry & Elevation */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);

    /* Legacy Bridge Mappings (ensures existing code doesn't break) */
    --bg-primary: var(--bg-main);
    --bg-secondary: var(--bg-card);
    --text-primary: var(--text-heading);
    --text-secondary: var(--text-body);
    --text-muted: var(--text-muted);
    
    /* Missing Legacy Variables */
    --light-bg: var(--bg-secondary);
    --dark-text: var(--text-primary);
    --medium-text: var(--text-secondary);
    --light-text: var(--text-muted);
    
    --card-bg: var(--bg-card);
    --card-border: var(--border-subtle);
    --primary-color: var(--brand-primary);
    --secondary-color: #334155;
    --success-color: var(--success);
    --warning-color: var(--warning);
    --danger-color: var(--danger);
    --border-radius: var(--radius-md);
    --border-radius-sm: var(--radius-sm);
    --header-gradient: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);

    /* Chart / Gradient Colors - Clinical Precision */
    --chart-teal: #0d9488;    /* Teal-600 */
    --chart-blue: #0284c7;    /* Sky-600 */

    /* Tables - light theme */
    --table-header-bg: #f1f5f9;
    --table-row-odd: #ffffff;
    --table-row-even: #f8fafc;
    --table-row-hover: #eef2ff;
    --table-border: #e2e8f0;
}

/* 1.3 Form Section Headers - Ensure high contrast in light mode */
.form-section-header {
    background: linear-gradient(90deg, var(--chart-teal), var(--chart-blue)) !important;
    color: white !important;
}
.form-section-header * {
    color: white !important;
}

/* Ensure User Info in Header is visible against the dark header gradient */
.logout-container .user-info {
    color: white !important;
    background: rgba(255, 255, 255, 0.15) !important;
    border: 1px solid rgba(255, 255, 255, 0.25);
}
.logout-container .user-info * {
    color: white !important;
}

/* Dashboard KPI Cards - Modern Glass Effect */
.kpi-cards-container {
    display: flex;
    gap: 1.25rem;
    justify-content: space-between;
    align-items: stretch;
    margin-bottom: 1.5rem;
}

.kpi-card {
    flex: 1 1 0;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    padding: 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
    transition: var(--transition);
    border: 1px solid var(--card-border);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--chart-teal), var(--chart-blue));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.kpi-card:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-4px);
    border-color: var(--primary-color);
}

.kpi-card:hover::before {
    opacity: 1;
}

.kpi-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.kpi-value {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--chart-teal), var(--chart-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.25rem;
    text-align: center;
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.kpi-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 0.5rem;
    font-weight: 500;
    line-height: 1.4;
}
/* Custom style for multiple select input (previouslyOnDrug) */
#previouslyOnDrug[multiple] {
    min-height: 120px;
    max-height: 220px;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    font-size: 1rem;
    color: var(--dark-text);
    padding: 0.5rem 0.75rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    outline: none;
    width: 100%;
    margin-bottom: 0.5rem;
    transition: border-color 0.2s;
}
#previouslyOnDrug[multiple]:focus {
    border-color: var(--primary-color);
}
#previouslyOnDrug[multiple] option {
    padding: 6px 12px;
    font-size: 1rem;
    background: #fff;
    color: #222;
    border-radius: 6px;
    margin: 2px 0;
}
/* Restrict patient status distribution chart to its grid/container */
#patientStatusDoughnut {
    width: 100% !important;
    max-width: 400px;
    height: auto !important;
    display: block;
    margin: 0 auto;
    box-sizing: border-box;
}
/* Premium Typography for system header — login page */
.system-header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: white !important;
    -webkit-text-fill-color: white !important;
    margin-bottom: 0.5rem;
}

.system-header p {
    font-size: 1.1rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.9) !important;
    letter-spacing: 0.3px;
}
/* Ensure all form labels, input placeholders, and headings are visible on light backgrounds */
label, .form-label, .login-form label, .add-patient-form label {
    color: #222 !important;
    font-weight: 500;
}

input, select, textarea {
    color: #222;
    background-color: #fff;
}

input::placeholder, textarea::placeholder {
    color: #888 !important;
    opacity: 1;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary) !important;
}

/* Preserve white text on gradient section headers */
.form-section-header,
.chart-box .form-section-header,
.form-section-header .section-title,
.form-section-header span {
    color: white !important;
}

/* For Nepali/Hindi/other language labels, ensure color is also set */
.form-label[lang], label[lang] {
    color: #222 !important;
}
/* Clinical Decision Support Alert Styles */
.dose-adequate {
    background-color: #dcfce7 !important;
    color: #166534 !important;
    font-weight: 600;
    position: relative;
    border-left: 4px solid #22c55e;
    padding: 2px 8px;
    border-radius: 4px;
}
.dose-inadequate {
    background-color: #fee2e2 !important;
    color: #991b1b !important;
    font-weight: 600;
    position: relative;
    border-left: 4px solid #ef4444;
    padding: 2px 8px;
    border-radius: 4px;
}
.dose-excessive {
    background-color: rgba(253,126,20,0.18) !important;
    color: var(--dark-text) !important;
    font-weight: 600;
    position: relative;
    border-left: 4px solid #fd7e14;
}
.dose-suboptimal {
    background-color: rgba(255,193,7,0.18) !important;
    color: var(--dark-text) !important;
    font-weight: 600;
    position: relative;
    border-left: 4px solid #ffc107;
}
.dose-adequacy-icon {
    margin-left: 6px;
    font-size: 1em;
    vertical-align: middle;
    opacity: 0.85;
}
.cds-no-alerts {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 20px;
}

/* Admin Cards Grid for Management Tab */
.admin-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.admin-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    display: flex;
    flex-direction: column;
}

.admin-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--brand-primary);
}

.admin-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 1.25rem;
}

.admin-card-title {
    margin: 0 0 0.5rem 0;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-heading);
}

.admin-card-desc {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
    flex-grow: 1;
}

.admin-card-footer {
    margin-top: auto;
}

/* Specific Card Icon Colors */
.icon-viewer { background: var(--brand-soft); color: var(--brand-primary); }
.icon-reset { background: #fee2e2; color: var(--danger); }
.icon-sync { background: #e0f2fe; color: var(--info); }
.icon-patient { background: #fef3c7; color: var(--warning); }
.icon-cds { background: #ecfdf5; color: var(--success); }
.icon-storage { background: #fff7ed; color: #ea580c; }

@media (max-width: 640px) {
    .admin-cards-grid {
        grid-template-columns: 1fr;
    }
}

.cds-section {
    margin-bottom: 25px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: #fff;
}

.cds-section h5 {
    margin: 0;
    padding: 12px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    border-radius: 8px 8px 0 0;
    font-size: 1rem;
    font-weight: 600;
    color: #495057;
}

.cds-section .alert {
    margin: 10px 16px;
    border-radius: 6px;
}

.cds-section .alert:last-child {
    margin-bottom: 16px;
}

/* Screening Tool Styles */
.screening-tool-container {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 16px;
    margin-top: 12px;
}

.screening-tool-title {
    color: #2c5aa0;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.screening-instructions {
    background: #fff;
    border-left: 4px solid #17a2b8;
    padding: 10px 12px;
    margin-bottom: 16px;
    font-style: italic;
    color: #495057;
}

.screening-questions {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.screening-question {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 12px;
}

.screening-question label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #212529;
}

.screening-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.screening-option {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 2px solid #dee2e6;
    border-radius: 20px;
    padding: 6px 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    color: #495057;
}

.screening-option:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.screening-option input[type="radio"] {
    margin: 0;
}

.screening-option input[type="radio"]:checked + * {
    color: #2c5aa0;
}

.screening-scoring {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    padding: 12px;
    margin-top: 16px;
}

.screening-scoring strong {
    color: #856404;
    display: block;
    margin-bottom: 8px;
}

.screening-scoring ul {
    margin: 0;
    padding-left: 20px;
}

.screening-scoring li {
    color: #856404;
    margin-bottom: 4px;
}

.alert-next-steps {
    background: #d1ecf1;
    border-left: 4px solid #17a2b8;
    padding: 12px;
    margin-top: 12px;
    border-radius: 4px;
}

.alert-next-steps strong {
    color: #0c5460;
    display: block;
    margin-bottom: 8px;
}

.alert-next-steps ol {
    margin: 0;
    padding-left: 20px;
}

.alert-next-steps li {
    color: #0c5460;
    margin-bottom: 6px;
}

.alert-references {
    background: #e7f3ff;
    border-left: 4px solid #007bff;
    padding: 12px;
    margin-top: 12px;
    border-radius: 4px;
}

.alert-references strong {
    color: #004085;
    display: block;
    margin-bottom: 8px;
}

.alert-references ul {
    margin: 0;
    padding-left: 20px;
}

.alert-references li {
    color: #004085;
    margin-bottom: 4px;
    font-size: 0.9em;
}

.alert-body {
    padding: 10px 0;
    color: #495057;
    line-height: 1.5;
}

.alert-rationale strong {
    font-weight: 600;
    color: #212529;
}

.cds-action-section {
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
    margin: 0;
}

/* Streamlined Medication Interface */
.streamlined-medication-interface {
    background: #fff;
    border-radius: 8px;
    padding: 0;
}

/* Ultra-Compact Safety Pills */
.safety-pills-container {
    animation: slideIn 0.3s ease-out;
}

.safety-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 15px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.75em;
    font-weight: 500;
    color: #6c757d;
    transition: all 0.2s ease;
    user-select: none;
    min-width: 70px;
    justify-content: center;
}

.safety-pill:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.safety-pill i {
    font-size: 11px;
    opacity: 0.7;
}

.safety-pill.checked {
    background: linear-gradient(135deg, #28a745, #20c997);
    border-color: #28a745;
    color: white;
    font-weight: 600;
}

.safety-pill.checked i {
    opacity: 1;
    animation: checkPulse 0.3s ease-out;
}

@keyframes checkPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Offline Mode Styles */
body.offline-mode {
    filter: saturate(0.8);
}

body.offline-mode::before {
    content: '';
    position: fixed;
    top: 48px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 107, 107, 0.02);
    pointer-events: none;
    z-index: 1;
}

.offline-disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
    position: relative;
}

.offline-disabled::after {
    content: '\f1eb';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    color: #ff6b6b;
    font-size: 12px;
    text-decoration: line-through;
}

#global-offline-banner {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Structured Data Entry Styles */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 2px 0;
    margin: 0;
}

.checkbox-label input[type="checkbox"] {
    margin: 0;
    width: 16px;
    height: 16px;
}

.checkbox-label span {
    font-weight: 500;
    color: #495057;
}

/* Addiction Other Text Field Styling */
#addictionOtherContainer {
    display: none;
    margin-left: 24px;
    margin-top: 4px;
    padding: 0;
    animation: slideDown 0.25s ease-out;
}

#addictionOtherContainer input[type="text"] {
    width: 100%;
    padding: 6px 10px;
    border: 1.5px solid var(--border-subtle, #e2e8f0);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: all 0.2s ease;
    background-color: var(--bg-card, #ffffff);
    color: var(--text-primary, #0f172a);
}

#addictionOtherContainer input[type="text"]:focus {
    outline: none;
    border-color: var(--border-focus, #4f46e5);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    background-color: var(--bg-card, #ffffff);
}

#addictionOtherContainer input[type="text"]::placeholder {
    color: var(--text-secondary, #334155);
    opacity: 0.6;
}

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

.medication-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 10px;
}

.medication-item-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.medication-item-group label {
    font-weight: 600;
    color: #2c5aa0;
    font-size: 0.9rem;
}

.medication-item-group select,
.medication-item-group input {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.medication-item-group select:focus,
.medication-item-group input:focus {
    outline: 0;
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Compact Breakthrough Seizure Checklist (Alternative Style) */
.safety-checklist-compact {
    animation: slideIn 0.3s ease-out;
}

.safety-check-item {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(240, 198, 116, 0.3);
    border-radius: 20px;
    padding: 6px 12px;
    margin: 2px;
    font-size: 0.85em;
    transition: all 0.2s ease;
    position: relative;
    user-select: none;
}

.safety-check-item:hover {
    background: rgba(255, 255, 255, 0.9);
    border-color: #f0c674;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.safety-check-item input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.safety-check-item .checkmark {
    width: 16px;
    height: 16px;
    border: 2px solid #856404;
    border-radius: 50%;
    margin-right: 8px;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.safety-check-item input[type="checkbox"]:checked ~ .checkmark {
    background: #28a745;
    border-color: #28a745;
}

.safety-check-item input[type="checkbox"]:checked ~ .checkmark::after {
    content: "✓";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 11px;
    font-weight: bold;
}

.safety-check-item input[type="checkbox"]:checked ~ .check-text {
    color: #28a745;
    font-weight: 600;
}

.check-text {
    color: #856404;
    font-weight: 500;
    transition: color 0.2s ease;
}

.breakthrough-checklist-compact {
    animation: slideIn 0.3s ease-out;
}

.breakthrough-checklist-compact h5 {
    display: flex;
    align-items: center;
    gap: 8px;
}

.breakthrough-checklist-compact label {
    transition: background-color 0.2s ease;
    padding: 5px;
    border-radius: 4px;
}

.breakthrough-checklist-compact label:hover {
    background-color: rgba(255, 193, 7, 0.1);
}

.inline-guidance {
    padding: 5px 8px;
    border-radius: 4px;
    background-color: rgba(40, 167, 69, 0.1);
    border-left: 3px solid #28a745;
    animation: fadeInUp 0.3s ease-out;
}

.loading-spinner {
    animation: pulse 1.5s ease-in-out infinite;
}

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

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Epilepsy Type Classification UI */
#epilepsyTypeSection {
    transition: all 0.3s ease;
}

#epilepsyTypeSection .classification-help {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 4px;
    border-left: 3px solid #007bff;
}

#epilepsyTypeSection .status-indicator {
    background: #d4edda;
    color: #155724;
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #c3e6cb;
}

/* Follow-up Frequency Selector - COMPACT */
.frequency-selector {
    position: relative;
    min-width: 150px;
    text-align: right;
    z-index: 20002;
}

.frequency-label {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    font-size: 0.75rem;
    color: #666;
    margin-bottom: 3px;
    gap: 4px;
}

.frequency-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: white;
    border: 2px solid #2196f3;
    border-radius: 6px;
    cursor: pointer;
    min-width: 180px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.frequency-button:hover {
    border-color: #1976d2;
    background: #e3f2fd;
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
    transform: translateY(-2px);
}

.frequency-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.frequency-dropdown {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border: 1px solid #bbdefb;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 220px;
    margin-top: 8px;
    overflow: hidden;
}

.frequency-option {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9rem;
}

.frequency-option:last-child {
    border-bottom: none;
}

.frequency-option:hover {
    background: #e3f2fd;
    border-left: 3px solid #2196f3;
    padding-left: 13px;
}

.frequency-option i {
    margin-right: 12px;
    width: 18px;
    color: var(--primary-color);
    font-size: 1.1em;
}

.frequency-option span {
    font-weight: 500;
    margin-right: auto;
}

.frequency-option small {
    color: #666;
    font-size: 0.7rem;
}

.frequency-status {
    margin-top: 3px;
    padding: 4px 8px;
    background: #d4edda;
    color: #155724;
    border-radius: 4px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Radio button styling for frequency selector */
#followFrequencySection label {
    position: relative;
}

#followFrequencySection input[type="radio"] {
    accent-color: #2196f3;
}

#followFrequencySection input[type="radio"]:checked + div {
    font-weight: 700;
}

#followFrequencySection label:has(input[type="radio"]:checked) {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border-color: #2196f3 !important;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.15);
}

#followFrequencySection label:hover {
    border-color: #2196f3;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.15);
}

.modal-header {
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
    margin-bottom: 8px;
    position: relative;
}

#followUpModal .modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 20001;
}

.cds-severity-section {
    margin-bottom: 20px;
}

.cds-severity-header {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    background: #f8f9fa;
    border-left: 4px solid #dee2e6;
}

.cds-high .cds-severity-header {
    background: #f8d7da;
    border-left-color: #dc3545;
    color: #721c24;
}

.cds-medium .cds-severity-header {
    background: #fff3cd;
    border-left-color: #ffc107;
    color: #856404;
}

.cds-info .cds-severity-header {
    background: #d1ecf1;
    border-left-color: #17a2b8;
    color: #0c5460;
}

.cds-alert {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 10px;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.cds-alert:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.cds-alert-high {
    border-left: 4px solid #dc3545;
}

.cds-alert-medium {
    border-left: 4px solid #ffc107;
}

.cds-alert-info {
    border-left: 4px solid #17a2b8;
}

.cds-alert-low {
    border-left: 4px solid #28a745;
}

.cds-alert-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    border-radius: 8px 8px 0 0;
}

.cds-alert-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #495057;
}

.cds-alert-actions {
    display: flex;
    gap: 8px;
}

.cds-ack-btn {
    font-size: 0.85rem;
    padding: 4px 12px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.cds-ack-btn:hover {
    background-color: #007bff;
    border-color: #007bff;
    color: white;
}

.cds-alert-content {
    padding: 16px;
}

.cds-alert-description {
    margin-bottom: 12px;
    color: #495057;
    line-height: 1.5;
}

.cds-alert-rationale {
    margin-bottom: 12px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 0.9rem;
    color: #6c757d;
}

.cds-alert-recommendations {
    margin-top: 12px;
}

.cds-alert-recommendations strong {
    color: #495057;
}

.cds-alert-recommendations ul {
    margin: 8px 0 0 0;
    padding-left: 20px;
}

.cds-alert-recommendations li {
    margin-bottom: 4px;
    color: #495057;
    line-height: 1.4;
}

.cds-acknowledged {
    opacity: 0.6;
    border-color: #28a745;
}

.cds-acknowledged .cds-alert-header {
    background: #d4edda;
}

.cds-acknowledged .cds-alert-title::after {
    content: " ✓ Acknowledged";
    font-size: 0.8rem;
    color: #155724;
    font-weight: normal;
}

/* Responsive CDS alerts */
@media (max-width: 768px) {
    .cds-alert-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .cds-alert-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .cds-ack-btn {
        flex: 1;
        max-width: 100px;
    }
}

/* Referral Workflow Styles */
.referral-summary-box {
    background: #fff3cd;
    border-left: 4px solid var(--warning-color);
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 8px;
}

.referral-summary-box {
    color: #000; /* Ensure all text is black by default */
}

.referral-summary-box p,
.referral-summary-box .summary-label,
.referral-summary-box .summary-value,
.referral-summary-box h4,
.referral-summary-box strong {
    /* Removed global force black text */
    margin: 0 0 8px 0;
}

.referral-summary-box p:last-child {
    margin-bottom: 0;
}

.referral-summary-box p:last-child {
    margin-bottom: 0;
}

.breakthrough-checklist {
    background: #e8f4fd;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.breakthrough-checklist h4 {
    color: var(--primary-color);
    margin-top: 0;
}

.dosage-aid {
    background: #e8f5e9;
    border-left: 4px solid var(--success-color);
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Referral Patient List Styles */
.referral-queue-header {
    background: #fff;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    box-shadow: var(--box-shadow);
}

.referral-queue-header h3 {
    margin: 0 0 0.5rem 0;
    color: var(--secondary-color);
    font-weight: 600;
}

.referral-queue-header p {
    color: var(--light-text);
    margin-bottom: 1rem;
}

.referral-stats {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.referral-card {
    background: #fff;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 1.25rem;
    overflow: hidden;
    transition: var(--transition);
    border-left: 4px solid var(--primary-color);
}

.referral-card.tertiary {
    border-left-color: var(--warning-color);
}

.referral-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.referral-card-header {
    padding: 1.25rem 1.5rem 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
}

.patient-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.patient-info h4 {
    margin: 0;
    color: var(--secondary-color);
    font-size: 1.1rem;
}

.patient-id {
    color: var(--light-text);
    font-size: 0.9rem;
    background: #f5f5f5;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
}

.referral-meta {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.days-ago {
    font-size: 0.85rem;
    color: var(--success-color);
    background: rgba(39, 174, 96, 0.1);
    padding: 0.3rem 0.7rem;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.days-ago.urgent {
    color: var(--danger-color);
    background: rgba(231, 76, 60, 0.1);
}

.seizure-freq {
    font-size: 0.85rem;
    color: var(--primary-color);
    background: rgba(52, 152, 219, 0.1);
    padding: 0.3rem 0.7rem;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.referral-card-body {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #f0f0f0;
}

.patient-details {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
    color: var(--medium-text);
    font-size: 0.95rem;
}

.patient-details div {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.patient-details i {
    color: var(--primary-color);
    width: 16px;
    text-align: center;
}

.referral-reason {
    background: #f8f9fa;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin: 1rem 0;
    font-size: 0.95rem;
    line-height: 1.5;
}

.current-meds {
    background: #e8f4fd;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--secondary-color);
    margin-top: 1rem;
}

.referral-card-actions {
    padding: 1rem 1.5rem;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.tertiary-badge {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--warning-color);
    font-size: 0.85rem;
    font-weight: 500;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .referral-card-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .referral-meta {
        margin-top: 0.5rem;
        flex-wrap: wrap;
    }
    
    .patient-details {
        grid-template-columns: 1fr;
    }
    
    .referral-card-actions {
        flex-direction: column;
    }
    
    .tertiary-badge {
        margin-left: 0;
        justify-content: center;
    }
}

/* CSS Variables for consistent theming */

/* CSS Variables for consistent theming - Light Mode */


/* Dark Mode Overrides */
body[data-theme="dark"], body.dark-mode {
    /* 1.1 Base Surfaces - Deep, rich backgrounds */
    --bg-primary: #0a0f1a;
    --bg-secondary: #111827;
    --bg-elevated: #1f2937;
    --bg-overlay: rgba(0, 0, 0, 0.7);
    --bg-glass: rgba(17, 24, 39, 0.9);

    /* 1.2 Text - Excellent contrast for readability */
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-inverse: #0f172a;
    --text-on-primary: #ffffff;
    --text-link: #38bdf8;

    /* 1.3 Interactive / Inputs */
    --input-bg: #0f172a;
    --input-border: #374151;
    --input-border-focus: #38bdf8;
    --input-placeholder: #6b7280;
    --button-primary-bg: linear-gradient(135deg, #0284c7 0%, #0ea5e9 100%);
    --button-primary-text: #ffffff;
    --button-secondary-bg: #1f2937;
    --button-secondary-text: #e2e8f0;

    /* 1.4 Cards & Panels - Elevated surfaces */
    --card-bg: #111827;
    --card-border: #1f2937;
    --card-hover-bg: #1f2937;
    --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.2);
    --card-shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.5);
    --card-shadow-elevated: 0 12px 48px rgba(0, 0, 0, 0.6);

    /* 1.5 Section Headers */
    --section-header-bg: linear-gradient(135deg, #0f766e 0%, #0284c7 100%);
    --section-header-text: #f1f5f9;
    --section-header-border: #1f2937;

    /* 1.6 Consent / Checkbox / Warning Boxes */
    --warning-bg: rgba(234, 179, 8, 0.1);
    --warning-border: #ca8a04;
    --warning-text: #fde047;

    /* 1.7 Info / Help Boxes */
    --info-bg: rgba(2, 132, 199, 0.1);
    --info-border: #0284c7;
    --info-text: #7dd3fc;
    --info-accent-text: #38bdf8;

    /* 1.8 Success / Confirmation Boxes */
    --success-bg: rgba(22, 163, 74, 0.1);
    --success-border: #16a34a;
    --success-text: #86efac;

    /* 1.9 Error / Danger Boxes */
    --danger-bg: rgba(220, 38, 38, 0.1);
    --danger-border: #dc2626;
    --danger-text: #fca5a5;

    /* 1.10 Tables */
    --table-header-bg: #0f172a;
    --table-row-odd: #111827;
    --table-row-even: #0f172a;
    --table-row-hover: rgba(56, 189, 248, 0.08);
    --table-border: #1f2937;

    /* 1.11 Status Semantic Colors - Vibrant for dark mode */
    --primary-color: #38bdf8;
    --primary-dark: #0284c7;
    --primary-light: rgba(56, 189, 248, 0.15);
    --secondary-color: #94a3b8;
    --accent-color: #2dd4bf;
    --success-color: #4ade80;
    --warning-color: #fbbf24;
    --danger-color: #f87171;

    /* Chart colors for dark mode */
    --chart-blue: #38bdf8;
    --chart-teal: #2dd4bf;
    --chart-emerald: #34d399;
    --chart-amber: #fbbf24;
    --chart-rose: #fb7185;
    --chart-violet: #a78bfa;
    --chart-slate: #94a3b8;

    /* Header gradient for dark mode */
    --header-gradient: linear-gradient(135deg, #0a0f1a 0%, #0f766e 40%, #0284c7 100%);

    /* Legacy variables mapping to new tokens */
    --light-bg: var(--bg-primary);
    --dark-text: var(--text-primary);
    --medium-text: var(--text-secondary);
    --light-text: var(--text-muted);
    --border-color: var(--card-border);
    --box-shadow: var(--card-shadow);

    color-scheme: dark;
}



/* Light reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Ensure all text in the patient education center is dark for readability */
#patientEducationCenter {
    background: #fff !important;
    color: var(--dark-text) !important;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--primary-color);
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
    padding: 1rem;
    margin-bottom: 1rem;
}
#patientEducationCenter * {
    color: var(--dark-text) !important;
}

/* Consistent text colors for medication elements */
#breakthroughChecklist, #breakthroughChecklist *,
.medication-item-group label,
.medication-item-group .hindi-translation {
    color: var(--dark-text) !important;
}

/* Ensure all drug names are visible on any background */
.medication-item-group label {
    font-weight: 500;
}

/* Critical Alerts Section */
#criticalAlertsSection {
    margin-bottom: 2rem;
    transition: var(--transition);
    border-radius: var(--border-radius);
    overflow: hidden;
}

#criticalAlertsHeader {
    padding: 1rem 1.5rem;
    background-color: #fff5f5;
    border-left: 5px solid var(--danger-color);
    transition: var(--transition);
}

#criticalAlertsHeader:hover {
    background-color: #ffebee;
}

#criticalAlertsHeader h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    color: var(--danger-color);
    font-weight: 600;
}

#criticalAlertsToggle {
    transition: transform 0.3s ease;
    color: var(--danger-color);
}

#criticalAlertsContent {
    background-color: white;
    transition: max-height 0.3s ease-out;
    overflow: hidden;
}

.patient-card .card-details .detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--light-bg);
    border-radius: 12px;
    margin-bottom: 10px;
    border: none;
}
.patient-card .card-details .detail-item:last-child {
    margin-bottom: 0;
}

/* Badge for alert count */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    padding: 0 0.5rem;
}

/* Reset and base styles */
/* ── Base Global Styles ── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-body);
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
    line-height: 1.5;
    min-height: 100vh;
}

/* ── Hyper-Modern Mobile-First Login Rebuild ──────────────────────────── */

.login-page-wrapper {
    min-height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background: linear-gradient(135deg, #c0392b 0%, #8e2d7f 35%, #4a1a7f 65%, #1a1a4e 100%);
    background-attachment: fixed;
    padding: 20px;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: #fff;
    overflow-x: hidden;
}

html.offline-boot #loginForm {
    display: none !important;
}

html.offline-boot #offlineBootNotice {
    display: block !important;
}

/* Compact Top Nav */
.top-nav-compact {
    width: 100%;
    max-width: 440px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    z-index: 10;
}

.lang-pill {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 6px 14px;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
}

.lang-pill option {
    background: #1e293b;
    color: white;
}

.desktop-about-link {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Branding Area */
.login-branding-area {
    text-align: center;
    margin-bottom: 32px;
}

.brain-icon-circle {
    width: 64px;
    height: 64px;
    background: rgba(20, 184, 166, 0.2);
    border: 2px solid rgba(20, 184, 166, 0.4);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 1.75rem;
    color: #2dd4bf;
    box-shadow: 0 0 30px rgba(13, 148, 136, 0.4);
    animation: pulse-teal 3s infinite ease-in-out;
}

@keyframes pulse-teal {
    0%, 100% { transform: scale(1); box-shadow: 0 0 20px rgba(13, 148, 136, 0.3); }
    50% { transform: scale(1.05); box-shadow: 0 0 40px rgba(13, 148, 136, 0.6); }
}

.app-title-main {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-bottom: 8px;
    color: #ffffff !important;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
}

.app-subtitle-main {
    font-size: 0.85rem;
    opacity: 0.8;
    font-weight: 400;
    color: #ffffff !important;
    letter-spacing: 0.3px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* The Core Card */
.login-card-container {
    width: 100%;
    max-width: 420px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
}

.rainbow-stripe {
    height: 4px;
    width: 100%;
    background: linear-gradient(to right, #ef4444, #f97316, #eab308, #22c55e, #3b82f6, #a855f7);
}

.login-card-content {
    padding: 24px;
    color: #1e293b;
}

.login-heading {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
    text-align: center;
}

.login-subheading {
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 24px;
    text-align: center;
}

/* Modern Form Elements */
.form-input-group {
    margin-bottom: 20px;
}

.form-input-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #475569;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-input-group input {
    width: 100%;
    height: 48px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 0 16px;
    font-size: 16px; /* Prevents iOS zoom */
    color: #0f172a;
    transition: all 0.2s;
}

.form-input-group input:focus {
    background: #fff;
    border-color: #0d9488;
    box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.1);
    outline: none;
}

.pass-wrapper {
    position: relative;
}

.pass-eye-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 12px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-error-text {
    color: #dc2626;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 6px;
}

.remember-row {
    margin-bottom: 24px;
}

.compact-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #475569;
    cursor: pointer;
    min-height: 44px;
}

/* Redesigned Role Selector */
.role-selection-area {
    margin-bottom: 28px;
}

.section-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.role-grid-redesign {
    display: grid;
    grid-template-columns: 1fr; /* Mobile-first: single column */
    gap: 10px;
}

@media (min-width: 380px) {
    .role-grid-redesign {
        grid-template-columns: repeat(3, 1fr);
    }
}

.role-card-new {
    cursor: pointer;
}

.role-card-new input {
    display: none;
}

.role-card-inner {
    height: 100%;
    display: flex;
    flex-direction: row; /* Horizontal on mobile */
    align-items: center;
    padding: 12px 16px;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    color: #64748b;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 48px;
}

@media (min-width: 380px) {
    .role-card-inner {
        flex-direction: column; /* Vertical on tablet/desktop */
        padding: 12px 8px;
        min-height: 72px;
    }
}

.role-card-inner i {
    font-size: 1.25rem;
    margin-right: 12px;
}

@media (min-width: 380px) {
    .role-card-inner i {
        margin-right: 0;
        margin-bottom: 8px;
    }
}

.role-name-new {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.role-card-new input:checked + .role-card-inner {
    background: #f0fdfa;
    border-color: #0d9488;
    color: #0d9488;
    box-shadow: 0 4px 6px -1px rgba(13, 148, 136, 0.1);
}

/* Actions */
.login-action-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.btn-login-teal-new {
    width: 100%;
    height: 52px;
    background: #0d9488;
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-login-teal-new:hover {
    background: #0f766e;
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(13, 148, 136, 0.4);
}

.btn-outline-minimal {
    background: none;
    border: none;
    color: #64748b;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 4px;
    cursor: pointer;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Security Box */
.security-box-teal {
    background: #f0fdfa;
    border-radius: 12px;
    padding: 16px;
    border-left: 4px solid #0d9488;
}

.sec-title {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #0d9488;
    margin-bottom: 4px;
}

.sec-body {
    font-size: 0.75rem;
    color: #334155;
    line-height: 1.4;
}

/* PIN Bottom Sheet */
.pin-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

@media (min-width: 640px) {
    .pin-modal-overlay {
        align-items: center;
    }
}

.pin-bottom-sheet {
    width: 100%;
    max-width: 500px;
    background: #fff;
    border-radius: 32px 32px 0 0;
    padding: 24px 24px calc(24px + env(safe-area-inset-bottom));
    animation: slideUpSheet 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    color: #1e293b;
}

@media (min-width: 640px) {
    .pin-bottom-sheet {
        border-radius: 24px;
        padding: 32px;
    }
}

.drag-handle {
    width: 40px;
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    margin: 0 auto 24px;
}

@media (min-width: 640px) {
    .drag-handle {
        display: none;
    }
}

.pin-bottom-sheet h2 { font-size: 1.25rem; font-weight: 800; margin-bottom: 8px; text-align: center; }
.pin-subtitle { font-size: 0.85rem; color: #64748b; margin-bottom: 24px; text-align: center; }

.pin-input-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.pin-input-group input {
    height: 52px;
    background: #f1f5f9;
    border: 2px solid transparent;
    border-radius: 16px;
    text-align: center;
    font-size: 1.5rem;
    letter-spacing: 0.3em;
    font-weight: 700;
}

.pin-input-group input:focus {
    border-color: #0d9488;
    background: #fff;
    outline: none;
}

.pin-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

@media (min-width: 380px) {
    .pin-actions {
        flex-direction: row;
    }
    .pin-actions button {
        flex: 1;
    }
}

/* Mobile About Pill */
.mobile-about-pill {
    margin-top: 24px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 12px 24px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    width: auto;
    min-height: 48px;
    transition: all 0.2s;
}

.mobile-about-pill:active {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(0.98);
}

@media (min-width: 768px) {
    .mobile-about-pill {
        display: none;
    }
}

/* Animations */
@keyframes slideUpSheet {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

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

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Media Queries */
@media (min-width: 768px) {
    .login-page-wrapper {
        justify-content: center;
    }
    .login-branding-area {
        margin-bottom: 40px;
    }
    .brain-icon-circle {
        width: 80px;
        height: 80px;
        font-size: 2.25rem;
    }
    .app-title-main {
        font-size: 2.5rem;
    }
    .login-card-container {
        max-width: 440px;
    }
    .login-card-content {
        padding: 40px;
    }
}

.system-header {
    text-align: center;
    margin-bottom: 2rem;
    color: white;
}

.system-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: white;
    font-weight: 800;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.system-header p {
    font-size: 1.1rem;
    opacity: 0.95;
    max-width: 600px;
    margin: 0 auto;
    font-weight: 500;
}

.system-header i {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, var(--chart-teal), var(--chart-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.2);
    background-color: rgba(255, 255, 255, 0.95);
}

.login-card {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--border-radius-lg);
    padding: 2rem 2rem 2rem 2rem;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    animation: fadeIn 0.6s ease-out;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--chart-teal), var(--chart-blue), var(--chart-violet));
}

.login-logo {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-logo h2 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.3px;
}

.login-logo p {
    color: var(--text-muted);
    font-size: 0.925rem;
    margin-bottom: 0;
}

/* Form styles */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-form h3 {
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.login-form h3 i {
    color: var(--chart-teal);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
    max-width: 100%;
}

/* Full-width elements inside form grid */
.form-grid > .medication-form-grid,
.form-grid > [style*="grid-column"],
.form-grid > .seizure-helper-card,
.form-grid > #draftIndicator {
    grid-column: 1 / -1;
}

/* Follow-up form specific styling for better layout */
#followUpForm.form-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

/* Offline Login UI - Modern and touch-friendly */
.offline-profiles-container {
    padding: 1.25rem 0;
    animation: fadeInUp 0.4s ease-out;
}

.offline-section-title {
    text-align: center;
    margin-bottom: 1.25rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.offline-section-title::before,
.offline-section-title::after {
    content: '';
    width: 24px;
    height: 2px;
    background: linear-gradient(90deg, var(--chart-teal), var(--chart-blue));
    border-radius: 1px;
}

.offline-profiles-grid {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding: 0.5rem;
}

.offline-profile-card {
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: var(--border-radius);
    padding: 1.25rem 1rem;
    width: 110px;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--card-shadow);
    position: relative;
    overflow: hidden;
}

.offline-profile-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--chart-teal), var(--chart-blue));
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.offline-profile-card:hover,
.offline-profile-card:focus {
    transform: translateY(-6px);
    border-color: var(--chart-blue);
    box-shadow: 0 12px 28px rgba(2, 132, 199, 0.2);
}

.offline-profile-card:hover::before,
.offline-profile-card:focus::before {
    transform: scaleX(1);
}

.offline-profile-card:active {
    transform: translateY(-2px) scale(0.98);
}

.offline-profile-card i {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--chart-teal), var(--chart-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    transition: transform 0.3s ease;
}

.offline-profile-card:hover i {
    transform: scale(1.15);
}

.offline-profile-name {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    line-height: 1.3;
}

.offline-profile-role {
    font-size: 0.65rem;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, var(--chart-teal), var(--chart-blue));
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.offline-divider {
    text-align: center;
    margin: 1.25rem 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.offline-divider::before,
.offline-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--card-border), transparent);
}

.offline-divider span {
    padding: 0 1rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.offline-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
}

.btn-modern-secondary {
    background: var(--card-bg);
    color: var(--text-secondary);
    border: 2px solid var(--card-border);
    padding: 0.875rem 1.5rem;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    font-size: 0.875rem;
    width: 100%;
    max-width: 280px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-modern-secondary:hover {
    border-color: var(--chart-blue);
    color: var(--chart-blue);
    background: var(--primary-light);
}

.btn-modern-secondary i {
    font-size: 0.9rem;
}

.btn-modern-secondary:hover {
    background: var(--card-border);
    color: var(--text-primary);
}

.btn-modern-danger {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    padding: 0.875rem 1.5rem;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.95rem;
    width: 100%;
    max-width: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.25s ease;
    box-shadow: 0 2px 4px rgba(185, 28, 28, 0.05);
}

.btn-modern-danger:hover {
    background: #fecaca;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(185, 28, 28, 0.1);
}

/* For very wide screens, use 3 columns */
@media (min-width: 1400px) {
    .form-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
    
    #followUpForm.form-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
}

/* For large screens, use 2 columns */
@media (min-width: 1200px) and (max-width: 1399px) {
    .form-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

/* For tablet screens, maintain single column */
@media (min-width: 768px) and (max-width: 1199px) {
    .form-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    #followUpForm.form-grid {
        grid-template-columns: 1fr;
    }
}

/* For mobile screens, single column */
@media (max-width: 767px) {
    .form-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    #followUpForm.form-grid {
        grid-template-columns: 1fr;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
}

/* Custom fields injected by Dynamic Form Renderer */
.custom-section-container {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.4rem;
}

.custom-section-container .form-group {
    background: #f8faff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
}

.custom-section-container .form-group label {
    font-weight: 600;
    color: #2c5aa0;
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
}

.custom-section-container .media-record-btn,
.custom-section-container .media-stop-btn,
.custom-section-container .media-delete-btn {
    font-size: 0.8rem;
    padding: 0.3rem 0.6rem;
}

.custom-section-container audio {
    max-width: 100%;
    height: 36px;
}

.seizure-helper-card {
    grid-column: 1 / -1;
    margin-top: 0.5rem;
    padding: 0.6rem 0.8rem;
    background: #f0f7ff;
    border: 1px solid #cfe2ff;
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.seizure-helper-card strong {
    color: #0f5ad3;
    font-size: 0.9rem;
}

.seizure-helper-card p {
    margin: 0.2rem 0 0;
    font-size: 0.8rem;
    color: #495057;
}

.seizure-helper-card .btn {
    white-space: nowrap;
}

.form-group label {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    letter-spacing: 0.01em;
}

/* Compact styling for checkbox-group form-groups */
.form-group:has(.checkbox-group) {
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
}

.form-group:has(.checkbox-group) label {
    margin-bottom: 0.25rem;
}

.form-group:has(.checkbox-group) .checkbox-group {
    gap: 4px;
}

.label-line {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    max-width: 100%;
    display: block;
    padding: 0.75rem 1rem;
    border: 2px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    font-size: 0.95rem;
    color: var(--dark-text);
    background: #fff;
    transition: var(--transition);
}

.form-group textarea {
    min-height: 70px;
    resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.15);
}

/* Scope: Slightly reduce form sizes only inside follow-up modal - COMPACT */
#followUpModal .form-group label {
    font-size: 0.85rem;
    color: var(--dark-text);
    margin-bottom: 0.2rem;
}
#followUpModal .form-group input,
#followUpModal .form-group select,
#followUpModal .form-group textarea {
    padding: 0.5rem 0.6rem;
    font-size: 0.9rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    width: 100%;
    transition: border-color 0.2s ease;
}

#followUpModal .form-group select {
    height: auto;
    min-height: 38px;
}

#followUpModal .form-group input:focus,
#followUpModal .form-group select:focus,
#followUpModal .form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.password-input-wrapper input {
    width: 100%;
    padding-right: 2.8rem;
    flex: 1;
}

.password-toggle {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--light-text);
    font-size: 1rem;
    padding: 0.4rem 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
    z-index: 10;
    pointer-events: auto;
    flex-shrink: 0;
    min-width: 2rem;
    min-height: 2rem;
    border-radius: 4px;
}

.password-toggle:hover {
    color: var(--primary-color);
    background-color: rgba(52, 152, 219, 0.05);
}

.password-toggle:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
}

/* Ensure input field receives clicks properly */
.password-input-wrapper input:focus {
    outline: 2px solid var(--primary-color);
}

/* Mobile optimization */
@media (max-width: 600px) {
    .password-toggle {
        padding: 0.35rem 0.4rem;
        min-width: 1.8rem;
        min-height: 1.8rem;
        font-size: 0.95rem;
    }
    
    .password-input-wrapper input {
        padding-right: 2.4rem;
    }
}

.remember-me-group {
    margin: 0.15rem 0;
}

.remember-me-label {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--medium-text);
    font-weight: 400 !important;
}

.remember-me-label input[type="checkbox"] {
    width: 16px;
    min-width: 16px;
    height: 16px;
    min-height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary-color);
    flex-shrink: 0;
}

.form-group input.error {
    border-color: var(--danger-color);
    background: #fdecea;
}

.error-message {
    color: var(--danger-color);
    font-size: 0.875rem;
    margin-top: 0.3125rem;
    display: none;
}

/* Form section headers - Collapsible on all devices */
.form-section-header {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, var(--chart-teal), var(--chart-blue));
    color: white;
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0.75rem 0 0 0;
    padding: 0.875rem 1.25rem;
    border-radius: var(--border-radius-sm) var(--border-radius-sm) 0 0;
    border-bottom: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
    cursor: pointer;
    letter-spacing: 0.01em;
}

.form-section-header:hover {
    background: linear-gradient(135deg, var(--chart-blue), var(--chart-teal));
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.2);
}

.form-section-header.collapsed {
    border-radius: 6px;
    margin-bottom: 0.25rem;
}

.form-section-header .section-title {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: white;
}

.form-section-header .collapse-icon {
    transition: transform 0.3s ease;
    color: white;
    font-size: 1.2rem;
    min-width: 24px;
    text-align: center;
}

.form-section-header.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.form-section-content {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-top: none;
    border-radius: 0 0 var(--border-radius-sm) var(--border-radius-sm);
    margin-bottom: 0.5rem;
    transition: var(--transition);
    overflow: hidden;
}

/* Follow-up form specific adjustments - COMPACT */
#followUpForm .form-section-content {
    grid-template-columns: 1fr;
    gap: 0.25rem;
    padding: 0.4rem 0.6rem;
}

/* Follow-up form input and text sizing - COMPACT */
#followUpForm input,
#followUpForm select,
#followUpForm textarea {
    font-size: 0.85rem;
}

#followUpForm label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--dark-text);
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

#followUpForm .form-group label {
    font-size: 0.82rem;
    font-weight: 500;
}

/* Follow-up form groups - COMPACT single column for better readability */
#followUpForm .form-group {
    margin-bottom: 0.25rem;
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
    background: #f9f9f9;
    border-left: 3px solid #e9ecef;
    transition: all 0.2s ease;
}

#followUpForm .form-group:hover {
    border-left-color: var(--primary-color);
    background: #f0f8ff;
}

/* Special styling for important sections */
#followUpForm .form-group[style*="grid-column: 1 / -1"] {
    background: #fff8e1;
    border-left-color: var(--warning-color);
    border-width: 3px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Checkbox sections get special treatment */
#followUpForm .form-group:has(input[type="checkbox"]) {
    background: #e8f5e8;
    border-left-color: var(--success-color);
}

.form-section-content.collapsed {
    display: none;
}

/* Better organization for medication change section - COMPACT */
.medication-change-section {
    background: #f0f8ff;
    border: 1px dashed var(--primary-color);
    border-radius: 8px;
    padding: 0.75rem;
    margin: 0.5rem 0;
}

.medication-change-section h4 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 1rem;
    border-bottom: 1px solid var(--primary-color);
    padding-bottom: 0.3rem;
}

/* Breakthrough checklist styling - COMPACT */
#breakthroughChecklist {
    margin-bottom: 0.75rem !important;
}

#breakthroughChecklist .form-group {
    background: #fff8e1;
    margin-bottom: 0.4rem;
    padding: 0.4rem 0.5rem;
}

/* Side effects container styling - COMPACT */
.side-effects-container {
    background: #fff5f5;
    border: 1px solid #ffcdd2;
    border-radius: 6px;
    padding: 0.5rem;
}

.side-effects-container .checkbox-label {
    background: white;
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.25rem !important;
    border: 1px solid #e0e0e0;
    font-size: 0.85rem;
}

.form-section-content.no-border {
    border: none;
    border-radius: 0;
    background: transparent;
    padding: 0;
}

/* Follow-up form section headers - COMPACT */
#followUpForm .form-section-header {
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 0.5rem 0.75rem;
    margin: 0.4rem 0 0 0;
    border-radius: 5px 5px 0 0;
    font-size: 0.95rem;
    border: none;
}

#followUpForm .form-section-header .collapse-icon {
    color: white;
}

/* Better spacing between logical groups - COMPACT */
#followUpForm .form-group + .form-group {
    border-top: 1px solid #e9ecef;
    padding-top: 0.3rem;
    margin-top: 0.15rem;
}

/* Hindi translations in follow-up */
#followUpForm .hindi-translation {
    display: block;
    font-style: italic;
    color: #B8D4FF;
    font-size: 0.85rem;
    margin-top: 0.25rem;
    font-weight: normal;
}

/* Follow-up frequency selector improvements - COMPACT */
#followUpSeizureFrequency {
    font-size: 0.85rem !important;
    padding: 0.5rem !important;
    line-height: 1.3;
    max-height: 180px;
    overflow-y: auto;
}

#followUpSeizureFrequency option {
    padding: 4px 6px;
    font-size: 0.8rem;
    line-height: 1.2;
    white-space: normal;
    word-wrap: break-word;
    max-width: 100%;
}

/* Better select styling for long options - COMPACT */
#followUpForm select {
    font-size: 0.85rem;
    padding: 0.5rem 0.6rem;
    line-height: 1.3;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: white;
    cursor: pointer;
}

/* All form inputs in follow-up form - COMPACT */
#followUpForm input,
#followUpForm textarea {
    font-size: 0.85rem;
    padding: 0.5rem 0.6rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    width: 100%;
    transition: border-color 0.2s ease;
}

#followUpForm input:focus,
#followUpForm select:focus,
#followUpForm textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.form-section-header:first-of-type {
    margin-top: 0;
}

/* Enhanced Hindi translation styling */
.hindi-translation {
    color: #B8D4FF;
    font-size: 0.9rem;
    font-weight: 500;
    font-style: italic;
    margin-top: 2px;
}

/* Role selector - Modern card selection */
.role-selector {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.role-option {
    flex: 1;
    text-align: center;
    padding: 1.25rem 1rem;
    border: 2px solid var(--card-border);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    background: var(--card-bg);
    position: relative;
    overflow: hidden;
}

.role-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--chart-teal), var(--chart-blue));
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.role-option:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(2, 132, 199, 0.12);
}

.role-option:hover::before {
    transform: scaleX(1);
}

.role-option.active {
    border-color: var(--chart-blue);
    background: linear-gradient(180deg, var(--primary-light), var(--card-bg));
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(2, 132, 199, 0.2);
}

.role-option.active::before {
    transform: scaleX(1);
}

.role-option i {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    display: block;
    background: linear-gradient(135deg, var(--chart-teal), var(--chart-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    transition: transform 0.3s ease;
}

.role-option.active i {
    transform: scale(1.15);
}

.role-option .role-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.role-option .role-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Error highlight for role selector when a selected role is not permitted */
.role-selector.role-error {
    animation: roleErrorPulse 1s ease-in-out 0s 2;
}

@keyframes roleErrorPulse {
    0% { box-shadow: 0 0 0 rgba(231, 76, 60, 0); }
    50% { box-shadow: 0 0 12px rgba(231, 76, 60, 0.25); }
    100% { box-shadow: 0 0 0 rgba(231, 76, 60, 0); }
}

/* Visually indicate a role not permitted option */
.role-option.not-permitted {
    border-color: #e74c3c;
    color: #e74c3c;
}

/* Enhanced button styles - Modern and accessible */
.btn {
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 0.925rem;
    font-weight: 600;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    min-height: 44px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    letter-spacing: 0.01em;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

.btn:focus {
    outline: 3px solid var(--primary-light);
    outline-offset: 2px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--chart-teal), var(--chart-blue));
    color: white;
    border: none;
}

.btn-primary:not(:disabled):hover {
    background: linear-gradient(135deg, var(--chart-blue), var(--chart-teal));
    box-shadow: 0 8px 24px rgba(2, 132, 199, 0.35);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
}

.btn-secondary:not(:disabled):hover {
    background: var(--card-hover-bg);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color), #15803d);
    color: white;
}

.btn-success:not(:disabled):hover {
    box-shadow: 0 8px 24px rgba(22, 163, 74, 0.35);
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning-color), #d97706);
    color: #1f2937;
}

.btn-warning:not(:disabled):hover {
    box-shadow: 0 8px 24px rgba(234, 179, 8, 0.35);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color), #b91c1c);
    color: white;
}

.btn-danger:not(:disabled):hover {
    box-shadow: 0 8px 24px rgba(220, 38, 38, 0.35);
}

/* Security notice */
.security-notice {
    text-align: center;
    margin-top: 1.5rem;
    padding: 1rem 1.25rem;
    background: var(--info-bg);
    border-radius: var(--border-radius-sm);
    border-left: 4px solid var(--chart-teal);
}

.security-notice h3 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 700;
}

.security-notice h3 i {
    color: var(--chart-teal);
}

.security-notice p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.5;
}

/* Dashboard Styles */
.dashboard-container {
    display: none;
    width: 100%;
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--card-shadow-elevated);
    overflow: hidden;
    position: relative;
    animation: slideIn 0.5s ease-out;
    border: 1px solid var(--card-border);
}

.header {
    background: var(--header-gradient);
    color: white;
    padding: 2rem 2rem 1.75rem;
    text-align: center;
    position: relative;
    border-radius: 0;
    overflow: visible;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}

.header h1 {
    font-size: 2rem;
    font-weight: 800;
    color: #fff !important;
    letter-spacing: -0.5px;
    position: relative;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin: 0;
    word-wrap: break-word;
    hyphens: auto;
}

.header p {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.9);
    position: relative;
    font-weight: 500;
    margin: 0;
    word-wrap: break-word;
    hyphens: auto;
}

.nav-tabs {
    display: flex;
    background: var(--card-bg);
    border-bottom: 1px solid var(--card-border);
    overflow-x: auto;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    gap: 0.25rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.nav-tabs::-webkit-scrollbar {
    display: none;
}

.nav-tab {
    flex: 1;
    padding: 0.75rem 1.25rem;
    background: transparent;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
    min-width: auto;
    position: relative;
}

.nav-tab i {
    font-size: 0.9rem;
    opacity: 0.8;
}

.nav-tab:hover {
    color: var(--primary-color);
    background: var(--primary-light);
}

.nav-tab:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: var(--border-radius-sm);
}

.nav-tab.active {
    background: linear-gradient(135deg, var(--chart-teal), var(--chart-blue));
    color: white;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
}

.nav-tab.active i {
    opacity: 1;
}

.tab-content {
    padding: 2rem;
    background: var(--bg-primary);
    min-height: calc(100vh - 250px);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

/* Stat cards in the stats grid */
.stats-grid > .stat-card,
.stats-grid > div {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    border: 1px solid var(--card-border);
    box-shadow: var(--card-shadow);
    transition: var(--transition);
}

.stats-grid > .stat-card:hover,
.stats-grid > div:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
}

/* Chart Row Layout */
.chart-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin: 1.75rem 0;
}

.chart-row .chart-box {
    flex: 1;
    min-width: 300px;
}

/* Scope: Compact typography for Follow-up tab */
#follow-up {
    font-size: 0.95rem;
}
#follow-up h3 {
    font-size: 1.25rem;
}
#follow-up .patient-card .patient-name {
    font-size: 1.15rem;
}
#follow-up .action-btn {
    font-size: 0.95rem;
    padding: 12px 20px;
}

.chart-box {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--card-border);
    transition: var(--transition);
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

.chart-box::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--chart-teal), var(--chart-blue), var(--chart-violet));
    opacity: 0.8;
}

.chart-box:hover {
    transform: translateY(-3px);
    box-shadow: var(--card-shadow-hover);
    border-color: var(--primary-light);
}

.chart-box h3:not(.form-section-header) {
    color: var(--text-primary);
    margin-bottom: 1.25rem;
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    letter-spacing: -0.2px;
}

.chart-box h3 i {
    color: var(--chart-teal);
    font-size: 1.1rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    border-radius: 8px;
}

/* KPI Gauges */
.kpi-gauge {
    position: relative;
    width: 100%;
    height: 200px;
    margin: 0 auto;
}

.kpi-footer {
    text-align: center;
    margin-top: 1rem;
    color: var(--medium-text);
    font-size: 0.9em;
}

/* Critical Alerts — Triage Dashboard */
#criticalAlertsList {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.ca-queue-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}
.ca-queue-card {
    border-radius: 10px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}
.ca-queue-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(0,0,0,0.1);
}
.ca-queue-card.high {
    background: linear-gradient(135deg, #fff5f5 0%, #ffe8e8 100%);
    border: 1px solid #f5c6c6;
}
.ca-queue-card.medium {
    background: linear-gradient(135deg, #fffbf0 0%, #fff3d4 100%);
    border: 1px solid #f2dfb5;
}
.ca-queue-card.low {
    background: linear-gradient(135deg, #f0f9ff 0%, #dbeafe 100%);
    border: 1px solid #bfdbfe;
}
.ca-queue-count {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1;
}
.ca-queue-card.high .ca-queue-count { color: #dc2626; }
.ca-queue-card.medium .ca-queue-count { color: #d97706; }
.ca-queue-card.low .ca-queue-count { color: #2563eb; }
.ca-queue-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--dark-text);
    margin-top: 4px;
}
.ca-queue-action {
    font-size: 0.75rem;
    color: var(--medium-text);
    margin-top: 4px;
    line-height: 1.35;
}
.ca-alert-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid #f0f0f0;
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.ca-alert-card:hover {
    background: #fafbfc;
    border-color: #d0d5dd;
}
.ca-alert-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.9rem;
}
.ca-alert-icon.high { background: #fee2e2; color: #dc2626; }
.ca-alert-icon.medium { background: #fef3c7; color: #d97706; }
.ca-alert-icon.low { background: #dbeafe; color: #2563eb; }
.ca-alert-body { flex: 1; min-width: 0; }
.ca-alert-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.ca-alert-patient {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--dark-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ca-alert-badge {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 7px;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}
.ca-alert-badge.high { background: #fee2e2; color: #b91c1c; }
.ca-alert-badge.medium { background: #fef3c7; color: #92400e; }
.ca-alert-badge.low { background: #dbeafe; color: #1e40af; }
.ca-alert-reasons {
    font-size: 0.82rem;
    color: var(--medium-text);
    margin-top: 4px;
    line-height: 1.4;
}
.ca-alert-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
}
.ca-alert-phc {
    font-size: 0.75rem;
    color: var(--light-text);
    background: #f3f4f6;
    padding: 1px 8px;
    border-radius: 4px;
}
.ca-alert-time { font-size: 0.75rem; color: var(--light-text); }
.ca-alert-action-btn {
    font-size: 0.75rem;
    font-weight: 600;
    color: #3b82f6;
    background: #eff6ff;
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    transition: background 0.15s;
}
.ca-alert-action-btn:hover { background: #dbeafe; }
.ca-show-more {
    text-align: center;
    padding: 10px;
    font-size: 0.85rem;
    color: var(--primary-color);
    cursor: pointer;
    font-weight: 600;
    border-radius: 8px;
    transition: background 0.15s;
}
.ca-show-more:hover { background: #f0f7ff; }
.ca-no-alerts {
    text-align: center;
    padding: 20px;
    color: var(--medium-text);
    font-size: 0.92rem;
}

/* Redesigned Modern Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
    width: 100%;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    border: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    min-height: 100px;
    min-width: 0; /* Prevents overflow in flex/grid */
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1.25rem;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.stat-card:hover .stat-icon {
    transform: scale(1.1) rotate(-5deg);
}

.stat-icon i {
    font-size: 1.5rem;
    color: #64748b;
}

.stat-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.stat-number {
    font-size: 1.85rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.5rem;
    color: #0f172a;
    letter-spacing: -0.025em;
    word-break: break-all;
}

.stat-label {
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Color variations using modern palette */
.stat-card[style*="border-left: 4px solid #e74c3c"],
.stat-card[style*="border-left: 4px solid rgb(231, 76, 60)"] {
    border-left: 5px solid #ef4444 !important;
}
.stat-card[style*="border-left: 4px solid #e74c3c"] .stat-icon,
.stat-card[style*="border-left: 4px solid rgb(231, 76, 60)"] .stat-icon {
    background: #fef2f2;
}
.stat-card[style*="border-left: 4px solid #e74c3c"] .stat-icon i,
.stat-card[style*="border-left: 4px solid rgb(231, 76, 60)"] .stat-icon i {
    color: #ef4444;
}

.stat-card[style*="border-left: 4px solid #f39c12"],
.stat-card[style*="border-left: 4px solid rgb(243, 156, 18)"] {
    border-left: 5px solid #f59e0b !important;
}
.stat-card[style*="border-left: 4px solid #f39c12"] .stat-icon,
.stat-card[style*="border-left: 4px solid rgb(243, 156, 18)"] .stat-icon {
    background: #fffbeb;
}
.stat-card[style*="border-left: 4px solid #f39c12"] .stat-icon i,
.stat-card[style*="border-left: 4px solid rgb(243, 156, 18)"] .stat-icon i {
    color: #f59e0b;
}

.stat-card[style*="border-left: 4px solid #3498db"],
.stat-card[style*="border-left: 4px solid rgb(52, 152, 219)"] {
    border-left: 5px solid #3b82f6 !important;
}
.stat-card[style*="border-left: 4px solid #3498db"] .stat-icon,
.stat-card[style*="border-left: 4px solid rgb(52, 152, 219)"] .stat-icon {
    background: #eff6ff;
}
.stat-card[style*="border-left: 4px solid #3498db"] .stat-icon i,
.stat-card[style*="border-left: 4px solid rgb(52, 152, 219)"] .stat-icon i {
    color: #3b82f6;
}

/* Dark mode adjustments for stat cards */
body.dark-mode .stat-card {
    background: #1e293b;
    border-color: #334155;
    color: #f1f5f9;
}
body.dark-mode .stat-number { color: #f1f5f9; }
body.dark-mode .stat-label { color: #94a3b8; }
body.dark-mode .stat-icon { background: #334155; }

@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .stat-card {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        min-height: 120px;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
        margin-right: 0;
        margin-bottom: 0.75rem;
        border-radius: 10px;
    }

    .stat-icon i {
        font-size: 1.1rem;
    }
    
    .stat-number {
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
    }

    .stat-label {
        font-size: 0.7rem;
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stat-card {
        padding: 0.85rem;
    }
    
    .stat-number {
        font-size: 1.35rem;
    }
}

.logout-container {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    z-index: 100;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.user-info {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.5rem 0.9375rem;
    border-radius: 20px;
    font-size: 0.875rem;
}

.logout-btn {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 0.5rem 0.9375rem;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.3125rem;
    transition: var(--transition);
    z-index: 101;
    position: relative;
}

.logout-btn:focus {
    outline: 2px solid white;
}

.logout-btn:hover {
    background: #b91c1c;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.export-container {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1.25rem;
    gap: 0.625rem;
}

.deidentified {
    background: var(--light-bg);
    border-radius: var(--border-radius);
    padding: 0.9375rem;
    margin-top: 0.9375rem;
    border-left: 4px solid var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.deidentified i {
    color: var(--primary-color);
    font-size: 1.125rem;
}

.deidentified div {
    color: var(--medium-text);
}

/* Chart containers */
.chart-container {
    display: flex;
    gap: 1.25rem;
    margin-top: 1.875rem;
    flex-wrap: wrap;
}

.chart-box {
    flex: 1;
    min-width: 300px;
    background: white;
    border-radius: var(--border-radius);
    padding: 1.25rem;
    box-shadow: var(--box-shadow);
    animation: fadeIn 0.5s ease-out;
}

.chart-box h3:not(.form-section-header) {
    color: var(--secondary-color);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 1.25rem;
}

/* Management subtabs and analytics improvements */
.management-shell {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(15, 23, 42, 0.06);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 252, 0.98));
}

.management-hero {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: -1.25rem -1.25rem 1rem;
    padding: 0.75rem 1.25rem;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 60%, #0f766e 100%);
    color: #fff;
}

.management-hero-copy {
    flex: 1;
    min-width: 0;
}

.management-hero-top-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.management-eyebrow {
    display: none;
}

.management-hero h3:not(.form-section-header) {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
    color: #fff !important;
    font-size: 1.1rem;
    white-space: nowrap;
}

.management-lead {
    display: none;
}

.management-hero-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.management-hero-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
}

.management-hero-chip-muted {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.84);
}

.management-hero-stats {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.management-hero-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.1);
    min-width: 60px;
}

.management-hero-stat strong {
    font-size: 1.2rem;
    line-height: 1;
    color: #fff;
}

.management-hero-stat span {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
}

.management-hero-stat-danger {
    background: rgba(127, 29, 29, 0.24);
    border-color: rgba(254, 202, 202, 0.16);
}

.management-layout {
    display: grid;
    grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
    transition: grid-template-columns 0.3s ease;
}

/* Expanded mode: hide sidebar, let content fill full width */
.management-layout--expanded {
    grid-template-columns: 1fr;
}

.management-layout--expanded > .management-sidebar {
    display: none;
}

.management-back-btn {
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.45rem 0.9rem;
    gap: 0.35rem;
}

.management-sidebar,
.management-content-column {
    min-width: 0;
}

.management-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: sticky;
    top: 1rem;
    align-self: start;
}

.management-search-panel,
.management-overview-shell,
.management-nav-shell,
.management-content-shell,
.management-quick-tools {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.06);
}

.management-search-panel,
.management-overview-shell,
.management-nav-shell,
.management-content-shell {
    padding: 1rem;
}

.management-search-label {
    display: block;
    margin-bottom: 0.6rem;
    font-weight: 600;
    color: var(--secondary-color);
}

.management-search-input {
    position: relative;
}

.management-search-input i {
    position: absolute;
    left: 0.95rem;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
}

.management-search-input input {
    width: 100%;
    padding: 0.85rem 1rem 0.85rem 2.6rem;
    border-radius: 12px;
    border: 1px solid #dbe4ee;
    background: #f8fafc;
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.management-search-input input:focus {
    outline: none;
    border-color: #2563eb;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.management-overview-head,
.management-nav-head,
.management-quick-tools-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.9rem;
}

.management-overview-kicker {
    margin: 0 0 0.25rem;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
    font-weight: 700;
}

.management-overview-head h4,
.management-nav-head h4,
.management-quick-tools-header h4 {
    margin: 0;
    color: var(--secondary-color);
    font-size: 1rem;
}

.management-nav-head p,
.management-quick-tools-copy {
    margin: 0.3rem 0 0;
    font-size: 0.9rem;
    color: var(--medium-text);
}

.management-overview-count,
.management-quick-tools-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    border: 1px solid #dbeafe;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

.management-overview-grid {
    display: grid;
    gap: 0.75rem;
}

.management-overview-card {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    width: 100%;
    padding: 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    background: linear-gradient(180deg, #ffffff, #f8fbff);
    text-align: left;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.management-overview-card:hover {
    transform: translateY(-2px);
    border-color: rgba(37, 99, 235, 0.35);
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.08);
}

.management-overview-card.active {
    border-color: #1d4ed8;
    box-shadow: 0 14px 28px rgba(30, 58, 138, 0.16);
    background: linear-gradient(180deg, #eff6ff, #ffffff);
}

.management-overview-card[data-tone="danger"] {
    background: linear-gradient(180deg, #fff7f7, #ffffff);
}

.management-overview-card[data-tone="ai"] {
    background: linear-gradient(180deg, #f5fff9, #ffffff);
}

.management-overview-card[data-tone="expansion"] {
    background: linear-gradient(180deg, #f5f9ff, #ffffff);
}

.management-overview-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.management-overview-icon {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: linear-gradient(135deg, #dbeafe, #eff6ff);
    color: #1d4ed8;
    font-size: 1rem;
    flex-shrink: 0;
}

.management-overview-card[data-tone="danger"] .management-overview-icon {
    background: linear-gradient(135deg, #fee2e2, #fff1f2);
    color: #b91c1c;
}

.management-overview-card[data-tone="ai"] .management-overview-icon {
    background: linear-gradient(135deg, #dcfce7, #f0fdf4);
    color: #15803d;
}

.management-overview-card[data-tone="design"] .management-overview-icon {
    background: linear-gradient(135deg, #e0f2fe, #f0f9ff);
    color: #0369a1;
}

.management-overview-card[data-tone="expansion"] .management-overview-icon {
    background: linear-gradient(135deg, #ede9fe, #f5f3ff);
    color: #6d28d9;
}

.management-overview-card-group {
    padding: 0.3rem 0.55rem;
    border-radius: 999px;
    background: #eef2ff;
    color: #4338ca;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.management-overview-card h5 {
    margin: 0;
    font-size: 1rem;
    color: var(--secondary-color);
}

.management-overview-card p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--medium-text);
}

.management-overview-empty {
    padding: 1.1rem;
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
    background: #f8fafc;
    text-align: center;
    color: #64748b;
}

.management-subtabs {
    display: grid;
    gap: 0.6rem;
    margin-top: 0 !important;
}

.management-subtabs .management-subtab {
    width: 100%;
    min-height: 52px;
    padding: 0.85rem 1rem;
    border-radius: 14px;
    border: 1px solid #dbe4ee;
    background: linear-gradient(180deg, #fcfdff, #f8fafc);
    color: var(--secondary-color);
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    font-size: 0.95rem;
    white-space: normal;
    box-shadow: none;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.management-subtabs .management-subtab i {
    width: 1.1rem;
    text-align: center;
    color: inherit;
}

.management-subtabs .management-subtab:hover {
    transform: translateY(-1px);
    border-color: rgba(37, 99, 235, 0.35);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.management-subtabs .management-subtab:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}

.management-subtabs .management-subtab.active {
    background: linear-gradient(135deg, #1e3a8a, #0f766e);
    color: white !important;
    border-color: transparent;
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.16);
    transform: translateY(-1px);
}

.management-content-column {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

.management-content-shell {
    padding: 1.25rem;
}

.management-active-context {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.management-context-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-bottom: 0.6rem;
}

.management-context-group,
.management-context-tone {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}

.management-context-group {
    background: #eff6ff;
    color: #1d4ed8;
}

.management-context-tone {
    background: #f8fafc;
    color: #475569;
}

.management-context-tone[data-tone="danger"] {
    background: #fef2f2;
    color: #b91c1c;
}

.management-context-tone[data-tone="ai"] {
    background: #f0fdf4;
    color: #15803d;
}

.management-context-tone[data-tone="expansion"] {
    background: #f5f3ff;
    color: #6d28d9;
}

.management-context-tone[data-tone="insight"] {
    background: #ecfeff;
    color: #0f766e;
}

.management-context-tone[data-tone="design"] {
    background: #eff6ff;
    color: #0369a1;
}

.management-active-context h4 {
    margin: 0 0 0.45rem;
    font-size: 1.35rem;
    color: var(--secondary-color);
}

.management-active-context p {
    margin: 0;
    max-width: 68ch;
    color: var(--medium-text);
}

.management-content-stage > .mg-subtab {
    margin-top: 0 !important;
    animation: fadeIn 0.25s ease-out;
}

.management-content-stage > .mg-subtab > h4:first-child,
.management-content-stage > .mg-subtab > p:first-child {
    margin-top: 0;
}

.management-content-stage .chart-box {
    box-shadow: none;
    border: 1px solid #ebf0f6;
    background: linear-gradient(180deg, #ffffff, #fbfdff);
}

.management-quick-tools {
    padding: 1rem 1.25rem;
}

.management-quick-tools-badge {
    background: #fff7ed;
    color: #c2410c;
    border-color: #fed7aa;
}

.management-quick-tools-copy {
    margin: 0 0 0.95rem;
}

#adminTools > button {
    align-self: flex-start;
}

/* Analytics container grid */
#mg-analytics #managementAnalyticsContainer {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  align-items: start;
}

/* Analytics card */
.analytics-card {
  background: linear-gradient(180deg, #fff, #fbfdff);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
  min-height: 160px;
  display:flex;
  flex-direction:column;
  gap: 0.5rem;
}

/* Chart title inside card */
.analytics-card h5 {
  margin: 0;
  color: var(--secondary-color);
  font-weight: 700;
}

/* Responsive tweak */
@media (max-width: 520px) {
    .management-hero {
        flex-direction: column;
        align-items: stretch;
    }
    .management-hero-stats {
        flex-wrap: wrap;
        justify-content: center;
    }

    .management-overview-head,
    .management-nav-head,
    .management-quick-tools-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .management-subtabs {
        gap: 6px;
    }

    .management-subtabs .management-subtab {
        font-size: 0.9rem;
        padding: 0.5rem;
        min-height: 44px;
    }

  #mg-analytics #managementAnalyticsContainer { grid-template-columns: 1fr; }
}

/* Patient cards - Modern elevated design */
.patient-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    cursor: pointer;
    animation: slideInCard 0.5s ease-out;
    animation-fill-mode: backwards;
    border: 1px solid var(--card-border);
    position: relative;
    overflow: hidden;
}

.patient-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--chart-teal), var(--chart-blue));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.patient-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-shadow-hover);
    border-color: var(--primary-light);
}

.patient-card:hover::before {
    opacity: 1;
}

.patient-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.25rem;
}

/* Search */
.search-container {
    margin-bottom: 1.25rem;
    position: relative;
}

/* Remove margin when search is in the follow-up filters row */
.follow-up-filters .search-container {
    margin-bottom: 0;
}

.search-container input {
    width: 100%;
    padding: 0.9375rem 0.9375rem 0.9375rem 2.8125rem;
    border: 2px solid #e9ecef;
    border-radius: var(--border-radius);
    font-size: 1.125rem;
    transition: var(--transition);
}

.search-container input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.2);
}

.search-container i {
    position: absolute;
    left: 0.9375rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--light-text);
}

/* Patient detail */
.patient-detail {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.875rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    display: none;
}

.patient-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5625rem;
    padding-bottom: 0.9375rem;
    border-bottom: 2px solid var(--light-bg);
}

.patient-header h2 {
    color: var(--primary-color);
    font-size: 1.75rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5625rem;
}

.detail-item {
    background: var(--light-bg);
    padding: 0.9375rem;
    border-radius: var(--border-radius);
}

.detail-item h4 {
    color: var(--medium-text);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.detail-item p {
    font-size: 1.125rem;
    color: var(--dark-text);
    font-weight: 500;
}

.medication-grid {
    display: flex;
    gap: 0.9375rem;
    flex-wrap: wrap;
    margin-bottom: 1.5625rem;
}

.medication-item {
    background: var(--bg-elevated);
    padding: 0.75rem 1.25rem;
    border-radius: 20px;
    font-weight: 600;
    color: var(--primary-color);
}

.history-container {
    margin-top: 1.5625rem;
}

.history-item {
    padding: 0.9375rem;
    border-left: 3px solid var(--primary-color);
    margin-bottom: 0.9375rem;
    background: var(--light-bg);
    border-radius: 0 8px 8px 0;
}

.history-item h4 {
    color: var(--secondary-color);
    margin-bottom: 0.3125rem;
}

.history-item p {
    color: var(--medium-text);
}

/* Empty state for history/follow-ups - ensure high contrast and readable spacing */
.history-container p {
    color: var(--dark-text);
    background: rgba(255,255,255,0.85);
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    display: inline-block;
    margin: 0.25rem 0 0.75rem 0;
}

.history-empty {
    color: var(--dark-text) !important;
    background: #fff7e6; /* subtle warm background to denote empty state */
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    display: inline-block;
    font-weight: 600;
}

.back-btn {
    margin-top: 1.25rem;
}

/* Loading indicator */
.loading-indicator {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(12px);
    /* Make sure the global loader overlays modals (follow-up modal uses z-index:10000) */
    z-index: 50000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    color: white;
    font-size: 1.2rem;
}

/* Ensure modal content inside loading-indicator uses readable dark text */
.loading-indicator .modal-content {
    color: var(--dark-text);
}
/* Exempt buttons that define their own color (e.g. btn-danger with white text) */
.loading-indicator .modal-content .btn-danger {
    color: white !important;
}
.loading-indicator .modal-content .modal-close {
    color: white !important;
    background: var(--danger-color) !important;
}
.loading-indicator .modal-content .modal-close:hover {
    color: white !important;
    background: #c0392b !important;
}

/* Modern login spinner - Pulsing dots animation */
.spinner {
    width: 60px;
    height: 60px;
    position: relative;
    margin-bottom: 1rem;
}

.spinner::before,
.spinner::after {
    content: '';
    position: absolute;
    border-radius: 50%;
}

.spinner::before {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--chart-teal), var(--chart-blue));
    animation: spinnerPulse 1.5s ease-in-out infinite;
    opacity: 0.4;
}

.spinner::after {
    width: 60%;
    height: 60%;
    top: 20%;
    left: 20%;
    background: white;
    animation: spinnerCore 1.5s ease-in-out infinite;
}

@keyframes spinnerPulse {
    0%, 100% { 
        transform: scale(1);
        opacity: 0.4;
    }
    50% { 
        transform: scale(1.15);
        opacity: 0.8;
    }
}

@keyframes spinnerCore {
    0%, 100% { 
        transform: scale(1);
    }
    50% { 
        transform: scale(0.85);
    }
}

/* Alternative modern spinner - three dots */
.spinner-dots {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    margin-bottom: 1rem;
}

.spinner-dots span {
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, var(--chart-teal), var(--chart-blue));
    border-radius: 50%;
    animation: spinnerBounce 1.4s ease-in-out infinite both;
}

.spinner-dots span:nth-child(1) { animation-delay: -0.32s; }
.spinner-dots span:nth-child(2) { animation-delay: -0.16s; }
.spinner-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes spinnerBounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Legacy spin keyframe for backwards compatibility */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Medication grid */
.medication-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)) !important;
    gap: 1.25rem;
    margin-bottom: 1.875rem;
    grid-column: 1 / -1;
    width: 100%;
}

/* Medication section should not use parent grid */
#section-content-2 {
    display: block !important;
    grid-template-columns: none !important;
}

.medication-item-group {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: var(--border-radius);
}

.medication-item-group label {
    font-weight: 600;
    color: var(--dark-text);
    font-size: 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

/* Modal styles - Modern glass morphism design */
.modal {
    display: none;
    position: fixed;
    z-index: 70000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(10, 15, 26, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    overflow-y: auto;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    animation: modalBackdropFade 0.25s ease-out;
}

@keyframes modalBackdropFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* When a modal should be explicitly in front (e.g. helper opened on top of follow-up modal) */
.modal--top {
    z-index: 20010 !important;
}

#followUpModal {
    align-items: flex-start;
    padding-top: 20px;
}

.modal-content {
    background: var(--card-bg);
    padding: 1.75rem 2rem;
    border-radius: var(--border-radius-lg);
    width: 95%;
    max-width: 900px;
    text-align: left;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.05);
    max-height: 90vh;
    overflow-y: auto;
    margin: 0 auto 30px;
    position: relative;
    border: 1px solid var(--card-border);
    animation: modalSlideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Ensure modal displays when inline flex style is applied */
.modal[style*="display: flex"] {
    display: flex !important;
    pointer-events: auto !important;
}

.modal[style*="visibility: visible"] {
    visibility: visible !important;
}

/* Modal header styling */
.modal-content h2,
.modal-content h3 {
    color: var(--text-primary);
    font-weight: 800;
    letter-spacing: -0.3px;
    margin-bottom: 0.5rem;
}

.modal-content > p {
    color: var(--text-secondary);
    font-size: 0.925rem;
    line-height: 1.5;
    margin-bottom: 1.25rem;
}

/* Make follow-up modal a bit wider like old system */
#followUpModal .modal-content {
    max-width: 1100px;
    padding: 1rem;
}

/* Ensure wide sections span full width in follow-up modal */
#followUpModal #drugDoseVerificationSection,
#followUpModal [id*="Section"],
#followUpModal .full-width {
    grid-column: 1 / -1;
}

/* Support for grid-column: span 2 declarations - now just span 1 for single column */
[style*="grid-column: span 2"] {
    grid-column: span 1;
}

/* Contextual panels within forms */
.warning-box,
[style*="background: #fff3cd"] {
    background: #fff3cd !important;
    border-left: 4px solid var(--warning-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    color: #000 !important;
}

.info-box,
[style*="background: #e8f4fd"] {
    background: #e8f4fd !important;
    border-left: 4px solid var(--primary-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    color: #000 !important;
}

@media (max-width: 767px) {
    [style*="grid-column: span 2"] {
        grid-column: span 1;
    }
}

.modal-content h4 {
    font-size: 1.2rem;
    color: var(--secondary-color);
    margin-bottom: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--card-border);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 1rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20001;
    pointer-events: auto;
    touch-action: manipulation;
}

.modal-close:hover {
    background: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
    transform: scale(1.1) rotate(90deg);
}

/* Expand clickable area without changing visual size */
.modal-close::before {
    content: '';
    position: absolute;
    top: -8px;
    left: -8px;
    right: -8px;
    bottom: -8px;
    border-radius: 50%;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}
.report-table th, .report-table td {
    border: 1px solid #ddd;
    padding: 12px;
    text-align: left;
}
.report-table th {
    background-color: var(--light-bg);
    color: var(--secondary-color);
    font-weight: 600;
}
.report-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

/* Hindi translations */
.hindi-translation {
    font-size: 0.8em;
    color: var(--hindi-blue);
    font-style: italic;
    font-weight: 600;
}

/* Dialer link */
.dial-link {
    color: #3498db;
    text-decoration: none;
    font-weight: 600;
}
.dial-link:hover {
    text-decoration: underline;
}

/* Guidance message */
.guidance-message {
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    font-weight: 500;
    border-left: 4px solid;
}

/* Success message */
.success-message {
    background: var(--success-color);
    color: white;
    padding: 1rem;
    border-radius: var(--border-radius);
    margin: 1rem 0;
    display: none;
    align-items: center;
    gap: 0.5rem;
}

/* Close button for modal */
.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: #f8f9fa;
    border: 2px solid #e1e5e9;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
    z-index: 20001;
    pointer-events: auto;
}

.modal-close:hover {
    background: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
    transform: scale(1.05);
}

/* Prescribed drugs section - COMPACT */
.prescribed-drugs-section {
    background: #e8f4fd;
    border: 1px solid var(--primary-color);
    border-radius: 6px;
    padding: 0.3rem 0.5rem;
    margin-bottom: 0.3rem;
}

.prescribed-drugs-section h4 {
    color: var(--primary-color);
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}

.drug-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.drug-item {
    background: white;
    padding: 0.2rem 0.4rem;
    border-radius: 16px;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

/* Pill-style for prescribed drugs (clickable) - COMPACT */
.prescribed-pill {
    background: #ffffff;
    border: 1px solid #3b82f6;
    color: #1e3a8a;
    border-radius: 999px;
    padding: 3px 10px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    box-shadow: 0 1px 4px rgba(59, 130, 246, 0.1);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
    font-size: 0.85rem;
}
.prescribed-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.18);
    background: #f8fbff;
}
.prescribed-pill:active {
    transform: translateY(0);
}
.prescribed-pill .pill-name {
    font-weight: 700;
    color: #1f3a83;
    font-size: 0.95rem;
}
.prescribed-pill .pill-dosage {
    color: #3b82f6;
    background: #e8f1ff;
    border-radius: 999px;
    padding: 3px 9px;
    font-weight: 600;
    font-size: 0.85rem;
}

/* Medication change section */
.medication-change-section {
    display: none;
    grid-column: 1 / -1;
    background: #fff3cd;
    border: 2px solid var(--warning-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 3px 10px rgba(243, 156, 18, 0.1);
}

/* Enhanced medication form styling */
.medication-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-top: 1rem;
}

.medication-item-group {
    background: var(--card-bg);
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid #e1e5e9;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.medication-item-group:hover {
    background: #f0f4f8;
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.1);
    transform: translateY(-1px);
}

.medication-item-group label {
    font-weight: 600;
    color: var(--dark-text);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.info-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.info-btn:hover {
    background: var(--secondary-color);
    transform: scale(1.1);
}

/* Special form sections styling */
.form-group[style*="background"] {
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
}

.form-group[style*="background"]:hover {
    box-shadow: 0 5px 15px rgba(0,0,0,0.12);
    transform: translateY(-1px);
}

.medication-change-section h4 {
    color: var(--warning-color);
    margin-bottom: 1rem;
}

/* Seizure frequency options with descriptions */
.seizure-frequency-option {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.seizure-frequency-option:hover {
    background: #f8f9fa;
    border-color: var(--primary-color);
}

.seizure-frequency-option.selected {
    background: #e3f2fd;
    border-color: var(--primary-color);
}

.seizure-frequency-title {
    font-weight: 600;
    color: var(--dark-text);
}

.seizure-frequency-desc {
    font-size: 0.9rem;
    color: var(--medium-text);
    margin-top: 0.25rem;
}

/* Checkbox Styling */
input[type="checkbox"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid #ccc;
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    position: relative;
    margin: 0 10px 0 0;
    vertical-align: middle;
    transition: all 0.2s ease;
}

input[type="checkbox"]:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

input[type="checkbox"]:focus {
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
    border-color: var(--primary-color);
}

/* Side Effects Checklist Styles */
.side-effects-container {
    margin: 15px 0;
    padding: 15px;
    background: #f9f9f9;
    border-radius: var(--border-radius);
    border: 1px solid #e0e0e0;
}

.side-effect-item {
    display: flex;
    align-items: center;
    margin: 10px 0;
    padding: 12px 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    transition: var(--transition);
}

.side-effect-item:hover {
    background: #f0f7ff;
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.1);
}

.side-effect-item input[type="checkbox"] {
    flex-shrink: 0;
    margin-right: 12px;
}

.side-effect-item label {
    margin: 0;
    font-size: 1rem;
    color: var(--dark-text);
    cursor: pointer;
    flex-grow: 1;
    display: flex;
    align-items: center;
    line-height: 1.4;
    padding: 2px 0;
    min-height: 24px;
    align-items: center;
}

.side-effect-item .hindi-translation {
    margin-left: 10px;
    font-size: 0.9rem;
    color: var(--hindi-blue);
    font-style: normal;
    font-weight: 500;
    opacity: 0.9;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
    .side-effects-container {
        grid-template-columns: 1fr !important;
    }
    
    .side-effect-item {
        margin: 6px 0;
        padding: 6px 10px;
    }
}

/* Text visibility improvements for warning and info boxes */
[style*="background: #fff3cd"],
[style*="background: #e8f4fd"] {
    color: #000 !important;
}

[style*="background: #fff3cd"] *,
[style*="background: #e8f4fd"] *,
[style*="background: #fff3cd"] .form-text,
[style*="background: #e8f4fd"] .form-text,
[style*="background: #fff3cd"] .hindi-translation,
[style*="background: #e8f4fd"] .hindi-translation,
.warning-box,
.warning-box *,
.alert-warning,
.alert-warning *,
.alert-info,
.alert-info * {
    color: #000 !important;
}

/* Specific styles for warning boxes with yellow background */
[style*="background: #fff3cd"],
.warning-box,
.alert-warning {
    background-color: #fff3cd !important;
    border-left: 4px solid #ffc107 !important;
}

/* Specific styles for info boxes with blue background */
[style*="background: #e8f4fd"],
.alert-info {
    background-color: #e8f4fd !important;
    border-left: 4px solid #17a2b8 !important;
}

/* Style for warning text */
.text-warning {
    color: #000 !important;
}

/* Responsive design */
@media (max-width: 768px) {
    .role-selector {
        flex-direction: column;
    }
    
    .login-card {
        padding: 1.25rem;
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .logout-container {
        position: static;
        justify-content: center;
        margin-top: 1.25rem;
        flex-direction: row;
        align-items: center;
        gap: 0.375rem;
        flex-wrap: wrap;
    }

    .system-header h1 {
        font-size: 1.75rem;
    }

    .system-header p {
        font-size: 1rem;
    }

    .system-header i {
        font-size: 3rem;
        width: 90px;
        height: 90px;
    }

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

    .header {
        padding: 1rem;
    }

    .header h1 {
        font-size: 1.25rem;
        margin-bottom: 0.25rem;
    }

    .header p {
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
    }

    /* Compact header buttons on tablets/mobile */
    .logout-container .logout-btn span,
    .logout-container .user-info {
        display: none;
    }

    .logout-container .logout-btn {
        padding: 0.4rem 0.7rem;
        font-size: 0.75rem;
    }

    .logout-container .logout-btn i {
        font-size: 0.9rem;
    }

    .logout-container .theme-toggle-btn {
        font-size: 1rem;
    }

    .logout-container {
        gap: 0.25rem;
    }
    
    .tab-content {
        padding: 1rem;
    }
    
    .chart-container {
        flex-direction: column;
    }
    
    .export-container {
        flex-direction: column;
        align-items: flex-end;
    }
    
    .nav-tab {
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
        min-width: auto;
    }
    
    .btn {
        padding: 0.75rem;
        font-size: 0.9rem;
        min-height: 44px;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Make headers display properly on mobile - All forms */
    .form-section-header {
        font-size: 0.95rem;
        padding: 0.5rem 0.75rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
        min-height: 48px; /* Touch-friendly */
        transition: all 0.2s ease;
    }
    
    .form-section-header:hover {
        background: linear-gradient(90deg, #2980b9, #1a252f);
    }
    
    /* Add Patient form section headers on mobile - ONLY ON MOBILE */
    #patientForm .form-section-header {
        font-size: 0.95rem;
        padding: 0.6rem 0.75rem;
        min-height: 48px;
    }
    
    /* Add Patient form section content on mobile - ONLY ON MOBILE */
    #patientForm .form-section-content {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        padding: 0.6rem 0.75rem;
    }
    
    /* Follow-up form headers stay compact on mobile */
    #followUpForm .form-section-header {
        font-size: 0.9rem;
        padding: 0.45rem 0.6rem;
    }
    
    .form-section-content {
        grid-template-columns: 1fr;
        gap: 0.3rem;
        padding: 0.4rem 0.5rem;
    }
    
    /* Follow-up form sections - responsive grid on mobile */
    #followUpForm .form-section-content {
        grid-template-columns: 1fr;
        gap: 0.2rem;
        padding: 0.3rem 0.5rem;
    }
    
    .form-group {
        margin-bottom: 0.5rem;
    }
    
    /* Mobile-optimized form inputs - Touch-friendly */
    input, select, textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
        min-height: 48px; /* Touch-friendly size */
        padding: 0.6rem 0.75rem;
        border-radius: 6px;
    }
    
    /* Mobile labels - Improved readability */
    label {
        font-size: 0.9rem;
        font-weight: 600;
        margin-bottom: 0.4rem;
        display: block;
    }
    
    /* Touch-friendly buttons on mobile */
    .btn {
        min-height: 48px;
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
        touch-action: manipulation;
    }
    
    /* Sticky form actions on mobile - Enhanced */
    .form-actions {
        position: sticky;
        bottom: 0;
        background: white;
        padding: 1rem;
        border-top: 1px solid #dee2e6;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        z-index: 100;
        margin: 0 -1rem;
    }
    
    /* Better modal padding on mobile */
    .modal-content {
        padding: 1rem;
        max-height: 95vh;
        overflow-y: auto;
    }
    
    /* Compact CDSS display on mobile */
    #cdssPromptsContainer {
        margin: 0.5rem 0;
        padding: 1rem;
    }
}

/* Very small screens - minimal spacing adjustments */
@media (max-width: 480px) {
    .cdss-prompt-item {
        margin-bottom: 0.5rem;
    }
    
    /* Better mobile modal - COMPACT */
    .modal-content {
        margin: 0.25rem;
        padding: 0.75rem;
        max-height: 96vh;
        overflow-y: auto;
    }
    
    /* Even smaller section headers on very small screens */
    .form-section-header,
    #patientForm .form-section-header {
        font-size: 0.88rem;
        padding: 0.5rem 0.6rem;
    }
    
    /* Single column medication grid */
    .medication-form-grid,
    .medication-item-group {
        grid-template-columns: 1fr !important;
    }
    
    /* Smaller buttons on very small screens */
    .btn {
        padding: 0.6rem 0.8rem;
        font-size: 0.85rem;
    }
    
    /* Mobile form progress indicator */
    .form-progress {
        margin-top: 0.5rem;
        padding: 0.3rem 0;
    }
    
    .progress-bar {
        width: 100%;
        height: 8px;
        background: #e9ecef;
        border-radius: 4px;
        overflow: hidden;
        margin-bottom: 0.5rem;
    }
    
    .progress-fill {
        height: 100%;
        background: #007bff;
        transition: width 0.3s ease;
        border-radius: 4px;
    }
    
    .progress-text {
        font-size: 0.85rem;
        color: #666;
        text-align: center;
    }
}

@media (max-width: 900px) {
    .chart-box {
        min-width: 100%;
    }
    
    .modal-content {
        width: 98%;
        padding: 12px;
        margin: 5px auto;
        max-height: 92vh;
    }
    
    .patient-card {
        padding: 0.75rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .medication-form-grid {
        grid-template-columns: 1fr;
    }

    .injury-modal-content {
        width: 95%;
        max-width: 400px;
        padding: 15px;
    }

    .injury-type-options {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .injury-type-options .btn {
        width: 100%;
        padding: 15px;
        font-size: 1rem;
    }
}

/* Additional mobile improvements */
@media (max-width: 480px) {
    .system-header h1 {
        font-size: 1.5rem;
    }
    
    .login-card {
        padding: 1rem;
    }
    
    .nav-tabs {
        overflow-x: scroll;
        -webkit-overflow-scrolling: touch;
    }
    
    .nav-tab {
        flex-shrink: 0;
        min-width: 100px;
    }
    
    .form-group label {
        font-size: 1rem;
    }
    
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    font-size: 0.925rem;
    color: var(--text-primary);
    background: var(--input-bg);
    transition: var(--transition);
    font-weight: 500;
}

    .drug-list {
        flex-direction: column;
    }

    .drug-item {
        text-align: center;
    }

    .seizure-frequency-option {
        padding: 10px;
        margin-bottom: 6px;
    }

    .role-option {
        padding: 15px 12px;
    }

    #followUpModal {
        padding-top: 10px;
    }

    .modal-content {
        margin: 8px;
        padding: 10px;
    }
}

@media (max-width: 900px) {
    .form-group, .form-group[style*="grid-column"] {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        margin-bottom: 0.5rem !important;
    }
    .form-section-header {
        grid-column: 1 / -1 !important;
    }
    .form-grid {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    .form-group input,
    .form-group select,
    .form-group textarea,
    .form-group button {
        width: 100% !important;
        min-width: 0 !important;
    }
    .btn {
        width: 100% !important;
    }
    #add-patient .chart-box {
        padding: 10px !important;
    }
    .injury-type-options .btn {
        width: 100% !important;
    }
}

/* Injury Modal Styles */
#injury-modal {
    display: none;
    position: fixed;
    z-index: 10001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    overflow-y: auto;
    align-items: center;
    justify-content: center;
}

.injury-modal-content {
    background: white;
    padding: 30px;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    position: relative;
}

.injury-type-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.injury-type-options .btn {
    padding: 15px 20px;
    font-size: 1rem;
    font-weight: 600;
}

/* NEW STYLES for Injury Map */
.injury-map-container {
    grid-column: 1 / -1;
    display: flex;
    gap: 20px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.body-svg-container {
    flex: 1;
    min-width: 200px;
    max-width: 250px;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.03) 0%, rgba(99, 102, 241, 0.05) 100%);
    border: 1px solid rgba(79, 70, 229, 0.1);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.2s ease;
}

.body-svg-container:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* SVG container styling */
.body-svg-container svg {
    touch-action: manipulation;
    display: block;
    width: 100%;
    height: auto;
}

/* Body part base styling */
.body-svg path, 
.body-svg rect, 
.body-svg ellipse,
.body-svg polygon,
.body-svg circle {
    fill: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    stroke: #60a5fa;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    cursor: pointer;
    transition: fill 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), 
                stroke 0.2s ease,
                transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
                filter 0.2s ease;
    transform-origin: center center;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.05));
}

/* Injury details container styling */
.injury-details-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.injury-details-container h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary, #0f172a);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.injury-details-container h4::before {
    content: '✓';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #fca5a5 0%, #f87171 100%);
    color: white;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: bold;
}

/* Hover state - improved visual feedback */
.body-svg path:hover, 
.body-svg rect:hover,
.body-svg ellipse:hover,
.body-svg polygon:hover,
.body-svg circle:hover {
    fill: linear-gradient(135deg, #fecaca 0%, #fca5a5 100%);
    stroke: #ef4444;
    stroke-width: 2;
    transform: scale(1.06);
    filter: drop-shadow(0 4px 8px rgba(239, 68, 68, 0.25));
}

/* Selected state - injury identified */
.body-svg path.selected, 
.body-svg rect.selected,
.body-svg ellipse.selected,
.body-svg polygon.selected,
.body-svg circle.selected {
    fill: linear-gradient(135deg, #fca5a5 0%, #f87171 100%);
    stroke: #dc2626;
    stroke-width: 2.5;
    filter: drop-shadow(0 0 0 3px rgba(220, 38, 38, 0.2));
}

/* Focus state for keyboard navigation */
.body-svg [tabindex] {
    outline: none;
}

.body-svg [tabindex]:focus {
    stroke: #3b82f6;
    stroke-width: 2;
    filter: drop-shadow(0 0 0 3px rgba(59, 130, 246, 0.3));
}

/* Add labels to body parts on hover */
.body-svg text {
    font-size: 11px;
    font-weight: 600;
    fill: #1f2937;
    pointer-events: none;
    user-select: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* transient tapped feedback - improved animation */
.body-svg .tapped {
    transform: scale(1.1) !important;
    transition: transform 100ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Keyframe animation for tap feedback */
@keyframes bodyPartTap {
    0% {
        transform: scale(1);
        filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.05));
    }
    50% {
        transform: scale(1.12);
        filter: drop-shadow(0 6px 12px rgba(239, 68, 68, 0.3));
    }
    100% {
        transform: scale(1);
        filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.05));
    }
}

/* Selected injuries list animations */
#selected-injuries-list {
    list-style: none;
}

#selected-injuries-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: linear-gradient(135deg, #fff5f5 0%, #fef2f2 100%);
    border: 1px solid #fee2e2;
    box-shadow: 0 1px 3px rgba(220, 38, 38, 0.1);
    transform-origin: left center;
    transition: transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1), 
                opacity 200ms ease,
                background 0.2s ease;
    opacity: 1;
}

#selected-injuries-list li:hover {
    background: linear-gradient(135deg, #ffecec 0%, #fde8e8 100%);
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.15);
}

#selected-injuries-list li.adding {
    transform: translateX(-12px) scale(0.92);
    opacity: 0;
}

#selected-injuries-list li.removing {
    transform: translateX(12px) scale(0.92);
    opacity: 0;
}

/* Remove button styling in injury list */
#selected-injuries-list .remove-injury {
    background: transparent;
    border: none;
    color: #dc2626;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    margin-left: auto;
}

#selected-injuries-list .remove-injury:hover {
    background: rgba(220, 38, 38, 0.1);
    color: #991b1b;
    transform: scale(1.1);
}

#selected-injuries-list .remove-injury:active {
    transform: scale(0.95);
}

/* Print styles for patient summary (moved from inline in script.js) */
/* Use .print-content wrapper in the print window */
@page { 
    size: A4;
    margin: 1cm;
}
.print-content {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    padding: 20px;
}
.print-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #3498db;
}
.print-header h2 {
    color: #2c3e50;
    margin: 0;
}
.print-section {
    margin-bottom: 20px;
    page-break-inside: avoid;
}
.print-section h3 {
    color: #3498db;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
    margin-bottom: 10px;
}
.detail-row {
    display: flex;
    margin-bottom: 8px;
    page-break-inside: avoid;
}
.detail-label {
    font-weight: bold;
    min-width: 200px;
    color: #555;
}
.medication-item {
    background: var(--bg-elevated);
    border-left: 3px solid #3498db;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 0 4px 4px 0;
}
.print-timestamp {
    text-align: right;
    color: #777;
    font-size: 0.9em;
    margin-top: 20px;
    border-top: 1px solid #eee;
    padding-top: 10px;
}
@media print {
    /* Ensure colors are preserved in print output where possible */
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
    .no-print { display: none !important; }
}

/* Remove button: larger tap target */
#selected-injuries-list .remove-injury {
    background: transparent;
    border: none;
    color: #a02b20;
    font-size: 1.1rem;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
}

#selected-injuries-list .remove-injury:active {
    transform: scale(0.96);
}

/* Ensure the SVG parts enlarge slightly on touch for clarity */
.body-svg path:active, .body-svg rect:active, .body-svg polygon:active {
    transform: scale(1.06);
}
.injury-details-container {
    flex: 2;
    min-width: 250px;
}
#selected-injuries-list {
    list-style-type: none;
    padding: 0;
    margin-top: 10px;
    max-height: 150px;
    overflow-y: auto;
    background: var(--light-bg);
    border-radius: 8px;
    padding: 10px;
}
#selected-injuries-list li {
    background: white;
    padding: 8px 12px;
    border-radius: 20px;
    margin-bottom: 8px;
    font-size: 0.95rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
#selected-injuries-list .remove-injury {
    background: #f1f1f1;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-weight: bold;
}

/* ── Screening Panel (matches form design language) ────────────────── */

.screening-panel {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: var(--border-radius);
    overflow: hidden;
}
.screening-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    color: #fff;
    padding: 0.6rem 1rem;
    font-weight: 700;
    font-size: 0.95rem;
}
.screening-panel__title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.screening-panel__badge {
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    background: rgba(255,255,255,0.2);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}
.screening-panel__status {
    margin: 0.75rem 1rem;
    padding: 0.6rem 0.9rem;
    border-radius: 6px;
    font-size: 0.88rem;
}
.screening-panel__status--ok {
    background: #ecfdf5;
    border-left: 3px solid var(--success-color);
    color: #065f46;
}
.screening-panel__instructions {
    font-size: 0.88rem;
    color: var(--medium-text);
    margin: 0 1rem 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--light-bg);
    border-radius: 6px;
    border-left: 3px solid var(--primary-color);
}
.screening-panel__questions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0 1rem;
}
.screening-panel__actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin-top: 0.75rem;
    border-top: 1px solid #dee2e6;
}
.screening-panel__submit-status {
    font-size: 0.85rem;
}
.screening-panel__not-due {
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--medium-text);
}
.screening-panel__not-due i {
    margin-bottom: 0.5rem;
}
.screening-panel__not-due p {
    margin: 0.4rem 0;
    font-size: 0.9rem;
}
.screening-panel__next-date {
    font-size: 0.82rem;
    color: var(--light-text);
}
.screening-panel__override {
    margin-top: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
}
.screening-panel__override input { cursor: pointer; }
/* ─────────────────────────────────────────────────────────────────────
   Modern Patient Timeline v2.0
   ───────────────────────────────────────────────────────────────────── */

/* Wrapper */
.tl-wrapper { padding: 0 4px; }

/* Stats bar */
.tl-stats {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06); margin-bottom: 12px;
}
.tl-stat {
  display: flex; flex-direction: column; align-items: center;
  background: var(--light-bg, #f8f9fa); border-radius: 8px;
  padding: 8px 14px; min-width: 70px; flex: 1;
}
.tl-stat__val { font-weight: 700; font-size: 1rem; color: var(--dark-text, #1a1a2e); }
.tl-stat__label { font-size: 0.72rem; color: var(--light-text, #94a3b8); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 2px; }

/* Filter bar */
.tl-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tl-filter {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px; border-radius: 20px; border: 1px solid rgba(0,0,0,0.08);
  background: #fff; font-size: 0.82rem; cursor: pointer;
  color: var(--medium-text, #64748b); transition: all 0.15s ease;
}
.tl-filter:hover { background: var(--light-bg, #f1f5f9); }
.tl-filter--active { background: var(--primary-color, #3b82f6) !important; color: #fff !important; border-color: transparent; }
.tl-filter__count {
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.06); border-radius: 10px; padding: 0 6px;
  font-size: 0.72rem; min-width: 18px; height: 18px; font-weight: 600;
}
.tl-filter--active .tl-filter__count { background: rgba(255,255,255,0.25); color: #fff; }

/* Type-specific filter coloring */
.tl-filter--registration { border-color: #3b82f6; color: #3b82f6; }
.tl-filter--followup { border-color: #10b981; color: #10b981; }
.tl-filter--med-change { border-color: #8b5cf6; color: #8b5cf6; }
.tl-filter--referral { border-color: #ef4444; color: #ef4444; }
.tl-filter--warning { border-color: #f59e0b; color: #f59e0b; }
.tl-filter--deceased { border-color: #6b7280; color: #6b7280; }
.tl-filter--info { border-color: #94a3b8; color: #94a3b8; }

/* Track */
.tl-track { position: relative; padding-left: 28px; }
.tl-track::before {
  content: ''; position: absolute; left: 15px; top: 0; bottom: 0;
  width: 2px; background: linear-gradient(to bottom, transparent, rgba(0,0,0,0.08) 40px, rgba(0,0,0,0.08) calc(100% - 40px), transparent);
}

/* Month group */
.tl-group { margin-bottom: 8px; }
.tl-group__label {
  position: relative; left: -28px; width: calc(100% + 28px);
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--light-text, #94a3b8); padding: 10px 0 6px 38px;
  background: linear-gradient(90deg, var(--light-bg, #f8f9fa) 60%, transparent);
  border-radius: 4px; margin-bottom: 4px;
}

/* Event */
.tl-event {
  display: flex; gap: 10px; margin-bottom: 10px; position: relative;
  animation: tl-fadein 0.3s ease forwards; opacity: 0;
}
@keyframes tl-fadein { to { opacity: 1; } }
.tl-event:nth-child(2) { animation-delay: 0.03s; }
.tl-event:nth-child(3) { animation-delay: 0.06s; }
.tl-event:nth-child(4) { animation-delay: 0.09s; }
.tl-event:nth-child(5) { animation-delay: 0.12s; }

/* Marker */
.tl-event__marker { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; width: 32px; }
.tl-event__dot {
  width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 14px; background: #fff; border: 2px solid #e5e7eb; z-index: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06); transition: transform 0.15s;
}
.tl-event:hover .tl-event__dot { transform: scale(1.15); }
.tl-event__connector { flex: 1; width: 2px; background: transparent; }

/* Dot colors by type */
.tl-event__dot--registration { border-color: #3b82f6; background: #eff6ff; }
.tl-event__dot--followup { border-color: #10b981; background: #ecfdf5; }
.tl-event__dot--med-change { border-color: #8b5cf6; background: #f5f3ff; }
.tl-event__dot--referral { border-color: #ef4444; background: #fef2f2; }
.tl-event__dot--warning { border-color: #f59e0b; background: #fffbeb; }
.tl-event__dot--deceased { border-color: #6b7280; background: #f3f4f6; }
.tl-event__dot--info { border-color: #94a3b8; background: #f8fafc; }

/* Card */
.tl-event__card {
  flex: 1; background: #fff; border-radius: 10px;
  padding: 10px 14px; min-width: 0;
  border: 1px solid rgba(0,0,0,0.05);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.tl-event:hover .tl-event__card { box-shadow: 0 3px 12px rgba(0,0,0,0.08); border-color: rgba(0,0,0,0.1); }

/* Card type accents */
.tl-event--registration .tl-event__card { border-left: 3px solid #3b82f6; }
.tl-event--followup .tl-event__card { border-left: 3px solid #10b981; }
.tl-event--med-change .tl-event__card { border-left: 3px solid #8b5cf6; }
.tl-event--referral .tl-event__card { border-left: 3px solid #ef4444; }
.tl-event--warning .tl-event__card { border-left: 3px solid #f59e0b; }
.tl-event--deceased .tl-event__card { border-left: 3px solid #6b7280; }
.tl-event--info .tl-event__card { border-left: 3px solid #94a3b8; }

/* Card header */
.tl-event__header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.tl-event__badge {
  font-size: 0.82rem; font-weight: 600; padding: 2px 8px; border-radius: 6px;
}
.tl-event__badge--registration { color: #1d4ed8; background: #dbeafe; }
.tl-event__badge--followup { color: #047857; background: #d1fae5; }
.tl-event__badge--med-change { color: #6d28d9; background: #ede9fe; }
.tl-event__badge--referral { color: #b91c1c; background: #fee2e2; }
.tl-event__badge--warning { color: #92400e; background: #fef3c7; }
.tl-event__badge--deceased { color: #374151; background: #e5e7eb; }
.tl-event__badge--info { color: #475569; background: #e2e8f0; }

.tl-event__time { font-size: 0.75rem; color: var(--light-text, #94a3b8); white-space: nowrap; font-weight: 500; }

/* Card body */
.tl-event__body { font-size: 0.88rem; color: var(--medium-text, #475569); line-height: 1.5; }
.tl-event__meta { font-size: 0.78rem; color: var(--light-text, #94a3b8); margin-top: 4px; }
.tl-event__date { font-size: 0.72rem; color: var(--light-text, #b0b8c8); margin-top: 4px; }

/* Tags inside follow-up body */
.tl-tag {
  display: inline-block; font-size: 0.78rem; padding: 2px 8px; border-radius: 4px;
  margin-right: 4px; margin-bottom: 2px; font-weight: 500;
}
.tl-tag--adherence { background: #dbeafe; color: #1e40af; }
.tl-tag--seizure { background: #fef3c7; color: #92400e; }
.tl-tag--improvement { background: #d1fae5; color: #065f46; }

/* Empty state */
.tl-empty { text-align: center; padding: 40px 20px; }
.tl-empty__icon { font-size: 2.5rem; margin-bottom: 8px; opacity: 0.5; }
.tl-empty__title { font-size: 1.1rem; font-weight: 600; color: var(--dark-text, #1a1a2e); margin-bottom: 4px; }
.tl-empty__desc { font-size: 0.9rem; color: var(--light-text, #94a3b8); }

/* Keep old classes for backward compat (other code may reference) */
.timeline { display:flex; flex-direction:column; gap:10px; padding:8px 4px; }
.timeline-item { display:flex; gap:12px; align-items:flex-start; padding:10px; border-radius:8px; background: #fff; border:1px solid rgba(0,0,0,0.04); }
.timeline-date { min-width:120px; color:var(--light-text); font-size:0.9rem; }
.timeline-body { flex:1; }
.timeline-title { font-weight:700; margin-bottom:4px; }
.timeline-details { color:var(--medium-text); font-size:0.95rem; }
.timeline-registration { border-left:4px solid var(--primary-color); }
.timeline-followup { border-left:4px solid #3b82f6; }
.timeline-med-change { border-left:4px solid #10b981; }
.timeline-referral { border-left:4px solid #ef4444; }
.timeline-info { border-left:4px solid var(--light-text); }

.patient-detail-tabs { margin-top:12px; }
.tab-buttons { display:flex; gap:8px; margin-bottom:10px; }
.detail-tab { background:transparent; border:1px solid rgba(0,0,0,0.06); padding:8px 12px; border-radius:6px; cursor:pointer; }
.detail-tab.active { background:var(--light-bg); border-color:var(--primary-color); }
.detail-tab:focus { outline:2px solid rgba(59,130,246,0.2); }
.tab-contents { padding: 0; }
.detail-tab-pane { padding:4px 0; }

/* ─────────────────────────────────────────────────────────────────────
   Prediction Tab Styles — CDS ML Predictions v1.0
   ───────────────────────────────────────────────────────────────────── */

/* Main container */
.prediction-main-header { margin-bottom:16px; }
.prediction-title-row { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:8px; }
.prediction-main-title { font-size:1.25rem; color:var(--dark-text); margin:0; display:flex; align-items:center; gap:8px; }
.prediction-icon { font-size:1.4rem; }
.prediction-meta-badges { display:flex; flex-wrap:wrap; gap:5px; }

/* Badges */
.prediction-badge { display:inline-flex; align-items:center; padding:3px 10px; border-radius:12px; font-size:0.75rem; font-weight:600; line-height:1.4; white-space:nowrap; }
.prediction-badge-info { background:#dbeafe; color:#1d4ed8; }
.prediction-badge-success { background:#dcfce7; color:#15803d; }
.prediction-badge-warning { background:#fef9c3; color:#a16207; }
.prediction-badge-danger { background:#fee2e2; color:#dc2626; }
.prediction-badge-muted { background:#f3f4f6; color:#6b7280; }
.prediction-badge-ml { background:linear-gradient(135deg,#e0e7ff,#c7d2fe); color:#4338ca; border:1px solid #a5b4fc; }
.prediction-badge-tiny { padding:2px 6px; font-size:0.65rem; border-radius:8px; }

/* Sections */
.prediction-section { background:#fff; border-radius:10px; padding:16px 18px; margin-bottom:14px; border:1px solid #e5e7eb; position:relative; }
.prediction-section-success { border-left:4px solid #22c55e; }
.prediction-section-warning { border-left:4px solid #eab308; }
.prediction-section-danger { border-left:4px solid #ef4444; }
.prediction-section-muted { border-left:4px solid #9ca3af; }
.prediction-section-compact { padding:14px 16px; }

/* Section header */
.prediction-section-header { margin-bottom:10px; }
.prediction-section-title-row { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:8px; margin-bottom:4px; }
.prediction-section-title { font-size:1rem; color:var(--dark-text); margin:0 0 4px 0; font-weight:700; }

/* Confidence badge (larger) */
.prediction-confidence-badge { display:inline-flex; align-items:center; gap:4px; padding:4px 14px; border-radius:16px; font-size:0.9rem; font-weight:700; }
.prediction-confidence-badge small { font-weight:400; font-size:0.75rem; opacity:0.85; }

/* Narrative text */
.prediction-narrative { font-size:0.92rem; line-height:1.6; color:#374151; margin-bottom:12px; padding:10px 14px; background:#f9fafb; border-radius:8px; border-left:3px solid #d1d5db; }
.prediction-narrative-sm { font-size:0.85rem; padding:8px 12px; }

/* Probability bar */
.prediction-prob-bar-container { margin:10px 0 14px; }
.prediction-prob-bar { background:#e5e7eb; border-radius:8px; height:28px; position:relative; overflow:hidden; }
.prediction-prob-fill { height:100%; border-radius:8px; display:flex; align-items:center; justify-content:flex-end; padding-right:8px; transition:width 0.6s ease; min-width:40px; }
.prediction-prob-fill-success { background:linear-gradient(90deg, #4ade80, #16a34a); }
.prediction-prob-fill-warning { background:linear-gradient(90deg, #fbbf24, #d97706); }
.prediction-prob-fill-danger { background:linear-gradient(90deg, #f87171, #dc2626); }
.prediction-prob-label { color:#ffffff !important; font-weight:700; font-size:0.85rem; text-shadow:0 1px 3px rgba(0,0,0,0.4); }
/* Specifically ensure text is dark on warning fill if it's too light */
.prediction-prob-fill-warning .prediction-prob-label { color: #1e293b !important; text-shadow: none; }
.prediction-prob-ci { display:flex; font-size:0.65rem; color:#9ca3af; margin-top:2px; padding:0 2px; }

/* Charts */
.prediction-chart-container { position:relative; height:220px; width:100%; margin:10px 0; }
.prediction-chart-radar { height:240px; }

/* Gauge */
.prediction-gauge-container { position:relative; width:160px; height:100px; margin:8px auto 12px; }
.prediction-gauge-label { position:absolute; bottom:4px; left:50%; transform:translateX(-50%); font-size:1.6rem; font-weight:800; color:var(--dark-text); }
.prediction-gauge-label small { font-size:0.8rem; font-weight:400; color:#9ca3af; }

/* Risk level badge */
.prediction-risk-level { display:inline-block; padding:3px 12px; border-radius:12px; font-size:0.8rem; font-weight:700; text-transform:uppercase; letter-spacing:0.5px; }
.prediction-risk-success { background:#dcfce7; color:#15803d; }
.prediction-risk-warning { background:#fef9c3; color:#a16207; }
.prediction-risk-danger { background:#fee2e2; color:#dc2626; }
.prediction-risk-muted { background:#f3f4f6; color:#6b7280; }

/* Stat rows */
.prediction-stat-row { display:flex; justify-content:space-between; align-items:center; padding:4px 0; border-bottom:1px solid #f3f4f6; font-size:0.85rem; }
.prediction-stat-row:last-child { border-bottom:none; }
.prediction-stat-label { color:#6b7280; }
.prediction-stat-value { font-weight:600; color:var(--dark-text); }
.prediction-stat-sm { font-size:0.75rem; }

/* Factor summary */
.prediction-factor-summary { margin:8px 0; display:flex; gap:6px; flex-wrap:wrap; }

/* Cohort note */
.prediction-cohort-note { font-size:0.8rem; color:#6b7280; padding:6px 10px; background:#f0f9ff; border-radius:6px; margin:8px 0; font-style:italic; }

/* Recommendation */
.prediction-recommendation { font-size:0.85rem; padding:8px 12px; background:#fffbeb; border-radius:6px; border-left:3px solid #f59e0b; margin:8px 0; color:#92400e; }

/* 2-column grid for DRE + SUDEP */
.prediction-grid-2col { display:grid; grid-template-columns:repeat(2, 1fr); gap:14px; margin-bottom:14px; }

/* Risk factors (Adherence section) */
.prediction-risk-factors { margin-top:10px; }
.prediction-risk-factors h5 { font-size:0.9rem; margin:0 0 8px; color:var(--dark-text); }
.prediction-risk-factor-item { padding:8px 12px; margin-bottom:6px; border-radius:8px; border:1px solid #e5e7eb; }
.prediction-rf-success { border-left:3px solid #22c55e; background:#f0fdf4; }
.prediction-rf-warning { border-left:3px solid #f59e0b; background:#fffbeb; }
.prediction-rf-header { display:flex; align-items:center; gap:6px; flex-wrap:wrap; margin-bottom:4px; }
.prediction-rf-icon { font-size:1rem; }
.prediction-rf-detail { font-size:0.8rem; color:#6b7280; margin-top:2px; }
.prediction-rf-recommendation { font-size:0.8rem; color:#1e40af; margin-top:4px; font-style:italic; }

/* Drug cards */
.prediction-drug-cards { display:grid; grid-template-columns:repeat(auto-fit, minmax(220px, 1fr)); gap:10px; margin:10px 0; }
.prediction-drug-card { padding:12px; border-radius:8px; border:1px solid #e5e7eb; background:#fafafa; }
.prediction-drug-success { border-left:3px solid #22c55e; }
.prediction-drug-info { border-left:3px solid #3b82f6; }
.prediction-drug-warning { border-left:3px solid #f59e0b; }
.prediction-drug-danger { border-left:3px solid #ef4444; }
.prediction-drug-muted { border-left:3px solid #9ca3af; }
.prediction-drug-header { font-size:0.95rem; margin-bottom:6px; }
.prediction-drug-stats { margin-bottom:6px; }
.prediction-drug-trajectory { margin-top:4px; }

/* Optimization suggestions */
.prediction-optimization { margin-top:12px; }
.prediction-optimization h5 { font-size:0.9rem; margin:0 0 8px; color:var(--dark-text); }
.prediction-suggestion-card { padding:10px 14px; border-radius:8px; border:1px dashed #93c5fd; background:#eff6ff; margin-bottom:8px; }

/* Treatment Response Characterization Subsections */
.prediction-subsection { margin-top:16px; padding:14px; background:#f8fafc; border-radius:10px; border:1px solid #e2e8f0; }
.prediction-subsection-title { font-size:0.95rem; margin:0 0 4px; color:var(--dark-text); }
.prediction-subsection-desc { font-size:0.78rem; color:#64748b; margin:0 0 12px; }
.prediction-cluster-card { padding:12px; border-radius:8px; border:1px solid #e5e7eb; background:#fff; margin-bottom:10px; }
.prediction-cluster-badges { display:flex; flex-wrap:wrap; gap:6px; margin:8px 0; }
.prediction-patient-cluster { margin:6px 0; }
.prediction-early-warning { font-size:0.82rem; color:#b45309; background:#fffbeb; padding:6px 10px; border-radius:6px; border-left:3px solid #f59e0b; margin:6px 0; }
.prediction-predictor-card { padding:12px; border-radius:8px; border:1px solid #e5e7eb; background:#fff; margin-bottom:10px; }
.prediction-predictor-table { width:100%; border-collapse:collapse; font-size:0.8rem; margin-top:8px; }
.prediction-predictor-table th { background:#f1f5f9; padding:6px 8px; text-align:left; font-weight:600; color:#334155; border-bottom:2px solid #e2e8f0; white-space:nowrap; font-size:0.78rem; }
.prediction-predictor-table td { padding:6px 8px; border-bottom:1px solid #f1f5f9; vertical-align:middle; }
.prediction-predictor-table tr:hover { background:#f8fafc; }

/* Expand/collapse */
.prediction-expand-section { margin-top:8px; }
.prediction-expand-btn { background:none; border:none; color:#3b82f6; font-size:0.8rem; cursor:pointer; padding:4px 0; font-weight:600; }
.prediction-expand-btn:hover { text-decoration:underline; }
.prediction-detail-panel { margin-top:8px; padding:10px; background:#f9fafb; border-radius:8px; border:1px solid #e5e7eb; overflow-x:auto; }

/* Tables */
.prediction-table { width:100%; border-collapse:collapse; font-size:0.8rem; }
.prediction-table th { background:#f3f4f6; padding:6px 8px; text-align:left; font-weight:600; color:#374151; border-bottom:2px solid #e5e7eb; white-space:nowrap; }
.prediction-table td { padding:6px 8px; border-bottom:1px solid #f3f4f6; vertical-align:top; }
.prediction-table tr:hover { background:#f9fafb; }
.prediction-impact-positive { color:#15803d; font-weight:600; }
.prediction-impact-negative { color:#dc2626; font-weight:600; }
.prediction-impact-neutral { color:#6b7280; }
.prediction-feature-desc { color:#9ca3af; font-size:0.72rem; }
.prediction-factor-present { background:#fef2f2; }

/* References */
.prediction-references { margin-top:8px; padding:6px 10px; background:#f0f9ff; border-radius:6px; }
.prediction-ref { display:block; font-size:0.75rem; color:#4b5563; line-height:1.5; margin-bottom:2px; }

/* Disclaimer */
.prediction-disclaimer { margin-top:16px; padding:12px 16px; background:#f9fafb; border-radius:8px; border:1px solid #e5e7eb; font-size:0.78rem; color:#6b7280; line-height:1.5; }

/* Loading skeleton */
.prediction-loading { opacity:0.9; }
.prediction-skeleton { border-radius:6px; }
.prediction-skeleton-section { background:#fff; }
.prediction-skeleton-title { height:20px; width:40%; background:linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%); background-size:200% 100%; animation:predictionShimmer 1.5s infinite; margin-bottom:10px; }
.prediction-skeleton-text { height:60px; width:100%; background:linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%); background-size:200% 100%; animation:predictionShimmer 1.5s infinite; margin-bottom:10px; border-radius:6px; }
.prediction-skeleton-chart { height:180px; width:100%; background:linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%); background-size:200% 100%; animation:predictionShimmer 1.5s infinite; border-radius:8px; }
.prediction-skeleton-gauge { height:100px; width:120px; margin:10px auto; background:linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%); background-size:200% 100%; animation:predictionShimmer 1.5s infinite; border-radius:50%; }

@keyframes predictionShimmer {
  0% { background-position:200% 0; }
  100% { background-position:-200% 0; }
}

/* Quick stats (loading/error state) */
.prediction-quick-stats { display:grid; grid-template-columns:repeat(auto-fit, minmax(120px, 1fr)); gap:10px; margin:12px 0; }
.prediction-quick-stat { background:#f9fafb; padding:10px 12px; border-radius:8px; text-align:center; border:1px solid #e5e7eb; }
.prediction-quick-label { display:block; font-size:0.72rem; color:#6b7280; margin-bottom:4px; text-transform:uppercase; letter-spacing:0.5px; }
.prediction-quick-value { display:block; font-size:1rem; font-weight:700; color:var(--dark-text); }
.prediction-quick-success { color:#15803d; }
.prediction-quick-danger { color:#dc2626; }
.prediction-quick-muted { color:#6b7280; }

/* Insufficient data / empty state */
.prediction-empty-state { text-align:center; padding:40px 20px; }
.prediction-empty-icon { font-size:3rem; margin-bottom:12px; }
.prediction-empty-state h4 { font-size:1.1rem; color:var(--dark-text); margin:0 0 8px; }
.prediction-empty-state p { font-size:0.9rem; color:#6b7280; max-width:400px; margin:0 auto 16px; line-height:1.5; }
.prediction-empty-progress { max-width:300px; margin:0 auto; }
.prediction-empty-progress-bar { background:#e5e7eb; border-radius:8px; height:10px; overflow:hidden; margin-bottom:6px; }
.prediction-empty-progress-fill { background:linear-gradient(90deg, #93c5fd, #3b82f6); height:100%; border-radius:8px; transition:width 0.4s ease; }
.prediction-empty-progress span { font-size:0.8rem; color:#6b7280; }

/* Error state */
.prediction-error-card { text-align:center; padding:30px 20px; background:#fef2f2; border-radius:10px; border:1px solid #fecaca; margin-bottom:16px; }
.prediction-error-icon { font-size:2.5rem; margin-bottom:8px; }
.prediction-error-card h4 { color:#991b1b; margin:0 0 8px; }
.prediction-error-card p { color:#7f1d1d; font-size:0.9rem; margin:0 0 12px; }
.prediction-retry-btn { padding:8px 20px; background:#3b82f6; color:#fff; border:none; border-radius:8px; cursor:pointer; font-size:0.85rem; font-weight:600; }
.prediction-retry-btn:hover { background:#2563eb; }

/* Responsive mobile-first adjustments */
@media (max-width: 640px) {
  .prediction-grid-2col { grid-template-columns:1fr; }
  .prediction-drug-cards { grid-template-columns:1fr; }
  .prediction-chart-container { height:180px; }
  .prediction-chart-radar { height:200px; }
  .prediction-title-row { flex-direction:column; align-items:flex-start; }
  .prediction-section-title-row { flex-direction:column; align-items:flex-start; }
  .prediction-table { font-size:0.72rem; }
  .prediction-table th, .prediction-table td { padding:4px 6px; }
  .prediction-gauge-container { width:130px; height:85px; }
  .prediction-quick-stats { grid-template-columns:repeat(2, 1fr); }
  .prediction-confidence-badge { font-size:0.8rem; }
  .prediction-narrative { font-size:0.85rem; padding:8px 10px; }
  .prediction-section { padding:12px 14px; }
  .tab-buttons { overflow-x:auto; -webkit-overflow-scrolling:touch; }
  .detail-tab { white-space:nowrap; font-size:0.85rem; }
  
  /* Responsive injury map styling */
  .injury-map-container {
    flex-direction: column;
    gap: 16px;
  }
  .body-svg-container {
    max-width: 100%;
    width: 100%;
  }
  #selected-injuries-list {
    max-height: 200px;
    overflow-y: auto;
  }
}

@media (max-width: 400px) {
  .prediction-quick-stats { grid-template-columns:1fr 1fr; }
  .prediction-drug-cards { grid-template-columns:1fr; }
  .prediction-chart-container { height:150px; }
}

/* ── end of Prediction Tab Styles ── */

/* ──────────────────────────────────────────────────────────────
   Prediction Tab v1.1 — New Styles
   Quality Panel, KM Charts, Drug Comparisons, Outcome Validation,
   Role Toggle, Validation Badges, Contribution Bars, Offline
   ────────────────────────────────────────────────────────────── */

/* Role Toggle */
.prediction-role-toggle { display:flex; align-items:center; gap:6px; margin:8px 0 4px; }
.prediction-role-label { font-size:0.78rem; color:#6b7280; font-weight:600; margin-right:4px; }
.prediction-role-btn { padding:4px 12px; border:1px solid #d1d5db; border-radius:16px; background:#fff; cursor:pointer; font-size:0.78rem; font-weight:500; transition:all 0.2s; }
.prediction-role-btn:hover { border-color:#3b82f6; color:#3b82f6; }
.prediction-role-btn.prediction-role-active { background:#3b82f6; color:#fff; border-color:#3b82f6; }

/* Validation Badge */
.prediction-validation-badge { font-size:0.72rem; padding:2px 8px; border-radius:10px; font-weight:600; }

/* Version Badge */
.prediction-version-badge { display:inline-block; font-size:0.7rem; padding:2px 8px; border-radius:10px; background:#ede9fe; color:#6d28d9; font-weight:500; cursor:help; margin-left:4px; }

/* Cohort Quality Panel */
.prediction-quality-panel { background:#f9fafb; border:1px solid #e5e7eb; }
.prediction-quality-score { display:inline-block; font-size:1rem; font-weight:700; padding:4px 12px; border-radius:16px; }
.prediction-badge-success.prediction-quality-score, .prediction-quality-score.prediction-badge-success { background:#dcfce7; color:#15803d; }
.prediction-badge-warning.prediction-quality-score, .prediction-quality-score.prediction-badge-warning { background:#fef3c7; color:#92400e; }
.prediction-badge-danger.prediction-quality-score, .prediction-quality-score.prediction-badge-danger { background:#fee2e2; color:#dc2626; }

.prediction-quality-fields { margin:10px 0; }
.prediction-quality-field-row { display:flex; align-items:center; gap:8px; margin-bottom:5px; }
.prediction-quality-field-name { width:100px; font-size:0.8rem; font-weight:500; color:#374151; flex-shrink:0; }
.prediction-quality-bar { flex:1; height:8px; background:#e5e7eb; border-radius:4px; overflow:hidden; }
.prediction-quality-bar-fill { height:100%; border-radius:4px; transition:width 0.4s ease; }
.prediction-quality-field-pct { width:40px; text-align:right; font-size:0.78rem; font-weight:600; color:#374151; }
.prediction-quality-demo { margin:8px 0; }
.prediction-quality-warning { padding:6px 10px; background:#fef3c7; border-left:3px solid #f59e0b; border-radius:4px; font-size:0.8rem; color:#92400e; margin-top:6px; }
.prediction-quality-info { padding:6px 10px; background:#dbeafe; border-left:3px solid #3b82f6; border-radius:4px; font-size:0.8rem; color:#1e40af; margin-top:6px; }

/* KM Survival Chart */
.prediction-km-section { border-left:3px solid #6366f1; }
.prediction-km-chart-container { height:260px; }
.prediction-km-stats { margin:8px 0; }

/* Drug Comparison Table */
.prediction-drug-comp-section { border-left:3px solid #8b5cf6; }
.prediction-drug-comp-table th { font-size:0.78rem; }
.prediction-drug-comp-table td { font-size:0.82rem; }
.prediction-sig-positive { background:#f0fdf4; }
.prediction-sig-neutral { background:transparent; }

/* Feature Contribution Bars */
.prediction-contrib-bar { position:relative; width:100%; height:14px; background:#f3f4f6; border-radius:7px; overflow:hidden; }
.prediction-contrib-fill { position:absolute; top:0; left:0; height:100%; border-radius:7px; transition:width 0.4s ease; }
.prediction-contrib-pos { background:rgba(34,197,94,0.5); }
.prediction-contrib-neg { background:rgba(239,68,68,0.4); }
.prediction-contrib-label { position:relative; z-index:1; font-size:0.7rem; font-weight:600; color:#374151; padding-left:4px; line-height:14px; white-space:nowrap; }

/* Offline Notice */
.prediction-offline-notice { padding:10px 14px; background:#fef3c7; border:1px solid #fcd34d; border-radius:8px; font-size:0.85rem; color:#92400e; margin-bottom:12px; }
.prediction-offline-fallback { margin:12px 0; }
.prediction-offline-card { padding:8px 12px; background:#fffbeb; border-left:3px solid #f59e0b; border-radius:4px; margin-bottom:6px; font-size:0.85rem; }

/* Outcome Validation */
.prediction-outcome-section { border-left:3px solid #10b981; }
.prediction-outcome-pending { margin:10px 0; }
.prediction-outcome-pending h5 { font-size:0.9rem; color:#374151; margin:0 0 8px; }
.prediction-outcome-card { background:#fff; border:1px solid #e5e7eb; border-radius:8px; padding:12px; margin-bottom:10px; }
.prediction-outcome-pending-card { border-left:3px solid #f59e0b; }
.prediction-outcome-card-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:6px; }
.prediction-outcome-card-body { font-size:0.85rem; color:#374151; }
.prediction-outcome-card-body p { margin:4px 0; }
.prediction-outcome-eligible { color:#f59e0b; font-weight:500; font-size:0.8rem; }

.prediction-outcome-form-inner { display:flex; flex-direction:column; gap:6px; margin-top:8px; padding-top:8px; border-top:1px solid #f3f4f6; }
.prediction-outcome-form-inner label { font-size:0.8rem; font-weight:600; color:#374151; }
.prediction-outcome-select { padding:6px 10px; border:1px solid #d1d5db; border-radius:6px; font-size:0.85rem; font-family:inherit; }
.prediction-outcome-notes { padding:6px 10px; border:1px solid #d1d5db; border-radius:6px; font-size:0.85rem; font-family:inherit; resize:vertical; }
.prediction-outcome-submit { padding:8px 16px; background:#10b981; color:#fff; border:none; border-radius:6px; cursor:pointer; font-weight:600; font-size:0.85rem; transition:background 0.2s; align-self:flex-start; }
.prediction-outcome-submit:hover { background:#059669; }
.prediction-outcome-submitting { color:#6b7280; font-size:0.85rem; font-style:italic; }
.prediction-outcome-success { color:#15803d; font-weight:600; font-size:0.85rem; }
.prediction-outcome-error { color:#dc2626; font-size:0.85rem; }

/* Per-model requirement table in insufficient state */
.prediction-per-model-reqs { margin-top:16px; text-align:left; max-width:480px; margin-left:auto; margin-right:auto; }
.prediction-per-model-reqs h5 { font-size:0.9rem; color:#374151; margin:0 0 8px; }

/* Responsive adjustments for v1.1 */
@media (max-width: 640px) {
  .prediction-role-toggle { flex-wrap:wrap; }
  .prediction-quality-field-row { flex-wrap:wrap; }
  .prediction-quality-field-name { width:auto; flex:1 1 100%; }
  .prediction-km-chart-container { height:200px; }
  .prediction-drug-comp-table { font-size:0.72rem; }
  .prediction-outcome-card-header { flex-direction:column; align-items:flex-start; gap:4px; }
}

/* ── end of Prediction Tab v1.1 Styles ── */

@media (max-width: 768px) {
    .injury-map-container {
        flex-direction: column;
    }
    .body-svg-container {
        margin: 0 auto;
    }
}

/* Patient Card Grid Styles */
.patient-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.patient-card {
    background: #fff;
    border-radius: 14px; /* slightly increased for closer old look */
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
    border: 1px solid #e5e7eb;
    overflow: hidden;
    transition: var(--transition);
    position: relative;
    padding: 1.5625rem; /* match old style card padding */
}

.patient-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 14px 32px rgba(0,0,0,0.16);
}

.patient-card.completed {
    background: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 100%);
    border-color: #10b981;
}

.patient-card.completed .status-badge.completed {
    background: #10b981;
    color: white;
}

/* Completed card dropdown menu */
.completed-dropdown-item:hover {
    background: #f0f4f8 !important;
}
.completed-edit-btn:hover {
    background: #5a6268 !important;
}

.patient-card.due {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border-color: #f59e0b;
}

.patient-card.due .status-badge.due {
    background: #f59e0b;
    color: white;
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
}

.card-content {
    padding: 0; /* padding moved to .patient-card as per older style */
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    padding-bottom: 0; /* remove divider spacing */
    border-bottom: none; /* closer to older layout */
}

.patient-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--secondary-color);
    margin: 0;
    line-height: 1.3;
    flex: 1;
    margin-right: 12px;
}

/* Follow-up frequency setup button */
.card-header .btn-outline-secondary {
    padding: 4px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
    min-width: auto;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-header .btn-outline-secondary:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.status-badge.completed {
    background: #10b981;
    color: white;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

.status-badge.due {
    background: #f59e0b;
    color: white;
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
}

.card-details {
    margin-bottom: 20px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f9fafb;
}

.detail-item:last-child {
    border-bottom: none;
}

.detail-label {
    font-weight: 500;
    color: #6b7280;
    font-size: 0.875rem;
    min-width: 80px;
}

.detail-value {
    color: #1f2937;
    font-weight: 500;
    text-align: right;
    flex: 1;
}

.phone-link {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
}

.phone-link:hover {
    text-decoration: underline;
}

.status-indicator {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.status-indicator.new {
    background: #dbeafe;
    color: #1d4ed8;
}

.status-indicator.active {
    background: #dcfce7;
    color: #166534;
}

.status-indicator.referred-to-mo {
    background: #fef3c7;
    color: #92400e;
}

.status-indicator.follow-up {
    background: #e0e7ff;
    color: #3730a3;
}

.referral-notice .detail-label,
.completion-notice .detail-label,
.due-notice .detail-label {
    color: #3b82f6;
    font-weight: 600;
}

.due-notice .detail-label {
    color: #f59e0b;
}

.referral-notice .detail-value {
    color: #3b82f6;
    font-weight: 500;
}

.completion-notice .detail-value {
    color: #10b981;
    font-weight: 500;
}

.card-actions {
    padding-top: 16px;
    border-top: 1px solid #f3f4f6;
}

.action-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--primary-color), #2980b9);
    color: white;
    border: none;
    padding: 14px 24px; /* slightly larger like old buttons */
    border-radius: var(--border-radius);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.action-btn:hover {
    background: linear-gradient(135deg, #2c7fbd, #1976d2);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(33, 150, 243, 0.35);
}

.action-btn:active {
    transform: translateY(0);
}

.text-primary {
    color: #3b82f6;
}

.text-success {
    color: #10b981;
}

.start-btn {
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.start-btn:hover {
    background: #1976d2;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.card-details {
    font-size: 0.95rem;
    line-height: 1.5;
}

.detail-row {
    margin-bottom: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.detail-row strong {
    color: var(--dark-text);
    min-width: 80px;
    font-weight: 600;
}

.phone-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.phone-link:hover {
    text-decoration: underline;
}

.patient-status {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
}

.patient-status.active {
    background: #e8f5e9;
    color: #2e7d32;
}

.patient-status.referred-to-mo,
.patient-status.referred-for-tertiary-care {
    background: #fff3e0;
    color: #f57c00;
}

.patient-status.inactive {
    background: #ffebee;
    color: #c62828;
}

.patient-status.completed {
    background: #d4edda;
    color: #155724;
}

.patient-status.tertiary-care {
    background: #f8d7da;
    color: #721c24;
}

/* Card type-specific styles */
.patient-card.referred {
    border-left: 4px solid #ffc107;
}

.patient-card.tertiary {
    border-left: 4px solid #dc3545;
}

/* Urgency indicators for tertiary care queue */
.patient-card.tertiary-card.high-urgency {
    border-left: 4px solid #dc2626;
    background: linear-gradient(135deg, #ffffff 0%, #fef2f2 100%);
}

.patient-card.tertiary-card.medium-urgency {
    border-left: 4px solid #f59e0b;
    background: linear-gradient(135deg, #ffffff 0%, #fffbeb 100%);
}

.patient-card.tertiary-card.normal-urgency {
    border-left: 4px solid #10b981;
    background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
}

.urgency-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #f8f9fa;
}

.tertiary-card .patient-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.patient-clinical-info {
    background: rgba(0, 0, 0, 0.02);
    padding: 10px;
    border-radius: 6px;
    margin: 10px 0;
}

.referral-timeline {
    background: #fef3c7;
    padding: 10px;
    border-radius: 6px;
    margin: 10px 0;
    border-left: 3px solid #f59e0b;
}

.patient-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

/* Info sections for different card types */
.card-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 8px;
    border-radius: 6px;
    font-size: 0.85rem;
}

.referral-info {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
}

.tertiary-info {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
}

.card-info i {
    color: #856404;
    font-size: 1rem;
}

.tertiary-info i {
    color: #721c24;
}

.card-info strong {
    color: #333;
    display: block;
    margin-bottom: 2px;
}

.card-info small {
    color: #666;
}

/* Enhanced Follow-up Modal Styles */
.prescribed-drugs-list {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 15px;
    margin: 10px 0;
}

.prescribed-drug-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
}

.prescribed-drug-item:last-child {
    border-bottom: none;
}

.drug-name-clickable {
    color: #007bff;
    cursor: pointer;
    font-weight: 500;
    text-decoration: underline;
}

.drug-name-clickable:hover {
    color: #0056b3;
    text-decoration: none;
}

.drug-dosage {
    color: #6c757d;
    font-size: 0.9rem;
}

.education-section {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 15px;
    margin: 15px 0;
}

.education-topic {
    margin-bottom: 15px;
}

.education-topic:last-child {
    margin-bottom: 0;
}

.education-topic h6 {
    color: #495057;
    margin-bottom: 8px;
    font-weight: 600;
}

.education-topic ul {
    margin: 8px 0 0 20px;
    padding: 0;
}

.education-topic li {
    margin-bottom: 4px;
    color: #6c757d;
}

.checklist-item {
    padding: 8px 12px;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    margin-bottom: 8px;
    background: #fff;
}

.checklist-item label {
    margin: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.checklist-item input[type="checkbox"] {
    margin-right: 10px;
}

.recommendations-content {
    background: #e7f3ff;
    border: 1px solid #b3d7ff;
    border-radius: 6px;
    padding: 15px;
    margin-top: 10px;
}

.recommendations-content h6 {
    color: #004085;
    margin-bottom: 10px;
}

.recommendations-content ul {
    margin: 0;
    padding-left: 20px;
}

.recommendations-content li {
    color: #004085;
    margin-bottom: 5px;
}

/* Drug Info Modal Styles */
#drugInfoModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 20020;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
    display: none; /* Initially hidden */
}

#drugInfoModal.show {
    display: flex !important;
}

#drugInfoModal.loading-indicator {
    flex-direction: column;
}

#drugInfoModal .modal-content {
    max-width: 660px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    margin: 0;
    position: relative;
    transform: scale(0.9);
    opacity: 0;
    transition: all 0.3s ease;
}

#drugInfoModal[style*="display: flex"] .modal-content,
#drugInfoModal[style*="display: block"] .modal-content {
    transform: scale(1);
    opacity: 1;
}

.drug-info-content {
    padding: 0;
}

.info-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e9ecef;
}

.info-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.info-section h6 {
    color: #495057;
    margin-bottom: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-section ul {
    margin: 8px 0 0 0;
    padding-left: 20px;
}

.info-section li {
    margin-bottom: 5px;
    color: #6c757d;
}

.warnings-section {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    padding: 15px;
}

.warnings-section h6 {
    color: #856404;
}

.warnings-section li {
    color: #856404;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    margin-bottom: 8px;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.checkbox-label:hover {
    background-color: #f8f9fa;
}

.checkbox-label input[type="checkbox"] {
    margin-right: 8px;
    margin-top: 2px;
}

/* No patients message styles */
.no-patients-message {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 20px 0;
}

.no-patients-message i {
    font-size: 3rem;
    color: #ddd;
    margin-bottom: 15px;
    display: block;
}

.no-patients-message p {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 500;
}

/* Permission denied styling */
.no-patients-message i.fa-lock {
    color: #dc3545;
}

/* Warning styling */
.no-patients-message i.fa-exclamation-triangle {
    color: #ffc107;
}

/* Success/completed styling */
.no-patients-message i.fa-check-circle {
    color: #28a745;
}

/* Section headers for referral queues */
h3:not(.form-section-header) {
    color: #333;
    font-size: 1.2rem;
    font-weight: 600;
    margin: 10px 0 15px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 8px;
}

h3 i {
    color: #6c757d;
    font-size: 1.1rem;
}

.completed-info {
    margin-top: 16px;
    background: #e8f8e8;
    border-left: 4px solid #27ae60;
    padding: 12px;
    border-radius: 6px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.completed-info i {
    color: #27ae60;
    margin-top: 2px;
}

.completed-info strong {
    color: #27ae60;
    font-size: 0.9rem;
}

.completed-info small {
    color: #666;
    font-size: 0.85rem;
}

.no-patients-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--medium-text);
}

.no-patients-message i {
    font-size: 3rem;
    color: var(--success-color);
    margin-bottom: 16px;
    display: block;
}

.no-patients-message p {
    font-size: 1.1rem;
    margin: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .patient-card-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .patient-card {
        margin: 0;
    }
    
    .card-content {
        padding: 16px;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .patient-name {
        margin-right: 0;
        font-size: 1.125rem;
    }
    
    .status-badge {
        align-self: flex-end;
    }
    
    .detail-item {
        padding: 6px 0;
    }
    
    .detail-label {
        min-width: 70px;
        font-size: 0.8125rem;
    }
    
    .detail-value {
        font-size: 0.875rem;
    }
    
    .action-btn {
        padding: 10px 20px;
        font-size: 0.8125rem;
    }
}

@media (max-width: 480px) {
    .patient-card-grid {
        gap: 12px;
    }
    
    .card-content {
        padding: 12px;
    }
    
    .patient-name {
        font-size: 1rem;
    }
    
    .detail-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .detail-label {
        min-width: auto;
        font-size: 0.75rem;
    }
    
    .detail-value {
        font-size: 0.8125rem;
        text-align: left;
    }
}

/* Prevent follow-up form from collapsing when dropdown changes */
#followUpForm.stable {
    display: grid !important;
    visibility: visible !important;
}

/* Drug dose verification highlighting */
#drugDoseVerification {
    transition: all 0.3s ease;
}

#drugDoseVerification:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

/* Toast Notification Styles */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 999999;
    max-width: 400px;
    word-wrap: break-word;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
}

.toast.toast-success {
    background-color: #28a745;
}

.toast.toast-error {
    background-color: #dc3545;
}

.toast.toast-warning {
    background-color: #ffc107;
    color: #212529;
}

.toast.toast-info {
    background-color: #17a2b8;
}

/* Show animation for toast */
.toast[style*="display: block"] {
    transform: translateX(0);
}

    /* Draft patient card styles */
    .patient-card.draft {
        border-left: 5px solid orange;
        background: linear-gradient(90deg, #fff3e0 80%, #ffe0b2 100%);
        box-shadow: 0 2px 8px rgba(255, 152, 0, 0.08);
        position: relative;
    }

    .patient-card .draft-badge {
        position: absolute;
        top: 12px;
        left: -2px;
        background: orange;
        color: white;
        font-weight: bold;
        font-size: 0.85rem;
        padding: 3px 12px;
        border-radius: 0 8px 8px 0;
        box-shadow: 0 2px 6px rgba(255, 152, 0, 0.12);
        z-index: 2;
        letter-spacing: 0.5px;
    }

/* Teleconsultation Styles */
.teleconsult-scheduler {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

.teleconsult-scheduler .help-text {
    color: #666;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.teleconsult-scheduler .required {
    color: #dc3545;
    margin-left: 2px;
}

.teleconsult-scheduler .info-box {
    background: #e8f4f8;
    border-left: 4px solid var(--primary-color);
    padding: 12px 16px;
    margin: 20px 0;
    border-radius: 4px;
    font-size: 0.9rem;
}

.teleconsult-scheduler .info-box i {
    color: var(--primary-color);
    margin-right: 8px;
}

.teleconsult-scheduler .action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    justify-content: flex-end;
}

/* Patient Summary Panel for Teleconsultation */
#teleconsultationPanel {
    position: fixed;
    right: 0;
    top: 0;
    width: 400px;
    height: 100vh;
    background: #fff;
    border-left: 2px solid #ddd;
    box-shadow: -4px 0 12px rgba(0,0,0,0.1);
    overflow-y: auto;
    z-index: 10000;
    display: none;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

.teleconsult-summary {
    padding: 20px;
}

.teleconsult-summary .summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #eee;
}

.teleconsult-summary .summary-header h4 {
    margin: 0;
    color: var(--primary-color);
    font-size: 1.3rem;
}

.teleconsult-summary .btn-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #999;
    cursor: pointer;
    padding: 5px 10px;
}

.teleconsult-summary .btn-close:hover {
    color: #333;
}

.teleconsult-summary .summary-section {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.teleconsult-summary .summary-section h5 {
    color: #333;
    font-size: 1.1rem;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.teleconsult-summary .summary-section h5 i {
    color: var(--primary-color);
}

.teleconsult-summary .summary-section p {
    margin: 6px 0;
    font-size: 0.95rem;
    color: #555;
}

.teleconsult-summary .medication-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.teleconsult-summary .medication-list li {
    background: #f8f9fa;
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 6px;
    font-size: 0.9rem;
}

.teleconsult-summary .alert-section .alert {
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.teleconsult-summary .alert-warning {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    color: #856404;
}

.teleconsult-summary .alert-danger {
    background: #f8d7da;
    border-left: 4px solid #dc3545;
    color: #721c24;
}

.teleconsult-summary .alert-info {
    background: #d1ecf1;
    border-left: 4px solid #17a2b8;
    color: #0c5460;
}

.teleconsult-summary .video-item,
.teleconsult-summary .followup-item {
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.teleconsult-summary .video-item a {
    color: var(--primary-color);
    text-decoration: none;
    margin-left: 8px;
}

.teleconsult-summary .video-item a:hover {
    text-decoration: underline;
}

.teleconsult-summary .video-item .date,
.teleconsult-summary .followup-date {
    color: #999;
    font-size: 0.85rem;
    float: right;
}

.teleconsult-summary .followup-details {
    margin-top: 5px;
    color: #666;
}

.teleconsult-summary .summary-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

/* Consultation History */
.consultation-history {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.consultation-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.consultation-card.scheduled {
    border-left: 4px solid #17a2b8;
}

.consultation-card.completed {
    border-left: 4px solid #28a745;
}

.consultation-card .consult-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.consultation-card .consult-date {
    font-weight: 600;
    color: #333;
}

.consultation-card .badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
}

.consultation-card .badge-info {
    background: #d1ecf1;
    color: #0c5460;
}

.consultation-card .badge-success {
    background: #d4edda;
    color: #155724;
}

.consultation-card .badge-secondary {
    background: #e2e3e5;
    color: #383d41;
}

.consultation-card .consult-details {
    margin-bottom: 12px;
    color: #666;
    font-size: 0.95rem;
}

.consultation-card .consult-details p {
    margin: 6px 0;
}

.consultation-card .consult-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #teleconsultationPanel {
        width: 100%;
        max-width: 100%;
    }
    
    .teleconsult-scheduler {
        padding: 15px;
    }
    
    .teleconsult-scheduler .action-buttons {
        flex-direction: column;
    }
}
/* ======================================
   ADVANCED ANALYTICS - CUSTOM REPORTS
   ====================================== */

/* Quick Reports Grid */
.quick-reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.quick-report-card {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.quick-report-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
    transform: translateY(-2px);
}

.quick-report-card .report-icon {
    font-size: 2.5rem;
}

.quick-report-card h4 {
    margin: 4px 0;
    color: #1f2937;
    font-size: 1.1rem;
    font-weight: 600;
}

.quick-report-card p {
    margin: 0;
    color: #6b7280;
    font-size: 0.85rem;
    line-height: 1.4;
}

.btn-generate-report {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s ease;
}

.btn-generate-report:hover {
    background: #2563eb;
}

/* Query Builder Styles */
.query-builder {
    background: white;
    border-radius: 8px;
    padding: 20px;
}

.qb-header {
    margin-bottom: 20px;
    border-bottom: 2px solid #f3f4f6;
    padding-bottom: 16px;
}

.qb-header h3 {
    margin: 0 0 8px 0;
    color: #1f2937;
}

.qb-subtitle {
    margin: 0;
    color: #6b7280;
    font-size: 0.9rem;
}

.qb-logic-selector {
    margin-bottom: 20px;
    padding: 12px;
    background: #f3f4f6;
    border-radius: 6px;
}

.qb-logic-selector label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #374151;
    font-size: 0.9rem;
}

.logic-buttons {
    display: flex;
    gap: 8px;
}

.logic-btn {
    padding: 8px 16px;
    border: 2px solid #d1d5db;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.logic-btn:hover {
    border-color: #3b82f6;
    color: #3b82f6;
}

.logic-btn.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.qb-conditions-container {
    margin-bottom: 20px;
    padding: 16px;
    background: #f9fafb;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.qb-condition {
    display: grid;
    grid-template-columns: 1fr 1fr 2fr auto;
    gap: 8px;
    align-items: end;
    margin-bottom: 12px;
    padding: 12px;
    background: white;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.qb-condition:last-child {
    margin-bottom: 0;
}

.qb-condition .condition-logic {
    text-align: center;
    font-weight: 600;
    color: #3b82f6;
    font-size: 0.85rem;
    grid-column: 1 / -1;
    padding: 4px;
}

.qb-field-select,
.qb-operator-select,
.qb-value-select {
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
}

.qb-value-input {
    display: flex;
    gap: 4px;
    align-items: center;
}

.qb-multiselect {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 6px;
    padding: 8px;
    background: #f3f4f6;
    border-radius: 4px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    cursor: pointer;
}

.qb-range-input,
.qb-numeric-input,
.qb-date-input {
    padding: 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.9rem;
}

.btn-remove-condition {
    background: #ef4444;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s ease;
}

.btn-remove-condition:hover {
    background: #dc2626;
}

.qb-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.btn-add-condition,
.btn-clear-filters {
    padding: 10px 16px;
    border: 2px solid #d1d5db;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-add-condition:hover {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.btn-clear-filters:hover {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
}

.qb-preview {
    padding: 12px;
    background: #dbeafe;
    border-left: 4px solid #3b82f6;
    border-radius: 4px;
    font-size: 0.9rem;
    color: #1e40af;
    margin-bottom: 16px;
}

.qb-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

.qb-preset-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.preset-input {
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.9rem;
}

.btn-preset {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

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

.btn-preset.secondary {
    background: #f3f4f6;
}

.btn-preset.secondary:hover {
    background: #3b82f6;
}

.qb-generate-actions {
    display: flex;
    gap: 8px;
}

.btn-primary.btn-lg {
    padding: 10px 20px;
    font-weight: 600;
}

.btn-primary:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

/* Report View Styles */
.report-view {
    margin-bottom: 20px;
}

.report-header {
    margin-bottom: 16px;
}

.report-header h3 {
    margin: 0 0 8px 0;
    color: #1f2937;
}

.report-filters {
    margin: 4px 0;
    padding: 8px 12px;
    background: #f3f4f6;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #4b5563;
}

.report-summary {
    margin: 4px 0;
    color: #10b981;
    font-weight: 600;
}

.report-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}

.report-search-input {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    flex: 1;
    min-width: 200px;
    font-size: 0.9rem;
}

.report-export-buttons {
    display: flex;
    gap: 8px;
}

.btn-export-csv,
.btn-export-excel,
.btn-export-pdf {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.btn-export-csv:hover {
    background: #f3f4f6;
}

.btn-export-excel:hover {
    background: #10b981;
    color: white;
    border-color: #10b981;
}

.btn-export-pdf:hover {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
}

.report-table-container {
    overflow-x: auto;
    margin-bottom: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.report-table thead {
    background: var(--table-header-bg);
    color: var(--text-heading);
    position: sticky;
    top: 0;
    z-index: 10;
}

.report-table th {
    padding: 12px 8px;
    text-align: left;
    border: 1px solid #ddd;
    font-weight: 600;
    cursor: pointer;
}

.report-table th.sortable:hover {
    background: #667eea;
}

.report-table td {
    padding: 10px 8px;
    border: 1px solid #e5e7eb;
}

.report-table tbody tr:nth-child(even) {
    background: #f9fafb;
}

.report-table tbody tr:hover {
    background: #eff6ff;
}

.sort-indicator {
    opacity: 0.5;
    margin-left: 4px;
}

.report-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    padding: 12px;
    background: #f9fafb;
    border-radius: 6px;
}

.btn-prev-page,
.btn-next-page {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-prev-page:hover:not(:disabled),
.btn-next-page:hover:not(:disabled) {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.btn-prev-page:disabled,
.btn-next-page:disabled {
    background: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
}

#pageIndicator {
    font-weight: 600;
    color: #374151;
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #6b7280;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

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

/* Responsive adjustments for reports */
@media (max-width: 768px) {
    .qb-condition {
        grid-template-columns: 1fr;
    }

    .report-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .report-search-input {
        min-width: auto;
    }

    .report-export-buttons {
        flex-wrap: wrap;
    }

    .quick-reports-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: 100% !important;
        max-height: 95vh !important;
    }
}

/* ===== Top Performing CHOs Leaderboard Styles ===== */
.top-chos-leaderboard {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.cho-rank-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 8px;
    border-left: 4px solid #3498db;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.cho-rank-item:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.15);
}

/* Rank Badge */
.cho-rank-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 1.2rem;
    color: white;
    position: relative;
}

/* Gold Badge (1st) */
.cho-rank-item.rank-1 .cho-rank-badge {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    box-shadow: 0 4px 8px rgba(255, 215, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.cho-rank-item.rank-1 {
    border-left-color: #FFD700;
    background: linear-gradient(135deg, #FFFAF0 0%, #FFFFEB 100%);
}

.cho-rank-item.rank-1::before {
    content: "🏆";
    position: absolute;
    top: -8px;
    right: 10px;
    font-size: 1.5rem;
    opacity: 0.3;
}

/* Silver Badge (2nd) */
.cho-rank-item.rank-2 .cho-rank-badge {
    background: linear-gradient(135deg, #C0C0C0, #A9A9A9);
    box-shadow: 0 4px 8px rgba(192, 192, 192, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.cho-rank-item.rank-2 {
    border-left-color: #C0C0C0;
    background: linear-gradient(135deg, #F5F5F5 0%, #FFFFFF 100%);
}

/* Bronze Badge (3rd) */
.cho-rank-item.rank-3 .cho-rank-badge {
    background: linear-gradient(135deg, #CD7F32, #B87333);
    box-shadow: 0 4px 8px rgba(205, 127, 50, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.cho-rank-item.rank-3 {
    border-left-color: #CD7F32;
    background: linear-gradient(135deg, #FFF8DC 0%, #FFFAF0 100%);
}

/* Star Rating for ranks 4-15 */
.cho-rank-item.rank-4,
.cho-rank-item.rank-5,
.cho-rank-item.rank-6,
.cho-rank-item.rank-7,
.cho-rank-item.rank-8,
.cho-rank-item.rank-9,
.cho-rank-item.rank-10,
.cho-rank-item.rank-11,
.cho-rank-item.rank-12,
.cho-rank-item.rank-13,
.cho-rank-item.rank-14,
.cho-rank-item.rank-15 {
    border-left-color: #3498db;
}

.cho-rank-item.rank-4 .cho-rank-badge,
.cho-rank-item.rank-5 .cho-rank-badge,
.cho-rank-item.rank-6 .cho-rank-badge {
    background: linear-gradient(135deg, #3498db, #2980b9);
    font-size: 1.1rem;
}

.cho-rank-item.rank-7 .cho-rank-badge,
.cho-rank-item.rank-8 .cho-rank-badge,
.cho-rank-item.rank-9 .cho-rank-badge {
    background: linear-gradient(135deg, #5DADE2, #3498db);
    font-size: 1.1rem;
}

.cho-rank-item.rank-10 .cho-rank-badge,
.cho-rank-item.rank-11 .cho-rank-badge,
.cho-rank-item.rank-12 .cho-rank-badge,
.cho-rank-item.rank-13 .cho-rank-badge,
.cho-rank-item.rank-14 .cho-rank-badge,
.cho-rank-item.rank-15 .cho-rank-badge {
    background: linear-gradient(135deg, #85C1E9, #5DADE2);
    font-size: 1rem;
}

/* CHO Info Section */
.cho-info {
    flex: 1;
    min-width: 0;
}

.cho-name {
    font-size: 1rem;
    font-weight: 600;
    color: #222;
    margin-bottom: 0.25rem;
    word-break: break-word;
}

.cho-facility {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: #7f8c8d;
}

.cho-facility i {
    color: #3498db;
}

/* Performance Metrics */
.cho-metrics {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-shrink: 0;
}

.cho-count {
    text-align: center;
}

.cho-count-value {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    color: #2c3e50;
    line-height: 1;
}

.cho-count-label {
    display: block;
    font-size: 0.75rem;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0.2rem;
}

/* Progress Bar */
.cho-progress-container {
    width: 150px;
    display: none;
}

.cho-progress-bar {
    width: 100%;
    height: 6px;
    background: #ecf0f1;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.25rem;
}

.cho-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2980b9);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.cho-rank-item.rank-1 .cho-progress-fill {
    background: linear-gradient(90deg, #FFD700, #FFA500);
}

.cho-rank-item.rank-2 .cho-progress-fill {
    background: linear-gradient(90deg, #C0C0C0, #A9A9A9);
}

.cho-rank-item.rank-3 .cho-progress-fill {
    background: linear-gradient(90deg, #CD7F32, #B87333);
}

.cho-progress-label {
    font-size: 0.7rem;
    color: #7f8c8d;
    text-align: center;
}

/* Empty State */
.cho-empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #7f8c8d;
}

.cho-empty-state i {
    font-size: 3rem;
    color: #bdc3c7;
    margin-bottom: 0.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    .cho-rank-item {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .cho-metrics {
        width: 100%;
        gap: 1rem;
    }

    .cho-progress-container {
        width: 100%;
    }

    .cho-progress-bar {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .cho-rank-badge {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .cho-name {
        font-size: 0.95rem;
    }

    .cho-count-value {
        font-size: 1.2rem;
    }

    .cho-metrics {
        gap: 0.8rem;
    }
}

/* ============================================
   ANALYTICS DASHBOARD STYLES (PHASE 3)
   ============================================ */

.analytics-dashboard {
    position: relative;
    padding: 2rem;
    background: #f5f5f5;
    border-radius: 8px;
}

.dashboard-header {
    margin-bottom: 2rem;
}

.dashboard-header h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 2rem;
}

.dashboard-filters {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
    background: white;
    padding: 1rem;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.9rem;
}

.filter-group input,
.filter-group select {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.dashboard-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    text-align: center;
    border-left: 4px solid var(--primary-color);
}

.kpi-header {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.kpi-value {
    font-size: 2.2rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.kpi-footer {
    font-size: 0.85rem;
    color: #999;
}

.dashboard-charts {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-bottom: 2rem;
}

.chart-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 1.5rem;
}

.chart-container {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.chart-container h3 {
    margin-bottom: 1rem;
    color: var(--text-color);
    font-size: 1.1rem;
}

.chart-container canvas {
    max-height: 350px;
}

.peer-comparison-container {
    background: white;
    padding: 1rem;
    border-radius: 8px;
}

.peer-metrics {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.peer-metric {
    padding: 1rem;
    border: 1px solid #eee;
    border-radius: 6px;
}

.metric-name {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.metric-bar {
    height: 24px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.bar-value {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #0056b3);
    transition: width 0.3s;
}

.metric-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
}

.your-value {
    font-weight: bold;
    color: var(--primary-color);
}

.avg-value {
    color: #666;
}

.rank {
    color: #999;
}

.improvement-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.improvement-section h3 {
    margin-bottom: 1rem;
    color: var(--text-color);
}

.recommendations-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.improvement-card {
    border: 1px solid #ffc107;
    border-radius: 6px;
    padding: 1rem;
    background: #fffbf0;
}

.improvement-card h4 {
    color: #d39e00;
    margin-bottom: 0.75rem;
}

.improvement-details {
    background: white;
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 0.75rem;
}

.detail {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    font-size: 0.9rem;
}

.detail .label {
    font-weight: 500;
    color: #666;
}

.recommendations {
    font-size: 0.9rem;
}

.recommendations ul {
    margin: 0.5rem 0 0 1.5rem;
    padding: 0;
}

.recommendations li {
    margin-bottom: 0.25rem;
    color: #555;
}

.detailed-table-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.detailed-table-section h3 {
    margin-bottom: 1rem;
    color: var(--text-color);
}

.table-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.table-controls input,
.table-controls select {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.table-controls input {
    flex: 1;
}

.detailed-metrics-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.detailed-metrics-table thead {
    background: #f8f9fa;
    border-bottom: 2px solid var(--primary-color);
}

.detailed-metrics-table th {
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-color);
}

.detailed-metrics-table td {
    padding: 0.75rem;
    border-bottom: 1px solid #eee;
}

.detailed-metrics-table tbody tr:hover {
    background: #f8f9fa;
}

.metrics-row {
    cursor: pointer;
    transition: background 0.2s;
}

.badge {
    padding: 0.35rem 0.65rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

.bg-success {
    background: #d4edda;
    color: #155724;
}

.bg-warning {
    background: #fff3cd;
    color: #856404;
}

.tier-badge {
    padding: 0.35rem 0.65rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
}

.tier-top {
    background: #d4edda;
    color: #155724;
}

.tier-average {
    background: #fff3cd;
    color: #856404;
}

.tier-needs\ support {
    background: #f8d7da;
    color: #721c24;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    border-radius: 8px;
    z-index: 10;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .dashboard-filters {
        flex-direction: column;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .chart-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .analytics-dashboard {
        padding: 1rem;
    }

    .dashboard-header h2 {
        font-size: 1.5rem;
    }

    .dashboard-kpis {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .kpi-value {
        font-size: 1.5rem;
    }

    .detailed-metrics-table {
        font-size: 0.8rem;
    }

    .detailed-metrics-table th,
    .detailed-metrics-table td {
        padding: 0.5rem;
    }

    .recommendations-container {
        grid-template-columns: 1fr;
    }
}

/* =========================================
   OFFLINE FORM INDICATOR STYLES
   ========================================= */

.form-offline-indicator {
    grid-column: 1 / -1;
    background-color: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 12px 15px;
    margin-bottom: 15px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: #856404;
    animation: slideIn 0.3s ease-out;
}

.form-offline-indicator.offline-hidden {
    display: none;
}

.offline-indicator-content {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.offline-indicator-icon {
    font-size: 1.2rem;
    opacity: 0.9;
}

.offline-indicator-text {
    font-weight: bold;
    min-width: 100px;
}

.offline-indicator-status {
    flex: 1;
    font-size: 0.85rem;
    opacity: 0.85;
}

/* Form Save Status Indicator */
.form-save-status {
    grid-column: 1 / -1;
    padding: 8px 12px;
    margin-top: 10px;
    margin-bottom: 15px;
    font-size: 0.85rem;
    text-align: center;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    animation: slideIn 0.3s ease-out;
}

.form-save-status.save-status-hidden {
    display: none;
}

/* Save Status: Saving State */
.form-save-status.saving {
    background-color: #e8f4f8;
    border-left: 4px solid #17a2b8;
    color: #0c5460;
}

/* Save Status: Saved State */
.form-save-status.saved {
    background-color: #d4edda;
    border-left: 4px solid #28a745;
    color: #155724;
}

/* Save Status: Error State */
.form-save-status.error {
    background-color: #f8d7da;
    border-left: 4px solid #dc3545;
    color: #721c24;
}

/* Status Icons */
.save-status-icon {
    font-size: 1rem;
}

.save-status-icon.fa-spin {
    animation: spin 1s linear infinite;
}

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

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

/* Responsive adjustments for offline indicators on mobile */
@media (max-width: 768px) {
    .form-offline-indicator {
        font-size: 0.85rem;
        padding: 10px 12px;
        gap: 8px;
    }

    .offline-indicator-text {
        min-width: 80px;
        font-size: 0.8rem;
    }

    .offline-indicator-status {
        font-size: 0.75rem;
    }

    .form-save-status {
        padding: 6px 10px;
        font-size: 0.8rem;
        margin-top: 8px;
        margin-bottom: 10px;
    }
}

/* ===================================================================
   MOBILE UX IMPROVEMENTS — Comprehensive responsive overhaul
   =================================================================== */

/* --- Navigation Tabs: Compact, scrollable, touch-friendly --- */
@media (max-width: 768px) {
    .nav-tabs {
        gap: 0;
        justify-content: flex-start;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding: 0 0.25rem;
    }
    .nav-tabs::-webkit-scrollbar {
        display: none;
    }
    .nav-tab {
        padding: 0.625rem 0.5rem;
        font-size: 0.78rem;
        min-width: unset;
        gap: 0.25rem;
        min-height: 44px;
    }
    .nav-tab i {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .nav-tab {
        padding: 0.5rem 0.375rem;
        font-size: 0.72rem;
        min-height: 44px;
    }
    .nav-tab span {
        display: none;
    }
    .nav-tab i {
        font-size: 1.15rem;
    }
    .nav-tab.active span {
        display: inline;
        font-size: 0.7rem;
    }
}

/* --- Dashboard Header: Stack filter below title --- */
@media (max-width: 768px) {
    #dashboard > div[style*="display: flex"][style*="justify-content: space-between"] {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem;
    }
    #dashboard > div[style*="display: flex"][style*="justify-content: space-between"] > div {
        width: 100%;
    }
    #dashboardPhcFilter {
        width: 100% !important;
        min-width: unset !important;
    }
    #dashboard h2 {
        font-size: 1.3rem;
    }
}

/* --- KPI Cards: Stack vertically on mobile --- */
@media (max-width: 768px) {
    .kpi-cards-container {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }
    .kpi-card {
        flex: none !important;
        width: 100%;
        padding: 1rem 0.75rem;
    }
    .kpi-value {
        font-size: 1.75rem;
    }
    .kpi-label {
        font-size: 0.8rem;
    }
    .kpi-desc {
        font-size: 0.78rem;
    }
}

@media (max-width: 480px) {
    .kpi-card {
        padding: 0.75rem;
    }
    .kpi-value {
        font-size: 1.5rem;
    }
}

/* --- Chart Row: Stack gauges vertically, remove inline margins --- */
@media (max-width: 768px) {
    .chart-row {
        flex-direction: column;
        gap: 0.75rem;
    }
    .chart-row > .chart-box {
        margin-left: 0 !important;
        margin-right: 0 !important;
        flex: none !important;
        width: 100%;
    }
    .chart-container {
        flex-direction: column;
        gap: 0.75rem;
    }
    .chart-box {
        min-width: unset !important;
        width: 100%;
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }
    .chart-box h3:not(.form-section-header) {
        font-size: 1rem;
    }
}

/* --- Stats Grid: More compact on mobile --- */
@media (max-width: 768px) {
    .stats-grid {
        gap: 0.75rem;
        margin-bottom: 1rem;
    }
    .stat-card {
        padding: 1rem 0.75rem;
    }
    .stat-number {
        font-size: 1.35rem;
    }
}

/* --- Tab Content: Reduce padding for more space --- */
@media (max-width: 768px) {
    .tab-content {
        padding: 0.75rem;
    }
}

@media (max-width: 480px) {
    .tab-content {
        padding: 0.5rem;
    }

    /* Compact injury map on mobile */
    .body-svg-container {
        min-width: 120px;
        max-width: 140px;
        padding: 8px;
        margin: 0 auto;
    }

    .body-svg-container svg {
        max-height: 280px;
    }

    /* Ultra-compact header for small phones */
    .header {
        padding: 0.5rem 0.5rem 0.375rem;
        gap: 0.25rem;
    }

    .header h1 {
        font-size: 0.95rem;
        margin-bottom: 0;
        line-height: 1.1;
        font-weight: 700;
    }

    .header p {
        font-size: 0.7rem;
        margin-bottom: 0.25rem;
        line-height: 1;
    }

    /* Hide button text, show only icons */
    .logout-container {
        gap: 0.15rem;
        top: 0.375rem;
        right: 0.375rem;
    }

    .logout-container .logout-btn span {
        display: none;
    }

    .logout-container .logout-btn {
        padding: 0.3rem 0.325rem;
        font-size: 0.65rem;
        min-height: auto;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
    }

    .logout-container .logout-btn i {
        margin: 0;
        font-size: 0.8rem;
    }

    .logout-container .user-info {
        display: none;
    }

    .logout-container .theme-toggle-btn {
        padding: 0.3rem 0.325rem;
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }

    /* Compact notification/sync badges */
    #notificationBadge,
    #syncQueueBadge,
    #offlinePatientBadge {
        width: 12px;
        height: 12px;
        font-size: 7px;
        top: -6px;
        right: -6px;
    }

    /* Stack injury map vertically on mobile */
    .injury-map-container {
        gap: 12px;
        flex-direction: column;
        align-items: center;
    }

    .injury-details-container {
        width: 100%;
        max-width: 140px;
        margin: 0 auto;
    }
}

/* --- Patient List: Prevent overflow on small phones --- */
@media (max-width: 480px) {
    .patient-list {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    .patient-card {
        padding: 0.75rem;
    }
    .patient-card .patient-name {
        font-size: 1rem;
    }
    .patient-card .card-details .detail-label {
        font-size: 0.82rem;
        min-width: 70px;
    }
    .patient-card .card-details .detail-value {
        font-size: 0.82rem;
    }
}

/* --- Tables: Horizontal scroll wrapper for all tables --- */
@media (max-width: 768px) {
    .report-table-container,
    .prediction-table-container,
    .detailed-table-section {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -0.75rem;
        padding: 0 0.75rem;
    }
    table:not(.report-table) {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
    .report-table {
        font-size: 0.78rem;
    }
    .report-table th,
    .report-table td {
        padding: 8px 6px;
        white-space: nowrap;
    }
    .prediction-table {
        font-size: 0.72rem;
    }
    .prediction-table th,
    .prediction-table td {
        padding: 4px 5px;
    }
}

/* --- Logout / Header: Stack and center on mobile --- */
@media (max-width: 768px) {
    .logout-container {
        gap: 0.4rem;
        flex-wrap: wrap;
    }
    .logout-container select,
    .logout-container .logout-btn {
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
        min-height: 40px;
    }
    .logout-container .user-info {
        font-size: 0.75rem;
        padding: 0.4rem 0.7rem;
        background: rgba(255, 255, 255, 0.15);
        border-radius: 16px;
        white-space: nowrap;
        min-height: 40px;
        display: flex;
        align-items: center;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    /* Tablet-specific header optimizations */
    .header {
        padding: 1rem;
    }

    .header h1 {
        font-size: 1.4rem;
    }

    .header p {
        font-size: 0.9rem;
    }

    .logout-container .logout-btn span {
        display: inline;
    }

    .logout-container .user-info {
        display: inline-flex;
    }
}

@media (max-width: 480px) {
    .system-header {
        padding: 1rem 0.5rem;
    }
    .system-header h1 {
        font-size: 1.25rem;
    }
    .system-header p {
        font-size: 0.85rem;
    }
    .system-header i {
        font-size: 2.25rem;
        width: 70px;
        height: 70px;
    }
}

/* --- Management Subtabs: Scrollable on small screens --- */
@media (max-width: 768px) {
    .management-hero {
        flex-wrap: wrap;
        padding: 0.6rem 1rem;
    }
    .management-layout {
        grid-template-columns: 1fr;
    }
    .management-sidebar {
        position: static;
    }
    .management-overview-grid {
        grid-template-columns: 1fr;
    }
    .management-subtabs {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 6px !important;
        padding-bottom: 6px;
        scrollbar-width: none;
    }
    .management-subtabs::-webkit-scrollbar {
        display: none;
    }
    .management-subtabs .management-subtab {
        flex-shrink: 0;
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
        min-height: 40px;
        white-space: nowrap;
        width: auto !important;
        min-width: max-content !important;
    }
    .management-content-shell,
    .management-search-panel,
    .management-overview-shell,
    .management-nav-shell,
    .management-quick-tools {
        padding: 0.95rem;
    }
}

/* --- Search Container: Full width inputs --- */
@media (max-width: 768px) {
    .search-container input {
        font-size: 16px;
        padding: 0.75rem 0.75rem 0.75rem 2.5rem;
    }
    .follow-up-filters {
        flex-direction: column !important;
        gap: 0.5rem;
    }
    .follow-up-filters > * {
        width: 100% !important;
    }
}

/* --- Modals: Better mobile sizing with safe area --- */
@media (max-width: 768px) {
    .modal-content {
        width: calc(100% - 16px) !important;
        max-width: none !important;
        margin: 8px auto;
        padding: 0.75rem;
        max-height: calc(100vh - 16px);
        border-radius: 8px;
    }
}

/* --- Touch targets: Ensure minimum 44px for all interactive elements --- */
@media (max-width: 768px) {
    .action-btn,
    .btn-sm,
    button:not(.nav-tab):not(.management-subtab) {
        min-height: 44px;
        touch-action: manipulation;
    }
    a, button, select, input[type="checkbox"], input[type="radio"] {
        touch-action: manipulation;
    }
    /* Prevent double-tap zoom on interactive elements */
    * {
        -webkit-tap-highlight-color: transparent;
    }
}

/* --- Critical Alerts: Compact on mobile --- */
@media (max-width: 768px) {
    #criticalAlertsSection {
        padding: 0.75rem !important;
        margin-bottom: 1rem !important;
    }
    #criticalAlertsSection h3 {
        font-size: 1rem !important;
    }
}

/* --- Top CHOs Leaderboard: Compact layout --- */
@media (max-width: 768px) {
    .top-chos-leaderboard {
        font-size: 0.85rem;
    }
}

/* --- Risk Bar in KPI: Readable text on narrow screens --- */
@media (max-width: 480px) {
    .risk-bar-container {
        height: 32px !important;
    }
    .risk-bar-container span.risk-label {
        font-size: 0.7rem !important;
    }
    .kpi-desc {
        flex-direction: column;
        align-items: center;
        gap: 0.25rem !important;
    }
}

/* --- Follow-up filters row: Vertical stack on mobile --- */
@media (max-width: 768px) {
    .filter-bar,
    [class*="filter-row"],
    [class*="filters-container"] {
        flex-direction: column;
        gap: 0.5rem;
    }
    .filter-bar select,
    .filter-bar input {
        width: 100%;
        min-width: unset;
    }
}

/* --- Canvas charts: Limit height on very small screens --- */
@media (max-width: 480px) {
    canvas {
        max-height: 200px;
    }
    .kpi-gauge {
        height: 150px;
    }
}

/* --- Export buttons: Stack on mobile --- */
@media (max-width: 768px) {
    .export-container {
        flex-direction: column;
        gap: 0.5rem;
    }
    .export-container .btn,
    .export-container button {
        width: 100%;
    }
}

/* --- District management table: Scrollable --- */
@media (max-width: 768px) {
    #districtsTableContainer {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    #districtsTableContainer table {
        min-width: 500px;
    }
}

/* --- District Setup Wizard --- */
.wizard-stepper {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 20px;
    padding: 12px 8px;
    background: var(--bg-secondary);
    border-radius: 10px;
    overflow-x: auto;
}
.wizard-step {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.82rem;
    white-space: nowrap;
    color: var(--medium-text);
    transition: all 0.2s;
}
.wizard-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #dee2e6;
    color: #666;
    font-weight: 700;
    font-size: 0.8rem;
    transition: all 0.2s;
}
.wizard-step.active .wizard-step-num {
    background: #6c5ce7;
    color: #fff;
}
.wizard-step.active {
    color: #6c5ce7;
    font-weight: 600;
}
.wizard-step.completed .wizard-step-num {
    background: #00b894;
    color: #fff;
}
.wizard-step.completed .wizard-step-num::after {
    content: '\f00c';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 0.65rem;
}
.wizard-step.completed .wizard-step-num span {
    display: none;
}
.wizard-step-line {
    flex: 1;
    height: 2px;
    background: #dee2e6;
    min-width: 16px;
}
.wizard-step-label {
    display: inline;
}
.wizard-panel {
    padding: 18px;
    background: var(--bg-secondary);
    border-radius: 10px;
    border: 1px solid #dee2e6;
}
.wizard-error {
    display: none;
    margin-top: 8px;
    color: var(--danger-color, #e74c3c);
    font-size: 0.85rem;
    font-weight: 500;
}
.wizard-success {
    display: none;
    margin-top: 8px;
    color: #00b894;
    font-size: 0.85rem;
    font-weight: 500;
}
.wizard-upload-area {
    border: 2px dashed #b2bec3;
    border-radius: 10px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-primary, #fff);
}
.wizard-upload-area:hover,
.wizard-upload-hover {
    border-color: #6c5ce7;
    background: rgba(108, 92, 231, 0.04);
}

@media (max-width: 768px) {
    .wizard-stepper {
        gap: 0;
        padding: 8px 4px;
    }
    .wizard-step-label {
        display: none;
    }
    .wizard-step {
        padding: 4px 6px;
    }
    .wizard-panel {
        padding: 12px;
    }
    .wizard-upload-area {
        padding: 16px 10px;
    }
}

/* --- Add form panels inside management: Full width --- */
@media (max-width: 768px) {
    #addDistrictForm,
    .chart-box form {
        padding: 0.75rem;
    }
    #addDistrictForm .form-group,
    .chart-box form .form-group {
        width: 100%;
    }
    #addDistrictForm input,
    #addDistrictForm select {
        width: 100%;
        font-size: 16px;
    }
}

/* --- Smooth scrolling for mobile --- */
@media (max-width: 768px) {
    html {
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }
    body {
        overflow-x: hidden;
    }
}

/* =====================================================
   PWA Install Prompt Banner
   ===================================================== */
.pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999998;
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: #fff;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.25);
    padding: 0;
    animation: pwa-slide-up 0.4s ease-out;
}
@keyframes pwa-slide-up {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
.pwa-install-content {
    display: flex;
    align-items: center;
    gap: 14px;
    max-width: 600px;
    margin: 0 auto;
    padding: 14px 20px;
}
.pwa-install-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    flex-shrink: 0;
    background: rgba(255,255,255,0.15);
    padding: 4px;
}
.pwa-install-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}
.pwa-install-text strong {
    font-size: 15px;
}
.pwa-install-text span {
    font-size: 12px;
    opacity: 0.85;
}
.pwa-install-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.pwa-install-accept {
    background: #fff;
    color: #2c3e50;
    border: none;
    padding: 8px 22px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.pwa-install-accept:hover {
    background: #ecf0f1;
    transform: scale(1.03);
}
.pwa-install-dismiss {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}
.pwa-install-dismiss:hover {
    color: #fff;
}
@media (max-width: 480px) {
    .pwa-install-content { gap: 10px; padding: 12px 14px; }
    .pwa-install-icon { width: 40px; height: 40px; }
    .pwa-install-accept { padding: 7px 16px; font-size: 13px; }
}

/* ─── LGDEA Consultation Recorder Widget ──────────────────────────────────── */
/* ── Active Learning Wizard ────────────────────────────────────────���──── */

.al-wizard {
    margin-top: 1.5rem;
    border: 1px solid #e2e8f0;
    border-radius: var(--border-radius);
    background: #fff;
    overflow: hidden;
}
.al-wizard__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 1rem;
    background: linear-gradient(90deg, #1e3a8a, #0f766e);
    color: #fff;
    font-weight: 700;
    font-size: 0.92rem;
}
.al-wizard__title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.al-wizard__badge {
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: rgba(255,255,255,0.2);
    font-size: 0.72rem;
    font-weight: 600;
}
.al-wizard__desc {
    padding: 0.75rem 1rem;
    font-size: 0.88rem;
    color: var(--medium-text);
    background: var(--light-bg);
    border-bottom: 1px solid #e2e8f0;
    margin: 0;
}
.al-wizard__section {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f0f0f0;
}
.al-wizard__section h5 {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--secondary-color);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.al-wizard__toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
    cursor: pointer;
    margin-bottom: 0.35rem;
}
.al-wizard__toggle input { cursor: pointer; }
.al-wizard__hint {
    display: block;
    font-size: 0.8rem;
    color: var(--light-text);
    margin-top: 0.25rem;
}
.al-wizard__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-top: 0.5rem;
}
.al-wizard__field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.al-wizard__field label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--dark-text);
}
.al-wizard__field input,
.al-wizard__field select {
    padding: 0.4rem 0.6rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.88rem;
    background: #fff;
}
.al-wizard__field input:focus,
.al-wizard__field select:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(52,152,219,0.15);
}
.al-wizard__field small {
    font-size: 0.75rem;
    color: var(--light-text);
}
.al-wizard__weight-sum {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    background: var(--light-bg);
    font-size: 0.85rem;
    color: var(--medium-text);
}
.al-wizard__weight-ok {
    color: var(--success-color);
    font-weight: 600;
}
.al-wizard__weight-warn {
    color: var(--warning-color);
    font-weight: 600;
}
.al-wizard__steps {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
    background: var(--light-bg);
    overflow-x: auto;
}
.al-wizard__step {
    flex: 1;
    padding: 0.6rem 0.75rem;
    border: none;
    background: transparent;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--light-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
}
.al-wizard__step:hover { color: var(--primary-color); }
.al-wizard__step.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: #fff;
}
.al-wizard__step.completed { color: var(--success-color); }
.al-wizard__step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #e2e8f0;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--medium-text);
}
.al-wizard__step.active .al-wizard__step-num {
    background: var(--primary-color);
    color: #fff;
}
.al-wizard__step.completed .al-wizard__step-num {
    background: var(--success-color);
    color: #fff;
}
.al-wizard__slider {
    width: 100%;
    cursor: pointer;
    accent-color: var(--primary-color);
}
.al-wizard__slider-val {
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--primary-color);
}
.al-wizard__panel {
    animation: wizardFadeIn 0.25s ease;
}
@keyframes wizardFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.al-wizard__actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid #e2e8f0;
    background: var(--light-bg);
}

.lgdea-recorder {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 1.25rem;
    max-width: 700px;
    margin: 0 auto;
}
.lgdea-recorder__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.lgdea-recorder__header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--primary-color, #2563eb);
}
.lgdea-recorder__patient {
    font-size: 0.85rem;
    color: #6b7280;
    background: #e5e7eb;
    padding: 2px 8px;
    border-radius: 4px;
}
.lgdea-recorder__meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.lgdea-recorder__field label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.lgdea-recorder__field select,
.lgdea-recorder__field input {
    width: 100%;
    padding: 0.4rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.85rem;
    background: #fff;
}
.lgdea-recorder__field select:disabled,
.lgdea-recorder__field input:disabled {
    background: #f3f4f6;
    color: #9ca3af;
}
.lgdea-recorder__waveform {
    width: 100%;
    height: 80px;
    background: #1a1a2e;
    border-radius: 8px;
    margin-bottom: 0.75rem;
}
.lgdea-recorder__timer {
    text-align: center;
    font-size: 1.8rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #1f2937;
    margin-bottom: 0.75rem;
}
.lgdea-recorder__timer--warn {
    color: #ef4444;
    animation: lgdea-pulse 1s ease-in-out infinite;
}
@keyframes lgdea-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
.lgdea-recorder__controls {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}
.lgdea-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
}
.lgdea-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.lgdea-btn--record {
    background: #ef4444;
    color: #fff;
}
.lgdea-btn--record:hover:not(:disabled) {
    background: #dc2626;
}
.lgdea-btn--pause {
    background: #f59e0b;
    color: #fff;
}
.lgdea-btn--pause:hover:not(:disabled) {
    background: #d97706;
}
.lgdea-btn--stop {
    background: #6b7280;
    color: #fff;
}
.lgdea-btn--stop:hover:not(:disabled) {
    background: #4b5563;
}
.lgdea-btn--discard {
    background: transparent;
    color: #6b7280;
    border: 1px solid #d1d5db;
}
.lgdea-btn--discard:hover:not(:disabled) {
    background: #fee2e2;
    color: #ef4444;
    border-color: #fca5a5;
}
.lgdea-btn__icon {
    font-size: 0.9rem;
}
.lgdea-recorder__status {
    text-align: center;
    font-size: 0.8rem;
    min-height: 1.2em;
    color: #6b7280;
}
.lgdea-recorder__status--info {
    color: #3b82f6;
}
.lgdea-recorder__status--success {
    color: #10b981;
}
.lgdea-recorder__status--warn {
    color: #f59e0b;
}
.lgdea-recorder__status--error {
    color: #ef4444;
}

/* Reasoning memo guided prompts */
.lgdea-recorder__prompts {
    background: #1e293b;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 8px 0;
}
.lgdea-recorder__prompts-header {
    font-weight: 600;
    color: #f59e0b;
    margin-bottom: 8px;
    font-size: 0.9rem;
}
.lgdea-recorder__prompts-list {
    margin: 0;
    padding-left: 20px;
    font-size: 0.85rem;
    color: #cbd5e1;
    line-height: 1.7;
}
.lgdea-recorder__prompts-list li {
    margin-bottom: 4px;
}

/* Device panel */
.lgdea-recorder__device-panel {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    margin: 8px 0;
    flex-wrap: wrap;
}
.lgdea-recorder__device-panel label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}
.lgdea-recorder__device-panel select {
    flex: 1;
    min-width: 180px;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-main);
    color: var(--text-primary);
    font-size: 0.85rem;
}
.lgdea-btn--small {
    padding: 4px 10px;
    font-size: 0.8rem;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-main);
    color: var(--text-secondary);
    cursor: pointer;
}
.lgdea-btn--small:hover {
    background: var(--bg-card);
    border-color: var(--brand-primary);
}

/* Upload panel */
.lgdea-recorder__upload-panel {
    margin-top: 8px;
}
.lgdea-recorder__upload-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 10px 0;
    color: var(--text-secondary);
    font-size: 0.82rem;
}
.lgdea-recorder__upload-divider::before,
.lgdea-recorder__upload-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-subtle);
}
.lgdea-btn--upload {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px dashed var(--border-subtle);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.lgdea-btn--upload:hover {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
    background: var(--brand-soft);
}
.lgdea-recorder__upload-info {
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--bg-main);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.lgdea-consultation-workspace {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.lgdea-consultation-review {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
}

.lgdea-consultation-review__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.lgdea-consultation-review__header h4 {
    margin: 0 0 4px;
    font-size: 1rem;
    color: #1e293b;
}

.lgdea-consultation-review__header p {
    margin: 0;
    font-size: 0.85rem;
    color: #64748b;
}

.lgdea-consultation-review__body {
    display: grid;
    grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
    gap: 16px;
}

.lgdea-consultation-review__list,
.lgdea-consultation-review__panel {
    min-height: 220px;
}

.lgdea-consultation-review__list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lgdea-consultation-review__panel {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px;
}

.lgdea-consultation-review__empty {
    color: #64748b;
    text-align: center;
    padding: 24px 16px;
    font-size: 0.9rem;
}

.lgdea-consultation-card {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 12px;
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.lgdea-consultation-card.is-active {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.lgdea-consultation-card__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.lgdea-consultation-card__title {
    font-weight: 700;
    color: #1e293b;
    font-size: 0.9rem;
}

.lgdea-consultation-card__meta {
    font-size: 0.76rem;
    color: #64748b;
    line-height: 1.45;
}

.lgdea-consultation-card__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.lgdea-review-history-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 0.7rem;
    font-weight: 700;
    border: 1px solid transparent;
    white-space: nowrap;
}

.lgdea-review-history-badge--draft,
.lgdea-review-history-badge--neutral {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #475569;
}

.lgdea-review-history-badge--submitted,
.lgdea-review-history-badge--ok {
    background: #dcfce7;
    border-color: #86efac;
    color: #166534;
}

.lgdea-review-history-badge--warn {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

.lgdea-review-history-badge--confirmed {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.lgdea-consultation-card__actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.lgdea-consultation-card__warning {
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #fff7ed;
    border: 1px solid #fdba74;
    color: #9a3412;
    font-size: 0.78rem;
    line-height: 1.45;
}

.lgdea-consultation-card__status {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.lgdea-consultation-card__status--completed {
    background: #dcfce7;
    color: #166534;
}

.lgdea-consultation-card__status--processing,
.lgdea-consultation-card__status--asr,
.lgdea-consultation-card__status--lgdea,
.lgdea-consultation-card__status--beg {
    background: #dbeafe;
    color: #1d4ed8;
}

.lgdea-consultation-card__status--pending {
    background: #f3f4f6;
    color: #4b5563;
}

.lgdea-consultation-card__status--failed {
    background: #fee2e2;
    color: #991b1b;
}

.lgdea-review-shell {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.lgdea-review-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
}

.lgdea-review-header h5 {
    margin: 0 0 4px;
    font-size: 1rem;
    color: #1e293b;
}

.lgdea-review-header p {
    margin: 0;
    font-size: 0.82rem;
    color: #64748b;
}

.lgdea-review-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lgdea-review-section__title {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #475569;
    font-weight: 800;
}

.lgdea-review-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}

.lgdea-review-metric {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 12px;
}

.lgdea-review-metric__label {
    font-size: 0.72rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.lgdea-review-metric__value {
    font-size: 1rem;
    font-weight: 800;
    color: #1e293b;
}

.lgdea-review-metric__hint {
    margin-top: 4px;
    font-size: 0.75rem;
    color: #64748b;
    line-height: 1.4;
}

.lgdea-review-callout {
    padding: 10px 12px;
    border-radius: 8px;
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
    font-size: 0.82rem;
}

.lgdea-review-callout--warn {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

.lgdea-review-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.lgdea-review-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.lgdea-review-field label {
    font-size: 0.76rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.lgdea-review-field select,
.lgdea-review-field input,
.lgdea-review-field textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.88rem;
    color: #1e293b;
    background: #fff;
}

.lgdea-review-field textarea {
    resize: vertical;
    min-height: 72px;
}

.lgdea-review-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.lgdea-review-statusline {
    font-size: 0.8rem;
    color: #64748b;
}

@media (max-width: 900px) {
    .lgdea-consultation-review__body {
        grid-template-columns: 1fr;
    }
}

/* ── LGDEA Analysis UI ───────────────────────────────────────────────── */

.lgdea-analysis {
    padding: 0;
}

.lgdea-analysis__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 8px 8px 0 0;
}

.lgdea-analysis__header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #1e293b;
}

.lgdea-analysis__patient {
    font-size: 0.85rem;
    color: #64748b;
    background: #e2e8f0;
    padding: 2px 8px;
    border-radius: 4px;
}

.lgdea-analysis__loading {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
}

.lgdea-analysis__error {
    color: #ef4444;
    text-align: center;
    padding: 20px;
}

.lgdea-analysis__empty {
    color: #94a3b8;
    text-align: center;
    padding: 24px 16px;
    font-style: italic;
}

.lgdea-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: lgdea-spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

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

/* Recording cards */
.lgdea-analysis__recordings {
    padding: 12px 16px;
}

.lgdea-analysis__rec-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lgdea-rec-card {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 16px;
    background: #fff;
    transition: box-shadow 0.15s;
}

.lgdea-rec-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.lgdea-rec-card__info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.lgdea-rec-card__type {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.95rem;
}

.lgdea-rec-card__meta {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 8px;
}

.lgdea-rec-card__actions {
    display: flex;
    gap: 8px;
}

/* Badges */
.lgdea-badge {
    display: inline-block;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.lgdea-badge--success {
    background: #dcfce7;
    color: #166534;
}

.lgdea-badge--warn {
    background: #fef3c7;
    color: #92400e;
}

.lgdea-badge--error {
    background: #fee2e2;
    color: #991b1b;
}

.lgdea-badge--muted {
    background: #f1f5f9;
    color: #64748b;
}

.lgdea-badge--info {
    background: #dbeafe;
    color: #1e40af;
}

/* Buttons */
.lgdea-btn--analyze {
    background: #3b82f6;
    color: #fff;
}

.lgdea-btn--analyze:hover:not(:disabled) {
    background: #2563eb;
}

.lgdea-btn--view {
    background: #22c55e;
    color: #fff;
}

.lgdea-btn--view:hover:not(:disabled) {
    background: #16a34a;
}

.lgdea-btn--status {
    background: #f1f5f9;
    color: #475569;
    transition: all 0.2s ease;
    border: 1px solid #cbd5e1;
}

.lgdea-btn--status:hover:not(:disabled) {
    background: #e2e8f0;
    border-color: #94a3b8;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}
.lgdea-btn--back {
    background: none;
    border: 1px solid #cbd5e1;
    color: #475569;
    margin-bottom: 12px;
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
}

.lgdea-btn--back:hover {
    background: #f1f5f9;
}

/* Results header */
.lgdea-results-header {
    padding: 12px 0;
    margin-bottom: 8px;
}

.lgdea-results-header h4 {
    margin: 0 0 6px;
    font-size: 1.05rem;
    color: #1e293b;
}

.lgdea-results-header__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.8rem;
    color: #64748b;
}

/* Results tabs */
.lgdea-results-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 16px;
    overflow-x: auto;
}

.lgdea-results-tab {
    padding: 8px 16px;
    border: none;
    background: none;
    font-size: 0.85rem;
    color: #64748b;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}

.lgdea-results-tab:hover {
    color: #1e293b;
}

.lgdea-results-tab.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
    font-weight: 600;
}

.lgdea-results-view {
    min-height: 200px;
}

/* ── BEG Section ─────────────────────────────────────────────────────── */

.lgdea-beg__summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.lgdea-beg__card {
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    border: 1px solid #e2e8f0;
}

.lgdea-beg__card--success {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.lgdea-beg__card--warning {
    background: #fffbeb;
    border-color: #fde68a;
}

.lgdea-beg__card--muted {
    background: #f8fafc;
    border-color: #e2e8f0;
}

.lgdea-beg__card-label {
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lgdea-beg__card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 6px;
}

.lgdea-beg__card-bar {
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    overflow: hidden;
}

.lgdea-beg__card-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.lgdea-beg__chart-wrap {
    margin-bottom: 16px;
    padding: 16px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 8px;
    border: 1px solid #d1dce6;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.lgdea-beg__chart-wrap h5 {
    margin: 0 0 8px;
    font-size: 0.9rem;
    color: #475569;
}

.lgdea-beg__chart-wrap canvas {
    max-height: 280px;
    transition: filter 0.2s ease;
}

.lgdea-beg__chart-wrap canvas:hover {
    filter: brightness(1.02);
}

.lgdea-beg__pivots {
    margin-bottom: 12px;
}

.lgdea-beg__pivots h5 {
    margin: 0 0 8px;
    font-size: 0.9rem;
    color: #dc2626;
}

.lgdea-beg__pivot-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: #fef2f2;
    border-radius: 6px;
    margin-bottom: 4px;
    border-left: 3px solid #ef4444;
}

.lgdea-beg__pivot-turn {
    font-weight: 600;
    font-size: 0.8rem;
    color: #991b1b;
    white-space: nowrap;
}

.lgdea-beg__pivot-summary {
    font-size: 0.8rem;
    color: #64748b;
}

.lgdea-beg__meta {
    display: flex;
    gap: 16px;
    font-size: 0.78rem;
    color: #94a3b8;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
}

/* ── Evidence Timeline ───────────────────────────────────────────────── */

.lgdea-evidence__summary {
    display: flex;
    gap: 16px;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 0.85rem;
    color: #475569;
}

.lgdea-evidence__split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    max-height: 600px;
}

@media (max-width: 768px) {
    .lgdea-evidence__split {
        grid-template-columns: 1fr;
    }
}

.lgdea-evidence__transcript,
.lgdea-evidence__cards {
    overflow-y: auto;
    max-height: 600px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px;
}

.lgdea-evidence__transcript h5,
.lgdea-evidence__cards h5 {
    margin: 0 0 8px;
    font-size: 0.85rem;
    color: #475569;
    padding-bottom: 6px;
    border-bottom: 1px solid #f1f5f9;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}

/* Transcript segments */
.lgdea-evidence__seg {
    display: flex;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    margin-bottom: 2px;
    transition: background 0.15s;
    font-size: 0.83rem;
}

.lgdea-evidence__seg:hover {
    background: #f8fafc;
}

.lgdea-evidence__seg--has-ev {
    background: #eff6ff;
    border-left: 3px solid #3b82f6;
}

.lgdea-evidence__seg--pivot {
    background: #fef2f2;
    border-left: 3px solid #ef4444;
}

.lgdea-evidence__seg-speaker {
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    min-width: 60px;
    letter-spacing: 0.3px;
}

.lgdea-evidence__seg-text {
    flex: 1;
    color: #334155;
    line-height: 1.5;
}

.lgdea-evidence__seg-time {
    font-size: 0.7rem;
    color: #94a3b8;
    white-space: nowrap;
}

/* Evidence cards */
.lgdea-ev-card {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: #fff;
    transition: border-color 0.15s;
}

.lgdea-ev-card:hover {
    border-color: #93c5fd;
}

.lgdea-ev-card--pivot {
    border-color: #fca5a5;
    background: #fef2f2;
}

.lgdea-ev-card__header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.lgdea-ev-card__term {
    font-weight: 600;
    font-size: 0.88rem;
    color: #1e293b;
}

.lgdea-ev-card__conf {
    font-size: 0.72rem;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 500;
}

.lgdea-ev-card__conf--high {
    background: #dcfce7;
    color: #166534;
}

.lgdea-ev-card__conf--med {
    background: #fef3c7;
    color: #92400e;
}

.lgdea-ev-card__conf--low {
    background: #fee2e2;
    color: #991b1b;
}

.lgdea-ev-card__pivot-badge {
    font-size: 0.72rem;
    background: #ef4444;
    color: #fff;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 600;
}

.lgdea-ev-card__prov {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
}

.lgdea-ev-card__badge {
    font-size: 0.68rem;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.lgdea-ev-card__badge--source {
    background: #dbeafe;
    color: #1e40af;
}

.lgdea-ev-card__badge--elicit {
    background: #e0e7ff;
    color: #3730a3;
}

.lgdea-ev-card__badge--domain {
    background: #fae8ff;
    color: #86198f;
}

.lgdea-ev-card__badge--turn {
    background: #f1f5f9;
    color: #475569;
}

.lgdea-ev-card__contrastive {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 4px;
}

.lgdea-ev-card__cx {
    font-size: 0.72rem;
    padding: 1px 6px;
    border-radius: 4px;
}

.lgdea-ev-card__cx--up {
    background: #dcfce7;
    color: #166534;
}

.lgdea-ev-card__cx--down {
    background: #fee2e2;
    color: #991b1b;
}

.lgdea-ev-card__desc {
    font-size: 0.78rem;
    color: #64748b;
    font-style: italic;
    margin-top: 4px;
    line-height: 1.4;
}

.lgdea-ev-card__al-status {
    font-size: 0.72rem;
    margin-top: 6px;
    padding: 3px 8px;
    border-radius: 4px;
}

.lgdea-ev-card__al-status--flagged {
    background: #fef3c7;
    color: #92400e;
}

.lgdea-ev-card--focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

/* ── Discordance Section ─────────────────────────────────────────────── */

.lgdea-discordance h5 {
    margin: 0 0 12px;
    font-size: 0.95rem;
    color: #475569;
}

.lgdea-discordance__grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lgdea-disc-card {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 16px;
    background: #fff;
}

.lgdea-disc--ok {
    border-left: 4px solid #22c55e;
}

.lgdea-disc--warn {
    border-left: 4px solid #f59e0b;
}

.lgdea-disc--muted {
    border-left: 4px solid #94a3b8;
}

.lgdea-disc--info {
    border-left: 4px solid #3b82f6;
}

.lgdea-disc-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.lgdea-disc-card__domain {
    font-weight: 600;
    color: #1e293b;
    text-transform: capitalize;
}

.lgdea-disc-card__class {
    font-size: 0.8rem;
    color: #64748b;
}

.lgdea-disc-card__accounts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (max-width: 600px) {
    .lgdea-disc-card__accounts {
        grid-template-columns: 1fr;
    }
}

.lgdea-disc-card__quote {
    border-radius: 6px;
    padding: 8px 12px;
}

.lgdea-disc-card__quote--patient {
    background: #f0fdf4;
}

.lgdea-disc-card__quote--witness {
    background: #faf5ff;
}

.lgdea-disc-card__quote-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    color: #64748b;
}

.lgdea-disc-card__quote blockquote {
    margin: 0;
    font-size: 0.85rem;
    color: #334155;
    line-height: 1.5;
    font-style: italic;
}

.lgdea-disc-card__notes {
    margin-top: 8px;
    font-size: 0.8rem;
    color: #64748b;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
}

/* ── Transcript Section ──────────────────────────────────────────────── */

.lgdea-transcript {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lgdea-transcript-state {
    border: 1px solid #dbe3ef;
    border-radius: 14px;
    padding: 16px;
    background: linear-gradient(180deg, #f8fbff 0%, #f1f5f9 100%);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.lgdea-transcript-state__headline {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.lgdea-transcript-state__eyebrow {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #2563eb;
    margin-bottom: 4px;
}

.lgdea-transcript-state h5 {
    margin: 0 0 4px;
    font-size: 1.02rem;
    color: #0f172a;
}

.lgdea-transcript-state p {
    margin: 0;
    font-size: 0.84rem;
    color: #475569;
    line-height: 1.5;
}

.lgdea-transcript-state__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.lgdea-transcript-state__dirty {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    background: #fff7ed;
    color: #c2410c;
    border: 1px solid #fdba74;
    font-size: 0.74rem;
    font-weight: 700;
}

.lgdea-transcript-state__callout {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1d4ed8;
    font-size: 0.82rem;
}

.lgdea-transcript-state__callout--warn {
    background: #fff7ed;
    border-color: #fdba74;
    color: #c2410c;
}

.lgdea-transcript-state__metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.lgdea-transcript-state__metric {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #dbe3ef;
    background: rgba(255, 255, 255, 0.82);
}

.lgdea-transcript-state__metric span {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 6px;
}

.lgdea-transcript-state__metric strong {
    font-size: 1rem;
    color: #0f172a;
}

.lgdea-transcript-state__issues {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.lgdea-transcript-issue-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid #dbe3ef;
    background: #fff;
    color: #334155;
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.lgdea-transcript-issue-pill:hover,
.lgdea-transcript-issue-pill.is-active {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
    transform: translateY(-1px);
}

.lgdea-transcript-issue-pill__count {
    min-width: 20px;
    padding: 2px 6px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    text-align: center;
}

.lgdea-transcript-state__controls {
    display: grid;
    grid-template-columns: minmax(180px, 240px) minmax(220px, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.lgdea-transcript-state__field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lgdea-transcript-state__field span {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #475569;
}

.lgdea-transcript-state__field select,
.lgdea-transcript-state__field input {
    width: 100%;
    min-height: 40px;
    padding: 9px 11px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
    color: #0f172a;
}

.lgdea-transcript-state__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.lgdea-transcript-state__status {
    margin-top: 12px;
    font-size: 0.82rem;
    color: #475569;
}

.lgdea-transcript-state__status--neutral {
    color: #475569;
}

.lgdea-transcript-state__status--success {
    color: #166534;
}

.lgdea-transcript-state__status--warn {
    color: #c2410c;
}

.lgdea-transcript-state__status--error {
    color: #b91c1c;
}

.lgdea-transcript-state__status--working {
    color: #1d4ed8;
}

.lgdea-transcript-reviewbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid #dbe3ef;
    border-radius: 10px;
    background: #fff;
}

.lgdea-transcript-reviewbar__search,
.lgdea-transcript-reviewbar__select {
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: #0f172a;
}

.lgdea-transcript-reviewbar__search {
    flex: 1 1 240px;
}

.lgdea-transcript-reviewbar__hint {
    margin-left: auto;
    font-size: 0.74rem;
    color: #64748b;
}

.lgdea-transcript-manual {
    padding: 14px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.lgdea-transcript-manual__callout {
    margin-bottom: 12px;
    padding: 10px 12px;
    background: #dbeafe;
    border-left: 4px solid #3b82f6;
    border-radius: 8px;
}

.lgdea-transcript-manual__textarea {
    width: 100%;
    min-height: 320px;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    resize: vertical;
    background: var(--card-bg);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.lgdea-transcript-manual__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 12px;
}

.lgdea-transcript-manual__status {
    margin-left: auto;
    font-size: 0.82rem;
    color: #64748b;
}

.lgdea-transcript-manual__status--neutral {
    color: #64748b;
}

.lgdea-transcript-manual__status--success {
    color: #166534;
}

.lgdea-transcript-manual__status--warn {
    color: #c2410c;
}

.lgdea-transcript-manual__status--error {
    color: #b91c1c;
}

.lgdea-transcript-manual__status--working {
    color: #1d4ed8;
}

.lgdea-transcript__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 0.8rem;
    color: #64748b;
}

.lgdea-transcript__body {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px;
}

.lgdea-transcript__line {
    display: flex;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    margin-bottom: 2px;
    font-size: 0.83rem;
    align-items: baseline;
}

.lgdea-transcript__line:hover {
    background: #f8fafc;
}

.lgdea-transcript__line--selected {
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.14);
}

.lgdea-transcript__time {
    font-size: 0.7rem;
    color: #94a3b8;
    min-width: 40px;
    font-variant-numeric: tabular-nums;
}

.lgdea-transcript__speaker {
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    min-width: 60px;
    letter-spacing: 0.3px;
}

.lgdea-transcript__text {
    flex: 1;
    color: #334155;
    line-height: 1.5;
}

.lgdea-transcript__conf {
    font-size: 0.68rem;
    color: #94a3b8;
}

.lgdea-transcript__prosodic {
    margin-top: 12px;
}

.lgdea-transcript__prosodic summary {
    cursor: pointer;
    font-size: 0.85rem;
    color: #475569;
    font-weight: 500;
    padding: 6px 0;
}

.lgdea-transcript__prosodic-grid {
    margin-top: 8px;
}

.lgdea-transcript__pf-row {
    display: flex;
    gap: 12px;
    padding: 4px 8px;
    font-size: 0.78rem;
    color: #64748b;
    border-bottom: 1px solid #f1f5f9;
}

@media (max-width: 900px) {
    .lgdea-transcript-state__headline {
        flex-direction: column;
    }

    .lgdea-transcript-state__meta {
        justify-content: flex-start;
    }

    .lgdea-transcript-state__controls {
        grid-template-columns: 1fr;
    }

    .lgdea-transcript-state__actions {
        justify-content: flex-start;
    }

    .lgdea-transcript-reviewbar__hint {
        width: 100%;
        margin-left: 0;
    }
}

/* ── Active Learning Admin UI ────────────────────────────────────────── */

.lgdea-al__header {
    padding: 16px 20px 8px;
}

.lgdea-al__header h3 {
    margin: 0 0 4px;
    font-size: 1.15rem;
    color: #1e293b;
}

.lgdea-al__subtitle {
    margin: 0;
    font-size: 0.85rem;
    color: #64748b;
}

.lgdea-al__stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    padding: 12px 20px;
}

.lgdea-al__stat {
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.lgdea-al__stat-val {
    display: block;
    font-size: 1.3rem;
    font-weight: 700;
    color: #1e293b;
}

.lgdea-al__stat-label {
    font-size: 0.72rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.lgdea-al__filter {
    display: flex;
    gap: 4px;
    padding: 0 20px 12px;
}

.lgdea-al__filter-btn {
    padding: 6px 14px;
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 6px;
    font-size: 0.8rem;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s;
}

.lgdea-al__filter-btn:hover {
    background: #f1f5f9;
}

.lgdea-al__filter-btn.active {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
}

.lgdea-al__list {
    padding: 0 20px;
}

.lgdea-al__item {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 12px;
    background: #fff;
}

.lgdea-al__item-header {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.lgdea-al__item-conf {
    font-size: 0.8rem;
    font-weight: 600;
}

.lgdea-al__item-conf--low {
    color: #dc2626;
}

.lgdea-al__item-conf--med {
    color: #d97706;
}

.lgdea-al__item-pass {
    font-size: 0.75rem;
    color: #64748b;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 4px;
}

.lgdea-al__item-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #94a3b8;
    margin-bottom: 4px;
}

.lgdea-al__item-context {
    margin-bottom: 10px;
}

.lgdea-al__item-quote {
    margin: 0;
    padding: 8px 12px;
    background: #f8fafc;
    border-left: 3px solid #94a3b8;
    border-radius: 0 6px 6px 0;
    font-size: 0.85rem;
    color: #334155;
    line-height: 1.5;
}

.lgdea-al__item-partial {
    margin-bottom: 12px;
}

.lgdea-al__item-partial-data {
    display: flex;
    gap: 16px;
    font-size: 0.83rem;
    color: #475569;
}

.lgdea-al__form {
    border-top: 1px solid #e2e8f0;
    padding-top: 12px;
    margin-top: 4px;
}

.lgdea-al__form-row {
    margin-bottom: 8px;
}

.lgdea-al__form-row label {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: #475569;
    margin-bottom: 3px;
}

.lgdea-al__input,
.lgdea-al__select,
.lgdea-al__textarea {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #334155;
    background: #fff;
    box-sizing: border-box;
}

.lgdea-al__input:focus,
.lgdea-al__select:focus,
.lgdea-al__textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.lgdea-al__form-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.lgdea-al__paging {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 16px 20px;
    font-size: 0.85rem;
    color: #64748b;
}

.lgdea-al__empty {
    color: #94a3b8;
    text-align: center;
    padding: 40px 20px;
    font-style: italic;
}

.lgdea-al__error {
    color: #ef4444;
    text-align: center;
    padding: 20px;
}

.lgdea-al__loading {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
}
/* =====================================================
   MOBILE UX & RESPONSIVENESS IMPROVEMENTS
   ===================================================== */

/* Ensure tables are scrollable on small screens to prevent overflow */
.report-table-container,
.detailed-table-section,
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.report-table,
.detailed-metrics-table {
    min-width: 600px;
}

@media (max-width: 768px) {
    /* Make navigation scrollable instead of squished */
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
        padding-bottom: 5px; /* space for scrollbar or hidden scrollbar */
    }

    .nav-tabs::-webkit-scrollbar {
        height: 4px;
    }

    .nav-tabs::-webkit-scrollbar-thumb {
        background: var(--border-color);
        border-radius: 2px;
    }

    .nav-tab {
        flex-shrink: 0;
        min-width: auto;
        padding: 12px 15px;
    }

    /* Stack form elements and widgets vertically */
    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }

    .dashboard-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .chart-row {
        flex-direction: column;
    }

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

    /* Improve touch targets (minimum 44px/48px height) */
    .btn,
    .form-group input,
    .form-group select,
    .form-group textarea,
    .search-container input,
    .nav-tab,
    .help-close-btn,
    .modal-close {
        min-height: 48px;
    }

    /* Ensure modals fit the screen nicely */
    .modal-content {
        width: 95% !important;
        max-width: 100% !important;
        max-height: 95vh !important;
        padding: 15px;
        margin: 10px auto;
    }

    /* Scale typography */
    .header h1 {
        font-size: 1.5rem;
    }

    .kpi-value {
        font-size: 1.8rem;
    }

    .stat-number {
        font-size: 1.5rem;
    }

    .chart-box h3 {
        font-size: 1.1rem;
    }

    /* Profile modal specific responsive tweaks */
    .profile-tabs {
        flex-wrap: wrap;
    }

    .profile-tabs button {
        flex: 1;
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    /* Stack stats grid into a single column for very small screens */
    .stats-grid {
        grid-template-columns: 1fr;
    }

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

    .kpi-cards-container {
        flex-direction: column;
    }

    .kpi-card {
        width: 100%;
    }

    /* Stack buttons in modals/forms */
    .action-buttons,
    .modal-footer {
        flex-direction: column;
        gap: 10px;
    }

    .action-buttons .btn,
    .modal-footer .btn {
        width: 100%;
    }

    /* Adjust header info */
    .user-info {
        font-size: 0.8rem;
        padding: 8px 12px;
    }
}

/* =====================================================
   DARK MODE (Legacy Fallback)
   ===================================================== */

body.dark-mode {
    /* 1.1 Base Surfaces */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-elevated: #334155;
    --bg-overlay: rgba(0,0,0,0.7);

    /* 1.2 Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0f172a;
    --text-on-primary: #ffffff;
    --text-link: #60a5fa;

    /* 1.3 Interactive / Inputs */
    --input-bg: #1e293b;
    --input-border: #334155;
    --input-border-focus: #3b82f6;
    --input-placeholder: #64748b;
    --button-primary-bg: #2563eb;
    --button-primary-text: #ffffff;
    --button-secondary-bg: #334155;
    --button-secondary-text: #f1f5f9;

    /* 1.4 Cards & Panels */
    --card-bg: #1e293b;
    --card-border: #334155;
    --card-hover-bg: #334155;
    --card-shadow: 0 4px 12px rgba(0,0,0,0.4);

    /* 1.5 Section Headers */
    --section-header-bg: linear-gradient(135deg, #1e3a8a, #1e40af);
    --section-header-text: #ffffff;
    --section-header-border: #1e40af;

    /* 1.11 Status Semantic Colors (Adjusted for Dark Mode) */
    --primary-color: #3b82f6;
    --secondary-color: #94a3b8;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;

    color-scheme: dark;
}

body.dark-mode .dashboard-container,
body.dark-mode .login-card,
body.dark-mode .chart-box,
body.dark-mode .kpi-card,
body.dark-mode .stat-card,
body.dark-mode .modal-content,
body.dark-mode .patient-card,
body.dark-mode .detail-item,
body.dark-mode .medication-item-group,
body.dark-mode .report-table th,
body.dark-mode .report-table td,
body.dark-mode .side-effects-container,
body.dark-mode .side-effect-item,
body.dark-mode .quick-report-card,
body.dark-mode .query-builder,
body.dark-mode .qb-conditions-container,
body.dark-mode .qb-condition,
body.dark-mode .detailed-table-section,
body.dark-mode .improvement-section,
body.dark-mode .peer-comparison-container,
body.dark-mode .teleconsult-scheduler,
body.dark-mode .lgdea-recorder,
body.dark-mode .lgdea-analysis__header,
body.dark-mode .lgdea-rec-card,
body.dark-mode .lgdea-disc-card,
body.dark-mode .lgdea-ev-card,
body.dark-mode .management-shell,
body.dark-mode .management-search-panel,
body.dark-mode .management-overview-shell,
body.dark-mode .management-nav-shell,
body.dark-mode .management-content-shell,
body.dark-mode .management-quick-tools,
body.dark-mode .management-subtab {
    background-color: var(--card-bg);
    border-color: var(--border-color);
    color: var(--text-primary);
}

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
    background-color: var(--input-bg);
    color: var(--text-primary);
    border-color: var(--input-border);
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
    color: var(--light-text) !important;
}

body.dark-mode .nav-tabs {
    background-color: var(--bg-secondary);
    border-bottom-color: var(--border-color);
}

body.dark-mode .nav-tab {
    color: var(--light-text);
}

body.dark-mode .nav-tab.active {
    background-color: var(--card-bg);
    color: var(--primary-color);
}

body.dark-mode .profile-tabs {
    border-bottom-color: var(--border-color) !important;
}

body.dark-mode #tabProfileBtn,
body.dark-mode #tabSettingsBtn {
    background: transparent !important;
    color: var(--text-secondary) !important;
}

body.dark-mode #tabProfileBtn.active,
body.dark-mode #tabSettingsBtn.active {
    background: #2a2a2a !important;
    color: var(--primary-color) !important;
}

body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4,
body.dark-mode h5,
body.dark-mode h6,
body.dark-mode label,
body.dark-mode .form-label,
body.dark-mode .login-form label,
body.dark-mode .add-patient-form label,
body.dark-mode .form-label[lang],
body.dark-mode label[lang],
body.dark-mode .kpi-label,
body.dark-mode .stat-label,
body.dark-mode .detail-label,
body.dark-mode .metric-name,
body.dark-mode .patient-name,
body.dark-mode .cho-name,
body.dark-mode strong {
    color: var(--text-primary) !important;
}

body.dark-mode .kpi-desc,
body.dark-mode .stat-number,
body.dark-mode .detail-value,
body.dark-mode .metric-info,
body.dark-mode .cho-facility,
body.dark-mode p,
body.dark-mode small {
    color: var(--text-secondary) !important;
}

/* Ensure sections headers remain white text on gradients */
body.dark-mode .form-section-header,
body.dark-mode .chart-box .form-section-header,
body.dark-mode .form-section-header .section-title,
body.dark-mode .form-section-header span,
body.dark-mode .system-header h1,
body.dark-mode .system-header p {
    color: white !important;
}

body.dark-mode .btn-secondary {
    background-color: var(--border-color);
    color: var(--text-primary);
    border-color: var(--border-color);
}

body.dark-mode .btn-secondary:not(:disabled):hover {
    background-color: #555555;
    color: white;
}

body.dark-mode .report-table tbody tr:nth-child(even),
body.dark-mode .prediction-table tbody tr:nth-child(even),
body.dark-mode .detailed-metrics-table tbody tr:nth-child(even) {
    background-color: #1a1a1a;
}

body.dark-mode .report-table tbody tr:hover,
body.dark-mode .prediction-table tbody tr:hover,
body.dark-mode .detailed-metrics-table tbody tr:hover {
    background-color: #2a2a2a;
}

/* Warnings and Alerts */
body.dark-mode [style*="background: #fff3cd"],
body.dark-mode .warning-box,
body.dark-mode .alert-warning {
    background-color: #453008 !important;
    border-left-color: #f59e0b !important;
    color: #fde68a !important;
}

body.dark-mode [style*="background: #fff3cd"] *,
body.dark-mode .warning-box *,
body.dark-mode .alert-warning * {
    color: #fde68a !important;
}

body.dark-mode [style*="background: #e8f4fd"],
body.dark-mode .info-box,
body.dark-mode .alert-info {
    background-color: #1a2a3a !important;
    border-left-color: #3b82f6 !important;
    color: #bfdbfe !important;
}

body.dark-mode [style*="background: #e8f4fd"] *,
body.dark-mode .info-box *,
body.dark-mode .alert-info * {
    color: #bfdbfe !important;
}

/* Custom form fields backgrounds */
body.dark-mode .custom-section-container .form-group {
    background-color: #1a1a1a;
}

body.dark-mode .seizure-helper-card {
    background-color: #1c2b36;
    border-color: #2b455c;
}

body.dark-mode .seizure-helper-card strong {
    color: #60a5fa;
}

body.dark-mode .seizure-helper-card p {
    color: #93c5fd;
}

/* ==========================================================================
   District Command Center (Hyper-Modern SuperAdmin Dashboard)
   ========================================================================== */
:root {
    --da-primary: #6366f1;
    --da-primary-dark: #4f46e5;
    --da-secondary: #0ea5e9;
    --da-bg: #f8fafc;
    --da-card-bg: #ffffff;
    --da-text-main: #1e293b;
    --da-text-muted: #64748b;
    --da-border: #e2e8f0;
    --da-radius: 16px;
    --da-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --da-shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.da-command-center {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 100px);
    background: var(--da-bg);
    border-radius: var(--da-radius);
    overflow: hidden;
    color: var(--da-text-main);
    font-family: 'Inter', system-ui, sans-serif;
}

/* Top Bar */
.da-top-bar {
    padding: 1.5rem 2rem;
    background: white;
    border-bottom: 1px solid var(--da-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.da-title-wrap {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.da-main-icon {
    font-size: 2rem;
    color: var(--da-primary);
    background: #eef2ff;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
}

.da-main-title {
    font-size: 1.25rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.01em;
}

.da-main-subtitle {
    font-size: 0.85rem;
    color: var(--da-text-muted);
    margin: 0;
}

.da-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.da-date-range {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 10px;
    gap: 4px;
}

.da-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
}

.da-input-group label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--da-text-muted);
}

.da-input-group input {
    background: transparent;
    border: none;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--da-text-main);
    outline: none;
}

.da-btn {
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.da-btn-primary {
    background: var(--da-primary);
    color: white;
}

.da-btn-primary:hover {
    background: var(--da-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.da-btn-outline {
    background: white;
    border: 1px solid var(--da-border);
    color: var(--da-text-main);
}

.da-btn-outline:hover {
    background: var(--da-bg);
}

/* Layout */
.da-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.da-sidebar {
    width: 260px;
    background: white;
    border-right: 1px solid var(--da-border);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.da-nav-item {
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--da-text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.da-nav-item i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.da-nav-item:hover {
    background: #f1f5f9;
    color: var(--da-text-main);
}

.da-nav-item.active {
    background: #eef2ff;
    color: var(--da-primary);
}

.da-sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--da-border);
}

.da-status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--da-text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.green {
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

/* Content Area */
.da-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
}

.da-view-pane {
    display: none;
    animation: fadeInDA 0.3s ease-out;
}

.da-view-pane.active {
    display: block;
}

@keyframes fadeInDA {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* KPI Grid */
.da-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.da-kpi-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--da-radius);
    box-shadow: var(--da-shadow);
    border: 1px solid var(--da-border);
}

.da-kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.da-kpi-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--da-text-muted);
}

.da-kpi-header i {
    color: var(--da-primary);
    opacity: 0.5;
}

.da-kpi-value {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 1rem;
    color: var(--da-text-main);
}

.da-kpi-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.da-kpi-trend {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--da-text-muted);
}

.da-kpi-trend.pos { color: #10b981; }
.da-kpi-trend.neg { color: #ef4444; }

.da-mini-sparkline {
    width: 80px;
    height: 24px;
}

/* Charts */
.da-charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.da-charts-row.full {
    grid-template-columns: 1fr;
}

.da-chart-container {
    background: white;
    padding: 1.5rem;
    border-radius: var(--da-radius);
    box-shadow: var(--da-shadow);
    border: 1px solid var(--da-border);
    display: flex;
    flex-direction: column;
}

.da-chart-header {
    margin-bottom: 1.5rem;
}

.da-chart-header h4 {
    margin: 0 0 4px 0;
    font-size: 1rem;
    font-weight: 700;
}

.da-chart-header p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--da-text-muted);
}

.da-chart-body {
    flex: 1;
    min-height: 280px;
}

.da-chart-body.large {
    min-height: 400px;
}

/* Matrix Table */
.da-matrix-wrapper {
    background: white;
    border-radius: var(--da-radius);
    border: 1px solid var(--da-border);
    overflow: hidden;
}

.da-matrix-table {
    width: 100%;
    border-collapse: collapse;
}

.da-matrix-table th {
    background: #f8fafc;
    padding: 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--da-text-muted);
    border-bottom: 1px solid var(--da-border);
}

.da-matrix-table td {
    padding: 1rem;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--da-border);
}

.da-matrix-cell {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* Heatmap intensity colors */
.da-heat-lv1 { background: #fef2f2; color: #991b1b; } /* Critical */
.da-heat-lv2 { background: #fffbeb; color: #92400e; } /* Warning */
.da-heat-lv3 { background: #f0fdf4; color: #166534; } /* Good */
.da-heat-lv4 { background: #ecfdf5; color: #065f46; border: 1px solid #10b981; } /* Exceptional */

/* Benchmarking */
.da-bench-layout {
    display: flex;
    gap: 2rem;
}

.da-bench-sidebar {
    width: 300px;
    flex-shrink: 0;
}

.da-bench-main {
    flex: 1;
}

.da-district-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: white;
    padding: 1rem;
    border-radius: var(--da-radius);
    border: 1px solid var(--da-border);
    max-height: 400px;
    overflow-y: auto;
}

.da-check-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.da-check-item:hover { background: #f1f5f9; }

/* Drill-Down Overlay */
.da-drilldown-overlay {
    position: absolute;
    inset: 0;
    background: var(--da-bg);
    z-index: 100;
    display: flex;
    flex-direction: column;
    animation: slideInDA 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideInDA {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.da-drilldown-header {
    padding: 1.5rem 2rem;
    background: white;
    border-bottom: 1px solid var(--da-border);
    display: flex;
    align-items: center;
    gap: 2rem;
}

.da-back-btn {
    background: #f1f5f9;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--da-text-muted);
}

.da-drilldown-title h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 800;
}

.da-badge {
    padding: 2px 8px;
    background: #eef2ff;
    color: var(--da-primary);
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.da-drilldown-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* Responsive */
@media (max-width: 1024px) {
    .da-sidebar { width: 80px; }
    .da-nav-item span, .da-sidebar-footer span { display: none; }
    .da-nav-item i { margin: 0 auto; font-size: 1.5rem; }
    .da-charts-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .da-command-center { height: auto; min-height: 100vh; border-radius: 0; }
    .da-top-bar { padding: 1rem; }
    .da-layout { flex-direction: column; }
    .da-sidebar { width: 100%; height: auto; flex-direction: row; overflow-x: auto; padding: 0.5rem; }
    .da-nav-item { width: auto; white-space: nowrap; }
    .da-content { padding: 1rem; }
    .da-kpi-grid { grid-template-columns: 1fr 1fr; }
    .da-drilldown-header { flex-direction: column; align-items: flex-start; gap: 1rem; }
}

/* Dark Mode Overrides */
body.dark-mode .da-command-center { background: #0f172a; border-color: #1e292b; }
body.dark-mode .da-top-bar, 
body.dark-mode .da-sidebar, 
body.dark-mode .da-chart-container, 
body.dark-mode .da-kpi-card,
body.dark-mode .da-matrix-wrapper,
body.dark-mode .da-drilldown-header {
    background: #1e293b;
    border-color: #334155;
}
body.dark-mode .da-main-title, 
body.dark-mode .da-kpi-value,
body.dark-mode .da-drilldown-title h3 { color: #f1f5f9; }
body.dark-mode .da-input-group { background: #334155; }
body.dark-mode .da-input-group input { color: #f1f5f9; }
body.dark-mode .da-matrix-table th { background: #334155; }
body.dark-mode .da-matrix-table td { color: #cbd5e1; border-color: #334155; }
body.dark-mode .da-drilldown-overlay { background: #0f172a; }

/* Theme utility classes */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

.alert-warning, .epilepsy-warning-section {
    background: var(--warning-bg);
    border-color: var(--warning-border);
    color: var(--warning-text);
}

.alert-info {
    background: var(--info-bg);
    border-color: var(--info-border);
    color: var(--info-text);
}

.alert-success {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: var(--success-text);
}

.alert-danger {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger-text);
}

/* Scrollbars */
* {
    scrollbar-color: var(--input-border) var(--bg-primary);
}
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--input-border);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* =====================================================
   COMPONENT FIXES (Using Variables)
   ===================================================== */

/* 4.1 Patient Cards */
.patient-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
}
.patient-name, .patient-id {
    color: var(--text-primary);
}
.patient-meta, .patient-facility {
    color: var(--text-secondary);
}
.patient-card:hover {
    background: var(--card-hover-bg);
    border-color: var(--primary-color);
}

/* 4.2 Medications */
.medication-item-group {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
}
.medication-name {
    color: var(--text-primary);
    font-weight: 600;
}
.medication-dose {
    color: var(--text-secondary);
}
.medication-frequency {
    color: var(--text-muted);
}
.medication-item-group:hover {
    background: var(--card-hover-bg);
    border-color: var(--primary-color);
}

/* 4.3 Forms */
.form-group {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}
.form-label, label, .add-patient-form label {
    color: var(--text-primary);
}
.form-hint {
    color: var(--text-secondary);
}
input, select, textarea {
    background: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--input-border);
}
input:focus, select:focus, textarea:focus {
    border-color: var(--input-border-focus);
    box-shadow: 0 0 0 3px rgba(96,165,250,0.15);
}
input::placeholder, textarea::placeholder {
    color: var(--input-placeholder);
}
input:disabled, select:disabled, textarea:disabled {
    background: var(--bg-primary);
    color: var(--input-border);
    border-color: var(--card-border);
}
.form-section-header {
    background: var(--section-header-bg);
    color: var(--section-header-text);
    border-bottom: 1px solid var(--section-header-border);
}
.form-section-header * {
    color: var(--section-header-text);
}

.system-header {
    background: transparent;
    border-bottom: none;
    padding: 2.5rem 1rem;
    text-align: center;
}

.login-card {
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
}

.login-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 25px 60px rgba(37, 99, 235, 0.1), 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* 4.6 KPI Cards */
.kpi-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
}
.kpi-label {
    color: var(--text-secondary);
}
.kpi-value {
    color: var(--primary-color);
}
.kpi-desc {
    color: var(--text-muted);
}
.kpi-card:hover {
    box-shadow: var(--card-shadow);
    border-color: var(--primary-color);
}

/* 4.7 Tables */
.report-table th, table th {
    background: var(--table-header-bg);
    color: var(--text-primary);
    border-bottom: 2px solid var(--table-border);
}
.report-table tr:nth-child(odd), table tr:nth-child(odd) {
    background: var(--table-row-odd);
}
.report-table tr:nth-child(even), table tr:nth-child(even) {
    background: var(--table-row-even);
}
.report-table tr:hover, table tr:hover {
    background: var(--table-row-hover);
}
.report-table td, table td {
    border: 1px solid var(--table-border);
    color: var(--text-primary);
}

/* 4.10 Modals */
.modal-overlay {
    background: var(--bg-overlay);
}
.modal-content {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
}
.modal-header {
    background: var(--table-header-bg);
    border-bottom: 1px solid var(--table-border);
    color: var(--text-primary);
}
.modal-body {
    background: var(--card-bg);
    color: var(--text-primary);
}
.modal-footer {
    background: var(--table-header-bg);
    border-top: 1px solid var(--table-border);
}

/* 4.12 Navigation / Header — Restore blue gradient anchor */
.header {
    background: var(--header-gradient);
    border-bottom: none;
    color: #ffffff;
}
.header h1, .header p {
    color: #ffffff !important;
}

/* 4.13 Buttons */
.btn-primary {
    background: var(--button-primary-bg);
    color: var(--button-primary-text);
}
.btn-secondary {
    background: var(--button-secondary-bg);
    color: var(--button-secondary-text);
    border: 1px solid var(--input-border);
}

/* Semantic utility classes */
.bg-card { background: var(--card-bg); }
.text-primary { color: var(--text-primary); }
.border-default { border: 1px solid var(--border-color); }

.alert-warning {
    background: var(--warning-bg);
    border-left: 4px solid var(--warning-border);
    color: var(--warning-text);
}
.alert-info {
    background: var(--info-bg);
    border-left: 4px solid var(--info-border);
    color: var(--info-text);
}
.alert-success {
    background: var(--success-bg);
    border-left: 4px solid var(--success-border);
    color: var(--success-text);
}
.alert-danger {
    background: var(--danger-bg);
    border-left: 4px solid var(--danger-border);
    color: var(--danger-text);
}

/* Theme Toggle Button */
.theme-toggle-btn {
  background: var(--bg-glass);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--border-radius-sm);
  padding: 8px 12px;
  cursor: pointer;
  font-size: 16px;
  transition: var(--transition);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}
.theme-toggle-btn .theme-icon-dark { display: none; }
body[data-theme="dark"] .theme-toggle-btn .theme-icon-light { display: none; }
body[data-theme="dark"] .theme-toggle-btn .theme-icon-dark { display: inline; }

/* =========================================
   MODERN UI ENHANCEMENTS
   ========================================= */

/* Custom Scrollbar - Light Mode */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--chart-teal), var(--chart-blue));
    border-radius: 5px;
    border: 2px solid var(--bg-primary);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--chart-blue), var(--chart-teal));
}

/* Firefox Scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--chart-teal) var(--bg-primary);
}

/* Selection styling */
::selection {
    background: var(--primary-light);
    color: var(--primary-dark);
}

/* Focus visible for accessibility */
:focus-visible {
    outline: 3px solid var(--chart-blue);
    outline-offset: 2px;
}

/* Enhanced input styling */
input, select, textarea {
    font-family: inherit;
    transition: var(--transition);
}

input:hover:not(:disabled):not(:focus),
select:hover:not(:disabled):not(:focus),
textarea:hover:not(:disabled):not(:focus) {
    border-color: var(--primary-color);
}

/* Smooth focus transitions */
input:focus, select:focus, textarea:focus {
    border-color: var(--chart-blue);
    box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.15);
    outline: none;
}

/* Search input enhancements */
.search-container input {
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    transition: var(--transition);
}

.search-container input:focus {
    border-color: var(--chart-blue);
    box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.12);
}

/* Badge enhancements */
.badge {
    font-weight: 700;
    letter-spacing: 0.02em;
    transition: var(--transition);
}

.badge-primary {
    background: linear-gradient(135deg, var(--chart-teal), var(--chart-blue));
    color: white;
}

.badge-success {
    background: var(--success-color);
    color: white;
}

.badge-warning {
    background: var(--warning-color);
    color: #1f2937;
}

.badge-danger {
    background: var(--danger-color);
    color: white;
}

/* Smooth page transitions */
.tab-pane {
    animation: fadeInUp 0.4s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Card hover effects - subtle glow */
.chart-box:hover,
.kpi-card:hover,
.patient-card:hover {
    box-shadow: var(--card-shadow-hover), 0 0 0 1px rgba(2, 132, 199, 0.1);
}

/* Logout container styling */
.logout-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logout-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

/* User info styling */
.user-info {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.user-info:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Improved alert cards */
.ca-queue-card {
    transition: var(--transition);
    border-radius: var(--border-radius);
}

.ca-queue-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--card-shadow-hover);
}

/* Risk bar container improvements */
.risk-bar-container {
    border-radius: var(--border-radius-sm);
    overflow: hidden;
}

.risk-high, .risk-medium, .risk-low {
    transition: width 0.5s ease;
}

/* Top CHOs leaderboard styling */
.top-chos-leaderboard {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Recent activities styling */
#recentActivities {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Dark mode specific enhancements */
body[data-theme="dark"] .login-card,
body.dark-mode .login-card {
    background: var(--bg-glass);
    border-color: var(--card-border);
    box-shadow: var(--card-shadow-elevated);
}

body[data-theme="dark"] .chart-box::after,
body.dark-mode .chart-box::after {
    opacity: 0.6;
}

body[data-theme="dark"] .kpi-value,
body.dark-mode .kpi-value {
    background: linear-gradient(135deg, var(--chart-teal), var(--chart-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Responsive improvements */
@media (max-width: 768px) {
    .kpi-cards-container {
        flex-direction: column;
    }
    
    .kpi-card {
        width: 100%;
    }
    
    .nav-tabs {
        padding: 0.5rem;
    }
    
    .nav-tab {
        padding: 0.625rem 1rem;
        font-size: 0.8rem;
    }
    
    .header {
        padding: 1.5rem 1rem;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .logout-container {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }
}



/* Medication Items (Fix for Bright White Pills) */
.medication-item-group {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}
.medication-name {
  color: var(--text-primary);
  font-weight: 600;
}
.medication-dose {
  color: var(--text-secondary);
}
.medication-item-group:hover {
  border-color: var(--primary-color);
  background: var(--bg-elevated);
}


/* Scrollbar — Light Mode */
html {
    scrollbar-color: #cbd5e1 #f1f5f9;
}
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Semantic Text Colors for Alerts/Cards */
.text-warning-bold { color: var(--warning-text); font-weight: bold; }
.text-warning-muted { color: var(--warning-text); opacity: 0.8; }
.text-info-bold { color: var(--info-text); font-weight: bold; }
.text-info { color: var(--info-text); }
.text-success-bold { color: var(--success-text); font-weight: bold; }
.text-danger-bold { color: var(--danger-text); font-weight: bold; }

/* ── Modern UI Utility Classes ────────────────────────────────────────── */

.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: calc(65px + var(--safe-area-bottom));
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: none; /* Desktop hidden */
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid var(--card-border);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    padding-bottom: var(--safe-area-bottom);
}

@media (max-width: 768px) {
    .mobile-bottom-nav { display: flex; }
    .nav-tabs { display: none !important; } /* Hide old sidebar/tabs on mobile */
    .dashboard-container { padding-bottom: 80px !important; } /* Space for nav */
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.65rem;
    gap: 4px;
    padding: 8px 12px;
    transition: all 0.2s ease;
    min-width: 60px;
}

.mobile-nav-item i {
    font-size: 1.25rem;
}

.mobile-nav-item.active {
    color: var(--text-link);
}

.mobile-nav-item.active i {
    transform: translateY(-2px);
}

/* Modernized Cards */
.modern-card {
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 1px solid var(--card-border);
    padding: var(--mobile-padding);
    box-shadow: var(--card-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
}

.modern-card:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-2px);
}

/* Glassmorphism Badge */
.glass-badge {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Modern Input */
.modern-input {
    border: 1px solid var(--input-border);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 1rem;
    width: 100%;
    transition: all 0.2s ease;
}

.modern-input:focus {
    border-color: var(--input-border-focus);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
    outline: none;
}

/* Additional state classes */
.bg-danger-light { background: var(--danger-bg); }
.bg-inactive { background: var(--button-secondary-bg); }
.phc-badge { background: var(--info-bg); color: var(--text-primary); }

/* ── Visual CDS Rules Editor Styles ────────────────────────────────── */
.cds-graph-toolbar .btn-teal {
    background: #14b8a6;
    color: white;
    border: none;
}
.cds-graph-toolbar .btn-teal:hover {
    background: #0d9488;
}

/* ── Palette ─────────────────────────────────────────────────────────── */
.palette-item {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    cursor: grab;
    user-select: none;
}
.palette-item:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}
.palette-item:active,
.palette-item.dragging {
    cursor: grabbing;
    transform: scale(0.96);
    opacity: 0.75;
}

/* ── Canvas ──────────────────────────────────────────────────────────── */
#cdsGraphCanvas {
    background-image: radial-gradient(#e2e8f0 1px, transparent 1px);
    background-size: 20px 20px;
}

/* ── Trace log entries ───────────────────────────────────────────────── */
.cds-trace-entry {
    border-left: 2px solid #334155;
    padding-left: 10px;
    margin-bottom: 8px;
    transition: background 0.3s;
}
.cds-trace-entry.active {
    border-left-color: #14b8a6;
    background: rgba(20, 184, 166, 0.05);
}

/* ── Simulation branch highlights (applied to Cytoscape node DOM overlay) */
/* Cytoscape doesn't expose direct DOM for node body; we use the node label
   via a qtip/popper trick. For branch indication we rely on the badge in
   the trace log below the canvas, and on edge colour which is handled inline. */

/* ── Simulator panel ─────────────────────────────────────────────────── */
#cdsSimulatorPanel {
    overflow-y: auto;
    max-height: calc(100vh - 220px);
}
.sim-section-header {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    padding: 4px 0 2px;
    border-bottom: 1px solid #334155;
    margin-bottom: 6px;
}

/* ── Node editor side panel (now position:absolute overlay) ─────────── */
#cdsGraphEditorPanel {
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1),
                opacity  0.18s ease;
    /* positioned absolute in HTML — no longer shrinks the canvas */
}
#cdsGraphEditorPanel[style*="display: none"],
#cdsGraphEditorPanel[style*="display:none"] {
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
}
#cdsGraphEditorPanel[style*="display: flex"],
#cdsGraphEditorPanel[style*="display:flex"] {
    transform: translateX(0);
    opacity: 1;
}

/* ── Toolbar label hiding on narrow containers ───────────────────────── */
/* When the CDS editor container is narrow, hide the text labels to keep
   the toolbar on one row. Triggered by JS adding .cds-compact to the toolbar. */
.cds-graph-toolbar.cds-compact .cds-btn-label {
    display: none;
}

/* Lock hint banner inside editor panel */
#cdsNodeLockHint {
    background: #1e3a5f;
    color: #93c5fd;
    font-size: 0.75rem;
    padding: 5px 10px;
    border-radius: 4px;
    margin-bottom: 8px;
    border-left: 3px solid #3b82f6;
}

/* Alert preview container */
#cdsAlertPreviewContent {
    min-height: 28px;
}

/* ── Cytoscape active-edit node glow (applied via cy.addClass) ─────── */
/* Cytoscape renders nodes on canvas; we override border colour via the
   style sheet registered in setupCanvas(). Ensure .active-edit is handled
   in the Cytoscape style array inside cds-graph-editor.js. */

/* ── Edge trace animation ────────────────────────────────────────────── */
@keyframes edge-trace-in {
    from { opacity: 0.3; }
    to   { opacity: 1;   }
}
/* .executed class on Cytoscape edges triggers colour change in setupCanvas styles */

/* ── Pulse animation for executed nodes in trace ─────────────────────── */
@keyframes pulse-glow {
    0%   { box-shadow: 0 0 0  0   rgba(20, 184, 166, 0.5); }
    70%  { box-shadow: 0 0 0 12px rgba(20, 184, 166, 0);   }
    100% { box-shadow: 0 0 0  0   rgba(20, 184, 166, 0);   }
}
.node-pulse {
    animation: pulse-glow 1.5s ease-out;
}

/* Branch indicator badges in trace panel */
.branch-badge-true  { color: #22c55e; font-weight: 700; }
.branch-badge-false { color: #ef4444; font-weight: 700; }

#cdsNodeJsEditor .CodeMirror {
    font-size: 13px;
    line-height: 1.5;
    height: 100%;
    min-height: 200px;
    border-radius: 4px;
    border: 1px solid #334155;
    background: #0f172a;
    color: #e2e8f0;
}

/* ── Tab fade-in ─────────────────────────────────────────────────────── */
.mg-subtab {
    animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Keep add-patient responsive layout stable across online/offline shells */
@media (min-width: 520px) and (max-width: 1199px) {
    #patientForm.form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 1rem;
    }

    #patientForm .form-section-content {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (min-width: 520px) and (max-width: 900px) {
    #patientForm .form-group:not([style*="grid-column"]) {
        grid-column: auto !important;
        width: auto !important;
    }
}
