/* ===== APP STYLES (Login + Dashboards) ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    line-height: 1.6;
    transition: background 0.4s cubic-bezier(0.4, 0, 0.2, 1), color 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
a { text-decoration: none; color: inherit; }

/* ===== DESIGN SYSTEM — LIGHT-FIRST ===== */
:root {
    /* Semantic accent palette — vibrant, WCAG-AA on white */
    --color-purple: #7c3aed;
    --color-green:  #059669;
    --color-red:    #dc2626;
    --color-yellow: #d97706;
    --color-blue:   #2563eb;
    --color-purple-bg: rgba(124,58,237,0.09);
    --color-green-bg:  rgba(5,150,105,0.09);
    --color-red-bg:    rgba(220,38,38,0.09);
    --color-yellow-bg: rgba(217,119,6,0.09);
    --color-blue-bg:   rgba(37,99,235,0.09);

    /* Light surfaces (default — no class required) */
    --bg-dark:       #f8fafc;
    --bg-card:       #ffffff;
    --bg-card-hover: #f1f5f9;
    --border:        #e2e8f0;
    --text:          #0f172a;
    --text-muted:    #64748b;
    --glow:          rgba(99,102,241,0.08);

    /* Default accent — overridden per dashboard */
    --accent:       #6366f1;
    --accent-2:     #06d6a0;
    --accent-light: rgba(99,102,241,0.1);
    --gradient:     linear-gradient(135deg, #6366f1, #06d6a0);
    --primary:      #6366f1;
    --primary-light:#818cf8;

    /* Elevation shadows */
    --shadow-sm:      0 1px 3px rgba(15,23,42,0.07), 0 1px 2px rgba(15,23,42,0.04);
    --shadow-md:      0 4px 16px rgba(15,23,42,0.09), 0 2px 4px rgba(15,23,42,0.04);
    --shadow-lg:      0 12px 40px rgba(15,23,42,0.11), 0 4px 12px rgba(15,23,42,0.05);
    --shadow-colored: 0 8px 24px rgba(99,102,241,0.22);

    /* Layout */
    --radius:           14px;
    --radius-sm:        8px;
    --sidebar-width:    272px;
    --transition-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===== PER-DASHBOARD ACCENT TOKENS ===== */
/* Doctor — Clinical Blue */
[data-dashboard="doctor"] {
    --accent:         #2563eb;
    --accent-2:       #60a5fa;
    --accent-light:   rgba(37,99,235,0.1);
    --gradient:       linear-gradient(135deg, #1e40af, #3b82f6);
    --shadow-colored: 0 8px 24px rgba(37,99,235,0.22);
    --bg-dark:        #eff6ff;
    --glow:           rgba(37,99,235,0.07);
    --primary:        #2563eb;
    --primary-light:  #60a5fa;
}
/* Lab — Technical Violet */
[data-dashboard="lab"] {
    --accent:         #7c3aed;
    --accent-2:       #a78bfa;
    --accent-light:   rgba(124,58,237,0.1);
    --gradient:       linear-gradient(135deg, #6d28d9, #a78bfa);
    --shadow-colored: 0 8px 24px rgba(124,58,237,0.22);
    --bg-dark:        #faf5ff;
    --glow:           rgba(124,58,237,0.07);
    --primary:        #7c3aed;
    --primary-light:  #a78bfa;
}
/* Patient — Health Green */
[data-dashboard="patient"] {
    --accent:         #059669;
    --accent-2:       #34d399;
    --accent-light:   rgba(5,150,105,0.1);
    --gradient:       linear-gradient(135deg, #047857, #34d399);
    --shadow-colored: 0 8px 24px rgba(5,150,105,0.22);
    --bg-dark:        #f0fdf4;
    --glow:           rgba(5,150,105,0.07);
    --primary:        #059669;
    --primary-light:  #34d399;
}

/* Super Admin — Deep Indigo */
[data-dashboard="super-admin"] {
    --accent:         #4f46e5;
    --accent-2:       #818cf8;
    --accent-light:   rgba(79,70,229,0.1);
    --gradient:       linear-gradient(135deg, #3730a3, #6366f1);
    --shadow-colored: 0 8px 24px rgba(79,70,229,0.22);
    --bg-dark:        #eef2ff;
    --glow:           rgba(79,70,229,0.07);
    --primary:        #4f46e5;
    --primary-light:  #818cf8;
}
/* Hospital Admin — Teal */
[data-dashboard="hospital-admin"] {
    --accent:         #0d9488;
    --accent-2:       #2dd4bf;
    --accent-light:   rgba(13,148,136,0.1);
    --gradient:       linear-gradient(135deg, #0f766e, #14b8a6);
    --shadow-colored: 0 8px 24px rgba(13,148,136,0.22);
    --bg-dark:        #f0fdfa;
    --glow:           rgba(13,148,136,0.07);
    --primary:        #0d9488;
    --primary-light:  #2dd4bf;
}
/* Nurse — Rose */
[data-dashboard="nurse"] {
    --accent:         #e11d48;
    --accent-2:       #fb7185;
    --accent-light:   rgba(225,29,72,0.1);
    --gradient:       linear-gradient(135deg, #be123c, #f43f5e);
    --shadow-colored: 0 8px 24px rgba(225,29,72,0.22);
    --bg-dark:        #fff1f2;
    --glow:           rgba(225,29,72,0.07);
    --primary:        #e11d48;
    --primary-light:  #fb7185;
}

/* ===== DARK THEME (preserved for toggle) ===== */
[data-theme="dark"] {
    --bg-dark:       #0a0a0a;
    --bg-card:       #111111;
    --bg-card-hover: #1c1c1c;
    --border:        #262626;
    --text:          #f5f5f5;
    --text-muted:    #737373;
    --glow:          var(--bg-card-hover);
    --shadow-sm:     0 1px 3px rgba(0,0,0,0.4);
    --shadow-md:     0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg:     0 12px 40px rgba(0,0,0,0.5);
    --color-purple: #a78bfa;
    --color-green:  #34d399;
    --color-red:    #f87171;
    --color-yellow: #fbbf24;
    --color-blue:   #60a5fa;
    --color-purple-bg: rgba(167,139,250,0.12);
    --color-green-bg:  rgba(52,211,153,0.12);
    --color-red-bg:    rgba(248,113,113,0.12);
    --color-yellow-bg: rgba(251,191,36,0.12);
    --color-blue-bg:   rgba(96,165,250,0.12);
}
[data-theme="dark"][data-dashboard="doctor"]       { --accent:#3b82f6; --accent-light:rgba(59,130,246,0.14); --bg-dark:#020c1e; --gradient:linear-gradient(135deg,#1e40af,#3b82f6); }
[data-theme="dark"][data-dashboard="lab"]          { --accent:#a78bfa; --accent-light:rgba(167,139,250,0.14); --bg-dark:#0d0714; --gradient:linear-gradient(135deg,#5b21b6,#a78bfa); }
[data-theme="dark"][data-dashboard="patient"]      { --accent:#34d399; --accent-light:rgba(52,211,153,0.14); --bg-dark:#021a0f; --gradient:linear-gradient(135deg,#065f46,#34d399); }
[data-theme="dark"][data-dashboard="super-admin"]  { --accent:#818cf8; --accent-light:rgba(129,140,248,0.14); --bg-dark:#060612; --gradient:linear-gradient(135deg,#3730a3,#6366f1); }
[data-theme="dark"][data-dashboard="hospital-admin"]{ --accent:#2dd4bf; --accent-light:rgba(45,212,191,0.14); --bg-dark:#021713; --gradient:linear-gradient(135deg,#0f766e,#14b8a6); }
[data-theme="dark"][data-dashboard="nurse"]        { --accent:#fb7185; --accent-light:rgba(251,113,133,0.14); --bg-dark:#1a020a; --gradient:linear-gradient(135deg,#9f1239,#f43f5e); }

/* Dark-theme component overrides (restores dark-specific colors) */
/* Auth pages always light — override even if dark theme is active */
[data-theme="dark"] .auth-form-panel { background: #ffffff !important; color: #0f172a !important; }
[data-theme="dark"] .auth-page { background: #ffffff; }
[data-theme="dark"] .login-card { box-shadow: 0 25px 60px rgba(0,0,0,0.6); }
[data-theme="dark"] .login-bg {
    background: radial-gradient(ellipse 80% 60% at 50% 30%, var(--bg-card-hover), transparent),
                radial-gradient(ellipse 60% 50% at 80% 70%, var(--bg-card), transparent);
}
[data-theme="dark"] .form-group input { background: var(--bg-card-hover); }
[data-theme="dark"] .form-group input:focus { border-color: var(--border); background: var(--bg-card-hover); }
[data-theme="dark"] .role-btn { background: var(--bg-card-hover); border-color: var(--border); }
[data-theme="dark"] .role-btn:hover { border-color: var(--accent-light); }
[data-theme="dark"] .role-btn.active { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }
[data-theme="dark"] .nav-item:hover { background: var(--bg-card-hover); }
[data-theme="dark"] .data-table th { background: var(--bg-card); }
[data-theme="dark"] .data-table tr:hover { background: var(--bg-card-hover); }
[data-theme="dark"] .sidebar { background: #0d0d0d; border-right-color: #1a1a1a; }
[data-theme="dark"] .user-info:hover { background: var(--bg-card-hover); }
[data-theme="dark"] .dash-card:hover { border-color: var(--accent-light); }
[data-theme="dark"] .chart-bar { background: linear-gradient(to top, var(--accent-light), var(--accent)); }

/* Gradient text utility */
.gradient-text { background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 24px; position: relative; overflow: hidden;
}
.login-bg {
    position: absolute; inset: 0;
    background: radial-gradient(ellipse 80% 60% at 50% 30%, var(--accent-light), transparent),
                radial-gradient(ellipse 60% 50% at 80% 70%, rgba(6,214,160,0.06), transparent);
}
.login-container { position: relative; width: 100%; max-width: 440px; }
.login-logo { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 40px; font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.4rem; }
.login-logo .logo-icon { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; background: var(--gradient); border-radius: 12px; font-size: 1.5rem; font-weight: 800; color: #fff; }
.login-logo .logo-accent { color: var(--accent); }
.login-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 20px;
    padding: 40px; box-shadow: var(--shadow-lg);
    transition: background 0.4s var(--transition-smooth), border-color 0.4s var(--transition-smooth), box-shadow 0.4s var(--transition-smooth);
    animation: fadeSlideUp 0.6s var(--transition-smooth) both;
}
.login-card h2 { font-family: 'Space Grotesk', sans-serif; font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; }
.login-card .subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 32px; }

/* Role Selector */
.role-selector { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 28px; }
.role-btn {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 16px 8px; border-radius: 12px;
    background: var(--bg-card-hover); border: 1.5px solid var(--border);
    cursor: pointer; transition: all 0.3s; color: var(--text-muted);
    font-size: 0.75rem; font-weight: 600; text-align: center;
}
.role-btn:hover { border-color: var(--accent); color: var(--text); }
.role-btn.active { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }
.role-btn svg { width: 28px; height: 28px; }
.role-btn input { display: none; }

/* Form Fields */
.form-group { margin-bottom: 20px; position: relative; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.form-group input {
    width: 100%; padding: 14px 16px; border-radius: 10px;
    background: var(--bg-card-hover); border: 1.5px solid var(--border);
    color: var(--text); font-size: 0.95rem; font-family: inherit;
    transition: all 0.3s; outline: none;
}
.form-group input:focus { border-color: var(--accent); background: var(--bg-card); box-shadow: 0 0 0 3px var(--accent-light); }
.form-group input::placeholder { color: var(--text-muted); }
.form-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.form-row label { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text-muted); cursor: pointer; }
.form-row label input[type="checkbox"] { accent-color: var(--primary); }
.form-row a { font-size: 0.85rem; color: var(--primary-light); }

.btn-login {
    width: 100%; padding: 16px; border: none; border-radius: 12px;
    background: var(--gradient); color: #fff;
    font-size: 1rem; font-weight: 700; cursor: pointer;
    font-family: inherit; transition: all 0.35s var(--transition-smooth);
    box-shadow: var(--shadow-colored);
    letter-spacing: -0.01em;
}
.btn-login:hover { transform: translateY(-2px); box-shadow: var(--shadow-colored), 0 12px 40px rgba(0,0,0,0.15); filter: brightness(1.06); }
.btn-login:active { transform: translateY(0); }
.login-footer { text-align: center; margin-top: 24px; font-size: 0.9rem; color: var(--text-muted); }
.login-footer a { color: var(--text); font-weight: 600; transition: opacity 0.2s; }
.login-footer a:hover { opacity: 0.7; }
.back-link { display: block; text-align: center; margin-top: 24px; font-size: 0.85rem; color: var(--text-muted); transition: color 0.2s; }
.back-link:hover { color: var(--text); }

/* ===== DASHBOARD LAYOUT ===== */
.dashboard { display: flex; min-height: 100vh; }

/* ===== REDESIGNED SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width); background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 0; display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
    transition: transform 0.4s var(--transition-smooth), background 0.4s var(--transition-smooth), border-color 0.4s var(--transition-smooth);
}
.sidebar-logo {
    display: flex; align-items: center; gap: 12px; padding: 24px 20px 20px;
    margin-bottom: 0; border-bottom: 1px solid var(--border);
    font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.2rem; flex-shrink: 0;
    transition: border-color 0.4s var(--transition-smooth);
}
.sidebar-logo .logo-icon {
    width: 36px; height: 36px; background: var(--gradient); border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; font-weight: 800; color: #fff;
    box-shadow: var(--shadow-colored);
    transition: transform 0.3s var(--transition-bounce), box-shadow 0.3s ease;
}
.sidebar-logo:hover .logo-icon {
    transform: scale(1.08) rotate(-3deg);
    box-shadow: var(--shadow-colored), 0 6px 20px rgba(0,0,0,0.1);
}
.sidebar-logo .logo-accent { color: var(--color-green); }
.sidebar-nav {
    flex: 1; padding: 16px 12px 16px; overflow-y: auto; overflow-x: hidden;
    scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
.nav-section { margin-bottom: 20px; }
.nav-section-title {
    font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.1em; color: var(--text-muted); padding: 0 12px 6px;
    margin-bottom: 4px; opacity: 0.6;
    transition: opacity 0.3s ease;
}
.nav-section:hover .nav-section-title { opacity: 1; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 10px; font-size: 0.85rem; font-weight: 500;
    color: var(--text-muted); cursor: pointer;
    margin-bottom: 1px; position: relative; border: none; background: none; width: 100;
    transition: all 0.25s var(--transition-smooth);
}
.nav-item:hover {
    background: var(--bg-card-hover); color: var(--text);
    transform: translateX(3px);
}
.nav-item.active {
    background: var(--accent-light); color: var(--accent); font-weight: 600;
    box-shadow: none;
    border-left: 3px solid var(--accent); padding-left: 9px;
}
.nav-item.active svg { color: var(--accent); }
.nav-item svg {
    width: 18px; height: 18px; flex-shrink: 0;
    transition: transform 0.25s var(--transition-smooth);
}
.nav-item:hover svg { transform: scale(1.1); }
.sidebar-footer {
    padding: 16px 12px 20px; border-top: 1px solid var(--border); flex-shrink: 0;
    transition: border-color 0.4s var(--transition-smooth);
}
.user-info {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
    transition: background 0.3s ease;
}
.user-info:hover { background: var(--bg-card-hover); }
.user-avatar {
    width: 36px; height: 36px; border-radius: 10px; background: var(--accent-light);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.8rem; color: var(--accent); flex-shrink: 0;
    transition: transform 0.3s var(--transition-bounce);
}
.user-info:hover .user-avatar { transform: scale(1.06); }
.user-name { font-size: 0.85rem; font-weight: 600; letter-spacing: -0.01em; }
.user-role { font-size: 0.72rem; color: var(--text-muted); }

/* Main Content */
.main-content {
    flex: 1; margin-left: var(--sidebar-width); padding: 32px;
    transition: background 0.4s var(--transition-smooth);
}
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 32px; flex-wrap: wrap; gap: 16px;
    padding: 24px 28px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    border-left: 4px solid var(--accent);
    box-shadow: var(--shadow-sm);
    position: relative;
}
.page-header h1 {
    font-family: 'Space Grotesk', sans-serif; font-size: 1.8rem; font-weight: 700;
    letter-spacing: -0.02em;
}
.page-header p { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }
.header-actions { display: flex; gap: 12px; align-items: center; }

/* Dashboard Cards */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-bottom: 32px; }
.dash-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 24px; transition: all 0.35s var(--transition-smooth);
    animation: fadeSlideUp 0.5s var(--transition-smooth) both;
}
.dash-card:nth-child(1) { animation-delay: 0s; }
.dash-card:nth-child(2) { animation-delay: 0.06s; }
.dash-card:nth-child(3) { animation-delay: 0.12s; }
.dash-card:nth-child(4) { animation-delay: 0.18s; }
.dash-card:hover {
    border-color: var(--accent-light); transform: translateY(-3px);
    box-shadow: var(--shadow-colored);
}
.dash-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.dash-card-icon {
    width: 44px; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.3s var(--transition-bounce);
}
.dash-card:hover .dash-card-icon { transform: scale(1.1); }
.dash-card-icon.purple { background: var(--color-purple-bg); color: var(--color-purple); }
.dash-card-icon.blue { background: var(--color-blue-bg); color: var(--color-blue); }
.dash-card-icon.green { background: var(--color-green-bg); color: var(--color-green); }
.dash-card-icon.red { background: var(--color-red-bg); color: var(--color-red); }
.dash-card-icon.yellow { background: var(--color-yellow-bg); color: var(--color-yellow); }
.dash-card-icon.accent { background: var(--accent-light); color: var(--accent); }
.dash-card-icon svg { width: 22px; height: 22px; }
.dash-card-trend { font-size: 0.8rem; font-weight: 600; padding: 4px 8px; border-radius: 6px; }
.dash-card-trend.up { color: var(--color-green); background: var(--color-green-bg); }
.dash-card-trend.down { color: var(--color-red); background: var(--color-red-bg); }
.dash-card .value {
    font-family: 'Space Grotesk', sans-serif; font-size: 2rem; font-weight: 700;
    margin-bottom: 4px; letter-spacing: -0.03em;
}
.dash-card .label { font-size: 0.85rem; color: var(--text-muted); }
.dash-card-footer { padding-top: 14px; margin-top: 14px; border-top: 1px solid var(--border); }
.dash-card-action { font-size: 0.78rem; font-weight: 600; color: var(--accent); cursor: pointer; transition: gap 0.2s; }
.dash-card-action:hover { gap: 6px; }
.dash-card.critical { border-color: rgba(220,38,38,0.3); box-shadow: 0 4px 16px rgba(220,38,38,0.08); }
.dash-card.critical:hover { border-color: var(--color-red); box-shadow: 0 8px 24px rgba(220,38,38,0.18); }

/* Quick Actions Bar */
.quick-actions-bar {
    display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap;
    animation: fadeSlideUp 0.4s var(--transition-smooth) both;
}
.quick-action-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 16px; border-radius: 10px;
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text); font-size: 0.85rem; font-weight: 600;
    cursor: pointer; transition: all 0.2s var(--transition-smooth);
    position: relative;
}
.quick-action-btn:hover {
    border-color: var(--accent); color: var(--accent);
    transform: translateY(-2px); box-shadow: var(--shadow-md);
}
.quick-action-btn.primary {
    background: var(--accent); color: #fff; border-color: var(--accent);
}
.quick-action-btn.primary:hover {
    background: var(--primary-light); border-color: var(--primary-light);
}
.quick-action-btn svg { width: 18px; height: 18px; }
.quick-action-badge {
    position: absolute; top: -6px; right: -6px;
    background: var(--color-red); color: #fff;
    font-size: 0.68rem; font-weight: 700;
    padding: 2px 6px; border-radius: 10px;
    min-width: 18px; text-align: center;
}

/* Dashboard Split Grid (Widgets) */
.dashboard-split-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 32px;
}
@media (max-width: 960px) { .dashboard-split-grid { grid-template-columns: 1fr; } }

/* Dashboard Widget */
.dashboard-widget {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px;
    transition: all 0.3s var(--transition-smooth);
    animation: fadeSlideUp 0.5s var(--transition-smooth) both;
}
.dashboard-widget:hover { border-color: var(--accent-light); box-shadow: var(--shadow-md); }
.widget-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.widget-header h3 { font-size: 0.95rem; font-weight: 700; font-family: 'Space Grotesk', sans-serif; }
.widget-count {
    font-size: 0.75rem; font-weight: 700; padding: 4px 10px;
    border-radius: 20px; background: var(--bg-card-hover); color: var(--text-muted);
}
.widget-count.critical { background: var(--color-red-bg); color: var(--color-red); }
.widget-footer { padding-top: 14px; margin-top: 14px; border-top: 1px solid var(--border); }
.full-width { width: 100%; }

/* Patient Queue List */
.patient-queue-list { display: flex; flex-direction: column; gap: 0; }
.patient-queue-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border-radius: 10px;
    margin-bottom: 8px; background: var(--bg-card-hover);
    border: 1px solid transparent; transition: all 0.2s;
}
.patient-queue-item:hover { border-color: var(--accent-light); background: var(--bg-card); }
.patient-queue-item.priority-high { border-left: 3px solid var(--color-red); }
.patient-queue-item.priority-medium { border-left: 3px solid var(--color-yellow); }
.patient-queue-item.priority-low { border-left: 3px solid var(--color-green); }
.patient-queue-info { display: flex; flex-direction: column; gap: 2px; }
.patient-queue-name { font-size: 0.88rem; font-weight: 600; color: var(--text); }
.patient-queue-reason { font-size: 0.75rem; color: var(--text-muted); }
.patient-queue-item.priority-high .patient-queue-reason { color: var(--color-red); }
.patient-queue-item.priority-medium .patient-queue-reason { color: var(--color-yellow); }
.patient-queue-actions { display: flex; gap: 6px; }
.btn-icon {
    width: 32px; height: 32px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text-muted); cursor: pointer;
    transition: all 0.2s;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }
.btn-icon svg { width: 16px; height: 16px; }
.btn-icon.btn-call:hover { border-color: var(--color-green); color: var(--color-green); }

/* Critical Results List */
.critical-results-list { display: flex; flex-direction: column; gap: 0; }
.critical-result-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 0; border-bottom: 1px solid var(--border);
}
.critical-result-item:last-child { border-bottom: none; }
.critical-result-icon {
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--color-red-bg); color: var(--color-red);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.critical-result-icon svg { width: 18px; height: 18px; }
.critical-result-info { flex: 1; }
.critical-result-name { font-size: 0.85rem; font-weight: 600; color: var(--text); display: block; }
.critical-result-test { font-size: 0.75rem; color: var(--text-muted); display: block; margin-top: 2px; }
.critical-result-time { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; }

/* Table Actions */
.table-actions { display: flex; gap: 6px; }

/* Compact Charts Row */
.dashboard-charts-row {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 24px;
}
@media (max-width: 1100px) { .dashboard-charts-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .dashboard-charts-row { grid-template-columns: 1fr; } }
.compact-chart-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 12px; padding: 16px;
    transition: all 0.3s var(--transition-smooth);
}
.compact-chart-card:hover { border-color: var(--accent-light); transform: translateY(-2px); }
.compact-chart-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px;
}
.compact-chart-header h4 { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.compact-chart-value { font-size: 1.1rem; font-weight: 700; font-family: 'Space Grotesk', sans-serif; }
.compact-chart-value.down { color: var(--color-red); }
.compact-chart-value.up { color: var(--color-green); }
.compact-chart { height: 80px; }
.compact-chart canvas { max-height: 80px !important; }

/* Lab Dashboard - Sample Pipeline Widget */
.sample-pipeline-widget {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px 24px;
    margin-bottom: 32px;
    transition: all 0.3s var(--transition-smooth);
    animation: fadeSlideUp 0.5s var(--transition-smooth) both;
}
.sample-pipeline-widget:hover { border-color: var(--accent-light); }

/* Equipment Alert List */
.equipment-alert-list { display: flex; flex-direction: column; gap: 0; }
.equipment-alert-item {
    display: flex; align-items: center; gap: 14px;
    padding: 14px; border-radius: 10px;
    margin-bottom: 8px; background: var(--bg-card-hover);
    border: 1px solid transparent; transition: all 0.2s;
}
.equipment-alert-item:hover { border-color: var(--accent-light); }
.equipment-alert-item.critical { border-left: 3px solid var(--color-red); }
.equipment-alert-item.warning { border-left: 3px solid var(--color-yellow); }
.equipment-alert-icon {
    width: 40px; height: 40px; border-radius: 10px;
    background: var(--bg-card); color: var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.equipment-alert-item.critical .equipment-alert-icon { background: var(--color-red-bg); color: var(--color-red); }
.equipment-alert-item.warning .equipment-alert-icon { background: var(--color-yellow-bg); color: var(--color-yellow); }
.equipment-alert-icon svg { width: 20px; height: 20px; }
.equipment-alert-info { flex: 1; }
.equipment-alert-name { font-size: 0.88rem; font-weight: 600; color: var(--text); display: block; }
.equipment-alert-issue { font-size: 0.75rem; color: var(--text-muted); display: block; margin-top: 2px; }
.equipment-alert-health { font-size: 0.85rem; font-weight: 700; font-family: 'Space Grotesk', sans-serif; }

/* Shift Notes List */
.shift-notes-list { display: flex; flex-direction: column; gap: 0; }
.shift-note-item {
    padding: 14px; border-radius: 10px;
    margin-bottom: 10px; background: var(--bg-card-hover);
    border: 1px solid var(--border); transition: all 0.2s;
}
.shift-note-item:hover { border-color: var(--accent-light); }
.shift-note-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 10px;
}
.shift-note-author { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.shift-note-time { font-size: 0.72rem; color: var(--text-muted); }
.shift-note-body { margin-bottom: 10px; }
.shift-note-body p { font-size: 0.85rem; color: var(--text-muted); line-height: 1.6; margin: 0; }
.shift-note-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.shift-tag {
    font-size: 0.68rem; font-weight: 600; padding: 3px 8px;
    border-radius: 6px; text-transform: uppercase; letter-spacing: 0.03em;
}
.shift-tag.warning { background: var(--color-yellow-bg); color: var(--color-yellow); }
.shift-tag.info { background: var(--color-blue-bg); color: var(--color-blue); }
.shift-tag.success { background: var(--color-green-bg); color: var(--color-green); }
.shift-tag { background: var(--bg-card); color: var(--text-muted); border: 1px solid var(--border); }

/* Patient Dashboard - Health Metrics List */
.health-metrics-list { display: flex; flex-direction: column; gap: 0; }
.health-metric-item {
    display: flex; align-items: center; gap: 14px;
    padding: 14px; border-radius: 10px;
    margin-bottom: 8px; background: var(--bg-card-hover);
    border: 1px solid var(--border); transition: all 0.2s;
}
.health-metric-item:hover { border-color: var(--accent-light); }
.health-metric-icon {
    width: 40px; height: 40px; border-radius: 10px;
    background: var(--bg-card);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.health-metric-icon svg { width: 20px; height: 20px; }
.health-metric-info { flex: 1; }
.health-metric-name { font-size: 0.85rem; font-weight: 600; color: var(--text); display: block; }
.health-metric-value { font-size: 0.9rem; font-weight: 700; font-family: 'Space Grotesk', sans-serif; display: block; margin-top: 2px; }
.health-metric-value.critical { color: var(--color-red); }
.health-metric-value.warning { color: var(--color-yellow); }
.health-metric-value.normal { color: var(--color-green); }
.health-metric-trend { font-size: 0.72rem; font-weight: 600; padding: 4px 8px; border-radius: 6px; }
.health-metric-trend.down { background: var(--color-red-bg); color: var(--color-red); }
.health-metric-trend.stable { background: var(--color-yellow-bg); color: var(--color-yellow); }
.health-metric-trend.up { background: var(--color-green-bg); color: var(--color-green); }

/* Appointments List */
.appointments-list { display: flex; flex-direction: column; gap: 0; }
.appointment-item {
    display: flex; align-items: center; gap: 14px;
    padding: 14px; border-radius: 10px;
    margin-bottom: 8px; background: var(--bg-card-hover);
    border: 1px solid var(--border); transition: all 0.2s;
}
.appointment-item:hover { border-color: var(--accent-light); }
.appointment-date-badge {
    width: 50px; height: 50px; border-radius: 10px;
    background: var(--accent-light); color: var(--accent);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.apt-month { font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.apt-day { font-size: 1.1rem; font-weight: 800; font-family: 'Space Grotesk', sans-serif; }
.appointment-info { flex: 1; }
.appointment-title { font-size: 0.88rem; font-weight: 600; color: var(--text); display: block; }
.appointment-doctor { font-size: 0.78rem; color: var(--text-muted); display: block; margin-top: 2px; }
.appointment-time { font-size: 0.72rem; color: var(--text-muted); display: block; margin-top: 2px; }
.appointment-actions { display: flex; gap: 6px; }

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

/* Data Table */
.data-table-container {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    overflow: hidden; margin-bottom: 32px;
    transition: background 0.4s var(--transition-smooth), border-color 0.4s var(--transition-smooth);
    animation: fadeSlideUp 0.5s var(--transition-smooth) both;
}
.table-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.table-header h3 { font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; }
.table-header .badge { padding: 4px 12px; border-radius: 6px; font-size: 0.75rem; font-weight: 600; background: var(--color-blue-bg); color: var(--color-blue); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    text-align: left; padding: 12px 24px; font-size: 0.7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted);
    border-bottom: 1px solid var(--border); background: var(--bg-card-hover);
}
.data-table td {
    padding: 16px 24px; border-bottom: 1px solid var(--border); font-size: 0.88rem;
    transition: background 0.2s ease;
}
.data-table tr { transition: background 0.2s ease; }
.data-table tr:hover { background: var(--bg-card-hover); }
.status-badge { display: inline-block; padding: 4px 10px; border-radius: 6px; font-size: 0.75rem; font-weight: 600; }
.status-badge.normal { background: var(--color-green-bg); color: var(--color-green); }
.status-badge.warning { background: var(--color-yellow-bg); color: var(--color-yellow); }
.status-badge.critical { background: var(--color-red-bg); color: var(--color-red); }
.status-badge.pending { background: var(--color-blue-bg); color: var(--color-blue); }

/* Charts */
.chart-container {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 24px; margin-bottom: 32px;
    transition: background 0.4s var(--transition-smooth), border-color 0.4s var(--transition-smooth);
    animation: fadeSlideUp 0.5s var(--transition-smooth) both;
}
.chart-container h3 { font-size: 1rem; font-weight: 700; margin-bottom: 20px; letter-spacing: -0.01em; }
.chart-placeholder {
    height: 200px; border-radius: 12px;
    background: var(--bg-card-hover);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 0.9rem;
    border: 1px dashed var(--border);
}
.chart-bars { display: flex; align-items: flex-end; gap: 8px; height: 160px; padding: 0 20px; }
.chart-bar {
    flex: 1; border-radius: 6px 6px 0 0;
    background: linear-gradient(to top, var(--accent-light), var(--accent));
    opacity: 0.7; transition: all 0.35s var(--transition-smooth); min-width: 20px;
}
.chart-bar:hover { opacity: 1; transform: scaleY(1.03); transform-origin: bottom; box-shadow: 0 -4px 12px var(--accent-light); }

/* Buttons */
.btn-sm {
    padding: 8px 16px; border-radius: 8px; font-size: 0.8rem; font-weight: 600;
    border: none; cursor: pointer; font-family: inherit;
    transition: all 0.3s var(--transition-smooth);
}
.btn-sm.primary {
    background: var(--accent); color: #fff;
    box-shadow: 0 2px 8px var(--accent-light);
}
.btn-sm.primary:hover {
    transform: translateY(-1px); box-shadow: var(--shadow-colored); filter: brightness(1.08);
}
.btn-sm.outline { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.btn-sm.outline:hover { border-color: var(--accent); color: var(--accent); }

/* Alert/Notification */
.alert-banner {
    display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-radius: 12px;
    margin-bottom: 24px; font-size: 0.9rem;
    animation: fadeSlideUp 0.4s var(--transition-smooth) both;
}
.alert-banner.info { background: var(--color-blue-bg); border: 1px solid rgba(96,165,250,0.2); color: var(--color-blue); }
.alert-banner.warning { background: var(--color-yellow-bg); border: 1px solid rgba(251,191,36,0.2); color: var(--color-yellow); }
.alert-banner.success { background: var(--color-green-bg); border: 1px solid rgba(52,211,153,0.2); color: var(--color-green); }

/* Grid Layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 32px; }

/* Mobile Sidebar Toggle */
.sidebar-toggle {
    display: none; position: fixed; top: 16px; left: 16px; z-index: 200;
    width: 44px; height: 44px; border-radius: 12px;
    background: var(--accent, #6366f1);
    border: none; color: #fff; cursor: pointer;
    align-items: center; justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.35), 0 0 0 2px rgba(255,255,255,0.12);
}
.sidebar-toggle:hover { filter: brightness(1.12); transform: scale(1.06); }
.sidebar-toggle:active { transform: scale(0.97); }

/* Sidebar Backdrop (mobile only) */
.sidebar-backdrop {
    display: none; position: fixed; inset: 0; z-index: 99;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
    opacity: 0; transition: opacity 0.3s ease;
    cursor: pointer;
}
.sidebar-backdrop.visible { display: block; opacity: 1; }

/* ====================================================================
   NEW ADDITIONS
   ==================================================================== */


/* ===== TOAST NOTIFICATIONS (improvement 2) ===== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-width: 420px;
    font-size: 0.88rem;
    color: var(--text);
    animation: toast-slide-in 0.4s var(--transition-smooth) forwards;
    position: relative;
    overflow: hidden;
}

.toast.removing {
    animation: toast-slide-out 0.3s ease forwards;
}

.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.toast-message {
    flex: 1;
    font-size: 0.875rem;
    line-height: 1.4;
}

.toast-close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.2s;
}

.toast-close:hover {
    background: var(--bg-card-hover);
    color: var(--text);
}

.toast.success {
    border-left: 4px solid var(--accent);
}
.toast.success .toast-icon {
    color: var(--accent);
}

.toast.error {
    border-left: 4px solid var(--color-red);
}
.toast.error .toast-icon {
    color: var(--color-red);
}

.toast.warning {
    border-left: 4px solid var(--color-yellow);
}
.toast.warning .toast-icon {
    color: var(--color-yellow);
}

.toast.info {
    border-left: 4px solid var(--primary-light);
}
.toast.info .toast-icon {
    color: var(--primary-light);
}

@keyframes toast-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toast-slide-out {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}


/* ===== FORM VALIDATION (improvement 2) ===== */
.form-error {
    color: var(--color-red);
    font-size: 0.8rem;
    margin-top: 6px;
    animation: form-error-slide 0.25s ease forwards;
    overflow: hidden;
}

@keyframes form-error-slide {
    from {
        opacity: 0;
        transform: translateY(-6px);
        max-height: 0;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        max-height: 40px;
    }
}

.form-group input.invalid {
    border-color: var(--color-red) !important;
    background: var(--color-red-bg);
}

.form-group input.invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.form-group input.valid {
    border-color: var(--accent) !important;
    background: rgba(6, 214, 160, 0.04);
}

.form-group input.valid:focus {
    box-shadow: 0 0 0 3px rgba(6, 214, 160, 0.12);
}

.password-strength {
    margin-top: 8px;
    height: 4px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.password-strength .bar {
    height: 100%;
    border-radius: 4px;
    width: 0%;
    transition: width 0.4s ease, background-color 0.4s ease;
}

.password-strength .bar.weak {
    width: 25%;
    background-color: var(--color-red);
}

.password-strength .bar.fair {
    width: 50%;
    background-color: var(--color-yellow);
}

.password-strength .bar.good {
    width: 75%;
    background-color: var(--color-blue);
}

.password-strength .bar.strong {
    width: 100%;
    background-color: var(--accent);
}

.password-strength-label {
    font-size: 0.75rem;
    margin-top: 4px;
    color: var(--text-muted);
}


/* ===== LOADING SKELETONS (improvement 7) ===== */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 14px;
    width: 100%;
    border-radius: 4px;
    margin-bottom: 10px;
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-text:last-child {
    width: 60%;
}

.skeleton-text.short {
    width: 40%;
}

.skeleton-card {
    height: 160px;
    border-radius: var(--radius);
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border: 1px solid var(--border);
}

.skeleton-row {
    height: 48px;
    width: 100%;
    border-radius: 6px;
    margin-bottom: 8px;
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

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


/* ===== THEME TOGGLE (improvement 9) ===== */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.1rem;
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Light (default): show moon icon so user can switch to dark */
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: flex; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* Smooth transitions on all themed elements */
.sidebar,
.login-card,
.dash-card,
.data-table-container,
.chart-container,
.nav-item,
.alert-banner,
.toast,
.chat-panel,
.notification-dropdown {
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
}


/* ===== PWA INSTALL BANNER (improvement 12) ===== */
.pwa-install-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 14px 24px;
    background: var(--gradient);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 4px 20px var(--shadow-colored);
    animation: pwa-banner-slide-down 0.4s ease forwards;
}

.pwa-install-banner.hidden {
    animation: pwa-banner-slide-up 0.3s ease forwards;
    pointer-events: none;
}

.pwa-install-banner p {
    flex: 1;
    text-align: center;
}

.pwa-install-btn {
    flex-shrink: 0;
    padding: 8px 20px;
    border: none;
    border-radius: 8px;
    background: #fff;
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.pwa-install-btn:hover {
    transform: scale(1.04);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.pwa-install-dismiss {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: var(--bg-card-hover);
    color: #fff;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.pwa-install-dismiss:hover {
    background: var(--bg-card-hover);
}

@keyframes pwa-banner-slide-down {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes pwa-banner-slide-up {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(-100%);
        opacity: 0;
    }
}


/* ===== NOTIFICATION BELL (improvement 13) ===== */
.notification-bell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.notification-bell:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--color-red);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border: 2px solid var(--bg-dark);
}

.notification-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 360px;
    max-height: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    display: none;
    z-index: 500;
    flex-direction: column;
}

.notification-dropdown.open {
    display: flex;
}

.notification-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    font-weight: 700;
}

.notification-dropdown-header a {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    cursor: pointer;
}

.notification-list {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.notification-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.notification-item:hover {
    background: var(--bg-card-hover);
}

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

.notification-item.unread {
    background: var(--accent-light);
    border-left: 3px solid var(--accent);
}

.notification-item-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    background: var(--accent-light);
    color: var(--accent);
}

.notification-item-content {
    flex: 1;
    min-width: 0;
}

.notification-item-content p {
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--text);
    margin-bottom: 2px;
}

.notification-item-content .time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.notification-dropdown-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.notification-dropdown-footer a {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
    cursor: pointer;
}


/* ===== TABLE SEARCH & FILTER (improvement 14) ===== */
.table-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.table-search {
    flex: 1;
    min-width: 200px;
    position: relative;
}

.table-search input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border-radius: 10px;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    transition: all 0.3s;
}

.table-search input:focus {
    border-color: var(--accent);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.table-search input::placeholder {
    color: var(--text-muted);
}

.table-search .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

.table-filter {
    position: relative;
}

.table-filter select {
    appearance: none;
    -webkit-appearance: none;
    padding: 10px 36px 10px 14px;
    border-radius: 10px;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: all 0.3s;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.table-filter select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.table-filter select option {
    background: var(--bg-card);
    color: var(--text);
}

.sortable th {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.sortable th:hover {
    background: var(--bg-card-hover);
    color: var(--text);
}

.sort-icon {
    display: inline-block;
    margin-left: 6px;
    font-size: 0.7rem;
    color: var(--text-muted);
    vertical-align: middle;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.sort-icon.active {
    opacity: 1;
    color: var(--accent);
}

.sort-icon.asc::after {
    content: "\25B2";
}

.sort-icon.desc::after {
    content: "\25BC";
}

.no-results {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.no-results svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
}

.no-results p {
    margin-top: 8px;
    font-size: 0.85rem;
}

/* (light-themed inputs handled by default above) */


/* ===== LANGUAGE SWITCHER (improvement 16) ===== */
.lang-switcher {
    position: relative;
}

.lang-switcher select {
    appearance: none;
    -webkit-appearance: none;
    padding: 8px 30px 8px 10px;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: all 0.3s;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.lang-switcher select:focus {
    border-color: var(--accent);
}

.lang-switcher select option {
    background: var(--bg-card);
    color: var(--text);
}


/* ===== CHAT WIDGET (improvement 18) ===== */
.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--gradient);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-colored);
    z-index: 999;
    transition: all 0.3s;
}

.chat-fab:hover {
    transform: scale(1.08);
    box-shadow: var(--shadow-colored), 0 12px 32px rgba(0,0,0,0.15);
    filter: brightness(1.08);
}

.chat-fab .unread-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-red);
    border: 2px solid var(--bg-dark);
}

.chat-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    height: 500px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: none;
    flex-direction: column;
    z-index: 998;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.96);
}

.chat-panel.open {
    display: flex;
    animation: chat-panel-open 0.3s ease forwards;
}

.chat-panel.closing {
    animation: chat-panel-close 0.25s ease forwards;
}

@keyframes chat-panel-open {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes chat-panel-close {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--gradient);
    color: #fff;
    flex-shrink: 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header-info .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
}

.chat-header-info .name {
    font-weight: 600;
    font-size: 0.95rem;
}

.chat-header-info .status {
    font-size: 0.75rem;
    opacity: 0.8;
}

.chat-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: var(--bg-card-hover);
    color: #fff;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}

.chat-close:hover {
    background: var(--bg-card-hover);
}

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

.chat-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.875rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-bubble.sent {
    align-self: flex-end;
    background: var(--gradient);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-bubble.received {
    align-self: flex-start;
    background: var(--bg-card-hover);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.chat-bubble .time {
    display: block;
    font-size: 0.7rem;
    margin-top: 4px;
    opacity: 0.6;
}

.chat-typing {
    align-self: flex-start;
    padding: 10px 16px;
    background: var(--bg-card-hover);
    border-radius: 14px;
    border: 1px solid var(--border);
    display: flex;
    gap: 4px;
    align-items: center;
}

.chat-typing .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typing-dot 1.2s ease infinite;
}

.chat-typing .dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-dot {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

.chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-input-area input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.3s;
}

.chat-input-area input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.chat-input-area input::placeholder {
    color: var(--text-muted);
}

.chat-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: var(--gradient);
    color: #fff;
    cursor: pointer;
    font-size: 1rem;
    flex-shrink: 0;
    transition: all 0.2s;
}

.chat-send-btn:hover {
    transform: scale(1.06);
}

.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}


/* ===== ONBOARDING TOUR (improvement 19) ===== */
.tour-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    transition: opacity 0.3s ease;
}

.tour-highlight {
    position: absolute;
    z-index: 10001;
    border-radius: 8px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
    pointer-events: none;
    transition: all 0.35s ease;
}

.tour-tooltip {
    position: absolute;
    z-index: 10002;
    max-width: 320px;
    padding: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    animation: tour-tooltip-pop 0.3s ease forwards;
}

.tour-tooltip::before {
    content: "";
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    transform: rotate(45deg);
}

.tour-tooltip.arrow-top::before {
    top: -7px;
    left: 24px;
    border-right: none;
    border-bottom: none;
}

.tour-tooltip.arrow-bottom::before {
    bottom: -7px;
    left: 24px;
    border-left: none;
    border-top: none;
}

.tour-tooltip.arrow-left::before {
    left: -7px;
    top: 24px;
    border-top: none;
    border-right: none;
}

.tour-tooltip.arrow-right::before {
    right: -7px;
    top: 24px;
    border-bottom: none;
    border-left: none;
}

@keyframes tour-tooltip-pop {
    from {
        opacity: 0;
        transform: scale(0.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.tour-tooltip h4 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
}

.tour-tooltip p {
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.tour-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.tour-actions .tour-skip {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    transition: color 0.2s;
}

.tour-actions .tour-skip:hover {
    color: var(--text);
}

.tour-actions .tour-next {
    padding: 8px 20px;
    border-radius: 8px;
    border: none;
    background: var(--gradient);
    color: #fff;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.2s;
}

.tour-actions .tour-next:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-colored);
    filter: brightness(1.08);
}

.tour-step-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 16px;
}

.tour-step-indicator .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: all 0.3s;
}

.tour-step-indicator .dot.active {
    background: var(--accent);
    width: 20px;
    border-radius: 4px;
}

.tour-step-indicator .dot.completed {
    background: var(--accent);
}


/* ===== AUDIT & EXPORT (improvement 20) ===== */
.export-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 160px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    z-index: 200;
    overflow: hidden;
    display: none;
    animation: export-menu-fade 0.2s ease forwards;
}

.export-menu.open {
    display: block;
}

@keyframes export-menu-fade {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.export-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
}

.export-menu-item:hover {
    background: var(--bg-card-hover);
}

.export-menu-item svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.export-menu-item + .export-menu-item {
    border-top: 1px solid var(--border);
}


/* ===== ACCESSIBILITY (improvement 8) ===== */
.skip-link {
    position: absolute;
    top: -100%;
    left: 16px;
    padding: 12px 24px;
    background: var(--accent);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 0 0 8px 8px;
    z-index: 99999;
    text-decoration: none;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 0;
}

*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Remove focus outline for mouse clicks, keep for keyboard navigation */
*:focus:not(:focus-visible) {
    outline: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Ensure interactive elements have clear focus styles */
.btn-login:focus-visible,
.btn-sm:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px var(--accent-light);
}

.nav-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.role-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.form-group input:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border: #555555;
    }
    .dash-card,
    .data-table-container,
    .chart-container {
        border-width: 2px;
    }
}


/* ===== PRINT STYLES ===== */
@media print {
    body {
        background: #fff !important;
        color: #000 !important;
        font-size: 12pt;
    }

    .sidebar,
    .sidebar-toggle,
    .chat-fab,
    .chat-panel,
    .toast-container,
    .notification-bell,
    .notification-dropdown,
    .pwa-install-banner,
    .tour-overlay,
    .tour-highlight,
    .tour-tooltip,
    .theme-toggle,
    .lang-switcher,
    .header-actions .btn-sm,
    .export-menu {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .dashboard {
        display: block;
    }

    .dash-card,
    .data-table-container,
    .chart-container {
        break-inside: avoid;
        border: 1px solid #ccc !important;
        background: #fff !important;
        box-shadow: none !important;
    }

    .dash-card {
        page-break-inside: avoid;
    }

    .dash-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-2 {
        grid-template-columns: 1fr 1fr;
    }

    .data-table th,
    .data-table td {
        border: 1px solid #ccc !important;
        color: #000 !important;
    }

    .status-badge {
        border: 1px solid currentColor;
    }

    .page-header h1 {
        color: #000 !important;
    }

    .gradient-text {
        -webkit-text-fill-color: #000 !important;
        color: #000 !important;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
}


/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); box-shadow: none; width: min(85vw, 320px); }
    .sidebar.open { transform: translateX(0); box-shadow: 20px 0 60px rgba(0,0,0,0.5); }
    .sidebar-toggle { display: flex; }
    .main-content { margin-left: 0; padding: 24px 16px; padding-top: 64px; overflow-x: hidden; max-width: 100vw; }
    .dash-grid { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .role-selector { grid-template-columns: 1fr; }
    .data-table { font-size: 0.8rem; }
    .data-table th, .data-table td { padding: 10px 12px; }

    /* Hide layout-switcher dropdown on mobile — not useful on small screens */
    .layout-dropdown { display: none !important; }

    /* Alert banner — allow text to wrap on small screens */
    .alert-banner { flex-wrap: wrap; gap: 8px; }
    .alert-banner span { word-break: break-word; min-width: 0; flex: 1; }

    /* Hide secondary page-header action buttons; keep icon buttons (bell, lang) */
    .page-header .header-actions > .btn-sm:not(#notification-bell),
    .page-header .header-actions > .btn-primary { display: none; }

    /* Chat FAB — move up when sim panel is visible */
    .chat-fab { bottom: 80px; }
    .data-table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* Chat responsive */
    .chat-panel {
        width: calc(100vw - 32px);
        height: calc(100vh - 140px);
        right: 16px;
        bottom: 88px;
    }

    /* Notification responsive */
    .notification-dropdown {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 60vh;
        border-radius: var(--radius) var(--radius) 0 0;
    }

    /* Table toolbar responsive */
    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .table-search {
        min-width: 100%;
    }

    /* Toast responsive */
    .toast-container {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }

    .toast {
        min-width: auto;
        max-width: 100%;
    }

    /* Tour responsive */
    .tour-tooltip {
        max-width: calc(100vw - 48px);
    }

    /* Quick actions — wrap on mobile, prevent overflow */
    .quick-actions-bar { flex-wrap: wrap; gap: 8px; }
    .quick-action-btn { font-size: 0.8rem; padding: 8px 12px; }

    /* Dashboard split grid → single column */
    .dashboard-split-grid { grid-template-columns: 1fr; }

    /* Section containers — clamp padding */
    .section-container { padding: 0; }

    /* Page header padding on mobile */
    .ph-row { padding: 16px 20px !important; }
    .page-header { padding: 0; }

    /* Charts row — 2-col on tablet, 1-col at 640px */
    .dashboard-charts-row { grid-template-columns: repeat(2, 1fr); }

    /* Stat cards min-width reset */
    .dash-card { min-width: 0; }
}

@media (max-width: 480px) {
    .page-header h1 {
        font-size: 1.4rem;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .chat-panel {
        right: 0;
        bottom: 80px;
        width: 100%;
        height: calc(100vh - 80px);
        border-radius: var(--radius) var(--radius) 0 0;
    }

    .pwa-install-banner {
        flex-wrap: wrap;
        gap: 10px;
        padding: 12px 16px;
        font-size: 0.8rem;
    }

    /* Quick actions — stack vertically on phones */
    .quick-actions-bar { flex-direction: column; }
    .quick-action-btn { width: 100%; justify-content: flex-start; }

    /* Charts row → single column */
    .dashboard-charts-row { grid-template-columns: 1fr; }

    /* Section inner padding */
    .section-inner { padding: 16px; }
}

/* 360px — smallest phones */
@media (max-width: 360px) {
    .main-content { padding: 16px 12px; padding-top: 60px; }
    .page-header h1 { font-size: 1.2rem; }
    .stat-value { font-size: 1.4rem; }
    .login-card { padding: 24px 16px; }
    .data-table th, .data-table td { padding: 8px 10px; font-size: 0.75rem; }
    .notification-dropdown { max-height: 70vh; }
}

/* Prevent horizontal overflow globally */
html, body { overflow-x: hidden; max-width: 100%; }

/* ============================================================
   NEW FEATURE STYLES (20 sections)
   ============================================================ */

/* ===== 1. Page Transitions ===== */
[data-section] {
    transition: opacity 0.35s ease, transform 0.35s ease;
}
[data-section].section-entering {
    opacity: 0;
    transform: translateY(12px);
}
[data-section].section-visible {
    opacity: 1;
    transform: translateY(0);
}
[data-section].section-exiting {
    opacity: 0;
    transform: translateY(-12px);
}

/* ===== 2. Layout Templates ===== */
/* Compact layout */
.layout-compact .dash-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; }
.layout-compact .dash-card { padding: 16px; }
.layout-compact .dash-card .value { font-size: 1.4rem; }
.layout-compact .data-table { font-size: 0.8rem; }
.layout-compact .chart-container { height: 200px; }

/* Analytics layout */
.layout-analytics .dash-grid { grid-template-columns: repeat(2, 1fr); }
.layout-analytics .dash-card .value { font-size: 2.2rem; }
.layout-analytics .grid-2 { grid-template-columns: 1fr; }
.layout-analytics .chart-container { min-height: 350px; }
.layout-analytics .data-table-container { max-height: 300px; overflow-y: auto; }

/* Layout switcher button/dropdown */
.layout-switcher { position: relative; }
.layout-dropdown {
    position: absolute; top: 100%; right: 0; margin-top: 8px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 12px; padding: 8px; min-width: 180px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.4); z-index: 100;
    display: none;
}
.layout-dropdown.open { display: block; }
.layout-option {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: 8px;
    cursor: pointer; color: var(--text-muted);
    transition: all 0.2s; border: none; background: none;
    width: 100%; font-family: inherit; font-size: 0.85rem; text-align: left;
}
.layout-option:hover { background: var(--bg-card-hover); color: var(--text); }
.layout-option.active { color: var(--accent); background: var(--accent-light); }

/* ===== 3. Command Palette ===== */
.cmd-palette-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px); z-index: 10010;
    display: flex; align-items: flex-start; justify-content: center;
    padding-top: 15vh;
    animation: cmd-fade-in 0.15s ease;
}
@keyframes cmd-fade-in { from { opacity: 0; } to { opacity: 1; } }

.cmd-palette {
    width: 560px; max-width: calc(100vw - 40px);
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 16px; overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: cmd-slide-in 0.2s cubic-bezier(.4,0,.2,1);
}
@keyframes cmd-slide-in { from { opacity:0; transform: translateY(-20px) scale(0.98); } to { opacity:1; transform: translateY(0) scale(1); } }

.cmd-search-wrapper {
    padding: 16px 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px;
}
.cmd-search-wrapper svg { color: var(--text-muted); flex-shrink: 0; }
.cmd-search-input {
    flex: 1; background: none; border: none; outline: none;
    color: var(--text); font-size: 1rem; font-family: inherit;
}
.cmd-search-input::placeholder { color: var(--text-muted); }
.cmd-shortcut-badge {
    font-size: 0.7rem; color: var(--text-muted);
    background: var(--bg-card-hover); padding: 3px 8px;
    border-radius: 6px; font-family: monospace; white-space: nowrap;
    border: 1px solid var(--border);
}

.cmd-results {
    max-height: 360px; overflow-y: auto; padding: 8px;
}
.cmd-group-title {
    font-size: 0.72rem; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.05em;
    padding: 8px 12px 4px;
}
.cmd-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; border-radius: 10px;
    cursor: pointer; color: var(--text-muted);
    transition: all 0.15s; border: none; background: none;
    width: 100%; font-family: inherit; font-size: 0.88rem; text-align: left;
}
.cmd-item:hover, .cmd-item.highlighted {
    background: var(--accent-light); color: var(--text);
}
.cmd-item-icon {
    width: 32px; height: 32px; border-radius: 8px;
    background: var(--bg-card-hover);
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
}
.cmd-item-name { flex: 1; }
.cmd-item-shortcut {
    font-size: 0.72rem; color: var(--text-muted);
    background: var(--bg-card-hover); padding: 2px 8px;
    border-radius: 4px; font-family: monospace;
    border: 1px solid var(--border);
}

.cmd-footer {
    padding: 10px 16px; border-top: 1px solid var(--border);
    display: flex; gap: 16px; font-size: 0.75rem; color: var(--text-muted);
}
.cmd-footer kbd {
    background: var(--bg-card-hover); padding: 1px 6px;
    border-radius: 4px; font-family: monospace; font-size: 0.7rem;
    border: 1px solid var(--border);
}

/* ===== 4. Breadcrumb Navigation ===== */
.breadcrumb {
    display: flex; align-items: center; gap: 8px;
    padding: 0 0 12px; font-size: 0.82rem; color: var(--text-muted);
    flex-wrap: wrap;
}
.breadcrumb-item {
    cursor: pointer; transition: color 0.2s;
    background: none; border: none; color: var(--text-muted);
    font-family: inherit; font-size: inherit; padding: 0;
}
.breadcrumb-item:hover { color: var(--accent); }
.breadcrumb-separator { color: var(--text-muted); opacity: 0.4; }
.breadcrumb-current {
    color: var(--text); font-weight: 600;
}

/* ===== 5. Profile Section ===== */
.profile-section {
    max-width: 640px;
}
.profile-header {
    display: flex; align-items: center; gap: 24px;
    padding: 32px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: 16px;
    margin-bottom: 24px;
}
.profile-avatar-large {
    width: 96px; height: 96px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; font-weight: 700; color: #fff;
    overflow: hidden; position: relative; cursor: pointer;
    transition: transform 0.2s;
}
.profile-avatar-large:hover { transform: scale(1.05); }
.profile-avatar-large img {
    width: 100%; height: 100%; object-fit: cover;
}
.profile-avatar-overlay {
    position: absolute; inset: 0; background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.2s; font-size: 0.8rem;
    color: #fff; font-weight: 600;
}
.profile-avatar-large:hover .profile-avatar-overlay { opacity: 1; }

.profile-info h2 { font-size: 1.3rem; margin-bottom: 4px; }
.profile-info .role-badge {
    display: inline-block; padding: 4px 12px; border-radius: 20px;
    background: var(--accent-light); color: var(--accent);
    font-size: 0.78rem; font-weight: 600; text-transform: capitalize;
}

.profile-form {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 16px; padding: 24px;
}
.profile-form .form-group { margin-bottom: 20px; }
.profile-form label {
    display: block; font-size: 0.82rem; color: var(--text-muted);
    margin-bottom: 6px; font-weight: 600;
}
.profile-form input, .profile-form select {
    width: 100%; padding: 10px 14px; border-radius: 10px;
    background: var(--bg-card-hover); border: 1px solid var(--border);
    color: var(--text); font-size: 0.9rem; font-family: inherit;
    outline: none; transition: border-color 0.3s;
}
.profile-form input:focus, .profile-form select:focus {
    border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light);
}
.profile-save-btn {
    padding: 10px 24px; border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border: none; color: #fff; font-weight: 700;
    cursor: pointer; font-family: inherit; font-size: 0.9rem;
    transition: transform 0.2s, box-shadow 0.2s;
}
.profile-save-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-colored); filter: brightness(1.08); }

/* ===== 6. Real-time Simulation ===== */
.realtime-toggle {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 14px; border-radius: 8px;
    background: var(--bg-card-hover); border: 1px solid var(--border);
    color: var(--text-muted); font-size: 0.82rem; font-weight: 600;
    cursor: pointer; font-family: inherit; transition: all 0.2s;
}
.realtime-toggle.active { border-color: var(--color-green); color: var(--color-green); }
.realtime-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--text-muted); transition: background 0.3s;
}
.realtime-toggle.active .realtime-dot {
    background: var(--color-green);
    animation: pulse-dot 1.5s infinite;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}
.cell-updated {
    animation: cell-flash 0.8s ease;
}
@keyframes cell-flash {
    0% { background: var(--accent-light); }
    100% { background: transparent; }
}

/* ===== 7. Patient Timeline ===== */
.timeline-container { padding: 0 0 24px; }
.timeline {
    position: relative; padding-left: 40px;
}
.timeline::before {
    content: ''; position: absolute; left: 15px; top: 0; bottom: 0;
    width: 2px; background: var(--border);
}
.timeline-item {
    position: relative; padding: 0 0 32px;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
    position: absolute; left: -33px; top: 4px;
    width: 20px; height: 20px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.6rem; color: #fff; z-index: 1;
}
.timeline-dot.lab { background: var(--color-green); }
.timeline-dot.doctor { background: var(--accent); }
.timeline-dot.alert { background: var(--color-red); }
.timeline-dot.prescription { background: var(--border); }
.timeline-dot.appointment { background: var(--color-yellow); }

.timeline-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 12px; padding: 16px 20px;
    transition: border-color 0.2s;
}
.timeline-card:hover { border-color: var(--accent); }
.timeline-card h4 { font-size: 0.9rem; margin-bottom: 6px; }
.timeline-card p { font-size: 0.82rem; color: var(--text-muted); line-height: 1.5; }
.timeline-time {
    font-size: 0.75rem; color: var(--text-muted); margin-top: 8px;
    display: flex; align-items: center; gap: 6px;
}

/* ===== 8. Appointment Calendar ===== */
.calendar-wrapper {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 16px; overflow: hidden;
}
.calendar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.calendar-header h3 { font-size: 1rem; }
.calendar-nav-btn {
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--bg-card-hover); border: 1px solid var(--border);
    color: var(--text); cursor: pointer; display: flex;
    align-items: center; justify-content: center; transition: all 0.2s;
}
.calendar-nav-btn:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }

.calendar-grid {
    display: grid; grid-template-columns: repeat(7, 1fr);
    gap: 1px; background: var(--border);
}
.calendar-day-header {
    padding: 10px; text-align: center;
    font-size: 0.75rem; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; background: var(--bg-card);
}
.calendar-day {
    min-height: 80px; padding: 8px; background: var(--bg-card);
    cursor: pointer; transition: background 0.2s; position: relative;
}
.calendar-day:hover { background: var(--bg-card-hover); }
.calendar-day.today { background: var(--accent-light); }
.calendar-day.other-month { opacity: 0.3; }
.calendar-day-number {
    font-size: 0.82rem; font-weight: 600; margin-bottom: 4px;
}
.calendar-day.today .calendar-day-number {
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
}
.calendar-event {
    font-size: 0.68rem; padding: 2px 6px; border-radius: 4px;
    margin-bottom: 2px; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis;
}
.calendar-event.checkup { background: var(--color-blue-bg); color: var(--color-blue); }
.calendar-event.followup { background: var(--color-green-bg); color: var(--color-green); }
.calendar-event.urgent { background: var(--color-red-bg); color: var(--color-red); }

.appointment-panel {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 16px; padding: 24px; margin-top: 16px;
}
.appointment-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 0; border-bottom: 1px solid var(--border);
}
.appointment-item:last-child { border-bottom: none; }
.appointment-time {
    font-size: 0.82rem; font-weight: 700; color: var(--accent);
    min-width: 60px;
}
.appointment-detail h4 { font-size: 0.88rem; margin-bottom: 2px; }
.appointment-detail p { font-size: 0.78rem; color: var(--text-muted); }

.appointment-form {
    margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border);
}
.appointment-form .form-row-inline {
    display: flex; gap: 12px; margin-bottom: 12px;
}
.appointment-form input, .appointment-form select {
    flex: 1; padding: 8px 12px; border-radius: 8px;
    background: var(--bg-card-hover); border: 1px solid var(--border);
    color: var(--text); font-size: 0.85rem; font-family: inherit;
    outline: none;
}

/* ===== 9. Lab Result Comparison ===== */
.comparison-controls {
    display: flex; gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.comparison-select {
    flex: 1; min-width: 200px; padding: 10px 14px; border-radius: 10px;
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text); font-size: 0.9rem; font-family: inherit;
}
.comparison-table {
    width: 100%; border-collapse: collapse;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 12px; overflow: hidden;
}
.comparison-table th, .comparison-table td {
    padding: 12px 16px; text-align: left;
    border-bottom: 1px solid var(--border); font-size: 0.85rem;
}
.comparison-table th {
    background: var(--bg-card-hover); color: var(--text-muted);
    font-weight: 700; font-size: 0.78rem; text-transform: uppercase;
}
.comparison-diff { font-weight: 700; }
.comparison-diff.improved { color: var(--color-green); }
.comparison-diff.worsened { color: var(--color-red); }
.comparison-diff.unchanged { color: var(--text-muted); }
.trend-arrow { font-size: 0.9rem; }

/* ===== 10. Medication Tracker ===== */
.medication-summary {
    display: flex; gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.medication-summary-card {
    flex: 1; min-width: 140px; padding: 16px 20px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 12px; text-align: center;
}
.medication-summary-card .value { font-size: 1.6rem; font-weight: 700; }
.medication-summary-card .label { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

.medication-list { display: flex; flex-direction: column; gap: 12px; }
.medication-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 14px; padding: 20px;
    display: flex; align-items: center; gap: 16px;
    transition: border-color 0.2s;
}
.medication-card:hover { border-color: var(--accent); }
.medication-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; flex-shrink: 0;
}
.medication-icon.pill { background: var(--color-blue-bg); }
.medication-icon.supplement { background: var(--color-green-bg); }
.medication-icon.vitamin { background: var(--color-yellow-bg); }

.medication-info { flex: 1; }
.medication-info h4 { font-size: 0.92rem; margin-bottom: 4px; }
.medication-info .dose { font-size: 0.8rem; color: var(--text-muted); }
.medication-info .next-dose { font-size: 0.75rem; color: var(--accent); margin-top: 6px; }

.adherence-bar {
    width: 100%; height: 6px; border-radius: 3px;
    background: var(--border); margin-top: 8px; overflow: hidden;
}
.adherence-fill {
    height: 100%; border-radius: 3px; transition: width 0.5s ease;
}
.adherence-fill.high { background: var(--color-green); }
.adherence-fill.medium { background: var(--color-yellow); }
.adherence-fill.low { background: var(--color-red); }

.medication-actions {
    display: flex; flex-direction: column; gap: 6px; flex-shrink: 0;
}
.take-med-btn {
    padding: 8px 16px; border-radius: 8px;
    background: var(--color-green); border: none; color: #fff;
    font-weight: 700; font-size: 0.78rem; cursor: pointer;
    font-family: inherit; transition: all 0.2s;
}
.take-med-btn:hover { transform: translateY(-1px); }
.take-med-btn.taken {
    background: var(--bg-card-hover); color: var(--text-muted);
    cursor: default;
}

/* ===== 11. Modal Common ===== */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px); z-index: 10005;
    display: flex; align-items: center; justify-content: center;
    animation: modal-fade-in 0.2s ease;
}
@keyframes modal-fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 16px; width: 480px; max-width: calc(100vw - 40px);
    max-height: calc(100vh - 80px); overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modal-slide-in 0.25s cubic-bezier(.4,0,.2,1);
}
@keyframes modal-slide-in { from { opacity:0; transform:translateY(20px) scale(0.97); } to { opacity:1; transform:translateY(0) scale(1); } }
.modal-header {
    padding: 20px 24px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 1rem; }
.modal-close {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; font-size: 1.3rem; padding: 4px;
    transition: color 0.2s;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px; border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 10px;
}
.modal-btn {
    padding: 8px 20px; border-radius: 8px; font-weight: 600;
    font-size: 0.85rem; cursor: pointer; font-family: inherit;
    transition: all 0.2s; border: none;
}
.modal-btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
}
.modal-btn.secondary {
    background: var(--bg-card-hover); color: var(--text-muted);
    border: 1px solid var(--border);
}
.modal-btn:hover { transform: translateY(-1px); }

/* ===== 12. Email Templates ===== */
.email-template-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px; margin-bottom: 24px;
}
.email-template-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 14px; padding: 20px; cursor: pointer;
    transition: all 0.2s;
}
.email-template-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.email-template-card.selected { border-color: var(--primary); background: var(--bg-card-hover); }
.email-template-card h4 { font-size: 0.92rem; margin-bottom: 8px; }
.email-template-card p { font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; }

.email-preview {
    background: #fff; color: #0a0a0a; border-radius: 12px;
    padding: 32px; max-width: 600px; margin: 0 auto;
    font-family: Georgia, serif; line-height: 1.8;
}
.email-preview .email-header {
    border-bottom: 2px solid var(--border); padding-bottom: 16px; margin-bottom: 20px;
}
.email-preview .email-subject { font-size: 1.1rem; font-weight: 700; }
.email-preview .email-meta { font-size: 0.82rem; color: var(--text-muted); }
.email-preview .placeholder {
    background: var(--bg-card-hover); padding: 1px 6px; border-radius: 4px;
    color: var(--text); font-weight: 600;
}

/* ===== 13. Patient Handoff ===== */
.handoff-patient-list {
    display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px;
}
.handoff-patient-card {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 18px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: 12px;
    transition: border-color 0.2s;
}
.handoff-patient-card:hover { border-color: var(--primary); }
.handoff-patient-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.8rem; color: #fff; flex-shrink: 0;
}
.handoff-patient-info { flex: 1; }
.handoff-patient-info h4 { font-size: 0.88rem; margin-bottom: 2px; }
.handoff-patient-info p { font-size: 0.78rem; color: var(--text-muted); }
.handoff-transfer-btn {
    padding: 6px 16px; border-radius: 8px;
    background: var(--bg-card-hover); color: var(--primary-light);
    border: none; font-weight: 600; font-size: 0.8rem;
    cursor: pointer; font-family: inherit; transition: all 0.2s;
}
.handoff-transfer-btn:hover { background: var(--bg-card-hover); }

.handoff-form textarea {
    width: 100%; min-height: 100px; padding: 12px; border-radius: 10px;
    background: var(--bg-card-hover); border: 1px solid var(--border);
    color: var(--text); font-family: inherit; font-size: 0.88rem;
    resize: vertical;
}
.handoff-form select, .handoff-form input {
    width: 100%; padding: 10px 14px; border-radius: 10px;
    background: var(--bg-card-hover); border: 1px solid var(--border);
    color: var(--text); font-family: inherit; font-size: 0.88rem;
}
.priority-select { display: flex; gap: 8px; margin: 12px 0; }
.priority-option {
    flex: 1; padding: 8px; text-align: center; border-radius: 8px;
    border: 1px solid var(--border); cursor: pointer;
    font-size: 0.82rem; font-weight: 600; transition: all 0.2s;
    background: none; color: var(--text-muted); font-family: inherit;
}
.priority-option.selected { border-color: var(--primary); color: var(--primary); background: var(--bg-card-hover); }
.priority-option.urgent.selected { border-color: var(--color-yellow); color: var(--color-yellow); background: var(--bg-card-hover); }
.priority-option.critical.selected { border-color: var(--color-red); color: var(--color-red); background: var(--bg-card-hover); }

.handoff-history {
    margin-top: 24px;
}
.handoff-history h3 { font-size: 0.95rem; margin-bottom: 12px; }

/* ===== 14. Analytics Digest ===== */
.digest-container {
    max-width: 800px;
}
.digest-actions {
    display: flex; gap: 10px; margin-bottom: 24px;
}
.digest-preview {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 16px; overflow: hidden;
}
.digest-header {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    padding: 32px; color: #fff; text-align: center;
}
.digest-header h2 { font-size: 1.3rem; margin-bottom: 8px; }
.digest-header p { font-size: 0.85rem; opacity: 0.8; }
.digest-body { padding: 32px; }
.digest-metric-row {
    display: flex; gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.digest-metric {
    flex: 1; min-width: 120px; text-align: center;
    padding: 16px; background: var(--bg-card);
    border-radius: 10px;
}
.digest-metric .value { font-size: 1.5rem; font-weight: 700; }
.digest-metric .label { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }
.digest-section { margin-bottom: 24px; }
.digest-section h3 {
    font-size: 0.95rem; margin-bottom: 12px;
    padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.digest-action-item {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 10px 0; font-size: 0.85rem;
}
.digest-action-dot {
    width: 8px; height: 8px; border-radius: 50%;
    margin-top: 6px; flex-shrink: 0;
}

/* ===== 15. Report Builder ===== */
.report-template-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px; margin-bottom: 24px;
}
.report-template-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 14px; padding: 24px; cursor: pointer;
    transition: all 0.25s; text-align: center;
}
.report-template-card:hover { border-color: var(--primary); transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,0.2); }
.report-template-card.selected { border-color: var(--primary); background: var(--bg-card-hover); }
.report-template-icon {
    width: 56px; height: 56px; border-radius: 14px;
    margin: 0 auto 14px; display: flex;
    align-items: center; justify-content: center; font-size: 1.5rem;
}
.report-template-icon.patient { background: var(--bg-card-hover); }
.report-template-icon.lab { background: var(--bg-card-hover); }
.report-template-icon.equipment { background: var(--bg-card-hover); }
.report-template-icon.financial { background: var(--bg-card-hover); }

.report-template-card h4 { font-size: 0.92rem; margin-bottom: 6px; }
.report-template-card p { font-size: 0.78rem; color: var(--text-muted); line-height: 1.5; }

.report-preview {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 16px; padding: 32px;
    display: none;
}
.report-preview.visible { display: block; }
.report-preview-header {
    text-align: center; padding-bottom: 20px;
    border-bottom: 1px solid var(--border); margin-bottom: 20px;
}
.report-preview-header h2 { font-size: 1.2rem; margin-bottom: 4px; }
.report-preview-header p { font-size: 0.82rem; color: var(--text-muted); }
.report-section { margin-bottom: 20px; }
.report-section h3 { font-size: 0.95rem; margin-bottom: 10px; color: var(--primary-light); }
.report-actions {
    display: flex; gap: 10px; margin-top: 24px;
    padding-top: 16px; border-top: 1px solid var(--border);
}

/* ===== 18. Instrument Health Dashboard ===== */
.instrument-health-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}
.instrument-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    transition: all 0.3s ease;
}
.instrument-card:hover {
    border-color: var(--border);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.health-gauge {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin: 0 auto 16px;
    background: conic-gradient(var(--text-muted) calc(var(--score, 0) * 1%), var(--border) 0);
}
.health-gauge::before {
    content: '';
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    background: var(--bg-card);
}
.health-gauge-value {
    position: relative;
    z-index: 1;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
}
.health-gauge.green {
    background: conic-gradient(var(--color-green) calc(var(--score, 0) * 1%), var(--color-green-bg) 0);
}
.health-gauge.yellow {
    background: conic-gradient(var(--color-yellow) calc(var(--score, 0) * 1%), var(--color-yellow-bg) 0);
}
.health-gauge.red {
    background: conic-gradient(var(--color-red) calc(var(--score, 0) * 1%), var(--color-red-bg) 0);
}
.instrument-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: center;
}
.instrument-meta h4 {
    font-size: 0.92rem;
    font-weight: 700;
}
.instrument-meta p {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.risk-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.risk-badge.risk-green {
    background: var(--color-green-bg);
    color: var(--color-green);
}
.risk-badge.risk-yellow {
    background: var(--color-yellow-bg);
    color: var(--color-yellow);
}
.risk-badge.risk-red {
    background: var(--color-red-bg);
    color: var(--color-red);
}
.uptime-bar {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: var(--bg-card-hover);
    margin-top: 12px;
    overflow: hidden;
}
.uptime-bar .uptime-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--accent);
    transition: width 0.5s ease;
}

/* ===== 19. Sensor Data Visualizer ===== */
.sensor-data-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(6px);
    z-index: 10005;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modal-fade-in 0.2s ease;
}
.sensor-modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 900px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    padding: 32px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.5);
    animation: modal-slide-in 0.25s cubic-bezier(.4,0,.2,1);
}
.sensor-chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}
.sensor-chart-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    position: relative;
}
.sensor-chart-box canvas {
    width: 100%;
    height: 160px;
}
.sensor-metric-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.sensor-range-selector {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
}
.sensor-range-selector button {
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}
.sensor-range-selector button:hover {
    border-color: var(--primary);
    color: var(--primary-light);
}
.sensor-range-selector button.active {
    background: var(--bg-card-hover);
    border-color: var(--primary);
    color: var(--primary-light);
}
.sensor-anomaly {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 6px;
    background: var(--color-red-bg);
    color: var(--color-red);
    font-size: 0.72rem;
    font-weight: 700;
    animation: anomaly-pulse 1.5s ease-in-out infinite;
}
@keyframes anomaly-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== 20. Failure Prediction ===== */
.prediction-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
}
.prediction-bar {
    width: 100%;
    height: 10px;
    border-radius: 5px;
    background: var(--bg-card-hover);
    overflow: hidden;
    margin: 12px 0;
}
.prediction-bar .prediction-fill {
    height: 100%;
    border-radius: 5px;
    background: linear-gradient(90deg, var(--color-green), var(--color-yellow), var(--color-red));
    transition: width 0.6s ease;
}
.prediction-days {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2.4rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 4px;
}
.confidence-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.confidence-badge.high {
    background: var(--color-green-bg);
    color: var(--color-green);
}
.confidence-badge.medium {
    background: var(--color-yellow-bg);
    color: var(--color-yellow);
}
.confidence-badge.low {
    background: var(--color-red-bg);
    color: var(--color-red);
}
.prediction-summary {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}
.prediction-summary-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    font-size: 0.85rem;
}
.risk-factor-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 600;
    background: var(--bg-card-hover);
    color: var(--primary-light);
}

/* ===== 21. Maintenance Scheduler ===== */
.maintenance-calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 24px;
}
.maintenance-calendar .cal-cell {
    background: var(--bg-card);
    padding: 10px;
    min-height: 90px;
}
.maintenance-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    border-left: 4px solid var(--primary);
    margin-bottom: 10px;
    transition: border-color 0.2s, transform 0.2s;
}
.maintenance-card:hover {
    transform: translateY(-1px);
}
.maintenance-card.priority-high {
    border-left-color: var(--color-red);
}
.maintenance-card.priority-medium {
    border-left-color: var(--color-yellow);
}
.maintenance-card.priority-low {
    border-left-color: var(--color-green);
}
.priority-high {
    color: var(--color-red);
}
.priority-medium {
    color: var(--color-yellow);
}
.priority-low {
    color: var(--color-green);
}
.maintenance-type-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.maintenance-type-badge.preventive {
    background: var(--color-green-bg);
    color: var(--color-green);
}
.maintenance-type-badge.corrective {
    background: var(--color-red-bg);
    color: var(--color-red);
}
.maintenance-type-badge.calibration {
    background: var(--color-blue-bg);
    color: var(--color-blue);
}
.maintenance-form-modal .modal-card {
    width: 540px;
}
.maintenance-form-modal .form-group {
    margin-bottom: 16px;
}
.maintenance-form-modal input,
.maintenance-form-modal select,
.maintenance-form-modal textarea {
    width: 100%;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
    font-size: 0.88rem;
}
.maintenance-auto-btn {
    padding: 10px 20px;
    border-radius: 10px;
    background: var(--gradient);
    color: #fff;
    border: none;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    font-family: inherit;
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
}
.maintenance-auto-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--shadow-colored);
}
.maintenance-auto-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, var(--accent-light), transparent);
    transform: translateX(-100%);
    animation: auto-btn-shimmer 2s ease-in-out infinite;
}
@keyframes auto-btn-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ===== 22. Reagent Waste Tracker ===== */
.reagent-table {
    width: 100%;
    border-collapse: collapse;
}
.reagent-table th {
    text-align: left;
    padding: 12px 24px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}
.reagent-table td {
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}
.reagent-table tr:hover {
    background: var(--bg-card);
}
.reagent-variance {
    font-weight: 700;
}
.reagent-variance.high {
    background: var(--color-yellow-bg);
    color: var(--color-yellow);
    padding: 2px 8px;
    border-radius: 4px;
}
.reagent-variance.critical {
    background: var(--color-red-bg);
    color: var(--color-red);
    padding: 2px 8px;
    border-radius: 4px;
}
.reagent-summary-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.reagent-summary-bar .summary-stat {
    flex: 1;
    min-width: 140px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-align: center;
}
.reagent-summary-bar .summary-stat .value {
    font-size: 1.4rem;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
}
.reagent-summary-bar .summary-stat .label {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.reagent-flag-btn {
    padding: 5px 12px;
    border-radius: 6px;
    background: var(--bg-card-hover);
    color: var(--text-muted);
    border: none;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}
.reagent-flag-btn:hover {
    background: var(--accent-light);
}
.waste-cost-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    background: var(--color-red-bg);
    color: var(--color-red);
    font-family: 'Space Grotesk', sans-serif;
}

/* ===== 23. Downtime Log ===== */
.downtime-log {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 600px;
    overflow-y: auto;
    padding-right: 8px;
}
.downtime-log::-webkit-scrollbar {
    width: 4px;
}
.downtime-log::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}
.downtime-entry {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: border-color 0.2s;
}
.downtime-entry:hover {
    border-color: var(--border);
}
.downtime-entry .duration {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    min-width: 70px;
}
.downtime-entry .details {
    flex: 1;
}
.downtime-entry .details h4 {
    font-size: 0.88rem;
    margin-bottom: 2px;
}
.downtime-entry .details p {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.downtime-cause-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.downtime-cause-badge.planned {
    background: var(--color-green-bg);
    color: var(--color-green);
}
.downtime-cause-badge.failure {
    background: var(--color-red-bg);
    color: var(--color-red);
}
.downtime-cause-badge.calibration {
    background: var(--color-blue-bg);
    color: var(--color-blue);
}
.downtime-cause-badge.power {
    background: var(--color-yellow-bg);
    color: var(--color-yellow);
}
.downtime-cause-badge.software {
    background: var(--color-purple-bg);
    color: var(--color-purple);
}
.downtime-stats-row {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.downtime-stat-card {
    flex: 1;
    min-width: 120px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-align: center;
}
.downtime-stat-card .value {
    font-size: 1.4rem;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
}
.downtime-stat-card .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.downtime-filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.downtime-filter-bar select {
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.82rem;
    font-family: inherit;
    cursor: pointer;
}

/* ===== 24. Alert Escalation System ===== */
.alert-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 20px;
    border-left: 4px solid var(--border);
    margin-bottom: 10px;
    transition: all 0.2s;
}
.alert-card:hover {
    transform: translateX(2px);
}
.alert-card.yellow {
    border-left-color: var(--color-yellow);
}
.alert-card.orange {
    border-left-color: #f97316;
}
.alert-card.red {
    border-left-color: var(--color-red);
}
.alert-card h4 {
    font-size: 0.9rem;
    margin-bottom: 6px;
}
.alert-card p {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}
.alert-actions {
    display: flex;
    gap: 8px;
}
.alert-acknowledge-btn {
    padding: 6px 14px;
    border-radius: 8px;
    background: var(--bg-card-hover);
    color: var(--text-muted);
    border: none;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}
.alert-acknowledge-btn:hover {
    background: var(--accent-light);
}
.alert-escalate-btn {
    padding: 6px 14px;
    border-radius: 8px;
    background: var(--color-red-bg);
    color: var(--color-red);
    border: none;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    animation: escalate-pulse 2s ease-in-out infinite;
}
.alert-escalate-btn:hover {
    background: var(--accent-light);
}
@keyframes escalate-pulse {
    0%, 100% { box-shadow: 0 0 0 0 var(--border); }
    50% { box-shadow: 0 0 0 6px rgba(255,255,255,0); }
}
.alert-bell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.1rem;
}
.alert-bell:hover {
    border-color: var(--primary);
    color: var(--primary-light);
}
.alert-bell-count {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-dark);
}
.threshold-config-modal .modal-card {
    width: 520px;
}
.threshold-config-modal .form-group {
    margin-bottom: 16px;
}
.threshold-config-modal input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
}

/* ===== 25. Parts Inventory ===== */
.parts-table {
    width: 100%;
    border-collapse: collapse;
}
.parts-table th {
    text-align: left;
    padding: 12px 24px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}
.parts-table td {
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}
.parts-table tr:hover {
    background: var(--bg-card);
}
.stock-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}
.stock-status.stock-green {
    background: var(--color-green-bg);
    color: var(--color-green);
}
.stock-status.stock-yellow {
    background: var(--color-yellow-bg);
    color: var(--color-yellow);
}
.stock-status.stock-red {
    background: var(--color-red-bg);
    color: var(--color-red);
}
.reorder-list {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
}
.reorder-list h3 {
    font-size: 0.95rem;
    margin-bottom: 12px;
}
.reorder-list .reorder-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}
.reorder-list .reorder-item:last-child {
    border-bottom: none;
}
.parts-link-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 600;
    background: var(--bg-card-hover);
    color: var(--primary-light);
    cursor: pointer;
}
.parts-link-badge:hover {
    background: var(--bg-card-hover);
}

/* ===== 26. Instrument Comparison ===== */
.comparison-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
}
.comparison-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    flex: 1;
    min-width: 260px;
}
.comparison-panel .cards-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.metric-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-radius: 8px;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    transition: background 0.2s;
}
.metric-row:last-child {
    border-bottom: none;
}
.metric-row:hover {
    background: var(--bg-card);
}
.metric-winner {
    background: var(--color-green-bg);
    color: var(--color-green);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
}
.metric-loser {
    background: var(--color-red-bg);
    color: var(--color-red);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
}
.comparison-insight {
    background: var(--bg-card-hover);
    border: 1px solid var(--bg-card-hover);
    border-radius: 10px;
    padding: 16px;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-top: 16px;
}
.comparison-selector {
    padding: 8px 14px;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    margin-bottom: 16px;
}

/* ===== 27. Cost Report ===== */
.cost-report-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}
.cost-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    text-align: center;
    transition: all 0.25s;
}
.cost-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}
.cost-card .cost-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 1.2rem;
}
.cost-card .cost-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 4px;
}
.cost-card .cost-label {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.cost-card.saved .cost-icon {
    background: var(--color-green-bg);
    color: var(--color-green);
}
.cost-card.saved {
    border-color: var(--color-green-bg);
}
.cost-card.spent .cost-icon {
    background: var(--color-red-bg);
    color: var(--color-red);
}
.cost-card.spent {
    border-color: var(--color-red-bg);
}
.cost-card.avoided .cost-icon {
    background: var(--color-blue-bg);
    color: var(--color-blue);
}
.cost-card.avoided {
    border-color: var(--color-blue-bg);
}
.cost-card.roi .cost-icon {
    background: var(--color-purple-bg);
    color: var(--color-purple);
}
.cost-card.roi {
    border-color: var(--accent-light);
}
.cost-breakdown-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 24px;
}
.cost-breakdown-table th {
    text-align: left;
    padding: 12px 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}
.cost-breakdown-table td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}
.cost-breakdown-table tr:hover {
    background: var(--bg-card);
}
.cost-trend-bar {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 60px;
}
.cost-trend-bar .bar {
    flex: 1;
    border-radius: 3px 3px 0 0;
    background: var(--primary);
    opacity: 0.7;
    min-width: 8px;
    transition: opacity 0.2s;
}
.cost-trend-bar .bar:hover {
    opacity: 1;
}
.generate-report-btn {
    padding: 12px 24px;
    border-radius: 10px;
    background: var(--gradient);
    color: #fff;
    border: none;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s;
    box-shadow: 0 4px 15px var(--border);
}
.generate-report-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--shadow-colored);
}

/* ===== 28. Smart Panel Recommender ===== */
.panel-recommender {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
}
.panel-order-form {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.panel-order-form select,
.panel-order-form input {
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
    font-size: 0.88rem;
    flex: 1;
    min-width: 180px;
}
.recommendation-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}
.rec-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-size: 0.85rem;
    transition: all 0.2s;
}
.rec-item .test-name {
    font-weight: 600;
    flex: 1;
}
.rec-item .test-cost {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    margin-left: 12px;
}
.rec-keep {
    background: var(--bg-card-hover);
    border-color: var(--accent-light);
}
.rec-redundant {
    background: var(--bg-card-hover);
    border-color: var(--accent-light);
}
.rec-skip {
    background: var(--bg-card-hover);
    border-color: var(--accent-light);
}
.rec-explanation {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.4;
}
.savings-display {
    text-align: center;
    padding: 20px;
    margin-bottom: 16px;
}
.savings-display .amount {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2.2rem;
    font-weight: 800;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.savings-display .label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.panel-action-btns {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.panel-action-btns .btn-sm {
    padding: 10px 24px;
    font-size: 0.85rem;
}

/* ===== 29. Test Correlation Matrix ===== */
.correlation-matrix {
    display: grid;
    gap: 2px;
    overflow-x: auto;
    margin-bottom: 24px;
}
.correlation-cell {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    font-weight: 700;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.15s;
    position: relative;
}
.correlation-cell:hover {
    transform: scale(1.15);
    z-index: 2;
}
.correlation-cell[data-value="high"] {
    background: var(--bg-card-hover);
    color: #fff;
}
.correlation-cell[data-value="medium"] {
    background: var(--shadow-colored);
    color: #fff;
}
.correlation-cell[data-value="low"] {
    background: var(--border);
    color: #fff;
}
.correlation-cell[data-value="none"] {
    background: var(--bg-card-hover);
    color: var(--text-muted);
}
.correlation-legend {
    display: flex;
    gap: 16px;
    align-items: center;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}
.correlation-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.correlation-legend .legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
}
.correlation-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.78rem;
    color: var(--text);
    white-space: nowrap;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    z-index: 10;
    pointer-events: none;
}
.correlation-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--border);
}
.correlation-detail-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-top: 16px;
    animation: modal-slide-in 0.2s ease;
}
.correlation-detail-panel h4 {
    font-size: 0.92rem;
    margin-bottom: 8px;
}
.correlation-detail-panel p {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
}
.matrix-header-cell {
    writing-mode: vertical-lr;
    transform: rotate(180deg);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    padding: 8px 4px;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 80px;
}

/* ===== 30. Ordering Pattern Analytics ===== */
.ordering-analytics {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
}
.doctor-ordering-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.doctor-ordering-card .doctor-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: #fff;
    flex-shrink: 0;
}
.doctor-ordering-card .doctor-info {
    flex: 1;
}
.doctor-ordering-card .doctor-info h4 {
    font-size: 0.88rem;
    margin-bottom: 2px;
}
.doctor-ordering-card .doctor-info p {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.css-bar-chart {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 16px 0;
}
.css-bar {
    display: flex;
    align-items: center;
    gap: 10px;
}
.css-bar .bar-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    min-width: 100px;
    text-align: right;
}
.css-bar .bar-track {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: var(--bg-card-hover);
    overflow: hidden;
}
.css-bar .bar-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--gradient);
    transition: width 0.6s ease;
}
.css-bar .bar-value {
    font-size: 0.78rem;
    font-weight: 700;
    min-width: 40px;
}
.optimization-gauge {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: conic-gradient(var(--primary) calc(var(--score, 0) * 1%), var(--border) 0);
    flex-shrink: 0;
}
.optimization-gauge::before {
    content: '';
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    background: var(--bg-card);
}
.optimization-gauge .gauge-value {
    position: relative;
    z-index: 1;
    font-size: 1rem;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
}
.department-mini-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.department-mini-table th {
    text-align: left;
    padding: 8px 12px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
.department-mini-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}
.department-mini-table tr:hover {
    background: var(--bg-card);
}

/* ===== 31. Duplicate Order Detection ===== */
.duplicate-detection {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
}
.order-form-sim {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.order-form-sim select,
.order-form-sim input {
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
    font-size: 0.88rem;
    flex: 1;
    min-width: 160px;
}
.duplicate-alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    background: var(--bg-card-hover);
    border: 1px solid var(--accent-light);
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    color: var(--text);
    animation: modal-fade-in 0.3s ease;
}
.duplicate-alert .alert-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}
.duplicate-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-radius: 8px;
    background: var(--bg-card-hover);
    border: 1px solid var(--bg-card-hover);
    margin-bottom: 8px;
    font-size: 0.85rem;
}
.duplicate-item .test-name {
    font-weight: 600;
}
.duplicate-item .last-ordered {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.override-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    margin-top: 12px;
}
.override-form label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 8px;
}
.override-form textarea {
    width: 100%;
    min-height: 60px;
    padding: 10px;
    border-radius: 8px;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
    font-size: 0.85rem;
    resize: vertical;
}
.savings-counter {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--accent);
    text-align: center;
    padding: 16px;
    transition: all 0.3s;
}
.validity-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}
.validity-badge.valid {
    background: var(--color-green-bg);
    color: var(--color-green);
}
.validity-badge.invalid {
    background: var(--color-red-bg);
    color: var(--color-red);
}

/* ===== 32. Panel Cost Calculator ===== */
.cost-calculator {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
}
.test-checklist {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 8px;
    margin-bottom: 16px;
}
.test-checklist::-webkit-scrollbar {
    width: 4px;
}
.test-checklist::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}
.test-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    transition: background 0.2s;
}
.test-row:hover {
    background: var(--bg-card);
}
.test-row:last-child {
    border-bottom: none;
}
.test-row input[type="checkbox"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
}
.test-row .test-name {
    flex: 1;
    font-weight: 500;
}
.test-row .test-cost {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    color: var(--text-muted);
}
.cost-summary-bar {
    position: sticky;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-top: 16px;
}
.cost-summary-bar .total-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.cost-summary-bar .total-amount {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
}
.cost-comparison {
    display: flex;
    gap: 20px;
    margin: 20px 0;
    flex-wrap: wrap;
}
.cost-comparison .comparison-side {
    flex: 1;
    min-width: 200px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    text-align: center;
}
.cost-comparison .comparison-side h4 {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.cost-comparison .comparison-side .price {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
}
.alternative-suggestion {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--bg-card-hover);
    border: 1px solid var(--bg-card-hover);
    font-size: 0.82rem;
    margin-top: 8px;
}
.alternative-suggestion .suggestion-icon {
    color: var(--accent);
    font-size: 1rem;
}
.alternative-suggestion .original-price {
    text-decoration: line-through;
    color: var(--text-muted);
}
.alternative-suggestion .new-price {
    font-weight: 700;
    color: var(--color-green);
}
.savings-percentage {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
    text-align: center;
}

/* ===== 33. Outcome Tracking ===== */
.outcome-dashboard {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
}
.outcome-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.outcome-stats .stat-card {
    flex: 1;
    min-width: 120px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-align: center;
}
.outcome-stats .stat-card .value {
    font-size: 1.4rem;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
}
.outcome-stats .stat-card .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.outcome-pie {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin: 0 auto 20px;
    background: conic-gradient(
        #888888 0% var(--same-pct, 70%),
        #ffffff var(--same-pct, 70%) 100%
    );
    position: relative;
}
.outcome-pie::before {
    content: '';
    position: absolute;
    inset: 20px;
    border-radius: 50%;
    background: var(--bg-card);
}
.outcome-pie .pie-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
    z-index: 1;
}
.outcome-table {
    width: 100%;
    border-collapse: collapse;
}
.outcome-table th {
    text-align: left;
    padding: 12px 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}
.outcome-table td {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}
.outcome-table tr:hover {
    background: var(--bg-card);
}
.outcome-table tr.outcome-same {
    background: var(--bg-card-hover);
}
.outcome-table tr.outcome-same:hover {
    background: var(--bg-card-hover);
}
.outcome-table tr.outcome-different {
    background: var(--bg-card-hover);
}
.outcome-table tr.outcome-different:hover {
    background: var(--bg-card-hover);
}
.confidence-bar {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-card-hover);
    overflow: hidden;
}
.confidence-bar .confidence-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--primary);
    transition: width 0.5s ease;
}

/* ===== 34. Reflex Testing Rules ===== */
.reflex-rules-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}
.reflex-rule-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 20px;
    transition: border-color 0.2s;
}
.reflex-rule-card:hover {
    border-color: var(--border);
}
.reflex-rule-card .rule-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.reflex-rule-card .rule-header h4 {
    font-size: 0.9rem;
}
.rule-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--bg-card-hover);
    border: 1px solid var(--bg-card-hover);
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.rule-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 0;
    color: var(--text-muted);
    font-size: 1.1rem;
}
.rule-action {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--bg-card-hover);
    border: 1px solid var(--bg-card-hover);
    font-size: 0.82rem;
    color: var(--text-muted);
}
.rule-toggle {
    position: relative;
    width: 40px;
    height: 22px;
    border-radius: 11px;
    background: var(--bg-card-hover);
    border: none;
    cursor: pointer;
    transition: background 0.3s;
    flex-shrink: 0;
}
.rule-toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.3s;
}
.rule-toggle.active {
    background: var(--accent);
}
.rule-toggle.active::after {
    transform: translateX(18px);
}
.rule-activity-count {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.68rem;
    font-weight: 700;
    background: var(--bg-card-hover);
    color: var(--primary-light);
}
.add-rule-modal .modal-card {
    width: 520px;
}
.add-rule-modal .form-group {
    margin-bottom: 16px;
}
.add-rule-modal input,
.add-rule-modal select {
    width: 100%;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
    font-size: 0.88rem;
}

/* ===== 35. Savings Leaderboard ===== */
.leaderboard {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
}
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
}
.leaderboard-table th {
    text-align: left;
    padding: 12px 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
.leaderboard-table td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}
.leaderboard-table tr:hover {
    background: var(--bg-card);
}
.rank-medal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: 700;
}
.rank-medal.gold {
    background: rgba(255,215,0,0.15);
    color: #b8860b;
}
.rank-medal.silver {
    background: rgba(192,192,192,0.15);
    color: #707070;
}
.rank-medal.bronze {
    background: rgba(205,127,50,0.15);
    color: #8b4513;
}
.your-ranking {
    background: var(--bg-card-hover);
    border: 1px solid var(--accent-light);
    border-radius: 12px;
    padding: 16px 20px;
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.your-ranking .rank-number {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary-light);
}
.your-ranking .rank-info h4 {
    font-size: 0.9rem;
    margin-bottom: 2px;
}
.your-ranking .rank-info p {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.progress-to-next {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-card-hover);
    overflow: hidden;
    margin-top: 8px;
}
.progress-to-next .progress-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--gradient);
    transition: width 0.5s ease;
}
.sparkline {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 20px;
    vertical-align: middle;
}
.sparkline .spark-bar {
    width: 3px;
    border-radius: 1px;
    background: var(--primary);
    opacity: 0.6;
    transition: opacity 0.2s;
}
.sparkline .spark-bar:last-child {
    opacity: 1;
}
.savings-counter-animated {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--accent);
    transition: all 0.3s;
}
.period-toggle {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
}
.period-toggle button {
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}
.period-toggle button:hover {
    border-color: var(--primary);
    color: var(--primary-light);
}
.period-toggle button.active {
    background: var(--bg-card-hover);
    border-color: var(--primary);
    color: var(--primary-light);
}

/* ===== 36. Insurance Billing Optimizer ===== */
.billing-optimizer {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
}
.coverage-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}
.coverage-table th {
    text-align: left;
    padding: 12px 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}
.coverage-table td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}
.coverage-table tr:hover {
    background: var(--bg-card);
}
.coverage-covered {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--color-green-bg);
    color: var(--color-green);
}
.coverage-partial {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--color-yellow-bg);
    color: var(--color-yellow);
}
.coverage-denied {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--color-red-bg);
    color: var(--color-red);
}
.coverage-preauth {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--color-blue-bg);
    color: var(--color-blue);
}
.denial-risk-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
}
.denial-risk-badge.high {
    background: var(--color-red-bg);
    color: var(--color-red);
}
.denial-risk-badge.medium {
    background: var(--color-yellow-bg);
    color: var(--color-yellow);
}
.denial-risk-badge.low {
    background: var(--color-green-bg);
    color: var(--color-green);
}
.alternative-panel {
    background: var(--bg-card-hover);
    border: 1px solid var(--bg-card-hover);
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 16px;
}
.alternative-panel h4 {
    font-size: 0.9rem;
    margin-bottom: 10px;
    color: var(--text);
}
.alternative-panel .alt-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--bg-card-hover);
    font-size: 0.85rem;
}
.alternative-panel .alt-item:last-child {
    border-bottom: none;
}
.billing-summary {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}
.billing-summary .summary-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border);
}
.billing-summary .summary-row:last-child {
    border-bottom: none;
    font-weight: 700;
    font-size: 1rem;
    padding-top: 12px;
}

/* ===== 37. Clinical Guidelines ===== */
.guidelines-browser {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
}
.guidelines-search {
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    margin-bottom: 20px;
    transition: border-color 0.2s;
}
.guidelines-search:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-card-hover);
}
.guidelines-search::placeholder {
    color: var(--text-muted);
}
.guideline-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 20px;
    margin-bottom: 10px;
    transition: border-color 0.2s;
}
.guideline-card:hover {
    border-color: var(--border);
}
.guideline-card h4 {
    font-size: 0.9rem;
    margin-bottom: 6px;
}
.guideline-card p {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 10px;
}
.guideline-card .tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.evidence-level {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
}
.evidence-level.level-a {
    background: var(--color-green-bg);
    color: var(--color-green);
}
.evidence-level.level-b {
    background: var(--color-yellow-bg);
    color: var(--color-yellow);
}
.evidence-level.level-c {
    background: var(--color-red-bg);
    color: var(--color-red);
}
.guideline-source {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    background: var(--accent-light);
    color: var(--accent);
}
.guideline-category {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 600;
    background: var(--bg-card-hover);
    color: var(--text-muted);
}
.guidelines-check-result {
    padding: 16px;
    border-radius: 10px;
    margin-top: 16px;
    font-size: 0.85rem;
}
.guidelines-check-result.compliant {
    background: var(--color-green-bg);
    border: 1px solid var(--color-green);
    color: var(--color-green);
}
.guidelines-check-result.non-compliant {
    background: var(--color-red-bg);
    border: 1px solid var(--color-red);
    color: var(--color-red);
}

/* ===== 16. Light Theme — New Components ===== */
[data-theme="light"] .cmd-palette { background: #fff; border-color: var(--border); }
[data-theme="light"] .cmd-search-input { color: #0a0a0a; }
[data-theme="light"] .cmd-item:hover, [data-theme="light"] .cmd-item.highlighted { background: #f0f0f0; }
[data-theme="light"] .cmd-item-icon { background: #f0f0f0; }
[data-theme="light"] .modal-card { background: #fff; border-color: var(--border); }
[data-theme="light"] .calendar-day { background: #fff; }
[data-theme="light"] .calendar-day:hover { background: #f5f5f5; }
[data-theme="light"] .timeline-card { background: #fff; border-color: var(--border); }
[data-theme="light"] .medication-card { background: #fff; border-color: var(--border); }
[data-theme="light"] .profile-header, [data-theme="light"] .profile-form { background: #fff; border-color: var(--border); }
[data-theme="light"] .handoff-patient-card { background: #fff; border-color: var(--border); }
[data-theme="light"] .report-template-card { background: #fff; border-color: var(--border); }
[data-theme="light"] .digest-preview { background: #fff; border-color: var(--border); }
[data-theme="light"] .layout-dropdown { background: #fff; border-color: var(--border); }
[data-theme="light"] .comparison-table { background: #fff; border-color: var(--border); }
[data-theme="light"] .comparison-table th { background: #f5f5f5; }
[data-theme="light"] .appointment-panel { background: #fff; border-color: var(--border); }
[data-theme="light"] .calendar-wrapper { background: #fff; border-color: var(--border); }

/* -- Light overrides for sections 18-37 -- */
[data-theme="light"] .instrument-card { background: #fff; border-color: var(--border); }
[data-theme="light"] .instrument-card:hover { box-shadow: 0 8px 24px rgba(0,0,0,0.06); }
[data-theme="light"] .health-gauge::before { background: #fff; }
[data-theme="light"] .uptime-bar { background: var(--border); }
[data-theme="light"] .sensor-modal-content { background: #fff; border-color: var(--border); }
[data-theme="light"] .sensor-chart-box { background: #f5f5f5; border-color: var(--border); }
[data-theme="light"] .sensor-range-selector button { border-color: var(--border); color: var(--text-muted); }
[data-theme="light"] .sensor-range-selector button.active { background: var(--bg-card-hover); }
[data-theme="light"] .prediction-panel { background: #fff; border-color: var(--border); }
[data-theme="light"] .prediction-bar { background: var(--border); }
[data-theme="light"] .prediction-summary-item { background: #f5f5f5; border-color: var(--border); }
[data-theme="light"] .maintenance-calendar { background: var(--border); }
[data-theme="light"] .maintenance-calendar .cal-cell { background: #fff; }
[data-theme="light"] .maintenance-card { background: #fff; border-color: var(--border); }
[data-theme="light"] .maintenance-form-modal input,
[data-theme="light"] .maintenance-form-modal select,
[data-theme="light"] .maintenance-form-modal textarea { background: #f5f5f5; border-color: var(--border); }
[data-theme="light"] .reagent-table th { background: #f5f5f5; }
[data-theme="light"] .reagent-table tr:hover { background: #f5f5f5; }
[data-theme="light"] .reagent-summary-bar .summary-stat { background: #fff; border-color: var(--border); }
[data-theme="light"] .downtime-entry { background: #fff; border-color: var(--border); }
[data-theme="light"] .downtime-stat-card { background: #fff; border-color: var(--border); }
[data-theme="light"] .downtime-filter-bar select { background: #fff; border-color: var(--border); }
[data-theme="light"] .downtime-log::-webkit-scrollbar-thumb { background: #b0b0b0; }
[data-theme="light"] .alert-card { background: #fff; border-color: var(--border); }
[data-theme="light"] .alert-bell { background: #fff; border-color: var(--border); }
[data-theme="light"] .alert-bell-count { border-color: #f5f5f5; }
[data-theme="light"] .threshold-config-modal .modal-card { background: #fff; }
[data-theme="light"] .parts-table th { background: #f5f5f5; }
[data-theme="light"] .parts-table tr:hover { background: #f5f5f5; }
[data-theme="light"] .reorder-list { background: #fff; border-color: var(--border); }
[data-theme="light"] .comparison-panel { background: #fff; border-color: var(--border); }
[data-theme="light"] .comparison-card { background: #fff; border-color: var(--border); }
[data-theme="light"] .metric-row:hover { background: #f5f5f5; }
[data-theme="light"] .comparison-insight { background: var(--bg-card-hover); border-color: var(--bg-card-hover); }
[data-theme="light"] .comparison-selector { background: #fff; border-color: var(--border); }
[data-theme="light"] .cost-card { background: #fff; border-color: var(--border); }
[data-theme="light"] .cost-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.06); }
[data-theme="light"] .cost-breakdown-table th { background: #f5f5f5; }
[data-theme="light"] .cost-breakdown-table tr:hover { background: #f5f5f5; }
[data-theme="light"] .panel-recommender { background: #fff; border-color: var(--border); }
[data-theme="light"] .panel-order-form select,
[data-theme="light"] .panel-order-form input { background: #f5f5f5; border-color: var(--border); }
[data-theme="light"] .rec-item { border-color: var(--border); }
[data-theme="light"] .rec-keep { background: var(--bg-card-hover); }
[data-theme="light"] .rec-redundant { background: var(--bg-card-hover); }
[data-theme="light"] .rec-skip { background: var(--bg-card-hover); }
[data-theme="light"] .correlation-tooltip { background: #fff; border-color: var(--border); box-shadow: 0 8px 24px rgba(0,0,0,0.08); }
[data-theme="light"] .correlation-detail-panel { background: #fff; border-color: var(--border); }
[data-theme="light"] .ordering-analytics { background: #fff; border-color: var(--border); }
[data-theme="light"] .doctor-ordering-card { background: #f5f5f5; border-color: var(--border); }
[data-theme="light"] .css-bar .bar-track { background: var(--border); }
[data-theme="light"] .optimization-gauge::before { background: #fff; }
[data-theme="light"] .department-mini-table th { border-color: var(--border); }
[data-theme="light"] .department-mini-table td { border-color: var(--border); }
[data-theme="light"] .department-mini-table tr:hover { background: #f5f5f5; }
[data-theme="light"] .duplicate-detection { background: #fff; border-color: var(--border); }
[data-theme="light"] .order-form-sim select,
[data-theme="light"] .order-form-sim input { background: #f5f5f5; border-color: var(--border); }
[data-theme="light"] .override-form { background: #f5f5f5; border-color: var(--border); }
[data-theme="light"] .override-form textarea { background: #fff; border-color: var(--border); }
[data-theme="light"] .cost-calculator { background: #fff; border-color: var(--border); }
[data-theme="light"] .test-row:hover { background: #f5f5f5; }
[data-theme="light"] .test-checklist::-webkit-scrollbar-thumb { background: #b0b0b0; }
[data-theme="light"] .cost-summary-bar { background: #fff; border-color: var(--border); }
[data-theme="light"] .cost-comparison .comparison-side { background: #f5f5f5; border-color: var(--border); }
[data-theme="light"] .outcome-dashboard { background: #fff; border-color: var(--border); }
[data-theme="light"] .outcome-stats .stat-card { background: #f5f5f5; border-color: var(--border); }
[data-theme="light"] .outcome-pie::before { background: #fff; }
[data-theme="light"] .outcome-table th { background: #f5f5f5; }
[data-theme="light"] .outcome-table tr:hover { background: #f5f5f5; }
[data-theme="light"] .outcome-table tr.outcome-same { background: var(--bg-card-hover); }
[data-theme="light"] .outcome-table tr.outcome-different { background: var(--bg-card-hover); }
[data-theme="light"] .confidence-bar { background: var(--border); }
[data-theme="light"] .reflex-rule-card { background: #fff; border-color: var(--border); }
[data-theme="light"] .rule-toggle { background: var(--border); }
[data-theme="light"] .add-rule-modal input,
[data-theme="light"] .add-rule-modal select { background: #f5f5f5; border-color: var(--border); }
[data-theme="light"] .leaderboard { background: #fff; border-color: var(--border); }
[data-theme="light"] .leaderboard-table th { border-color: var(--border); }
[data-theme="light"] .leaderboard-table td { border-color: var(--border); }
[data-theme="light"] .leaderboard-table tr:hover { background: #f5f5f5; }
[data-theme="light"] .your-ranking { background: var(--bg-card-hover); border-color: var(--bg-card-hover); }
[data-theme="light"] .progress-to-next { background: var(--border); }
[data-theme="light"] .period-toggle button { border-color: var(--border); color: var(--text-muted); }
[data-theme="light"] .period-toggle button.active { background: var(--bg-card-hover); }
[data-theme="light"] .billing-optimizer { background: #fff; border-color: var(--border); }
[data-theme="light"] .coverage-table th { background: #f5f5f5; }
[data-theme="light"] .coverage-table tr:hover { background: #f5f5f5; }
[data-theme="light"] .alternative-panel { background: var(--bg-card); border-color: var(--bg-card-hover); }
[data-theme="light"] .billing-summary { background: #f5f5f5; border-color: var(--border); }
[data-theme="light"] .billing-summary .summary-row { border-color: var(--border); }
[data-theme="light"] .guidelines-browser { background: #fff; border-color: var(--border); }
[data-theme="light"] .guidelines-search { background: #f5f5f5; border-color: var(--border); }
[data-theme="light"] .guidelines-search:focus { background: var(--bg-card-hover); }
[data-theme="light"] .guideline-card { background: #f5f5f5; border-color: var(--border); }
[data-theme="light"] .guidelines-check-result.compliant { background: var(--bg-card-hover); }
[data-theme="light"] .guidelines-check-result.non-compliant { background: var(--bg-card-hover); }

/* ===== 17. Responsive — New Components ===== */
@media (max-width: 768px) {
    .cmd-palette { width: calc(100vw - 24px); }
    .layout-compact .dash-grid { grid-template-columns: repeat(2, 1fr); }
    .comparison-controls { flex-direction: column; }
    .profile-header { flex-direction: column; text-align: center; }
    .calendar-day { min-height: 60px; }
    .calendar-event { display: none; }
    .email-template-grid { grid-template-columns: 1fr; }
    .report-template-grid { grid-template-columns: repeat(2, 1fr); }
    .medication-card { flex-direction: column; text-align: center; }
    .medication-actions { flex-direction: row; }
    .handoff-patient-card { flex-direction: column; text-align: center; }
    .digest-metric-row { flex-direction: column; }
    .appointment-form .form-row-inline { flex-direction: column; }

    /* 18. Instrument Health Dashboard */
    .instrument-health-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
    .instrument-card { padding: 18px; }
    .health-gauge { width: 64px; height: 64px; }
    .health-gauge-value { font-size: 0.9rem; }

    /* 19. Sensor Data Visualizer */
    .sensor-modal-content { padding: 20px; }
    .sensor-chart-grid { grid-template-columns: 1fr; }
    .sensor-range-selector { flex-wrap: wrap; }

    /* 20. Failure Prediction */
    .prediction-days { font-size: 1.8rem; }

    /* 21. Maintenance Scheduler */
    .maintenance-calendar { grid-template-columns: repeat(3, 1fr); }
    .maintenance-form-modal .modal-card { width: calc(100vw - 40px); }

    /* 22. Reagent Waste Tracker */
    .reagent-summary-bar { flex-direction: column; }
    .reagent-table th, .reagent-table td { padding: 10px 14px; font-size: 0.82rem; }

    /* 23. Downtime Log */
    .downtime-stats-row { flex-direction: column; }
    .downtime-entry { flex-direction: column; text-align: center; gap: 8px; }
    .downtime-filter-bar { flex-direction: column; }

    /* 24. Alert Escalation System */
    .alert-actions { flex-direction: column; }
    .threshold-config-modal .modal-card { width: calc(100vw - 40px); }

    /* 25. Parts Inventory */
    .parts-table th, .parts-table td { padding: 10px 14px; font-size: 0.82rem; }
    .reorder-list .reorder-item { flex-direction: column; gap: 6px; text-align: center; }

    /* 26. Instrument Comparison */
    .comparison-panel .cards-row { flex-direction: column; }
    .metric-row { font-size: 0.8rem; padding: 8px 12px; }

    /* 27. Cost Report */
    .cost-report-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .cost-card .cost-value { font-size: 1.3rem; }
    .cost-breakdown-table th, .cost-breakdown-table td { padding: 10px 14px; font-size: 0.82rem; }

    /* 28. Smart Panel Recommender */
    .panel-order-form { flex-direction: column; }
    .panel-action-btns { flex-direction: column; }
    .savings-display .amount { font-size: 1.6rem; }

    /* 29. Test Correlation Matrix */
    .correlation-cell { width: 36px; height: 36px; font-size: 0.6rem; }
    .matrix-header-cell { max-height: 60px; font-size: 0.62rem; }
    .correlation-legend { flex-wrap: wrap; }

    /* 30. Ordering Pattern Analytics */
    .doctor-ordering-card { flex-direction: column; text-align: center; }
    .css-bar .bar-label { min-width: 70px; font-size: 0.72rem; }

    /* 31. Duplicate Order Detection */
    .order-form-sim { flex-direction: column; }
    .duplicate-item { flex-direction: column; gap: 6px; text-align: center; }

    /* 32. Panel Cost Calculator */
    .cost-comparison { flex-direction: column; }
    .cost-summary-bar { flex-direction: column; gap: 8px; text-align: center; }
    .savings-percentage { font-size: 1.5rem; }

    /* 33. Outcome Tracking */
    .outcome-stats { flex-direction: column; }
    .outcome-pie { width: 100px; height: 100px; }
    .outcome-table th, .outcome-table td { padding: 10px 14px; font-size: 0.82rem; }

    /* 34. Reflex Testing Rules */
    .add-rule-modal .modal-card { width: calc(100vw - 40px); }
    .reflex-rule-card { padding: 14px 16px; }

    /* 35. Savings Leaderboard */
    .leaderboard-table th, .leaderboard-table td { padding: 10px 14px; font-size: 0.82rem; }
    .your-ranking { flex-direction: column; text-align: center; }
    .your-ranking .rank-number { font-size: 1.3rem; }
    .savings-counter-animated { font-size: 1.4rem; }
    .period-toggle { flex-wrap: wrap; }

    /* 36. Insurance Billing Optimizer */
    .coverage-table th, .coverage-table td { padding: 10px 14px; font-size: 0.82rem; }
    .alternative-panel .alt-item { flex-direction: column; gap: 4px; }
    .billing-summary .summary-row { font-size: 0.82rem; }

    /* 37. Clinical Guidelines */
    .guidelines-search { font-size: 0.85rem; padding: 10px 14px; }
    .guideline-card .tags { gap: 4px; }
}

@media (max-width: 480px) {
    .report-template-grid { grid-template-columns: 1fr; }
    .medication-summary { flex-direction: column; }
    .breadcrumb { font-size: 0.75rem; }

    /* 18. Instrument Health Dashboard */
    .instrument-health-grid { grid-template-columns: 1fr; }

    /* 21. Maintenance Scheduler */
    .maintenance-calendar { grid-template-columns: repeat(2, 1fr); }

    /* 27. Cost Report */
    .cost-report-grid { grid-template-columns: 1fr; }

    /* 29. Test Correlation Matrix */
    .correlation-cell { width: 28px; height: 28px; font-size: 0.55rem; }

    /* 33. Outcome Tracking */
    .outcome-pie { width: 80px; height: 80px; }

    /* 35. Savings Leaderboard */
    .sparkline { display: none; }

    /* 36. Insurance Billing Optimizer */
    .coverage-table { font-size: 0.78rem; }
}

/* =====================================================================
 * 38. TEST CREDENTIALS QUICK LOGIN
 * ===================================================================== */
.test-credentials {
    margin-top: 1.5rem;
    border-top: 1px solid var(--bg-card-hover);
    padding-top: 1.2rem;
}

.test-cred-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.8rem;
}

.test-cred-icon {
    font-size: 1rem;
}

.test-cred-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.test-cred-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.65rem 0.8rem;
    background: var(--bg-card-hover);
    border: 1px solid var(--bg-card-hover);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    color: inherit;
    font-family: inherit;
}

.test-cred-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--bg-card-hover);
    transform: translateY(-1px);
}

.test-cred-btn:active {
    transform: translateY(0);
}

.test-cred-role {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    min-width: 60px;
    text-align: center;
    flex-shrink: 0;
}

.test-cred-role.doctor {
    background: var(--color-blue-bg);
    color: var(--color-blue);
}

.test-cred-role.lab {
    background: var(--color-purple-bg);
    color: var(--color-purple);
}

.test-cred-role.patient {
    background: var(--color-green-bg);
    color: var(--color-green);
}

.test-cred-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    overflow: hidden;
}

.test-cred-info span:first-child {
    font-weight: 500;
    color: var(--text);
}

.test-cred-info span:last-child {
    font-family: 'Courier New', monospace;
    font-size: 0.72rem;
    color: var(--shadow-colored);
}

/* Light theme overrides for test credentials */
[data-theme="light"] .test-credentials {
    border-top-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .test-cred-header {
    color: rgba(0, 0, 0, 0.45);
}

[data-theme="light"] .test-cred-btn {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.08);
    color: var(--text);
}

[data-theme="light"] .test-cred-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.12);
}


[data-theme="light"] .test-cred-info {
    color: rgba(0, 0, 0, 0.6);
}

[data-theme="light"] .test-cred-info span:first-child {
    color: rgba(0, 0, 0, 0.85);
}

[data-theme="light"] .test-cred-info span:last-child {
    color: rgba(0, 0, 0, 0.35);
}

/* ===== PREDICTIVE MAINTENANCE ENHANCEMENTS ===== */

/* Risk Heatmap Grid */
.risk-heatmap-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    padding: 16px 0;
}

.risk-hm-cell {
    position: relative;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 10px 10px;
    text-align: center;
    overflow: hidden;
    transition: transform 0.2s;
}

.risk-hm-cell:hover {
    transform: translateY(-2px);
}

.risk-hm-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 0 0 10px 10px;
    transition: height 0.6s ease;
}

.risk-hm-cell[data-risk="low"] .risk-hm-bar { background: var(--color-green); }
.risk-hm-cell[data-risk="warning"] .risk-hm-bar { background: var(--color-yellow); }
.risk-hm-cell[data-risk="critical"] .risk-hm-bar { background: var(--color-red); }
.risk-hm-cell[data-risk="critical"] { border-color: var(--color-red); }
.risk-hm-cell[data-risk="warning"] { border-color: var(--color-yellow); }

.risk-hm-name {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
    position: relative;
    z-index: 1;
}

.risk-hm-score {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    position: relative;
    z-index: 1;
}

.risk-hm-cell[data-risk="low"] .risk-hm-score { color: var(--color-green); }
.risk-hm-cell[data-risk="warning"] .risk-hm-score { color: var(--color-yellow); }
.risk-hm-cell[data-risk="critical"] .risk-hm-score { color: var(--color-red); }

/* Anomaly Ticker */
.anomaly-ticker {
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-top: 20px;
}

.anomaly-ticker-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
}

.anomaly-ticker-header svg { color: var(--text-muted); }

.anomaly-ticker-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.anomaly-ticker-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.anomaly-ticker-item.critical {
    background: var(--color-red-bg);
    border-left: 3px solid var(--color-red);
    color: var(--color-red);
}

.anomaly-ticker-item.warning {
    background: var(--color-yellow-bg);
    border-left: 3px solid var(--color-yellow);
    color: var(--color-yellow);
}

.anomaly-ticker-item.info {
    background: var(--color-blue-bg);
    border-left: 3px solid var(--color-blue);
    color: var(--color-blue);
}

.anomaly-time {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 70px;
}

/* Prediction Timeline */
.prediction-timeline {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 0;
}

.pred-timeline-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.pred-tl-instrument {
    min-width: 200px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text);
}

.pred-tl-bar {
    flex: 1;
    height: 28px;
    background: var(--bg-card-hover);
    border-radius: 14px;
    overflow: hidden;
    position: relative;
}

.pred-tl-fill {
    height: 100%;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
    transition: width 0.8s ease;
}

.pred-tl-fill.critical { background: linear-gradient(90deg, rgba(248,113,113,0.4), rgba(248,113,113,0.8)); }
.pred-tl-fill.warning { background: linear-gradient(90deg, rgba(251,191,36,0.3), rgba(251,191,36,0.7)); }
.pred-tl-fill.stable { background: linear-gradient(90deg, rgba(52,211,153,0.3), rgba(52,211,153,0.6)); }

.pred-tl-marker {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}

.pred-tl-legend {
    display: flex;
    gap: 20px;
    padding: 12px 0 4px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.pred-legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.pred-legend-dot.critical { background: var(--color-red); }
.pred-legend-dot.warning { background: var(--color-yellow); }
.pred-legend-dot.stable { background: var(--color-green); }

/* Sensor Gauge Grid */
.sensor-gauge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.sensor-gauge-card {
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px 16px;
    text-align: center;
    transition: transform 0.2s;
}

.sensor-gauge-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.sensor-gauge-ring {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 12px;
}

.sensor-gauge-ring canvas {
    width: 120px;
    height: 120px;
}

.gauge-center-val {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.sensor-gauge-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.sensor-gauge-range {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.sensor-gauge-status {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
}

.sensor-gauge-status.normal { background: var(--color-green-bg); color: var(--color-green); }
.sensor-gauge-status.warning { background: var(--color-yellow-bg); color: var(--color-yellow); }
.sensor-gauge-status.critical { background: var(--color-red-bg); color: var(--color-red); }

/* Sensor Anomaly Feed */
.sensor-anomaly-feed {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 0;
}

/* Feature Importance Bars */
.feature-importance-bars {
    padding: 16px 0;
}

.fi-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.fi-label {
    min-width: 180px;
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
}

.fi-bar-wrap {
    flex: 1;
    height: 24px;
    background: var(--bg-card-hover);
    border-radius: 12px;
    overflow: hidden;
}

.fi-bar {
    height: 100%;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #fff;
    transition: width 0.6s ease;
}

/* RUL Grid */
.rul-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 16px 0;
}

.rul-card {
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}

.rul-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.rul-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
}

.rul-confidence {
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.rul-bar {
    height: 8px;
    background: var(--bg-card-hover);
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0;
}

.rul-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

.rul-days {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.rul-sublabel {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Work Order Kanban */
.wo-kanban {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 16px;
}

.wo-column {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 300px;
}

.wo-column-header {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.wo-col-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.wo-col-count {
    margin-left: auto;
    background: var(--bg-card-hover);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
}

.wo-card {
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.wo-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.wo-card.completed {
    opacity: 0.6;
}

.wo-card.priority-critical { border-left: 3px solid #ffffff; }
.wo-card.priority-high { border-left: 3px solid #cccccc; }
.wo-card.priority-medium { border-left: 3px solid #aaaaaa; }
.wo-card.priority-low { border-left: 3px solid #888888; }

.wo-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.wo-id {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 600;
}

.wo-priority {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
}

.wo-priority.critical { background: var(--color-red-bg); color: var(--color-red); }
.wo-priority.high { background: var(--color-yellow-bg); color: var(--color-yellow); }
.wo-priority.medium { background: var(--color-blue-bg); color: var(--color-blue); }
.wo-priority.low { background: var(--color-green-bg); color: var(--color-green); }

.wo-card-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
    line-height: 1.4;
}

.wo-card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.wo-progress-bar {
    height: 4px;
    background: var(--bg-card-hover);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 10px;
}

.wo-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.4s;
}

.wo-progress-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: right;
}

.wo-hold-reason {
    margin-top: 8px;
    padding: 8px;
    background: var(--bg-card-hover);
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Component Wear */
.component-wear-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.cw-card {
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    transition: transform 0.2s;
}

.cw-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.cw-card.critical { border-left: 4px solid #ffffff; }
.cw-card.warning { border-left: 4px solid #aaaaaa; }
.cw-card.ok { border-left: 4px solid #888888; }

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

.cw-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
}

.cw-status {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
}

.cw-status.critical { background: var(--color-red-bg); color: var(--color-red); }
.cw-status.warning { background: var(--color-yellow-bg); color: var(--color-yellow); }
.cw-status.ok { background: var(--color-green-bg); color: var(--color-green); }

.cw-wear-bar {
    height: 8px;
    background: var(--bg-card-hover);
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0 4px;
}

.cw-card.critical .cw-fill { background: linear-gradient(90deg, #ffffff, #e0e0e0); }
.cw-card.warning .cw-fill { background: linear-gradient(90deg, #aaaaaa, #888888); }
.cw-card.ok .cw-fill { background: linear-gradient(90deg, #666666, #555555); }

.cw-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

.cw-wear-pct {
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.cw-card.critical .cw-wear-pct { color: var(--color-red); }
.cw-card.warning .cw-wear-pct { color: var(--color-yellow); }
.cw-card.ok .cw-wear-pct { color: var(--color-green); }

.cw-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.cw-forecast {
    padding: 8px 12px;
    background: var(--bg-card-hover);
    border-radius: 8px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* ROI Strategy Grid */
.roi-strategy-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 16px;
}

.roi-card {
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    text-align: center;
    transition: transform 0.2s;
}

.roi-card:hover {
    transform: translateY(-2px);
}

.roi-card.active {
    border: 2px solid #888888;
    box-shadow: 0 0 24px var(--bg-card-hover);
}

.roi-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.roi-card h3 {
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 8px;
}

.roi-card p {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    line-height: 1.5;
}

.roi-metrics {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.roi-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: var(--bg-card-hover);
    border-radius: 8px;
}

.roi-metric-val {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
}

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

.roi-savings-banner {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 20px;
    padding: 20px;
    background: var(--bg-card-hover);
    border: 1px solid var(--accent-light);
    border-radius: 14px;
}

.roi-savings-item {
    text-align: center;
}

.roi-savings-label {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.roi-savings-val {
    font-size: 1.3rem;
    font-weight: 700;
}

/* Light theme overrides for new components */
[data-theme="light"] .risk-hm-cell { background: rgba(0,0,0,0.02); border-color: var(--border); }
[data-theme="light"] .risk-hm-name { color: var(--text); }
[data-theme="light"] .anomaly-ticker { background: rgba(0,0,0,0.02); border-color: var(--border); }
[data-theme="light"] .anomaly-ticker-header { color: var(--text); }
[data-theme="light"] .anomaly-ticker-item { color: var(--text-muted); }
[data-theme="light"] .anomaly-ticker-item.critical { background: var(--color-red-bg); color: var(--text); }
[data-theme="light"] .anomaly-ticker-item.warning { background: var(--color-yellow-bg); color: var(--text); }
[data-theme="light"] .anomaly-ticker-item.info { background: var(--color-blue-bg); color: var(--text); }
[data-theme="light"] .pred-tl-instrument { color: var(--text); }
[data-theme="light"] .pred-tl-marker { color: var(--text); }
[data-theme="light"] .sensor-gauge-card { background: rgba(0,0,0,0.02); border-color: var(--border); }
[data-theme="light"] .gauge-center-val { color: var(--text); }
[data-theme="light"] .sensor-gauge-label { color: var(--text); }
[data-theme="light"] .fi-label { color: var(--text-muted); }
[data-theme="light"] .wo-column { background: rgba(0,0,0,0.01); border-color: var(--border); }
[data-theme="light"] .wo-column-header { color: var(--text); }
[data-theme="light"] .wo-card { background: #fff; border-color: var(--border); }
[data-theme="light"] .wo-card-title { color: var(--text); }
[data-theme="light"] .wo-hold-reason { background: var(--bg-card-hover); }
[data-theme="light"] .cw-card { background: rgba(0,0,0,0.02); border-color: var(--border); }
[data-theme="light"] .cw-name { color: var(--text); }
[data-theme="light"] .cw-forecast { background: rgba(0,0,0,0.03); color: var(--text-muted); }
[data-theme="light"] .roi-card { background: rgba(0,0,0,0.02); border-color: var(--border); }
[data-theme="light"] .roi-card h3 { color: var(--text); }
[data-theme="light"] .roi-card.active { border-color: #333333; }
[data-theme="light"] .roi-metric-val { color: var(--text); }
[data-theme="light"] .roi-savings-banner { background: var(--bg-card-hover); border-color: var(--bg-card-hover); }
[data-theme="light"] .rul-card { background: rgba(0,0,0,0.02); border-color: var(--border); }
[data-theme="light"] .rul-name { color: var(--text); }

/* ===== NEW SECTIONS — AI Copilot, Integration, etc. ===== */

/* AI Copilot Chat */
.ai-chat-box {
    max-height: 320px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 0;
    margin-bottom: 12px;
}
.ai-chat-msg {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.ai-chat-msg.user {
    flex-direction: row-reverse;
}
.ai-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}
.ai-bubble {
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 0.875rem;
    line-height: 1.5;
    max-width: 80%;
}
.ai-chat-msg.user .ai-bubble {
    background: var(--bg-card-hover);
    border-color: var(--border);
}
.ai-chat-input-bar {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Status badge extensions */
.status-badge.justify { background: var(--color-yellow-bg); color: var(--color-yellow); }

/* Light theme overrides for new sections */
[data-theme="light"] .ai-bubble { background: #f5f5f5; border-color: var(--border); }
[data-theme="light"] .ai-chat-msg.user .ai-bubble { background: var(--bg-card-hover); }

/* Responsive — Tablet */
@media (max-width: 1024px) {
    .wo-kanban { grid-template-columns: repeat(2, 1fr); }
    .roi-strategy-grid { grid-template-columns: 1fr; }
    .roi-savings-banner { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .wo-kanban { grid-template-columns: 1fr; }
    .component-wear-grid { grid-template-columns: 1fr; }
    .pred-tl-instrument { min-width: 100px; }
    .fi-label { min-width: 80px; }
    .roi-savings-banner { grid-template-columns: 1fr; }
    .sensor-gauge-grid { grid-template-columns: repeat(2, 1fr); }
    .risk-heatmap-grid { grid-template-columns: repeat(2, 1fr); }
    .ai-chat-input-bar { flex-direction: column; }
    .ai-chat-input-bar .form-input { width: 100%; }
}

/* =====================================================================
 * SCROLLABLE TABLE WRAPPER (50+ row tables)
 * ===================================================================== */
.table-scroll-50 {
    max-height: 600px;
    overflow-y: auto;
    border: 1px solid var(--border, #1a1a1a);
    border-radius: 12px;
}
.table-scroll-50 table {
    border-collapse: collapse;
    width: 100%;
}
.table-scroll-50 thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-card, #0a0a0a);
}

/* =====================================================================
 * EQUIPMENT CATEGORY FILTER BAR
 * ===================================================================== */
.equipment-category-filter {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.filter-chip {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--border, #1a1a1a);
    background: transparent;
    color: var(--text-muted, #737373);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.filter-chip:hover,
.filter-chip.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* =====================================================================
 * SAMPLE PIPELINE (Patient Dashboard)
 * ===================================================================== */
.sample-pipeline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 32px 16px;
    overflow-x: auto;
}
.sample-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 90px;
}
.sample-stage .stage-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border, #1a1a1a);
    color: var(--text-muted, #737373);
    transition: all 0.3s ease;
}
.sample-stage.completed .stage-icon {
    border-color: var(--color-green);
    color: var(--color-green);
    background: var(--color-green-bg);
}
.sample-stage.active .stage-icon {
    border-color: var(--accent);
    color: #fff;
    background: var(--accent);
    animation: pulse-stage 2s infinite;
}
.sample-stage.pending .stage-icon {
    border-color: var(--border, #1a1a1a);
    color: var(--text-muted, #737373);
    opacity: 0.5;
}
.sample-stage .stage-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text, #f5f5f5);
}
.sample-stage.pending .stage-label {
    opacity: 0.5;
}
.sample-stage .stage-time {
    font-size: 0.72rem;
    color: var(--text-muted, #737373);
}
.stage-connector {
    width: 40px;
    height: 2px;
    background: var(--border, #1a1a1a);
    flex-shrink: 0;
    margin-bottom: 36px;
}
.stage-connector.completed {
    background: var(--color-green);
}
.stage-connector.active {
    background: linear-gradient(90deg, var(--color-green), var(--border));
}

@keyframes pulse-stage {
    0%, 100% { box-shadow: 0 0 0 0 var(--border); }
    50% { box-shadow: 0 0 0 8px rgba(255, 255, 255, 0); }
}

@media (max-width: 640px) {
    .sample-pipeline {
        flex-direction: column;
        gap: 0;
    }
    .stage-connector {
        width: 2px;
        height: 24px;
        margin-bottom: 0;
    }
}

/* =====================================================================
 * COMPREHENSIVE MOBILE RESPONSIVE FIXES
 * Covers 640px (landscape phones), 480px, and 360px
 * ===================================================================== */

/* ── 640px — landscape phones ──────────────────────────────────────── */
@media (max-width: 640px) {
    /* Chart pairs → single column */
    .grid-2                        { grid-template-columns: 1fr; }
    .sensor-chart-grid             { grid-template-columns: 1fr; }

    /* 4-col grids → 2-col intermediate */
    .instrument-health-grid        { grid-template-columns: repeat(2, 1fr); }
    .cost-report-grid              { grid-template-columns: repeat(2, 1fr); }
    .roi-savings-banner            { grid-template-columns: repeat(2, 1fr); }
    .risk-heatmap-grid             { grid-template-columns: repeat(3, 1fr); }

    /* Remaining multi-col → single */
    .wo-kanban                     { grid-template-columns: 1fr; }
    .roi-strategy-grid             { grid-template-columns: 1fr; }
    .component-wear-grid           { grid-template-columns: 1fr; }
    .rul-grid                      { grid-template-columns: 1fr; }

    /* Analytics layout */
    .layout-analytics .dash-grid   { grid-template-columns: 1fr; }
    .layout-analytics .chart-container { min-height: 250px; }

    /* Table toolbar stacks */
    .table-toolbar                 { flex-direction: column; align-items: stretch; }
    .table-search                  { min-width: 100%; }
}

/* ── 480px — phones ────────────────────────────────────────────────── */
@media (max-width: 480px) {
    /* Column hiding for dense tables */
    .col-hide-mobile               { display: none; }

    /* Compact layout: 4-col → 2-col already at 768px, now → 1-col */
    .layout-compact .dash-grid     { grid-template-columns: 1fr; }

    /* Analytics chart height */
    .layout-analytics .chart-container { min-height: 200px; }

    /* Sensor gauges: 2-col → 1-col */
    .sensor-gauge-grid             { grid-template-columns: 1fr; }

    /* Risk heatmap: 3-col → 2-col */
    .risk-heatmap-grid             { grid-template-columns: repeat(2, 1fr); }

    /* RUL grid spacing */
    .rul-grid                      { gap: 12px; }

    /* Prediction timeline — prevent min-width overflow */
    .pred-tl-instrument            { min-width: 0; width: auto; max-width: 120px; }
    .pred-timeline-row             { flex-wrap: wrap; gap: 8px; }

    /* Stat cards — tighter padding */
    .dash-card                     { padding: 16px 14px; }

    /* Header actions wrap instead of overflow */
    .header-actions                { flex-wrap: wrap; }

    /* Filter bars wrap */
    .downtime-filter-bar           { flex-wrap: wrap; gap: 8px; }
    .equipment-category-filter     { flex-wrap: wrap; }

    /* Specialized tables that don't use .data-table-container */
    .reagent-table,
    .cost-breakdown-table,
    .parts-table,
    .comparison-table              { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* Override inline max-width:600px on profile / settings forms */
    .data-table-container          { max-width: 100% !important; }

    /* AI explanation cards — reduce inline padding */
    [data-section="ai-explanations"] > div > div[style*="padding"] { padding: 12px !important; }

    /* Section containers */
    .section-container             { padding: 0 12px; }

    /* Page header */
    .page-header                   { flex-wrap: wrap; gap: 12px; }
}

/* ── 360px — smallest phones ───────────────────────────────────────── */
@media (max-width: 360px) {
    .risk-heatmap-grid             { grid-template-columns: 1fr; }
    .sensor-gauge-grid             { grid-template-columns: 1fr; }
    .instrument-health-grid        { grid-template-columns: 1fr; }
    .form-row                      { flex-wrap: wrap; }
    .pred-tl-instrument            { font-size: 0.7rem; max-width: 80px; }
    .dash-card                     { padding: 12px 10px; }
    .data-table th, .data-table td { padding: 8px 8px; font-size: 0.75rem; }
}

/* ===== AUTH PAGE — SPLIT-SCREEN REDESIGN ===== */
.auth-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}

/* Left brand panel */
.auth-brand {
    background: var(--gradient);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 60px 48px;
    position: relative;
    overflow: hidden;
    color: #fff;
}
.auth-brand::before {
    content: '';
    position: absolute;
    top: -120px;
    right: -120px;
    width: 420px;
    height: 420px;
    background: rgba(255,255,255,0.07);
    border-radius: 50%;
    pointer-events: none;
}
.auth-brand::after {
    content: '';
    position: absolute;
    bottom: -80px;
    left: -80px;
    width: 300px;
    height: 300px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
    pointer-events: none;
}
.auth-brand-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 52px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}
.auth-brand-logo .logo-icon {
    width: 46px;
    height: 46px;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 800;
}
.auth-brand-tagline {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 14px;
    text-align: center;
    max-width: 360px;
    letter-spacing: -0.02em;
}
.auth-brand-sub {
    font-size: 0.95rem;
    opacity: 0.85;
    margin-bottom: 48px;
    text-align: center;
    max-width: 300px;
    line-height: 1.65;
}
.auth-brand-features {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    max-width: 360px;
}
.auth-feature-pill {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: rgba(255,255,255,0.14);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 14px;
    font-size: 0.88rem;
    font-weight: 500;
}
.auth-feature-pill .pill-icon {
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.auth-feature-text strong {
    display: block;
    font-weight: 700;
    margin-bottom: 2px;
}
.auth-feature-text span {
    font-size: 0.78rem;
    opacity: 0.8;
}

/* Right form panel — always light regardless of dark theme */
.auth-form-panel {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 60px 48px;
    background: #ffffff;
    color: #0f172a;
    position: relative;
    overflow-y: auto;
    min-height: 100%;
}
.auth-form-inner {
    width: 100%;
    max-width: 400px;
}
.auth-back-link {
    position: absolute;
    top: 24px;
    left: 28px;
    font-size: 0.84rem;
    color: var(--text-muted);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s;
    font-weight: 500;
}
.auth-back-link:hover { color: var(--accent); }
.auth-form-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}
.auth-form-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 32px;
    line-height: 1.5;
}

/* Step indicators */
.auth-steps {
    display: flex;
    align-items: center;
    margin-bottom: 32px;
}
.auth-step {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}
.auth-step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-card-hover);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    transition: all 0.3s;
    flex-shrink: 0;
}
.auth-step.active .auth-step-num {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.auth-step.completed .auth-step-num {
    background: var(--color-green);
    border-color: var(--color-green);
    color: #fff;
}
.auth-step.active { color: var(--text); }
.auth-step-connector {
    height: 2px;
    flex: 1;
    background: var(--border);
    margin: 0 8px;
    min-width: 20px;
    transition: background 0.3s;
}
.auth-step-connector.completed { background: var(--color-green); }

/* Register role cards */
.auth-role-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 8px;
}
.auth-role-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 18px 10px;
    border-radius: 14px;
    border: 2px solid var(--border);
    background: var(--bg-card);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}
.auth-role-card:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}
.auth-role-card.active {
    border-color: var(--accent);
    background: var(--accent-light);
    box-shadow: 0 0 0 3px var(--accent-light);
}
.auth-role-card input[type="radio"] { display: none; }
.auth-role-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--bg-card-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--text-muted);
}
.auth-role-card.active .auth-role-icon {
    background: var(--accent);
    color: #fff;
}
.auth-role-icon svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}
.auth-role-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text);
}
.auth-role-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.3;
}

/* Multi-step panels */
.auth-step-panel { display: none; }
.auth-step-panel.active { display: block; }

/* Step nav buttons */
.auth-step-nav {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}
.auth-btn-back {
    padding: 12px 20px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card-hover);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}
.auth-btn-back:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.auth-btn-next {
    flex: 1;
    padding: 12px 20px;
    border-radius: 10px;
    border: none;
    background: var(--gradient);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    box-shadow: var(--shadow-colored);
}
.auth-btn-next:hover { opacity: 0.9; transform: translateY(-1px); }

/* Auth footer link */
.auth-footer-link {
    text-align: center;
    margin-top: 24px;
    font-size: 0.88rem;
    color: var(--text-muted);
}
.auth-footer-link a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}
.auth-footer-link a:hover { text-decoration: underline; }

/* Responsive */
@media (max-width: 900px) {
    .auth-brand { padding: 40px 32px; }
    .auth-brand-tagline { font-size: 1.6rem; }
    .auth-form-panel { padding: 40px 32px; }
}
@media (max-width: 768px) {
    .auth-page { grid-template-columns: 1fr; }
    .auth-brand { display: none !important; }
    .auth-form-panel { padding: 72px 24px 48px; min-height: 100vh; justify-content: flex-start; }
    .auth-back-link { top: 16px; left: 16px; }
}
@media (max-width: 480px) {
    .auth-role-grid { grid-template-columns: 1fr; }
    .auth-form-panel { padding: 68px 16px 48px; }
    .auth-form-inner { max-width: 100%; }
}

/* =====================================================================
 * GLOBAL MOBILE SAFETY NET
 * Prevents any element from causing horizontal overflow on phones
 * ===================================================================== */

/* All direct children of main-content clamp to viewport width */
@media (max-width: 768px) {
    .main-content > * { max-width: 100%; box-sizing: border-box; }

    /* Tables always scroll horizontally, never expand viewport */
    .data-table-container,
    .table-scroll-50 { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

    /* Any grid inside main-content that has 3+ columns → 2 col */
    .stat-cards-grid,
    .metrics-row,
    .kpi-grid,
    .summary-cards { grid-template-columns: repeat(2, 1fr) !important; }

    /* Flex rows with many items → wrap */
    .action-row,
    .btn-row,
    .filter-row { flex-wrap: wrap; }

    /* Page header ph-row padding clamp */
    .ph-row { padding: 14px 16px !important; }

    /* Modal max-width safety */
    .modal-card[style*="width:"],
    .modal-card[style*="width: "] { width: auto !important; max-width: calc(100vw - 32px) !important; }
}

@media (max-width: 480px) {
    /* Any 2-col grid → 1-col on phones (except intentionally 2-col tiny cards) */
    .form-row-grid,
    .chart-grid { grid-template-columns: 1fr !important; }

    /* All cards in stat grids → full width */
    .stat-cards-grid,
    .metrics-row,
    .kpi-grid,
    .summary-cards { grid-template-columns: 1fr !important; }

    /* Ensure all .dash-card wrappers fit */
    .dash-card,
    .widget-card,
    .chart-container { max-width: 100%; overflow: hidden; }

    /* Tables in new dashboards */
    .data-table { table-layout: auto; }
}

