/* Predigm SaMD Dashboard V6 - Advanced Features */

:root {
    --primary: #0066CC;
    --primary-light: #E6F0FA;
    --success: #10B981;
    --success-light: #D1FAE5;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --danger: #DC2626;
    --danger-light: #FEE2E2;
    --purple: #7C3AED;
    --purple-light: #EDE9FE;
    --bg: #F8FAFC;
    --panel: #FFFFFF;
    --text: #1E293B;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    --border: #E2E8F0;
    --font: 'Inter', -apple-system, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 13px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-text {
    font-size: 18px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), #00AAFF);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-ver {
    font-size: 9px;
    padding: 2px 5px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 4px;
    margin-left: 4px;
    -webkit-text-fill-color: var(--primary);
}

.patient-badge {
    display: flex;
    align-items: center;
    gap: 8px;
}

.patient-avatar {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--primary), #00AAFF);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 11px;
}

.patient-name {
    font-weight: 600;
    font-size: 13px;
}

.predigm-id-badge {
    font-size: 10px;
    padding: 2px 8px;
    background: linear-gradient(135deg, #10B981, #34D399);
    color: white;
    border-radius: 10px;
    font-weight: 600;
    font-family: monospace;
}

.practice-mode-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 12px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ccc;
    transition: 0.3s;
    border-radius: 20px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked+.toggle-slider {
    background: #F59E0B;
}

.toggle-switch input:checked+.toggle-slider:before {
    transform: translateX(20px);
}

.toggle-label {
    font-size: 11px;
    color: var(--text-secondary);
}

.practice-mode-banner {
    display: none;
    background: linear-gradient(90deg, #FEF3C7, #FDE68A);
    color: #92400E;
    text-align: center;
    padding: 8px;
    font-size: 12px;
    font-weight: 600;
}

.practice-mode-banner.active {
    display: block;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-smart,
.btn-lang {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border: none;
    border-radius: 14px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
}

.btn-smart {
    background: linear-gradient(135deg, var(--purple), #A855F7);
    color: white;
}

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

.analysis-mode {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: var(--primary-light);
    border-radius: 12px;
    font-size: 11px;
    color: var(--primary);
}

.analysis-mode.advanced {
    background: var(--success-light);
}

/* User Profile Dropdown */
.btn-cases {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    background: linear-gradient(135deg, #10B981, #34D399);
    color: white;
    border-radius: 14px;
    font-size: 11px;
    font-weight: 500;
    text-decoration: none;
    transition: transform 0.2s;
}

.btn-cases:hover {
    transform: scale(1.05);
}

.user-profile {
    position: relative;
    cursor: pointer;
}

.user-name {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text);
}

.user-name::after {
    content: "";
    font-size: 8px;
    opacity: 0.6;
}

.user-arrow {
    font-size: 10px;
    opacity: 0.6;
    margin-left: 4px;
    transition: transform 0.2s;
}

.user-profile.open .user-arrow {
    transform: rotate(180deg);
}

.user-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: #FFFFFF;
    /* Force white opaque background */
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    min-width: 200px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    /* Stronger shadow */
    z-index: 9999;
    /* Ensure it's on top */
}

.user-profile.open .user-dropdown {
    display: block;
}

.user-dropdown .user-info {
    margin-bottom: 8px;
}

.user-dropdown .user-info strong {
    display: block;
    font-size: 13px;
    color: var(--text);
}

.user-dropdown .user-info small {
    color: var(--text-secondary);
    font-size: 11px;
}

.user-dropdown hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 8px 0;
}

.user-dropdown a,
.user-dropdown button {
    display: block;
    width: 100%;
    padding: 8px 10px;
    text-align: left;
    background: none;
    border: none;
    color: var(--text);
    font-size: 12px;
    cursor: pointer;
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.2s;
}

.user-dropdown a:hover,
.user-dropdown button:hover {
    background: var(--bg);
}

.mode-dot {
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
}

/* Navigation */
.main-nav {
    display: flex;
    gap: 4px;
    padding: 8px 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}

.nav-btn {
    padding: 8px 16px;
    background: none;
    border: none;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
}

.nav-btn:hover {
    background: var(--bg);
}

.nav-btn.active {
    background: var(--primary);
    color: white;
}

/* Views & Dashboard Grid */
.view {
    display: none;
    flex: 1;
    overflow: auto;
}

.view.active {
    display: block;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 260px 1fr 280px;
    gap: 10px;
    padding: 10px;
    height: calc(100vh - 130px);
}

/* Panels */
.panel {
    background: var(--panel);
    border-radius: 10px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.panel-header h2 {
    font-size: 13px;
    font-weight: 600;
}

.btn-history {
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    opacity: 0.6;
}

/* Tabs & Form (inherited from V5) */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.tab {
    flex: 1;
    padding: 6px;
    background: none;
    border: none;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
}

.tab.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    margin-bottom: -1px;
}

.tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.compact-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-row label {
    width: 55px;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.form-row input,
.form-row select {
    flex: 1;
    padding: 5px 6px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 11px;
}

.unit {
    font-size: 9px;
    color: var(--text-muted);
    width: 20px;
}

.bmi-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: var(--primary-light);
    border-radius: 5px;
    font-size: 11px;
}

.bmi-val {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    margin-left: auto;
}

.level-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.level-chips label {
    padding: 2px 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    font-size: 9px;
    cursor: pointer;
}

.level-chips label:has(input:checked) {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.level-chips input {
    display: none;
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
}

.toggle {
    position: relative;
    width: 32px;
    height: 18px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--border);
    border-radius: 9px;
    transition: 0.2s;
}

.toggle .slider:before {
    content: "";
    position: absolute;
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: 0.2s;
}

.toggle input:checked+.slider {
    background: var(--primary);
}

.toggle input:checked+.slider:before {
    transform: translateX(14px);
}

.mri-badge, .imaging-badge {
    padding: 5px 8px;
    background: linear-gradient(135deg, var(--purple), #A855F7);
    color: white;
    border-radius: 5px;
    font-size: 10px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 8px;
}

.section-divider {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 0 2px;
    margin-top: 4px;
    border-top: 1px solid var(--border-light, #e5e7eb);
}

.key-field {
    padding: 8px;
    background: var(--warning-light);
    border: 1px solid var(--warning);
    border-radius: 5px;
    margin-top: 6px;
}

.key-field label {
    display: block;
    font-weight: 600;
    color: #92400E;
    margin-bottom: 4px;
    font-size: 11px;
}

.key-field select {
    width: 100%;
    padding: 5px;
    border: 1px solid var(--warning);
    border-radius: 4px;
    font-size: 11px;
}

.btn-calculate {
    margin: 8px;
    padding: 10px;
    background: linear-gradient(135deg, var(--primary), #0088FF);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    position: relative;
}

.btn-calculate.loading .btn-text {
    opacity: 0;
}

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

.btn-spinner {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Center Panel: Donuts & Sunburst */
.panel-center {
    padding: 12px;
    overflow-y: auto;
}

.risk-toggle {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
}

.risk-toggle-btn {
    flex: 1;
    padding: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.risk-toggle-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.dual-donut-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.donut-card {
    text-align: center;
    padding: 16px;
    background: var(--bg);
    border-radius: 12px;
    min-width: 180px;
    min-height: 260px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.donut-card.projected {
    background: linear-gradient(135deg, var(--success-light), #A7F3D0);
}

.donut-card h4 {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.donut-wrapper {
    position: relative;
    width: 140px;
    height: 140px;
    margin: 0 auto;
}

.donut-chart {
    width: 100%;
    height: 100%;
}

.donut-center-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    font-weight: 700;
    color: var(--danger);
}

.donut-center-text.projected {
    color: var(--success);
}

.risk-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 10px;
    background: var(--danger-light);
    color: var(--danger);
}

.risk-badge.success,
.risk-badge.low {
    background: var(--success-light);
    color: var(--success);
}

.risk-badge.moderate {
    background: var(--warning-light);
    color: #B45309;
}

.ci-display {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 6px;
}

.donut-arrow {
    font-size: 28px;
    color: var(--success);
    font-weight: bold;
}

.reduction-badge {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 12px;
    background: var(--success);
    color: white;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
}

.sunburst-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.sunburst-section h4 {
    font-size: 13px;
    margin-bottom: 10px;
}

.sunburst-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    justify-content: center;
}

#sunburstChart {
    min-height: 300px;
    min-width: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.sunburst-legend {
    width: 220px;
    flex-shrink: 0;
}

/* Factor Bar Chart */
.factor-bar-chart {
    padding: 10px;
    background: var(--bg);
    border-radius: 8px;
}

.factor-bar-chart h5 {
    font-size: 11px;
    margin-bottom: 10px;
    color: var(--text-secondary);
}

.factor-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.factor-name {
    width: 70px;
    font-size: 10px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.factor-bar-container {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.factor-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.factor-value {
    width: 40px;
    font-size: 10px;
    font-weight: 600;
    text-align: right;
    color: var(--text-secondary);
}

/* Explainability Sections (SaMD Compliance) */
.explainability-section {
    margin-top: 12px;
}

.cohort-card,
.time-curve-card {
    padding: 12px;
    background: var(--panel);
    border-radius: 10px;
    border: 1px solid var(--border);
}

.cohort-card h5,
.time-curve-card h5 {
    font-size: 12px;
    margin-bottom: 10px;
    color: var(--text);
}

.cohort-percentile {
    margin-bottom: 10px;
}

.percentile-bar {
    position: relative;
    height: 12px;
    background: linear-gradient(90deg, #10B981 0%, #F59E0B 50%, #DC2626 100%);
    border-radius: 6px;
}

.percentile-fill {
    display: none;
}

.percentile-marker {
    position: absolute;
    top: -4px;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    background: white;
    border: 3px solid var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.marker-value {
    font-size: 8px;
    font-weight: 700;
    color: var(--primary);
    position: absolute;
    top: -16px;
    white-space: nowrap;
}

.percentile-labels {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    color: var(--text-muted);
    margin-top: 4px;
}

.cohort-text {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 8px;
}

.cohort-evidence {
    display: flex;
    justify-content: flex-end;
}

.evidence-tag {
    font-size: 9px;
    padding: 2px 8px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 10px;
}

/* Time Risk Curve */
.time-curve-svg {
    display: block;
    margin: 0 auto;
}

.curve-legend {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 8px;
    font-size: 10px;
}

.legend-current {
    color: var(--danger);
}

.legend-projected {
    color: var(--success);
}

.curve-note {
    font-size: 9px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 11px;
    border-bottom: 1px solid var(--border);
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 4px;
}

/* Auto-Recommendation Panel (vNext v2) */
.auto-rec-panel {
    padding: 10px;
}

.auto-rec-panel .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 24px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

.rec-empty-icon {
    font-size: 28px;
    opacity: 0.7;
}

/* Summary Section */
.auto-rec-summary {
    margin-bottom: 14px;
}

.auto-rec-summary-text {
    font-size: 12px;
    color: var(--text);
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08), rgba(118, 75, 162, 0.08));
    border-radius: 10px;
    border-left: 3px solid var(--primary);
    margin-bottom: 10px;
    line-height: 1.5;
}

.rec-progress-wrap {
    padding: 0 2px;
}

.rec-progress-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.rec-progress-value {
    font-weight: 700;
    font-size: 14px;
    color: var(--success);
}

.rec-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.rec-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #16a34a);
    border-radius: 3px;
    transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Tier Section */
.auto-rec-tier {
    margin-bottom: 12px;
}

.tier-label {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 8px;
    padding: 4px 0;
}

.tier-must-do {
    color: var(--danger);
}

.tier-high-yield {
    color: #D97706;
}

.tier-optional {
    color: var(--text-muted);
}

/* Recommendation Cards */
.rec-item {
    padding: 12px 14px;
    background: var(--bg);
    border-radius: 10px;
    border: 1px solid var(--border);
    margin-bottom: 8px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.rec-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    opacity: 0;
    transition: opacity 0.3s;
}

.rec-must-do::before {
    background: linear-gradient(90deg, var(--danger), #f87171);
}

.rec-high-yield::before {
    background: linear-gradient(90deg, #D97706, #fbbf24);
}

.rec-optional::before {
    background: linear-gradient(90deg, var(--text-muted), #94a3b8);
}

.rec-item:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.rec-item:hover::before {
    opacity: 1;
}

.rec-must-do {
    border-left: 3px solid var(--danger);
}

.rec-high-yield {
    border-left: 3px solid #D97706;
}

.rec-optional {
    border-left: 3px solid var(--text-muted);
}

/* Applied state */
.rec-applied {
    opacity: 0.6;
    border-color: var(--success) !important;
    background: rgba(34, 197, 94, 0.04);
}

.rec-applied::before {
    background: linear-gradient(90deg, var(--success), #4ade80) !important;
    opacity: 1 !important;
}

/* Card Header */
.rec-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.rec-item-icon {
    font-size: 16px;
    margin-right: 6px;
}

.rec-item-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.rec-item-badge {
    font-size: 9px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.badge-must-do {
    background: var(--danger-light);
    color: var(--danger);
}

.badge-high-yield {
    background: var(--warning-light);
    color: #B45309;
}

.badge-optional {
    background: var(--bg);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* Effect Bar */
.rec-effect-bar-wrap {
    position: relative;
    height: 18px;
    background: rgba(34, 197, 94, 0.08);
    border-radius: 4px;
    margin-bottom: 6px;
    overflow: hidden;
}

.rec-effect-bar {
    height: 100%;
    background: linear-gradient(90deg, rgba(34, 197, 94, 0.25), rgba(34, 197, 94, 0.5));
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.rec-effect-text {
    position: absolute;
    top: 50%;
    left: 8px;
    transform: translateY(-50%);
    font-size: 10px;
    font-weight: 700;
    color: var(--success);
}

/* Card Meta */
.rec-item-meta {
    display: flex;
    gap: 12px;
    font-size: 10px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.rec-contrib {
    color: var(--text-muted);
}

.rec-time {
    color: var(--primary);
}

.rec-rationale {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 8px;
}

/* Apply Button */
.btn-rec-apply {
    padding: 5px 14px;
    background: linear-gradient(135deg, var(--primary), #0088FF);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    width: 100%;
}

.btn-rec-apply:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 102, 255, 0.3);
}

.btn-rec-apply.applied {
    background: linear-gradient(135deg, var(--success), #16a34a);
    pointer-events: none;
}

/* Apply All Button */
.btn-rec-apply-all {
    width: 100%;
    padding: 10px 16px;
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    margin-top: 8px;
}

.btn-rec-apply-all:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.35);
}

/* Decision Save Button */
.btn-save-decision {
    padding: 8px 16px;
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn-save-decision:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.btn-save-decision.saved {
    background: linear-gradient(135deg, #22c55e, #4ade80);
}

.whatif-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.whatif-actions .btn-action-plan {
    flex: 1;
}

/* Divider */
.whatif-divider {
    margin-top: 16px;
    padding-top: 8px;
}

.whatif-divider hr {
    border: none;
    border-top: 1px dashed var(--border);
    margin-bottom: 10px;
}

.whatif-divider h3 {
    font-size: 14px;
    font-weight: 600;
}

.whatif-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* What-If Panel */
.panel-whatif {
    padding: 10px;
    overflow-y: auto;
}

.whatif-desc {
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.whatif-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-item {
    padding: 8px;
    background: var(--bg);
    border-radius: 6px;
    border: 1px solid var(--border);
}

.control-item:has(input:checked) {
    border-color: var(--success);
    background: var(--success-light);
}

.control-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 500;
}

.control-slider {
    margin-top: 6px;
}

.control-slider input[type="range"] {
    width: 100%;
}

.control-slider select {
    width: 100%;
    padding: 4px;
    font-size: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.control-detail {
    font-size: 9px;
    color: var(--success);
    margin-top: 4px;
    display: none;
}

.control-item:has(input:checked) .control-detail {
    display: block;
}

.whatif-summary {
    margin-top: 12px;
    padding: 12px;
    background: linear-gradient(135deg, var(--primary-light), #DBEAFE);
    border-radius: 8px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 10px;
}

.summary-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--success);
}

.btn-action-plan,
.btn-export {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 6px;
}

.btn-action-plan {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

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

/* Enhanced Action Plan */
.action-plan-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.action-plan-header {
    margin-bottom: 24px;
}

.ap-hero {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.ap-hero-icon {
    font-size: 48px;
}

.ap-hero-content h1 {
    font-size: 28px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.ap-hero-content p {
    color: var(--text-secondary);
    font-size: 14px;
}

.ap-date-picker {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--panel);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.ap-date-picker label {
    font-weight: 600;
}

.ap-date-picker input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
}

.btn-today {
    padding: 8px 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
}

.ap-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 12px;
    color: white;
    margin-bottom: 16px;
}

.ap-stat {
    text-align: center;
}

.ap-stat-value {
    font-size: 28px;
    font-weight: 700;
}

.ap-stat-label {
    font-size: 11px;
    opacity: 0.9;
}

.ap-stat.primary {
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
}

.ap-stat.highlight .ap-stat-value {
    color: #10B981;
}

.ap-stat-arrow {
    font-size: 24px;
    opacity: 0.7;
}

.progress-container {
    padding: 16px;
    background: var(--panel);
    border-radius: 10px;
    border: 1px solid var(--border);
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.progress-bar {
    height: 10px;
    background: var(--border);
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), #34D399);
    border-radius: 5px;
    transition: width 0.5s;
}

/* Dynamic Milestones */
.milestone-title {
    font-size: 16px;
    margin: 24px 0 16px;
}

.empty-state {
    color: var(--text-muted);
    text-align: center;
    padding: 40px;
    background: var(--bg);
    border-radius: 10px;
}

.milestone-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.milestone-card {
    padding: 16px;
    background: var(--panel);
    border-radius: 10px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
}

.milestone-card.smoking {
    border-left-color: var(--danger);
}

.milestone-card.muscle {
    border-left-color: var(--warning);
}

.milestone-card.weight {
    border-left-color: #3B82F6;
}

.milestone-card.exercise {
    border-left-color: var(--success);
}

.milestone-card.diabetes {
    border-left-color: var(--purple);
}

.milestone-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.milestone-week {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.milestone-date {
    font-size: 11px;
    color: var(--primary);
    font-weight: 600;
    margin-top: 2px;
}

.milestone-card h3 {
    font-size: 16px;
    margin: 4px 0 8px;
}

.milestone-card p {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.milestone-card ul {
    list-style: none;
    font-size: 11px;
    color: var(--text-secondary);
}

.milestone-card li {
    padding: 4px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.milestone-card li input[type="checkbox"] {
    width: 14px;
    height: 14px;
}

.milestone-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    margin-top: 10px;
}

.milestone-badge.easy {
    background: var(--success-light);
    color: var(--success);
}

.milestone-badge.moderate {
    background: var(--warning-light);
    color: #B45309;
}

.milestone-badge.hard {
    background: var(--danger-light);
    color: var(--danger);
}

.milestone-impact {
    display: inline-block;
    margin-left: 6px;
    padding: 3px 8px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
}

/* Weekly Tracker */
.weekly-tracker {
    margin-top: 32px;
}

.weekly-tracker h3 {
    font-size: 16px;
    margin-bottom: 16px;
}

.week-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 8px;
}

.week-cell {
    padding: 10px 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    text-align: center;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.week-cell:hover {
    border-color: var(--primary);
}

.week-cell.completed {
    background: var(--success-light);
    border-color: var(--success);
}

.week-cell .week-num {
    font-weight: 600;
}

.week-cell .week-date {
    font-size: 8px;
    color: var(--text-muted);
}

/* QR Section */
.qr-section {
    margin-top: 32px;
    padding: 24px;
    background: linear-gradient(135deg, var(--primary-light), #DBEAFE);
    border-radius: 12px;
}

.qr-section h3 {
    font-size: 16px;
    margin-bottom: 16px;
}

.qr-container {
    display: flex;
    gap: 24px;
    align-items: center;
}

#qrCode {
    background: white;
    padding: 12px;
    border-radius: 8px;
}

.qr-info {
    flex: 1;
}

.qr-info p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.btn-share {
    padding: 10px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
}

.ap-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 24px;
}

.btn-back,
.btn-print {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

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

.btn-print {
    background: var(--primary);
    border: none;
    color: white;
}

/* Evidence View (same as V5) */
.evidence-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 24px;
}

.evidence-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.evidence-header h1 {
    font-size: 28px;
}

.evidence-update {
    text-align: right;
}

.update-badge {
    display: inline-block;
    padding: 6px 14px;
    background: linear-gradient(135deg, var(--success), #34D399);
    color: white;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.update-schedule {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.evidence-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.evidence-stat {
    text-align: center;
    padding: 20px;
    background: var(--panel);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.evidence-stat .stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
}

.evidence-stat .stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.evidence-sections {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.evidence-card {
    background: var(--panel);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.evidence-card.schedule {
    background: linear-gradient(135deg, var(--primary-light), #DBEAFE);
}

.evidence-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.evidence-card-header h3 {
    font-size: 14px;
}

.evidence-tag {
    padding: 4px 10px;
    background: var(--success-light);
    color: var(--success);
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
}

.evidence-items {
    padding: 12px 18px;
}

.evidence-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.evidence-item:last-child {
    border-bottom: none;
}

.ref-icon {
    font-size: 20px;
    width: 32px;
    flex-shrink: 0;
}

.ref-content {
    flex: 1;
}

.ref-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.ref-source {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.ref-meta {
    font-size: 10px;
    color: var(--primary);
    font-weight: 500;
}

.schedule-timeline {
    display: flex;
    justify-content: space-around;
    padding: 20px;
}

.schedule-item {
    text-align: center;
    position: relative;
}

.schedule-item::after {
    content: '→';
    position: absolute;
    right: -30px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 18px;
}

.schedule-item:last-child::after {
    display: none;
}

.schedule-date {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
}

.schedule-desc {
    font-size: 11px;
    color: var(--text-secondary);
}

.schedule-item.past {
    opacity: 0.5;
}

.schedule-item.current .schedule-date {
    color: var(--success);
}

.schedule-item.current .schedule-desc {
    color: var(--success);
    font-weight: 600;
}

.evidence-footer {
    margin-top: 24px;
}

/* Smart Input Modal - ENHANCED */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--panel);
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    overflow: auto;
}

.modal-content.wide {
    max-width: 700px;
}

.modal-content.small {
    max-width: 400px;
}

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

.modal-header h2 {
    font-size: 18px;
}

.modal-close {
    width: 32px;
    height: 32px;
    background: var(--bg);
    border: none;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
}

.smart-input-body {
    padding: 20px;
}

/* Smart Tabs */
.smart-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.smart-tab {
    flex: 1;
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
}

.smart-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.smart-pane {
    display: none;
}

.smart-pane.active {
    display: block;
}

/* Smart Lens */
.lens-info {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--purple-light), #DDD6FE);
    border-radius: 12px;
    margin-bottom: 20px;
}

.lens-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

.lens-info h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.lens-info p {
    font-size: 13px;
    color: var(--text-secondary);
}

.lens-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
}

.lens-status .status-icon {
    font-size: 18px;
}

.lens-status.capturing {
    background: var(--danger-light);
    color: var(--danger);
}

.lens-status.analyzing {
    background: var(--warning-light);
    color: #B45309;
}

.lens-status.success {
    background: var(--success-light);
    color: var(--success);
}

.btn-lens {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--danger), #EF4444);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-lens:hover {
    opacity: 0.9;
}

.btn-lens.stop {
    background: linear-gradient(135deg, #6B7280, #4B5563);
}

.lens-preview {
    display: none;
    margin-top: 16px;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
}

.lens-preview.active {
    display: block;
}

#screenVideo {
    width: 100%;
    border-radius: 8px;
}

.lens-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
}

.lens-overlay.active {
    display: flex;
}

.lens-overlay p {
    font-size: 16px;
    margin-bottom: 12px;
}

.lens-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.lens-extracted {
    display: none;
    margin-top: 16px;
    padding: 16px;
    background: var(--success-light);
    border-radius: 8px;
}

.lens-extracted.active {
    display: block;
}

.lens-extracted h4 {
    font-size: 14px;
    margin-bottom: 12px;
    color: var(--success);
}

.extracted-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}

.extracted-field {
    padding: 8px;
    background: white;
    border-radius: 6px;
    font-size: 12px;
}

.extracted-field .field-label {
    font-size: 10px;
    color: var(--text-muted);
}

.extracted-field .field-value {
    font-weight: 600;
}

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

.btn-apply {
    flex: 1;
    padding: 12px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.btn-retry {
    padding: 12px 20px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
}

/* File Upload (same as V5) */
.upload-zone {
    padding: 40px;
    border: 2px dashed var(--border);
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
}

.upload-zone:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-zone input {
    display: none;
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.upload-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

.btn-browse {
    margin-top: 12px;
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.smart-preview {
    display: none;
    margin-top: 16px;
}

.smart-preview.active {
    display: block;
}

.smart-preview img {
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: 12px;
}

.extracted-data {
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 12px;
}

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

.btn-cancel {
    padding: 10px 20px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
}

/* History Modal */
.history-list {
    padding: 16px;
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
}

.history-item:hover {
    background: var(--primary-light);
}

.history-item-name {
    font-weight: 600;
    font-size: 13px;
}

.history-item-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.history-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 20px;
}

/* Audit Footer with Model Info Badge */
.audit-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: linear-gradient(90deg, var(--bg), #EEF2FF, var(--bg));
    border-top: 1px solid var(--border);
    font-size: 10px;
    color: var(--text-muted);
    flex-wrap: wrap;
    gap: 8px;
}

.footer-left,
.footer-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.audit-footer strong {
    color: var(--text-secondary);
}

/* Model Info Badge */
.model-info-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 14px;
    background: linear-gradient(135deg, #F0F9FF, #EDE9FE);
    border: 1px solid #C7D2FE;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 500;
}

.model-info-badge .model-version {
    color: var(--primary);
}

.model-info-badge .model-auc {
    font-weight: 600;
    color: var(--success);
}

.model-info-badge .model-validated {
    color: var(--success);
}

.model-info-badge strong {
    font-weight: 700;
}

.evidence-badge {
    color: var(--success);
    font-weight: 600;
}

.disclaimer {
    color: var(--warning);
}

/* Disabled intervention items */
.control-item.disabled {
    opacity: 0.4;
    pointer-events: none;
    cursor: not-allowed;
}

.control-item.disabled .slider {
    background: #ccc !important;
}

.control-item.disabled::after {
    content: '✓ 해당 없음';
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    font-size: 10px;
    color: var(--success);
    font-weight: 500;
}

/* Disclaimer */
.disclaimer-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.disclaimer-critical {
    color: #DC2626;
    /* Danger red */
    font-weight: 700;
    font-size: 11px;
}

.disclaimer-legal {
    font-size: 9px;
    color: var(--text-muted);
    opacity: 0.8;
}

/* Session Alert */
.session-alert {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: #1E293B;
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 30000;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    gap: 12px;
}

.session-alert.visible {
    transform: translateX(-50%) translateY(0);
}

.session-alert .btn-refresh {
    background: var(--primary);
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.session-alert .btn-refresh:hover {
    background: #005bb8;
}

/* ============================================
   RESPONSIVE — Tablet (≤1100px)
   ============================================ */
@media (max-width: 1100px) {
    .dashboard-grid {
        grid-template-columns: 240px 1fr;
    }

    .panel-whatif {
        grid-column: 1 / -1;
    }

    .week-grid {
        grid-template-columns: repeat(8, 1fr);
    }

    .header-actions .btn-new-patient span:last-child {
        display: none;
    }
}

/* ============================================
   DESKTOP: Hide mobile-only components (≥769px)
   ============================================ */
.mobile-bottom-nav,
.mobile-cta-bar,
.mobile-risk-sticky,
.mobile-hamburger,
.mobile-menu-dropdown,
.mobile-whatif-toggle,
.mobile-whatif-overlay {
    display: none !important;
}

/* ============================================
   RESPONSIVE — Mobile (≤768px)
   ============================================ */
@media (max-width: 768px) {

    /* ── Body: padding for fixed bars ── */
    body {
        font-size: 14px;
        padding-bottom: 112px;
        /* CTA 56px + bottom-nav 56px */
    }

    /* ============================================
       HEADER: Compact mobile layout
       ============================================ */
    .header {
        flex-wrap: wrap;
        padding: 8px 12px;
        gap: 6px;
        position: sticky;
        top: 0;
        z-index: 200;
    }

    /* Hide desktop header elements */
    .patient-badge,
    .practice-mode-toggle,
    .header-actions {
        display: none !important;
    }

    /* Show hamburger */
    .mobile-hamburger {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: var(--bg);
        border: 1px solid var(--border);
        border-radius: 8px;
        font-size: 20px;
        cursor: pointer;
        margin-left: auto;
        order: 2;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-hamburger:active {
        background: var(--border);
    }

    .logo {
        order: 1;
    }

    .logo svg {
        width: 24px;
        height: 24px;
    }

    .logo-text {
        font-size: 15px;
    }

    /* Language button stays visible */
    .btn-lang {
        display: flex !important;
        order: 3;
        padding: 6px 10px;
        font-size: 12px;
    }

    /* Mobile Menu Dropdown */
    .mobile-menu-dropdown {
        display: none;
        position: absolute;
        top: 100%;
        right: 12px;
        background: white;
        border: 1px solid var(--border);
        border-radius: 12px;
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
        z-index: 300;
        min-width: 220px;
        padding: 8px;
        animation: menuSlideDown 0.2s ease;
    }

    .mobile-menu-dropdown.open {
        display: block !important;
    }

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

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .mobile-menu-dropdown button,
    .mobile-menu-dropdown a {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        padding: 12px 14px;
        background: none;
        border: none;
        border-radius: 8px;
        font-size: 14px;
        color: var(--text);
        cursor: pointer;
        text-decoration: none;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-menu-dropdown button:active,
    .mobile-menu-dropdown a:active {
        background: var(--bg);
    }

    .mobile-menu-dropdown hr {
        border: none;
        border-top: 1px solid var(--border);
        margin: 4px 0;
    }

    /* ============================================
       NAVIGATION: Hide desktop, show bottom nav
       ============================================ */
    .main-nav {
        display: none !important;
    }

    /* Mobile Bottom Tab Navigation */
    .mobile-bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 56px;
        background: white;
        border-top: 1px solid var(--border);
        z-index: 1000;
        padding: 0;
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
    }

    .mobile-tab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        background: none;
        border: none;
        color: var(--text-muted);
        font-size: 10px;
        cursor: pointer;
        padding: 4px 0;
        -webkit-tap-highlight-color: transparent;
        transition: color 0.2s;
    }

    .mobile-tab.active {
        color: var(--primary);
    }

    .mobile-tab-icon {
        font-size: 20px;
        line-height: 1;
    }

    .mobile-tab-label {
        font-size: 10px;
        font-weight: 600;
    }

    /* ============================================
       STICKY RISK SUMMARY BAR
       ============================================ */
    .mobile-risk-sticky {
        display: flex !important;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 8px 12px;
        background: white;
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 52px;
        /* below header */
        z-index: 150;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    }

    .mrs-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 1px;
    }

    .mrs-label {
        font-size: 10px;
        color: var(--text-muted);
        font-weight: 500;
    }

    .mrs-value {
        font-size: 18px;
        font-weight: 700;
    }

    .mrs-current .mrs-value {
        color: var(--danger);
    }

    .mrs-projected .mrs-value {
        color: var(--success);
    }

    .mrs-arrow {
        font-size: 18px;
        color: var(--success);
        font-weight: bold;
    }

    .mrs-reduction {
        background: var(--success);
        color: white;
        padding: 2px 8px;
        border-radius: 10px;
        font-size: 11px;
        font-weight: 700;
    }

    /* ============================================
       STICKY CTA BAR
       ============================================ */
    .mobile-cta-bar {
        display: flex !important;
        position: fixed;
        bottom: 56px;
        /* above bottom nav */
        left: 0;
        right: 0;
        padding: 8px 12px;
        background: white;
        border-top: 1px solid var(--border);
        z-index: 999;
        gap: 8px;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
    }

    .cta-primary {
        flex: 1;
        padding: 12px 16px;
        background: linear-gradient(135deg, var(--primary), #0088FF);
        color: white;
        border: none;
        border-radius: 10px;
        font-size: 15px;
        font-weight: 700;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: transform 0.1s;
    }

    .cta-primary:active {
        transform: scale(0.98);
    }

    .cta-save {
        flex: 1;
        padding: 12px 16px;
        background: linear-gradient(135deg, var(--success), #34D399);
        color: white;
        border: none;
        border-radius: 10px;
        font-size: 15px;
        font-weight: 700;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .cta-pdf {
        padding: 12px 16px;
        background: var(--bg);
        color: var(--text);
        border: 1px solid var(--border);
        border-radius: 10px;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    /* Hide floating save on mobile — CTA bar replaces it */
    .floating-save-btn {
        display: none !important;
    }

    /* ============================================
       DASHBOARD GRID: Single column
       ============================================ */
    .dashboard-grid {
        grid-template-columns: 1fr;
        height: auto;
        padding: 8px;
        gap: 8px;
    }

    /* ============================================
       PATIENT INPUT: Accordion form
       ============================================ */
    .panel {
        border-radius: 10px;
    }

    .panel-header h2 {
        font-size: 15px;
    }

    .panel-input {
        max-height: none;
        overflow: visible;
    }

    /* Tabs → Accordion style on mobile */
    .tabs {
        flex-direction: column;
        gap: 0;
        padding: 0;
    }

    .tab {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 12px 14px;
        font-size: 14px;
        font-weight: 600;
        border-radius: 0;
        border-bottom: 1px solid var(--border);
        text-align: left;
        background: var(--bg);
    }

    .tab::after {
        content: '▼';
        font-size: 10px;
        color: var(--text-muted);
        transition: transform 0.3s;
    }

    .tab.active {
        background: var(--primary-light);
        color: var(--primary);
        border-left: 3px solid var(--primary);
    }

    .tab.active::after {
        transform: rotate(180deg);
    }

    /* Tab completion checkmark (JS-driven) */
    .tab.completed::before {
        content: '✅';
        margin-right: 6px;
        font-size: 12px;
    }

    /* Form inputs — touch friendly */
    .compact-form {
        gap: 6px;
        padding: 8px;
    }

    .form-row {
        flex-direction: column;
        align-items: stretch;
        gap: 3px;
    }

    .form-row label {
        width: 100%;
        font-size: 12px;
        font-weight: 600;
        color: var(--text-secondary);
    }

    .form-row input,
    .form-row select {
        width: 100%;
        min-height: 44px;
        padding: 10px 12px;
        font-size: 16px;
        /* prevents iOS zoom */
        border-radius: 8px;
    }

    .hospital-id-row {
        flex-direction: column;
        align-items: stretch;
    }

    .hospital-id-row label {
        width: 100%;
    }

    .hospital-id-row input {
        width: 100%;
        min-height: 44px;
        font-size: 16px;
    }

    .toggle-row {
        min-height: 44px;
        padding: 8px 0;
    }

    .toggle {
        width: 44px;
        height: 24px;
    }

    .key-field select {
        min-height: 44px;
        font-size: 16px;
    }

    /* Level chips */
    .level-chips {
        gap: 6px;
        flex-wrap: wrap;
    }

    .level-chips label {
        padding: 8px 14px;
        font-size: 14px;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* Calculate button — in-panel version */
    .btn-calculate {
        padding: 14px;
        font-size: 15px;
        margin: 10px 6px;
        border-radius: 10px;
    }

    /* ============================================
       RISK VIEW: Center panel
       ============================================ */
    .risk-toggle-group {
        flex-direction: row;
        gap: 4px;
    }

    .risk-toggle-btn {
        font-size: 13px;
        padding: 10px;
        min-height: 44px;
    }

    .dual-donut-container {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .donut-card {
        min-width: unset;
        min-height: unset;
        width: 100%;
        padding: 16px;
    }

    .donut-card svg {
        max-width: 160px;
        max-height: 160px;
    }

    .donut-arrow {
        transform: rotate(90deg);
        font-size: 24px;
        text-align: center;
    }

    .risk-label {
        font-size: 14px;
    }

    .risk-value {
        font-size: 32px;
    }

    .ci-display {
        font-size: 11px;
    }

    .reduction-badge {
        font-size: 13px;
        padding: 4px 12px;
    }

    /* CDS Risk Alert */
    .risk-alert-banner {
        padding: 10px 12px;
        gap: 8px;
    }

    .alert-icon {
        font-size: 20px;
    }

    .alert-content strong {
        font-size: 13px;
    }

    .alert-content span {
        font-size: 11px;
    }

    /* Clinical Recommendation */
    .clinical-recommendations {
        padding: 10px;
    }

    /* Sunburst / Factor Chart */
    .sunburst-section {
        padding: 10px;
    }

    .factor-list {
        gap: 6px;
    }

    .factor-item {
        font-size: 12px;
    }

    /* ============================================
       WHAT-IF: Bottom Sheet on mobile
       ============================================ */
    .mobile-whatif-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        padding: 14px;
        background: linear-gradient(135deg, #F8FAFC, #EEF2FF);
        border: 1px solid var(--primary);
        border-radius: 10px;
        font-size: 14px;
        font-weight: 600;
        color: var(--primary);
        cursor: pointer;
        margin: 8px 0;
        -webkit-tap-highlight-color: transparent;
    }

    .toggle-chevron {
        font-size: 10px;
        transition: transform 0.3s;
    }

    .mobile-whatif-toggle.open .toggle-chevron {
        transform: rotate(180deg);
    }

    /* Hide What-if panel by default on mobile */
    .whatif-divider,
    .whatif-controls,
    .whatif-summary {
        display: none;
    }

    /* What-if as bottom sheet */
    .panel-whatif.bottom-sheet-open .whatif-divider,
    .panel-whatif.bottom-sheet-open .whatif-controls,
    .panel-whatif.bottom-sheet-open .whatif-summary {
        display: block;
    }

    .mobile-whatif-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 499;
    }

    .mobile-whatif-overlay.open {
        display: block !important;
    }

    .panel-whatif.bottom-sheet-open {
        position: fixed;
        bottom: 112px;
        left: 0;
        right: 0;
        max-height: 65vh;
        overflow-y: auto;
        z-index: 500;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.15);
        animation: sheetSlideUp 0.3s ease;
        padding-bottom: 20px;
    }

    @keyframes sheetSlideUp {
        from {
            transform: translateY(100%);
        }

        to {
            transform: translateY(0);
        }
    }

    /* What-if controls — full width */
    .control-item {
        padding: 10px 0;
        font-size: 13px;
    }

    .control-header {
        min-height: 44px;
    }

    .control-label {
        font-size: 13px;
    }

    /* ============================================
       EVIDENCE & ACTION PLAN
       ============================================ */
    .evidence-summary {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .evidence-card {
        padding: 10px;
    }

    /* Action Plan */
    .panel-whatif {
        grid-column: 1 / -1;
    }

    .week-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 4px;
    }

    .week-cell {
        font-size: 10px;
        padding: 4px;
    }

    .milestone-card {
        padding: 14px;
    }

    .milestone-card h3 {
        font-size: 15px;
    }

    .milestone-card ul {
        font-size: 13px;
    }

    .action-plan-header {
        padding: 12px;
    }

    .ap-hero {
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }

    .ap-hero h1 {
        font-size: 18px;
    }

    .ap-stats {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }

    .ap-stat {
        flex: 1;
        min-width: 80px;
        text-align: center;
    }

    /* QR Section */
    .qr-container {
        flex-direction: column;
        align-items: center;
    }

    #qrCode canvas,
    #qrCode img {
        max-width: 160px !important;
        max-height: 160px !important;
    }

    .plan-link-container {
        word-break: break-all;
        font-size: 12px;
    }

    /* ============================================
       MODALS
       ============================================ */
    .modal-content,
    .modal-body {
        width: 95vw !important;
        max-width: 95vw !important;
        max-height: 85vh !important;
        margin: 10px auto;
        border-radius: 12px;
    }

    .smart-modal-overlay .smart-modal {
        width: 95vw !important;
        max-width: 95vw !important;
        max-height: 90vh;
        margin: 5vh auto;
    }

    /* ============================================
       FOOTER / STATUS BAR
       ============================================ */
    .status-bar,
    footer {
        flex-wrap: wrap;
        font-size: 9px;
        padding: 4px 8px;
        gap: 4px;
        justify-content: center;
        text-align: center;
    }

    /* Session Alert */
    .session-alert {
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }

    .session-alert .btn-refresh {
        width: 100%;
    }

    /* Analysis Mode Badge */
    .analysis-mode {
        font-size: 10px;
        padding: 3px 6px;
    }

    /* Decision Log */
    .decision-section {
        padding: 8px;
    }

    .decision-log-inline {
        font-size: 12px;
    }

    /* User Menu */
    .user-dropdown {
        right: 0;
        min-width: 200px;
    }

    /* Predigm ID */
    .predigm-id-badge {
        font-size: 9px !important;
    }
}

/* ============================================
   RESPONSIVE — Small Mobile (≤480px)
   ============================================ */
@media (max-width: 480px) {
    .header {
        padding: 6px 8px;
    }

    .logo-text {
        font-size: 13px;
    }

    .mobile-hamburger {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    .dashboard-grid {
        padding: 4px;
        gap: 6px;
    }

    .form-row input,
    .form-row select {
        padding: 8px 10px;
    }

    .dual-donut-container {
        gap: 8px;
    }

    .donut-card svg {
        max-width: 130px;
        max-height: 130px;
    }

    .evidence-summary {
        grid-template-columns: 1fr;
    }

    .week-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .mobile-tab-label {
        font-size: 9px;
    }

    .cta-primary,
    .cta-save {
        font-size: 14px;
        padding: 10px 12px;
    }
}

/* ============================================
   CDS FEATURES - Clinical Decision Support
   ============================================ */

/* Risk Alert Banner */
.risk-alert-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin: 12px 0;
    border-radius: 10px;
    animation: pulse-alert 2s ease-in-out infinite;
}

.risk-alert-banner.hidden {
    display: none;
}

.risk-alert-banner.low {
    background: linear-gradient(135deg, #D1FAE5, #A7F3D0);
    border: 2px solid #10B981;
}

.risk-alert-banner.moderate {
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
    border: 2px solid #F59E0B;
}

.risk-alert-banner.high {
    background: linear-gradient(135deg, #FEE2E2, #FECACA);
    border: 2px solid #DC2626;
    animation: pulse-alert 1.5s ease-in-out infinite;
}

@keyframes pulse-alert {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.01);
    }
}

.alert-icon {
    font-size: 24px;
}

.alert-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.alert-content strong {
    font-size: 14px;
    color: var(--text);
}

.alert-content span {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Clinical Recommendations Panel */
.clinical-recommendations {
    padding: 12px;
    background: var(--panel);
    border-radius: 10px;
    border: 1px solid var(--border);
    margin: 12px 0;
}

.clinical-recommendations h5 {
    font-size: 13px;
    margin-bottom: 10px;
    color: var(--text);
}

.recommendations-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.recommendation-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: 8px;
    border-left: 4px solid;
}

.recommendation-item.critical {
    border-left-color: #DC2626;
    background: #FEF2F2;
}

.recommendation-item.important {
    border-left-color: #F59E0B;
    background: #FFFBEB;
}

.recommendation-item.suggested {
    border-left-color: #10B981;
    background: #F0FDF4;
}

.rec-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.rec-content {
    flex: 1;
}

.rec-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}

.rec-desc {
    font-size: 10px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.rec-evidence {
    font-size: 9px;
    color: var(--primary);
    display: inline-block;
}

.rec-evidence-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.btn-view-evidence {
    font-size: 9px;
    padding: 2px 8px;
    background: var(--primary-light);
    color: var(--primary);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-view-evidence:hover {
    background: var(--primary);
    color: white;
}

/* Evidence Detail Panel */
.evidence-detail {
    margin-top: 10px;
    padding: 10px;
    background: linear-gradient(135deg, var(--bg), #EEF2FF);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 10px;
    animation: slideDown 0.2s ease-out;
}

.evidence-detail.hidden {
    display: none;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }

    to {
        opacity: 1;
        max-height: 200px;
    }
}

.evidence-source {
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.pubmed-link {
    margin-left: 8px;
    padding: 2px 6px;
    background: #007bff;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 600;
}

.pubmed-link:hover {
    background: #0056b3;
}

.evidence-stats {
    display: flex;
    gap: 12px;
    margin-bottom: 6px;
    color: var(--text);
}

.evidence-stats strong {
    color: var(--primary);
}

.evidence-desc {
    margin-bottom: 6px;
    color: var(--text-secondary);
    line-height: 1.4;
    font-style: italic;
}

.evidence-level {
    color: var(--text-muted);
}

.level-badge {
    padding: 2px 6px;
    background: var(--success-light);
    color: var(--success);
    border-radius: 4px;
    font-weight: 600;
}

/* CI Error Bar Enhancement */
.ci-error-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 8px;
    padding: 6px 10px;
    background: var(--bg);
    border-radius: 6px;
}

.ci-bar-visual {
    display: flex;
    align-items: center;
    gap: 2px;
}

.ci-bar-line {
    height: 3px;
    background: var(--primary);
    border-radius: 2px;
}

.ci-bar-point {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
}

.ci-bar-cap {
    width: 2px;
    height: 10px;
    background: var(--primary);
}

.ci-text {
    font-size: 10px;
    color: var(--text-muted);
}

/* ============================================
   CDS FEATURE 4: AUDIT TRAIL / DECISION LOG
   ============================================ */
.audit-trail-section {
    margin-top: 12px;
    padding: 10px;
    background: var(--panel);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.audit-trail-section.hidden {
    display: none;
}

.audit-trail-section h5 {
    font-size: 12px;
    margin-bottom: 8px;
    color: var(--text);
}

.audit-trail-list {
    max-height: 120px;
    overflow-y: auto;
}

.audit-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: var(--bg);
    border-radius: 6px;
    margin-bottom: 4px;
    font-size: 10px;
}

.audit-time {
    color: var(--text-muted);
    font-family: monospace;
    font-size: 9px;
}

.audit-action {
    flex: 1;
    color: var(--text);
}

.audit-risk {
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--primary-light);
    color: var(--primary);
}

/* ============================================
   CDS FEATURE 5: COMPARATIVE CASES
   ============================================ */
.comparative-cases-section {
    margin-top: 12px;
    padding: 10px;
    background: var(--panel);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.comparative-cases-section.hidden {
    display: none;
}

.comparative-cases-section h5 {
    font-size: 12px;
    margin-bottom: 8px;
    color: var(--text);
}

.comparative-cases-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.case-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg);
    border-radius: 6px;
    border-left: 3px solid var(--primary);
}

.case-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
}

.case-info {
    flex: 1;
}

.case-profile {
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
}

.case-factors {
    font-size: 9px;
    color: var(--text-muted);
}

.case-outcome {
    text-align: right;
}

.case-risk {
    font-size: 13px;
    font-weight: 700;
    color: var(--danger);
}

.case-status {
    font-size: 9px;
    color: var(--text-muted);
}

.case-status.recurred {
    color: var(--danger);
}

.case-status.success {
    color: var(--success);
}

/* ============================================
   MODEL REGISTRY & PERFORMANCE MONITORING
   ============================================ */

/* Model Registry Panel */
.model-registry {
    background: linear-gradient(135deg, #F0F9FF, #EEF2FF);
}

.registry-status {
    font-size: 11px;
    padding: 2px 8px;
    background: var(--success-light);
    color: var(--success);
    border-radius: 10px;
}

.model-versions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 0;
}

.model-version-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: white;
    border-radius: 8px;
    border-left: 4px solid var(--border);
}

.model-version-item.production {
    border-left-color: var(--success);
    background: linear-gradient(90deg, #D1FAE5, white);
}

.model-version-item.staging {
    border-left-color: var(--warning);
    background: linear-gradient(90deg, #FEF3C7, white);
}

.model-version-item.archived {
    opacity: 0.7;
}

.version-badge {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    padding: 4px 10px;
    background: var(--primary-light);
    border-radius: 6px;
}

.version-badge.beta {
    background: var(--warning-light);
    color: #B45309;
}

.version-info {
    display: flex;
    gap: 12px;
    font-size: 11px;
}

.version-status {
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.version-status.production {
    background: var(--success-light);
    color: var(--success);
}

.version-status.staging {
    background: var(--warning-light);
    color: #B45309;
}

.version-status.archived {
    background: var(--bg);
    color: var(--text-muted);
}

.version-auc {
    color: var(--text);
    font-weight: 600;
}

.version-date {
    color: var(--text-muted);
}

/* Performance Monitoring Panel */
.performance-monitor {
    background: linear-gradient(135deg, #ECFDF5, #D1FAE5);
}

.monitor-status {
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 10px;
}

.monitor-status.healthy {
    background: var(--success);
    color: white;
}

.monitor-status.warning {
    background: var(--warning);
    color: white;
}

.performance-metrics {
    display: flex;
    gap: 12px;
    margin: 12px 0;
}

.metric-card {
    flex: 1;
    padding: 12px;
    background: white;
    border-radius: 8px;
    text-align: center;
}

.metric-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.metric-value.psi-good {
    color: var(--success);
}

.metric-value.psi-warning {
    color: var(--warning);
}

.metric-label {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
}

.metric-threshold {
    font-size: 9px;
    color: var(--success);
    margin-top: 2px;
}

/* Drift Indicator */
.drift-indicator {
    margin-top: 12px;
}

.drift-bar {
    position: relative;
    height: 10px;
    background: linear-gradient(90deg, #10B981 0%, #F59E0B 50%, #DC2626 100%);
    border-radius: 5px;
}

.drift-fill {
    position: absolute;
    top: -2px;
    left: 0;
    height: 14px;
    width: 4px;
    background: var(--text);
    border-radius: 2px;
}

.drift-threshold {
    position: absolute;
    top: -2px;
    left: 50%;
    height: 14px;
    width: 2px;
    background: var(--danger);
}

.drift-labels {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    color: var(--text-muted);
    margin-top: 4px;
}

.drift-labels .current {
    font-weight: 600;
    color: var(--success);
}

/* Shadow A/B Testing Panel */
.shadow-testing {
    background: linear-gradient(135deg, #EDE9FE, #DDD6FE);
}

.shadow-status {
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 10px;
}

.shadow-status.active {
    background: var(--purple);
    color: white;
}

.shadow-comparison {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 16px 0;
}

.shadow-model {
    padding: 12px 20px;
    background: white;
    border-radius: 10px;
    text-align: center;
    border: 2px solid var(--success);
}

.shadow-model.challenger {
    border-color: var(--purple);
}

.shadow-label {
    font-size: 10px;
    color: var(--text-muted);
}

.shadow-version {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.shadow-vs {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
}

.shadow-results {
    display: flex;
    justify-content: space-around;
    padding: 12px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
}

.shadow-stat {
    text-align: center;
}

.stat-num {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.stat-num.agreement {
    color: var(--success);
}

.stat-desc {
    font-size: 10px;
    color: var(--text-muted);
}

/* Evidence Level Badge (Simplified) */
.evidence-level-badge {
    display: inline-block;
    padding: 3px 10px;
    background: var(--success-light);
    color: var(--success);
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
}

/* Key References Papers List */
.key-references {
    background: #FAFBFC;
}

.model-description {
    padding: 12px 16px;
    background: #EEF6FF;
    border-left: 3px solid var(--primary);
    border-radius: 6px;
    margin-bottom: 16px;
}

.model-description p {
    margin: 0;
    font-size: 12px;
    color: var(--text);
    line-height: 1.5;
}

.paper-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 16px;
}

.paper-item {
    padding: 14px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.paper-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.paper-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.paper-stats {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.evidence-badge {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
}

.evidence-badge.high {
    background: #FEE2E2;
    color: #DC2626;
}

.evidence-badge.moderate {
    background: #FEF3C7;
    color: #B45309;
}

.stat-text {
    font-size: 11px;
    color: var(--text);
}

.paper-item .pubmed-link {
    display: inline-block;
    font-size: 11px;
    color: var(--text-muted);
    text-decoration: none;
}

.paper-item .pubmed-link:hover {
    text-decoration: underline;
    color: var(--text);
}

/* Meta-Analysis Citation */
.meta-analysis-citation {
    padding: 14px;
    background: #F8FAFC;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.citation-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.citation-text {
    font-size: 11px;
    color: var(--text);
    line-height: 1.5;
    margin-bottom: 8px;
}

.citation-note {
    font-size: 10px;
    color: var(--text-muted);
    font-style: italic;
}

/* Save Case Button and Modal */
.btn-save-case {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #10B981, #34D399);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
}

.btn-save-case:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.save-case-form {
    padding: 16px;
}

.save-case-form .form-group {
    margin-bottom: 16px;
}

.save-case-form label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.save-case-form .form-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
}

.predigm-id-preview {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: rgba(0, 212, 255, 0.1);
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
}

.predigm-id-preview strong {
    color: #00d4ff;
    font-family: monospace;
}

.save-case-form .btn-primary {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #00d4ff, #7c3aed);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.save-message {
    text-align: center;
    margin-top: 12px;
    font-size: 13px;
}

.save-message.success {
    color: #10B981;
}

.save-message.error {
    color: #EF4444;
}

/* Feedback Section */
.feedback-section {
    position: fixed;
    bottom: 80px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.feedback-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.feedback-btn {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg);
    color: var(--text);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.feedback-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.feedback-btn.active {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.feedback-thanks {
    font-size: 13px;
    color: var(--success);
    font-weight: 600;
}

/* Button Row */
.button-row {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.button-row .btn-calculate {
    flex: 1;
}

.button-row .btn-save-case {
    margin-top: 0;
    padding: 12px 16px;
}

/* Hospital ID Row */
.hospital-id-row {
    background: rgba(0, 212, 255, 0.05);
    border: 1px dashed rgba(0, 212, 255, 0.3);
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 12px;
}

.hospital-id-row input {
    border: 1px solid rgba(0, 212, 255, 0.3);
}

/* Direct Logout Button */
.btn-logout {
    padding: 8px 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #EF4444;
    color: #EF4444;
}

/* Dropdown links and buttons */
.dropdown-link,
.dropdown-btn {
    display: block;
    width: 100%;
    padding: 10px 12px;
    margin: 4px 0;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    text-decoration: none;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
}

.dropdown-link:hover,
.dropdown-btn:hover {
    background: rgba(0, 212, 255, 0.1);
    color: #00d4ff;
}

/* ===== NEW USER MENU ===== */
.user-menu-container {
    position: relative;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}

.user-menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
}

.user-avatar {
    font-size: 18px;
}

.user-menu-btn .user-name {
    font-size: 13px;
    font-weight: 500;
}

.user-menu-btn .user-arrow {
    font-size: 10px;
    opacity: 0.6;
    transition: transform 0.2s;
}

.user-menu-container.open .user-arrow {
    transform: rotate(180deg);
}

.user-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: #FFFFFF !important;
    /* Force white opaque background */
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    z-index: 10000;
    /* Higher z-index */
}

.user-menu-container.open .user-menu {
    display: block;
}

.user-menu-header {
    padding: 12px;
    text-align: center;
}

.user-menu-header strong {
    display: block;
    font-size: 14px;
    color: #1E293B !important;
    /* Dark text for light menu */
    margin-bottom: 4px;
}

.user-menu-header small {
    color: #64748B !important;
    font-size: 12px;
}

.user-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}

.user-menu-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    text-decoration: none;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s;
}

.user-menu-item:hover {
    background: rgba(0, 212, 255, 0.1);
    color: #00d4ff;
}

.user-menu-item.logout {
    color: #EF4444;
}

.user-menu-item.logout:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* ===== FLOATING SAVE BUTTON ===== */
.floating-save-btn {
    position: fixed;
    bottom: 100px;
    right: 30px;
    padding: 14px 24px;
    background: linear-gradient(135deg, #10B981, #34D399);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    transition: all 0.3s;
    z-index: 100;
}

.floating-save-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(16, 185, 129, 0.5);
}

.floating-save-btn.saved {
    background: linear-gradient(135deg, #6366F1, #8B5CF6);
}

/* ===== TAB FIX - ensure pointer events ===== */
.tabs .tab {
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Floating Save Button */
.floating-save-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #10B981, #059669);
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(16, 185, 129, 0.4);
    z-index: 9000;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.floating-save-btn:hover {
    transform: scale(1.1) translateY(-5px);
    box-shadow: 0 12px 40px rgba(16, 185, 129, 0.6);
}

.floating-save-btn:active {
    transform: scale(0.95);
}

.floating-save-btn .tooltip {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 15px;
    background: #1E293B;
    color: white;
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 13px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    pointer-events: none;
}

.floating-save-btn:hover .tooltip {
    opacity: 1;
    visibility: visible;
}

/* ===== MODALS ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 20000;
    align-items: center;
    justify-content: center;
}

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

.modal-card {
    background: #FFFFFF;
    width: 100%;
    max-width: 400px;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: modalSlide 0.3s ease-out;
}

@keyframes modalSlide {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px;
    background: #F8FAFC;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    color: #1E293B;
}

.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #64748B;
    cursor: pointer;
}

.modal-body {
    padding: 20px;
}

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

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #64748B;
    margin-bottom: 6px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

.form-group input:focus {
    border-color: var(--primary);
}

.modal-footer {
    padding: 16px 20px;
    background: #F8FAFC;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-secondary {
    padding: 8px 16px;
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: #64748B;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary {
    padding: 8px 16px;
    background: var(--primary);
    border: none;
    border-radius: 8px;
    color: #FFFFFF;
    font-weight: 600;
    cursor: pointer;
}