:root {
    --transition-base: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-w: 260px;
    --sidebar-collapsed-w: 80px;
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
}

[data-theme="dark"] {
    --bg: #0b0e14;
    --surface: rgba(22, 24, 33, 0.7);
    --card-bg: rgba(30, 33, 45, 0.5);
    --border: rgba(255, 255, 255, 0.08);
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #8b5cf6;
    /* Violet */
    --accent-soft: rgba(139, 92, 246, 0.15);
    --secondary: #10b981;
    /* Emerald */
    --danger: #f43f5e;
    --warning: #f59e0b;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

[data-theme="light"] {
    --bg: #f8fafc;
    --surface: rgba(255, 255, 255, 0.8);
    --card-bg: rgba(255, 255, 255, 0.9);
    --border: rgba(0, 0, 0, 0.1);
    --text: #0f172a;
    --text-muted: #64748b;
    --accent: #7c3aed;
    --accent-soft: rgba(124, 58, 237, 0.1);
    --secondary: #059669;
    --danger: #e11d48;
    --warning: #d97706;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg);
    background-image:
        radial-gradient(at 0% 0%, var(--accent-soft) 0px, transparent 50%),
        radial-gradient(at 100% 100%, var(--accent-soft) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    transition: var(--transition-base);
    min-height: 100vh;
}

h1,
h2,
h3,
.display-font {
    font-family: 'Inter', system-ui, sans-serif;
    letter-spacing: -0.02em;
}

#app {
    display: flex;
    min-height: 100vh;
}

#app.hidden {
    display: none;
}

/* --- SIDEBAR --- */
#sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* overflow: hidden; */
}

#sidebar.collapsed {
    width: var(--sidebar-collapsed-w);
}

.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    height: 72px;
    flex-shrink: 0;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
    white-space: nowrap;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    flex-shrink: 0;
}

.logo-text h1 {
    font-size: 16px;
    font-weight: 700;
}

.logo-text p {
    font-size: 11px;
    color: var(--text-muted);
}

#sidebar.collapsed .logo-text {
    display: none;
}

.nav-content {
    padding: 16px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-base);
    white-space: nowrap;
    position: relative;
}

.nav-item:hover {
    color: var(--text);
    background: var(--accent-soft);
}

.nav-item.active {
    color: #fff;
    background: var(--accent);
}

#sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
}

.nav-item i {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.nav-item span {
    font-weight: 500;
}

#sidebar.collapsed .nav-item span {
    display: none;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.admin-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}

#sidebar.collapsed .admin-profile {
    justify-content: center;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-weight: 600;
    flex-shrink: 0;
}

.admin-info {
    overflow: hidden;
    white-space: nowrap;
}

.admin-info .name {
    font-weight: 600;
    font-size: 13px;
}

.admin-info .role {
    font-size: 11px;
    color: var(--text-muted);
}

#sidebar.collapsed .admin-info {
    display: none;
}

/* --- MAIN CONTENT --- */
main {
    flex: 1;
    margin-left: var(--sidebar-w);
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 32px;
    max-width: 1400px;
}

#app.sidebar-collapsed main {
    margin-left: var(--sidebar-collapsed-w);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
}

/* --- BUTTONS --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition-base);
    border: 1px solid transparent;
    font-family: inherit;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--accent-soft);
}

.btn-secondary {
    background: var(--secondary);
    color: #fff;
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}

.btn-ghost:hover {
    background: var(--accent-soft);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

.btn-icon {
    padding: 8px;
    border-radius: var(--radius-sm);
}

/* --- CARDS & GRIDS --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--card-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: var(--transition-base);
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
}

.stat-card .icon-label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}

.stat-card .value {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-card .trend {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.trend.up {
    color: var(--secondary);
}

.trend.down {
    color: var(--danger);
}

/* --- TABLES --- */
.table-container {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.table-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: rgba(0, 0, 0, 0.02);
    padding: 12px 24px;
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--accent-soft);
}

/* --- THEME TOGGLE --- */
.theme-toggle-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    background: var(--bg);
    border-radius: 20px;
    border: 1px solid var(--border);
}

.theme-btn {
    flex: 1;
    padding: 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 16px;
    color: var(--text-muted);
    transition: var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-btn.active {
    background: var(--surface);
    color: var(--accent);
    box-shadow: var(--shadow);
}

/* --- BADGES --- */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-accent {
    background: var(--accent-soft);
    color: var(--accent);
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--secondary);
}

.badge-danger {
    background: rgba(244, 63, 94, 0.1);
    color: var(--danger);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

/* --- MODALS --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    transition: opacity 0.3s;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    padding: 32px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
}

/* --- LOGIN PAGE --- */
#login-screen {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
}

#login-screen.hidden {
    display: none;
}

.login-card {
    background: var(--surface);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 48px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--glass-shadow);
}

.login-card h2 {
    font-size: 28px;
    margin-bottom: 8px;
}

.login-card p {
    color: var(--text-muted);
    margin-bottom: 32px;
    font-size: 15px;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.input-group input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text);
    outline: none;
    transition: var(--transition-base);
}

.input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

/* --- UTILS --- */
.text-muted {
    color: var(--text-muted);
}

.hidden {
    display: none !important;
}

.section {
    display: none;
}

.section.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    background: var(--surface);
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.search-bar input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    color: var(--text);
    outline: none;
}

/* --- SECTION HEADERS --- */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    gap: 16px;
    flex-wrap: wrap;
}

.section-header h2 {
    margin: 0;
    font-size: 24px;
}

.section-header .actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.health-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--text-muted);
    box-shadow: 0 0 10px currentColor;
    /* glow effect */
}


@media (max-width: 768px) {
    #sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-w);
    }

    #sidebar.mobile-open {
        transform: translateX(0);
    }

    main {
        margin-left: 0 !important;
    }
}
/* ============================================================
   ADMIN CONSOLE EXPANSION  NEW COMPONENT STYLES
   ============================================================ */

/* Sidebar divider */
.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 16px;
    opacity: 0.5;
}

/* Danger button */
.btn-danger {
    background: linear-gradient(135deg, #dc2626, #991b1b);
    color: #fff;
    border: none;
}
.btn-danger:hover { background: linear-gradient(135deg, #b91c1c, #7f1d1d); }

/* Global Search */
.search-wrap {
    position: relative;
    flex: 1;
    max-width: 480px;
}
.search-wrap input {
    width: 100%;
    padding: 9px 36px 9px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 13px;
    transition: border-color 0.2s;
}
.search-wrap input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(139,92,246,0.15); }

#search-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0,0,0,0.35);
    z-index: 1000;
    max-height: 420px;
    overflow-y: auto;
    padding: 8px 0;
}
#search-dropdown.hidden { display: none; }

.search-group-label { padding: 8px 16px 4px; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }

.search-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
}
.search-item:hover { background: var(--bg-hover, rgba(139,92,246,0.08)); }
.search-type-icon { font-size: 16px; min-width: 22px; }
.search-item-name { font-weight: 600; font-size: 13px; }
.search-item-sub  { font-size: 11px; color: var(--text-muted); }
.search-empty { padding: 16px; text-align: center; font-size: 13px; color: var(--text-muted); }

/* System Health */
.health-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
}
.health-ok    { background: rgba(16,185,129,0.12); color: #10b981; border: 1px solid rgba(16,185,129,0.25); }
.health-error { background: rgba(220,38,38,0.12);  color: #dc2626; border: 1px solid rgba(220,38,38,0.25); }
.health-dot   { width: 10px; height: 10px; border-radius: 50%; background: currentColor; flex-shrink: 0; animation: pulse 2s infinite; }

.stat-mini { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; }
.stat-mini-label { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 4px; }
.stat-mini-value { font-size: 13px; font-weight: 600; }
.stat-mini-value.ok { color: #10b981; }

/* Error log */
.error-log-stream {
    background: #0d1117;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    line-height: 1.7;
    max-height: 360px;
    overflow-y: auto;
    color: #f85149;
}
.log-line { padding: 1px 0; border-bottom: 1px solid rgba(255,255,255,0.03); word-break: break-all; }

/* KPI mini cards */
.kpi-card-mini {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
}
.kpi-card-mini.kpi-highlight { border-color: var(--accent); background: rgba(139,92,246,0.06); }
.kpi-card-mini.kpi-warn      { border-color: #f59e0b;        background: rgba(245,158,11,0.06); }
.kpi-label   { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 6px; }
.kpi-value   { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; }
.kpi-sub     { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

.stats-grid-mini {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

/* Progress bars (plan distribution) */
.progress-bar-track { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-bar-fill  { height: 100%; border-radius: 99px; transition: width 0.4s ease; }

/* Section header small */
.section-header-sm {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin: 0 0 12px;
}

/* Badge warning */
.badge-warning { background: rgba(245,158,11,0.15); color: #f59e0b; }

/* ============================================================
   SKELETON / SHIMMER LOADING STATES
   ============================================================ */

@keyframes shimmer {
    0%   { background-position: -800px 0; }
    100% { background-position:  800px 0; }
}

.skel {
    display: block;
    border-radius: 6px;
    background: linear-gradient(
        90deg,
        var(--bg-card)         25%,
        rgba(139,92,246,0.08)  50%,
        var(--bg-card)         75%
    );
    background-size: 800px 100%;
    animation: shimmer 1.5s infinite linear;
}

/* Widths */
.skel-h  { height: 12px; width: 60%; }
.skel-md { height: 14px; width: 80%; }
.skel-lg { height: 14px; width: 100%; }
.skel-xl { height: 32px; width: 55%; }

/* Keep skeleton table rows at a comfortable height */
.skeleton-table td, .skeleton-table th { padding: 14px 16px; }
.skeleton-table thead th { border-bottom: 1px solid var(--border); }

/* ============================================================
   LOADING ANIMATIONS  PROGRESS BAR, SECTION TRANSITIONS, SPINNERS
   ============================================================ */

/* -- Top progress bar ------------------------------------- */
#progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #8b5cf6, #a78bfa, #c4b5fd);
    box-shadow: 0 0 10px rgba(139,92,246,0.7), 0 0 20px rgba(139,92,246,0.4);
    border-radius: 0 2px 2px 0;
    z-index: 9999;
    opacity: 0;
    transition: width 0.4s cubic-bezier(0.1,0.5,0.5,1), opacity 0.3s ease;
    pointer-events: none;
}

/* -- Section enter animation ------------------------------ */
.section {
    display: none;
    animation: none;
}
.section.active {
    display: block;
    animation: sectionIn 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

@keyframes sectionIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* -- Login card entrance ---------------------------------- */
.login-card {
    animation: loginIn 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

@keyframes loginIn {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* -- Sidebar nav item hover ------------------------------- */
.nav-item {
    transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.nav-item:active { transform: scale(0.97); }

/* -- Button loading spinner ------------------------------- */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.btn-loading {
    position: relative;
    pointer-events: none;
    color: transparent !important;
}
.btn-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* -- KPI card staggered entrance --------------------------- */
.kpi-card-mini {
    animation: cardIn 0.35s cubic-bezier(0.25,0.46,0.45,0.94) both;
}
.kpi-card-mini:nth-child(1) { animation-delay: 0.00s; }
.kpi-card-mini:nth-child(2) { animation-delay: 0.05s; }
.kpi-card-mini:nth-child(3) { animation-delay: 0.10s; }
.kpi-card-mini:nth-child(4) { animation-delay: 0.15s; }
.kpi-card-mini:nth-child(5) { animation-delay: 0.20s; }
.kpi-card-mini:nth-child(6) { animation-delay: 0.25s; }

@keyframes cardIn {
    from { opacity: 0; transform: scale(0.95) translateY(8px); }
    to   { opacity: 1; transform: scale(1)    translateY(0);   }
}

/* -- Table row entrance ----------------------------------- */
tbody tr {
    animation: rowIn 0.25s ease both;
}
tbody tr:nth-child(1)  { animation-delay: 0.02s; }
tbody tr:nth-child(2)  { animation-delay: 0.04s; }
tbody tr:nth-child(3)  { animation-delay: 0.06s; }
tbody tr:nth-child(4)  { animation-delay: 0.08s; }
tbody tr:nth-child(5)  { animation-delay: 0.10s; }
tbody tr:nth-child(6)  { animation-delay: 0.12s; }
tbody tr:nth-child(7)  { animation-delay: 0.14s; }
tbody tr:nth-child(8)  { animation-delay: 0.16s; }
tbody tr:nth-child(9)  { animation-delay: 0.18s; }
tbody tr:nth-child(10) { animation-delay: 0.20s; }

@keyframes rowIn {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: translateX(0);    }
}

/* -- Modal entrance --------------------------------------- */
.modal {
    animation: modalIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.93) translateY(8px); }
    to   { opacity: 1; transform: scale(1)    translateY(0);   }
}

/* -- Toast entrance --------------------------------------- */
#toast.show {
    animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes toastIn {
    from { opacity: 0; transform: translateY(16px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* -- Sidebar collapsed transition ------------------------- */
#sidebar {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================================
   SYSTEM HEALTH DASHBOARD
   ============================================================================ */

/* Summary bar */
.health-summary-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    padding: 20px 24px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 24px;
}

.health-summary-left,
.health-summary-right {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.health-overall-badge {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 6px 16px;
    border-radius: 20px;
}
.health-overall--ok       { background: #d1fae5; color: #065f46; }
.health-overall--degraded { background: #fef3c7; color: #92400e; }
.health-overall--error    { background: #fee2e2; color: #991b1b; }
.health-overall--starting { background: var(--hover-bg); color: var(--text-secondary); }
[data-theme="dark"] .health-overall--ok       { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .health-overall--degraded { background: #78350f; color: #fde68a; }
[data-theme="dark"] .health-overall--error    { background: #7f1d1d; color: #fca5a5; }

.health-uptime {
    display: flex;
    flex-direction: column;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}
.health-uptime strong { color: var(--text-primary); font-size: 14px; }

.infra-chip {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 12px;
}
.chip-ok    { background: #d1fae5; color: #065f46; }
.chip-error { background: #fee2e2; color: #991b1b; }
[data-theme="dark"] .chip-ok    { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .chip-error { background: #7f1d1d; color: #fca5a5; }

/* Component grid */
.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

/* Component card */
.health-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--border-color);
    border-radius: 12px;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: box-shadow 0.2s;
}
.health-card:hover { box-shadow: var(--shadow-md); }
.health-card--ok       { border-left-color: #10b981; }
.health-card--degraded { border-left-color: #f59e0b; }
.health-card--error    { border-left-color: #ef4444; }
.health-card--starting { border-left-color: #6b7280; }

.health-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.health-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}
.health-card-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Status dot */
.health-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.health-dot.status-ok       { background: #10b981; }
.health-dot.status-degraded { background: #f59e0b; animation: health-pulse 2s infinite; }
.health-dot.status-error    { background: #ef4444; animation: health-pulse 1.2s infinite; }
.health-dot.status-starting { background: #6b7280; animation: health-pulse 2s infinite; }
@keyframes health-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.3; }
}

/* Status badge */
.health-badge {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 3px 10px;
    border-radius: 10px;
    white-space: nowrap;
}
.health-badge.status-ok       { background: #d1fae5; color: #065f46; }
.health-badge.status-degraded { background: #fef3c7; color: #92400e; }
.health-badge.status-error    { background: #fee2e2; color: #991b1b; }
.health-badge.status-starting { background: var(--hover-bg); color: var(--text-muted); }
[data-theme="dark"] .health-badge.status-ok       { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .health-badge.status-degraded { background: #78350f; color: #fde68a; }
[data-theme="dark"] .health-badge.status-error    { background: #7f1d1d; color: #fca5a5; }

/* Meta rows */
.health-card-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px solid var(--border-color);
    padding-top: 10px;
}
.meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}
.meta-label { color: var(--text-secondary); }
.meta-value { font-weight: 600; color: var(--text-primary); }
.meta-value.good { color: #10b981; }
.meta-value.warn { color: #f59e0b; }
.meta-value.muted { color: var(--text-muted); font-weight: 400; }

/* Error message block */
.health-error-msg {
    font-size: 11px;
    font-family: monospace;
    background: var(--hover-bg);
    color: #ef4444;
    border: 1px solid #fee2e2;
    border-radius: 6px;
    padding: 8px 10px;
    word-break: break-all;
    white-space: pre-wrap;
    max-height: 80px;
    overflow-y: auto;
}
[data-theme="dark"] .health-error-msg { border-color: #7f1d1d; }

/* Skeleton */
.skeleton-card {
    pointer-events: none;
}
.skel {
    background: var(--hover-bg);
    border-radius: 6px;
    animation: skel-wave 1.4s infinite;
}
.skel-title  { height: 14px; width: 60%; margin-bottom: 8px; }
.skel-text   { height: 11px; width: 90%; margin-bottom: 6px; }
.skel-short  { width: 50%; }
@keyframes skel-wave {
    0%, 100% { opacity: 0.5; }
    50%       { opacity: 1; }
}

/* Refresh note */
.health-refresh-note {
    font-size: 11px;
    color: var(--text-muted);
    text-align: right;
    margin-top: 4px;
}

/* Audit C2: hover state moved out of an inline onmouseover handler. */
.btn-logout:hover { background: rgba(220,38,38,0.15) !important; }
