/* CoreAI Technology Clinical Dashboard Stylesheet */

:root {
    --bg-dark: hsl(220, 20%, 8%);
    --bg-card: hsla(220, 22%, 12%, 0.5);
    --border-glass: hsla(0, 0%, 100%, 0.08);
    --text-primary: hsl(0, 0%, 95%);
    --text-muted: hsl(215, 15%, 65%);
    
    /* Neon glow colors */
    --color-mri: hsl(220, 90%, 60%);
    --color-mri-glow: hsla(220, 90%, 60%, 0.15);
    
    --color-smartphone: hsl(270, 85%, 65%);
    --color-smartphone-glow: hsla(270, 85%, 65%, 0.15);
    
    --color-sleep: hsl(190, 85%, 55%);
    --color-sleep-glow: hsla(190, 85%, 55%, 0.15);
    
    --color-eeg: hsl(150, 75%, 50%);
    --color-eeg-glow: hsla(150, 75%, 50%, 0.15);
    
    --color-ehr: hsl(25, 85%, 60%);
    --color-ehr-glow: hsla(25, 85%, 60%, 0.15);

    --color-fusion: hsl(340, 85%, 60%);
    --color-fusion-glow: hsla(340, 85%, 60%, 0.25);
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow-x: hidden;
    height: 100vh;
}

h1, h2, h3, h4 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
}

/* Disclaimer Banner */
.disclaimer-banner {
    background: linear-gradient(90deg, hsl(38, 90%, 50%), hsl(38, 90%, 40%));
    color: hsl(220, 20%, 5%);
    text-align: center;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    z-index: 9999;
    position: relative;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

/* Main Layout Grid */
.app-container {
    display: flex;
    height: calc(100vh - 32px); /* Subtract disclaimer banner height */
    position: relative;
}

/* Sidebar Navigation */
.sidebar {
    width: 260px;
    background-color: hsla(220, 22%, 5%, 0.95);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 35px;
}

.brand-icon {
    font-size: 2rem;
    color: var(--color-fusion);
    text-shadow: 0 0 15px var(--color-fusion-glow);
}

.brand-text h1 {
    font-size: 1.3rem;
    letter-spacing: 1px;
}

.brand-text span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.95rem;
    border-radius: 8px;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
}

.nav-item:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.03);
    border-color: rgba(255,255,255,0.03);
}

.nav-item.active {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.05);
    border-color: var(--border-glass);
    box-shadow: inset 4px 0 0 var(--color-fusion);
}

.sidebar-footer {
    padding-top: 15px;
    border-top: 1px solid var(--border-glass);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* Workspace Area */
.main-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 25px;
    background: radial-gradient(circle at top right, hsla(340, 40%, 15%, 0.15), transparent 60%);
}

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

/* Dropdown styling */
.patient-selector-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.patient-selector-container label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.custom-select {
    padding: 10px 16px;
    background-color: hsla(220, 20%, 6%, 0.8);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    min-width: 300px;
}

.custom-select:focus {
    border-color: var(--color-fusion);
    outline: none;
    box-shadow: 0 0 10px var(--color-fusion-glow);
}

/* Button */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition-smooth);
}

.btn-secondary {
    background-color: transparent;
    border-color: var(--border-glass);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: rgba(255,255,255,0.05);
    border-color: var(--text-muted);
}

/* Glass Cards */
.card {
    border-radius: 16px;
    border: 1px solid var(--border-glass);
    overflow: hidden;
    margin-bottom: 20px;
    background-color: var(--bg-card);
}

.card.glass {
    backdrop-filter: blur(16px);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
}

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

.card-header h2, .card-header h3, .card-header h4 {
    font-size: 1.15rem;
}

.card-icon {
    font-size: 1.25rem;
}

.card-body {
    padding: 24px;
}

/* Hero card dashboard */
.dashboard-hero {
    background: linear-gradient(135deg, hsla(220, 20%, 15%, 0.4), hsla(340, 20%, 15%, 0.2));
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 25px;
    backdrop-filter: blur(12px);
    position: relative;
    overflow: hidden;
}

.dashboard-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 250px;
    height: 250px;
    background: radial-gradient(var(--color-fusion), transparent 60%);
    opacity: 0.15;
    pointer-events: none;
}

.hero-text h2 {
    font-size: 1.6rem;
    margin-bottom: 8px;
    background: linear-gradient(90deg, var(--text-primary), var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-text p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Tab Panels */
.tab-pane {
    display: none;
    animation: fadeIn 0.4s ease;
}

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

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

/* Grid helper */
.grid {
    display: grid;
    gap: 20px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-span-2 { grid-column: span 2; }

/* Sub risks action-cards */
.actionable-card {
    cursor: pointer;
    transition: var(--transition-smooth);
}

.actionable-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255,255,255,0.15);
    box-shadow: 0 8px 30px rgba(0,0,0,0.6);
}

/* Color classes & utilities */
.text-mri { color: var(--color-mri); text-shadow: 0 0 10px var(--color-mri-glow); }
.bg-mri { background-color: var(--color-mri); box-shadow: 0 0 15px var(--color-mri-glow); }
.bg-mri-dist { background-color: hsla(220, 90%, 60%, 0.7); }

.text-smartphone { color: var(--color-smartphone); text-shadow: 0 0 10px var(--color-smartphone-glow); }
.bg-smartphone { background-color: var(--color-smartphone); box-shadow: 0 0 15px var(--color-smartphone-glow); }

.text-sleep { color: var(--color-sleep); text-shadow: 0 0 10px var(--color-sleep-glow); }
.bg-sleep { background-color: var(--color-sleep); box-shadow: 0 0 15px var(--color-sleep-glow); }

.text-eeg { color: var(--color-eeg); text-shadow: 0 0 10px var(--color-eeg-glow); }
.bg-eeg { background-color: var(--color-eeg); box-shadow: 0 0 15px var(--color-eeg-glow); }

.text-ehr { color: var(--color-ehr); text-shadow: 0 0 10px var(--color-ehr-glow); }
.bg-ehr { background-color: var(--color-ehr); box-shadow: 0 0 15px var(--color-ehr-glow); }

.text-fusion { color: var(--color-fusion); text-shadow: 0 0 15px var(--color-fusion-glow); }
.color-fusion { stroke: var(--color-fusion); filter: drop-shadow(0 0 8px var(--color-fusion)); }

.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.centered { display: flex; flex-direction: column; justify-content: center; align-items: center; }
.width-100 { width: 100%; }

.phase-badge {
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1.2px;
}

.module-score-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.metric-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.metric-value {
    font-weight: 600;
}

/* Progress bars */
.progress-bar-container {
    margin-top: 15px;
}

.progress-bar-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.progress-bar-bg {
    width: 100%;
    height: 6px;
    background-color: rgba(255,255,255,0.05);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.1, 0.8, 0.2, 1);
}

/* Radial risk meter dashboard */
.overall-card {
    position: relative;
    overflow: hidden;
    border-color: hsla(340, 85%, 60%, 0.2);
}

.radial-gauge-container {
    position: relative;
    width: 150px;
    height: 150px;
    margin: 15px auto;
}

.radial-gauge {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.gauge-bg {
    fill: none;
    stroke: rgba(255,255,255,0.03);
    stroke-width: 8;
}

.gauge-bar {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 251.2; /* 2 * PI * r(40) = 251.2 */
    stroke-dashoffset: 251.2;
    transition: stroke-dashoffset 1s ease-in-out;
}

.gauge-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    display: flex;
    flex-direction: column;
}

.score-val {
    font-size: 1.8rem;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
}

.score-lbl {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.badge {
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-top: 10px;
    display: inline-block;
}

.badge-low { background-color: rgba(16, 185, 129, 0.15); color: hsl(150, 75%, 50%); border: 1px solid rgba(16, 185, 129, 0.2); }
.badge-mod { background-color: rgba(245, 158, 11, 0.15); color: hsl(38, 90%, 55%); border: 1px solid rgba(245, 158, 11, 0.2); }
.badge-high { background-color: rgba(244, 63, 94, 0.15); color: hsl(340, 85%, 60%); border: 1px solid rgba(244, 63, 94, 0.2); }

.score-desc {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    margin-top: 15px;
    line-height: 1.4;
}

/* Integration Flow Chart */
.flow-chart-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 10px;
}

.flow-nodes {
    display: flex;
    justify-content: space-between;
    width: 100%;
    gap: 10px;
}

.flow-node {
    flex: 1;
    background-color: rgba(0,0,0,0.2);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 15px 10px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.flow-node:hover {
    border-color: rgba(255,255,255,0.15);
    background-color: rgba(255,255,255,0.02);
}

.flow-node i {
    font-size: 1.4rem;
    margin-bottom: 8px;
}

.flow-node h4 {
    font-size: 0.8rem;
    margin-bottom: 6px;
    color: var(--text-muted);
}

.node-val {
    font-size: 1rem;
    font-weight: 700;
}

.flow-connector {
    display: flex;
    align-items: center;
    color: rgba(255,255,255,0.1);
    font-size: 0.8rem;
}

.flow-down-arrow {
    font-size: 1.2rem;
    color: rgba(255,255,255,0.15);
    margin: 15px 0;
}

.flow-fusion-node {
    width: 100%;
}

.fusion-box {
    background: linear-gradient(185deg, rgba(244, 63, 94, 0.05), rgba(244, 63, 94, 0.01));
    border: 1px solid hsla(340, 85%, 60%, 0.15);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.fusion-box i {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.fusion-box h3 {
    font-size: 1.05rem;
    margin-bottom: 6px;
}

.fusion-box p {
    font-size: 0.85rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.4;
}

/* Phase 1: MRI Workspace */
.mri-workspace {
    gap: 30px;
}

.drop-zone {
    width: 100%;
    height: 220px;
    border: 2px dashed rgba(255,255,255,0.15);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: var(--transition-smooth);
    background-color: rgba(0,0,0,0.1);
    padding: 20px;
    text-align: center;
}

.drop-zone:hover {
    border-color: var(--color-mri);
    background-color: var(--color-mri-glow);
}

.upload-icon {
    font-size: 2.5rem;
    color: var(--color-mri);
    margin-bottom: 15px;
}

.file-size-info {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 8px;
}

.sample-mri-picker {
    margin-top: 25px;
    width: 100%;
}

.sample-mri-picker h4 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.sample-mri-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.btn-mri-sample {
    background-color: rgba(0,0,0,0.2);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    padding: 8px 12px;
    font-size: 0.8rem;
}

.btn-mri-sample:hover {
    border-color: var(--color-mri);
    background-color: var(--color-mri-glow);
}

.preview-container {
    width: 100%;
    height: 200px;
    background-color: rgba(0,0,0,0.2);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
}

#mri-preview-img {
    height: 100%;
    width: auto;
    object-fit: contain;
}

.img-placeholder {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: rgba(255,255,255,0.1);
}

.img-placeholder i {
    font-size: 3rem;
    margin-bottom: 10px;
}

.img-placeholder span {
    font-size: 0.85rem;
}

.results-box {
    background-color: rgba(0,0,0,0.25);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 20px;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.result-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.result-value {
    font-size: 1.05rem;
    font-weight: 600;
}

.class-distribution h4 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.dist-row {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.8rem;
}

.dist-row span {
    width: 170px;
    color: var(--text-muted);
}

.bar-container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.bar {
    height: 8px;
    background-color: var(--color-mri);
    border-radius: 4px;
    width: 0%;
    transition: width 0.6s cubic-bezier(0.1, 0.8, 0.2, 1);
}

/* Phase 2: Smartphone Telemetry Sliders */
.slider-group {
    margin-bottom: 18px;
}

.slider-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.slider-info label {
    color: var(--text-muted);
}

.slider-info span {
    font-weight: 600;
}

.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.05);
    border-radius: 3px;
    outline: none;
    transition: var(--transition-smooth);
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-smartphone);
    cursor: pointer;
    box-shadow: 0 0 10px var(--color-smartphone-glow);
    transition: transform 0.1s;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.gauge-header {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.score-display {
    margin: 20px 0;
}

.large-score {
    font-size: 3.5rem;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
}

.explanation {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.4;
}

/* Phase 3: Sleep EEG Staging */
.drop-zone.small {
    height: 130px;
}

.upload-icon-small {
    font-size: 2rem;
    margin-bottom: 8px;
}

.card-dark {
    background-color: rgba(0,0,0,0.15);
}

.sleep-presets {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-sleep-preset, .btn-eeg-preset {
    background-color: rgba(255,255,255,0.02);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    text-align: left;
    padding: 10px 15px;
    font-size: 0.85rem;
}

.btn-sleep-preset:hover {
    border-color: var(--color-sleep);
    background-color: var(--color-sleep-glow);
}

.btn-eeg-preset:hover {
    border-color: var(--color-eeg);
    background-color: var(--color-eeg-glow);
}

.sleep-legend {
    display: flex;
    gap: 12px;
}

.legend-item {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.legend-dot.wake { background-color: hsl(0, 85%, 60%); }
.legend-dot.n1 { background-color: hsl(38, 90%, 55%); }
.legend-dot.n2 { background-color: hsl(50, 90%, 50%); }
.legend-dot.n3 { background-color: hsl(210, 85%, 55%); }
.legend-dot.rem { background-color: hsl(150, 75%, 45%); }

.hypnogram-container {
    width: 100%;
    height: 180px;
    background-color: rgba(0,0,0,0.3);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    align-items: center;
    position: relative;
}

.metric-card {
    background-color: rgba(0,0,0,0.2);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
}

.metric-lbl {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 6px;
}

/* Phase 4: EEG Imaginería */
.waveform-container {
    background-color: rgba(0,0,0,0.3);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    padding: 15px;
    height: 180px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#eeg-signal-canvas {
    width: 100%;
    height: 100%;
}

.trials-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 6px;
    max-height: 80px;
    overflow-y: auto;
}

.trial-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin: 2px auto;
    position: relative;
}

.trial-dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.6rem;
    color: white;
    font-weight: 700;
}

.trial-dot.t1 { background-color: hsl(200, 80%, 50%); } /* Left Hand -> Blue */
.trial-dot.t2 { background-color: hsl(300, 80%, 50%); } /* Right Hand -> Magenta */

.trial-dot.t1::after { content: 'L'; }
.trial-dot.t2::after { content: 'R'; }

/* Phase 5: EHR */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background-color: hsla(220, 20%, 6%, 0.8);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    transition: var(--transition-smooth);
}

.form-control:focus {
    border-color: var(--color-ehr);
    outline: none;
    box-shadow: 0 0 8px var(--color-ehr-glow);
}

.divider {
    border: none;
    border-top: 1px solid var(--border-glass);
    margin: 15px 0;
}

.fusion-inputs-summary h4 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.bold-val {
    font-weight: 600;
}

/* Clinical summary panel */
.summary-panel {
    width: 300px;
    background-color: hsla(220, 22%, 5%, 0.95);
    border-left: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.summary-header {
    margin-bottom: 25px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-glass);
}

.summary-header h3 {
    font-size: 1.1rem;
}

.summary-header .subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.patient-brief-box {
    background-color: rgba(255,255,255,0.02);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    padding: 12px;
    font-size: 0.85rem;
    margin-bottom: 20px;
}

.patient-brief-box p {
    margin-bottom: 4px;
}

.summary-metrics {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 25px;
}

.metric-item span {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 4px;
}

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

.bar-progress .bar {
    height: 6px;
    border-radius: 3px;
    width: 0%;
    transition: width 0.6s cubic-bezier(0.1, 0.8, 0.2, 1);
}

.bar-progress span {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    width: 35px;
    text-align: right;
    margin: 0;
}

.final-assessment-box {
    background: linear-gradient(135deg, rgba(244, 63, 94, 0.08), rgba(244, 63, 94, 0.02));
    border: 1px solid hsla(340, 85%, 60%, 0.15);
    border-radius: 12px;
    padding: 18px;
    text-align: center;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.final-assessment-box h4 {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fusion-risk-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 10px 0;
}

.fusion-risk-display .pct {
    font-size: 2.2rem;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
}

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

.summary-footer {
    padding-top: 15px;
    border-top: 1px solid var(--border-glass);
    margin-top: 15px;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.3;
}

/* Print views */
.print-only {
    display: none;
}

@media print {
    body {
        background-color: white !important;
        color: black !important;
        font-size: 11pt !important;
    }
    
    .disclaimer-banner, .app-container {
        display: none !important;
    }
    
    .print-only {
        display: block !important;
        padding: 20px;
    }
    
    .print-header {
        text-align: center;
        margin-bottom: 25px;
    }
    
    .print-warning {
        color: #b91c1c;
        border: 2px solid #b91c1c;
        padding: 8px;
        margin-top: 10px;
        font-size: 10pt;
    }
    
    .print-section {
        margin-bottom: 30px;
    }
    
    .print-section h3 {
        border-bottom: 1.5px solid #27272a;
        padding-bottom: 4px;
        margin-bottom: 15px;
        font-size: 13pt;
        color: #18181b;
    }
    
    .print-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 15px;
    }
    
    .print-table td, .print-table th {
        border: 1px solid #d4d4d8;
        padding: 8px 12px;
        font-size: 10pt;
    }
    
    .print-table th {
        background-color: #f4f4f5;
        text-align: left;
    }
    
    .print-result-box {
        border: 2px solid #27272a;
        padding: 20px;
        background-color: #fafafa;
        max-width: 500px;
        margin: 0 auto;
        border-radius: 8px;
    }
    
    .print-score-row {
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 20px;
        margin: 15px 0;
    }
    
    .print-score {
        font-size: 28pt;
        font-weight: 700;
        font-family: 'Space Grotesk', sans-serif;
    }
    
    .print-level {
        font-size: 14pt;
        font-weight: 600;
        text-transform: uppercase;
    }
    
    .print-footer {
        margin-top: 50px;
        border-top: 1px solid #d4d4d8;
        padding-top: 15px;
        font-size: 8pt;
        text-align: center;
        color: #71717a;
        line-height: 1.4;
    }
}

/* ==========================================================================
   Full-Stack Authentication and CRUD UI extensions
   ========================================================================== */

/* Authentication Sidebar Module */
.sidebar-user-section {
    padding: 12px 16px;
    margin: 10px 16px 20px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.username-badge {
    display: block;
    font-weight: bold;
    color: var(--color-fusion);
    margin-bottom: 4px;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-link {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition-smooth);
}

.logout-link:hover {
    color: #ef5350;
}

/* Frosted Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    width: 90%;
    max-width: 500px;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    position: relative;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 14px;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
}

.btn-close-modal {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.3rem;
    transition: color 0.2s;
    padding: 0;
}

.btn-close-modal:hover {
    color: #fff;
}

/* Modals Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    color: #fff;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-fusion);
    box-shadow: 0 0 0 2px rgba(186, 104, 200, 0.15);
}

.auth-switch-text {
    text-align: center;
    font-size: 0.88rem;
    color: var(--text-muted);
    margin: 12px 0 0;
}

.auth-switch-text a {
    color: var(--color-fusion);
    text-decoration: none;
    font-weight: 600;
}

.auth-switch-text a:hover {
    text-decoration: underline;
}

.auth-error-msg {
    font-size: 0.88rem;
    padding: 10px;
    background: rgba(239, 83, 80, 0.1);
    border: 1px solid rgba(239, 83, 80, 0.2);
    border-radius: 6px;
    margin-bottom: 16px;
}

/* Scores Summary Previews inside Modals */
.saved-scores-preview {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
}

.saved-scores-preview h4 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.bold-val {
    font-weight: bold;
    color: #fff;
}

/* Database Table styles */
.db-records-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.db-records-table th, 
.db-records-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.92rem;
}

.db-records-table th {
    background: rgba(255, 255, 255, 0.02);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.db-records-table tbody tr {
    transition: background-color 0.2s;
}

.db-records-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.01);
}

/* CRUD buttons */
.btn-crud {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 6px 10px;
    border-radius: 6px;
    transition: background-color 0.2s, color 0.2s;
}

.btn-crud-edit {
    color: var(--color-smartphone);
}

.btn-crud-edit:hover {
    background-color: rgba(77, 208, 225, 0.1);
}

.btn-crud-delete {
    color: #ef5350;
}

.btn-crud-delete:hover {
    background-color: rgba(239, 83, 80, 0.1);
}

/* Table Responsive wrapper */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Keyframe animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* ==========================================================================
   Week 3 AI Upgrades: Chatbot Panel & AI Clinical Summary Box
   ========================================================================== */

/* CoreAI Assistant Chatbot Widget */
.chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 320px;
    border-radius: 12px 12px 0 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chatbot-header {
    background: rgba(186, 104, 200, 0.25);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-chatbot-toggle {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 0.9rem;
    transition: transform 0.3s;
}

.chatbot-body {
    height: 350px;
    display: flex;
    flex-direction: column;
    background: rgba(15, 23, 42, 0.98);
}

.chatbot-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    max-width: 85%;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    line-height: 1.4;
}

.chat-message.assistant {
    background: rgba(255, 255, 255, 0.04);
    color: #e2e8f0;
    align-self: flex-start;
    border-left: 3px solid var(--color-fusion);
}

.chat-message.user {
    background: var(--color-fusion);
    color: #fff;
    align-self: flex-end;
}

.chatbot-input-area {
    display: flex;
    padding: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.3);
}

.chatbot-input-area input {
    flex: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 8px 12px;
    color: #fff;
    font-size: 0.85rem;
}

.chatbot-input-area input:focus {
    outline: none;
    border-color: var(--color-fusion);
}

.chatbot-input-area button {
    background: transparent;
    border: none;
    color: var(--color-fusion);
    padding: 0 10px;
    cursor: pointer;
    font-size: 1rem;
    transition: transform 0.2s;
}

.chatbot-input-area button:hover {
    transform: scale(1.1);
}

/* Typing loader animation */
.chat-typing {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 6px 12px;
}
.chat-typing span {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: blink 1.4s infinite both;
}
.chat-typing span:nth-child(2) { animation-delay: .2s; }
.chat-typing span:nth-child(3) { animation-delay: .4s; }

@keyframes blink {
    0% { opacity: .2; }
    20% { opacity: 1; }
    100% { opacity: .2; }
}

/* Markdown styling inside AI components */
.ai-summary-box p {
    margin-bottom: 8px;
}
.ai-summary-box ul, .ai-summary-box ol {
    margin-left: 16px;
    margin-bottom: 8px;
}
.ai-summary-box li {
    margin-bottom: 4px;
}
.ai-summary-box h3 {
    font-size: 0.95rem;
    margin-top: 12px;
    margin-bottom: 6px;
    color: var(--color-fusion);
}
.ai-summary-box h4 {
    font-size: 0.9rem;
    margin-top: 10px;
    margin-bottom: 4px;
    color: var(--color-fusion);
}

/* ==========================================================================
   Mobile Responsive Adjustments (under 768px)
   ========================================================================== */

/* Overflow protection globally */
body, html {
    overflow-x: hidden;
    max-width: 100vw;
}

@media (max-width: 768px) {
    /* Reset heights and container display */
    .app-container {
        flex-direction: column;
        height: auto !important;
        min-height: calc(100vh - 32px);
    }

    /* Mobile header bar toggle */
    .mobile-header {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 12px 16px;
        background: rgba(15, 23, 42, 0.98);
        border-bottom: 1px solid var(--border-glass);
        position: sticky;
        top: 0;
        z-index: 1000;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }

    .btn-hamburger {
        background: transparent;
        border: none;
        color: #fff;
        font-size: 1.3rem;
        cursor: pointer;
        padding: 4px;
        transition: transform 0.2s;
    }
    .btn-hamburger:active {
        transform: scale(0.9);
    }

    /* Left Sidebar Overlay Mode */
    .sidebar {
        position: fixed;
        top: 0;
        left: -280px; /* Off-screen */
        width: 260px;
        height: 100%;
        z-index: 1002;
        transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: 10px 0 30px rgba(0,0,0,0.8);
        background-color: hsla(220, 22%, 5%, 0.98);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }

    .sidebar.active {
        left: 0;
    }

    .btn-close-sidebar {
        display: block !important;
        background: transparent;
        border: none;
        color: var(--text-muted);
        font-size: 1.3rem;
        cursor: pointer;
        padding: 0;
        margin-left: auto;
    }

    /* Main Workspace Adjustment */
    .main-content {
        padding: 16px !important;
        width: 100% !important;
        overflow-x: hidden;
    }

    /* Sticky summary panel on the right becomes static bottom card */
    .summary-panel {
        width: 100% !important;
        height: auto !important;
        border-left: none !important;
        border-top: 1px solid var(--border-glass) !important;
        padding: 20px !important;
        background-color: hsla(220, 22%, 5%, 0.95) !important;
    }

    /* Grid columns collapse to 100% single column */
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .grid-span-2 {
        grid-column: span 1 !important;
    }

    /* Avoid horizontal overflow of dropdowns and form inputs */
    .custom-select {
        min-width: 100% !important;
        width: 100% !important;
    }

    .patient-selector-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        width: 100%;
    }

    /* Flex forms wrapping */
    .form-grid {
        grid-template-columns: 1fr !important;
    }

    /* Tabs wrapping and scrolling */
    .tabs-header {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .tab-btn {
        flex-grow: 1;
        text-align: center;
        font-size: 0.8rem !important;
        padding: 8px 12px !important;
    }

    /* Compact UI components */
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 20px;
    }

    .content-header h2 {
        font-size: 1.3rem;
    }

    /* Chatbot Responsive resizing */
    .chatbot-widget {
        width: 280px !important;
        bottom: 12px !important;
        right: 12px !important;
        border: 1px solid rgba(255,255,255,0.15) !important;
    }
    
    .chatbot-body {
        height: 280px !important;
    }

    .chatbot-messages {
        padding: 10px !important;
        gap: 8px !important;
    }

    .chat-message {
        font-size: 0.8rem !important;
        padding: 8px 10px !important;
    }

    /* Tables scrollable on tiny devices (390px / 430px) */
    .table-responsive {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-top: 10px;
    }

    /* EEG signal canvas */
    #eeg-signal-canvas {
        height: 120px !important;
    }

    /* Edit modals size limit */
    .modal-content {
        width: 95% !important;
        padding: 16px !important;
        max-height: 90vh;
        overflow-y: auto;
    }
}



