/* SmartScreen Admin - Design System
   Based on Glasslook/Workload Tracker shared design system */

:root {
    color-scheme: dark;
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #475569;
    --border-subtle: rgba(255, 255, 255, 0.05);
    --error: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --info: #3b82f6;
    --font-sans: 'Inter', 'Noto Sans Devanagari', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --bg-tertiary: #111827;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.25s ease;
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    background: var(--bg-dark);
    background-image:
        radial-gradient(ellipse at top, rgba(99,102,241,0.08), transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(99,102,241,0.05), transparent 50%);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

/* ============================================
   AUTH PAGES
   ============================================ */
body.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-container { width: 100%; max-width: 420px; }

.auth-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-subtle);
}

body.auth-page .logo { text-align: center; margin-bottom: 32px; }
body.auth-page .logo h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
body.auth-page .logo h1 span { color: var(--primary); }
body.auth-page .logo p { color: var(--text-secondary); font-size: 14px; margin-top: 8px; }

body.auth-page .form-group { margin-bottom: 20px; }
body.auth-page .form-group label {
    display: block; font-size: 13px; font-weight: 500;
    color: var(--text-secondary); margin-bottom: 8px;
}
body.auth-page .form-group input {
    width: 100%; padding: 14px 16px; background: var(--bg-input);
    border: 1px solid var(--border); border-radius: 10px; font-size: 15px;
    color: var(--text-primary); transition: all 0.2s ease;
}
body.auth-page .form-group input:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}
body.auth-page .form-group input::placeholder { color: var(--text-muted); }

.password-wrapper { position: relative; }
.password-wrapper input { padding-right: 48px !important; }
.password-toggle {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer; padding: 4px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); border-radius: 4px;
}
.password-toggle:hover { color: var(--text-primary); }
.password-toggle svg { width: 18px; height: 18px; }

input[type="password"] { color-scheme: dark; }

.form-options {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 24px; font-size: 13px;
}
.remember-me {
    display: flex; align-items: center; gap: 8px;
    color: var(--text-secondary); cursor: pointer;
}
.remember-me input { width: 16px; height: 16px; accent-color: var(--primary); }
.forgot-link { color: var(--primary-light); text-decoration: none; }
.forgot-link:hover { color: var(--primary); }

body.auth-page .btn {
    width: 100%; padding: 14px; border: none; border-radius: 10px;
    font-size: 15px; font-weight: 600; cursor: pointer; transition: all 0.2s ease;
}
body.auth-page .btn-primary { background: var(--primary); color: white; }
body.auth-page .btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
body.auth-page .btn-primary:disabled { background: var(--text-muted); cursor: not-allowed; transform: none; }
body.auth-page .btn-secondary {
    background: transparent; color: var(--text-secondary);
    border: 1px solid var(--border); margin-top: 16px;
    display: block; text-align: center; text-decoration: none;
}
body.auth-page .btn-secondary:hover { background: var(--bg-input); color: var(--text-primary); }

/* Alerts */
.alert {
    padding: 14px 16px; border-radius: 10px; margin-bottom: 20px;
    font-size: 14px; display: none;
}
.alert.show { display: block; }
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid var(--error); color: var(--error); }
.alert-success { background: rgba(34,197,94,0.1); border: 1px solid var(--success); color: var(--success); }
.alert-info { background: rgba(99,102,241,0.1); border: 1px solid var(--primary); color: var(--primary-light); }

/* 2FA Styles */
.twofa-container { text-align: center; }
.twofa-icon {
    width: 64px; height: 64px; background: rgba(99,102,241,0.1);
    border-radius: 16px; display: flex; align-items: center;
    justify-content: center; margin: 0 auto 24px;
}
.twofa-icon svg { width: 32px; height: 32px; color: var(--primary); }

.code-input-container { display: flex; gap: 8px; justify-content: center; margin-bottom: 24px; }
.code-input {
    width: 48px; height: 56px; text-align: center; font-size: 24px;
    font-weight: 600; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: 10px; color: var(--text-primary); transition: all 0.2s;
}
.code-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.2); }

.qr-container {
    background: white; padding: 16px; border-radius: 12px;
    display: inline-block; margin: 20px 0;
}
.qr-container img { display: block; }

.secret-key {
    font-family: var(--font-mono); background: var(--bg-input);
    padding: 12px 16px; border-radius: 8px; font-size: 14px;
    letter-spacing: 2px; color: var(--text-primary); margin: 16px 0; word-break: break-all;
}

.avatar-picker-wrap { max-height: 280px; overflow-y: auto; margin-top: 12px; }
.avatar-picker-grid {
    display: grid; grid-template-columns: repeat(4, 56px); gap: 10px; padding: 4px;
    justify-content: center;
}
.avatar-option {
    width: 56px; height: 56px; border-radius: 50%; cursor: pointer;
    border: 2px solid transparent; transition: all 0.2s; overflow: hidden;
    flex-shrink: 0;
}
.avatar-option:hover { border-color: var(--primary); transform: scale(1.1); }
.avatar-option img { width: 100%; height: 100%; object-fit: cover; display: block; }

.backup-codes { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; margin: 20px 0; }
.backup-code {
    font-family: var(--font-mono); background: var(--bg-input);
    padding: 10px; border-radius: 6px; font-size: 13px;
    text-align: center; color: var(--text-primary);
}

/* Spinner */
.spinner {
    width: 20px; height: 20px; border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white; border-radius: 50%;
    animation: spin 0.8s linear infinite; display: inline-block; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

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

.sidebar {
    width: 240px; background: var(--bg-card); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; position: fixed;
    top: 0; left: 0; height: 100vh; z-index: 100;
    transition: width var(--transition-slow);
}
.sidebar.collapsed { width: 72px; }

.sidebar-header {
    padding: 1rem 1rem 1rem 1.25rem; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; min-height: 64px;
}
.logo {
    display: flex; align-items: center; gap: 0.75rem;
    font-size: 1.1rem; font-weight: 700; white-space: nowrap; overflow: hidden;
}
.logo-icon { width: 24px; height: 24px; flex-shrink: 0; color: var(--primary); }
.logo-text { transition: opacity var(--transition-normal); }
.sidebar.collapsed .logo-text { opacity: 0; width: 0; }

.sidebar-toggle {
    background: transparent; border: none; padding: 0.5rem; cursor: pointer;
    color: var(--text-muted); border-radius: var(--radius-sm);
    transition: all var(--transition-fast); display: flex;
    align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--bg-input); color: var(--text-primary); }
.sidebar-toggle svg { width: 18px; height: 18px; transition: transform var(--transition-slow); }
.sidebar.collapsed .sidebar-toggle svg { transform: rotate(180deg); }

.sidebar-nav {
    flex: 1; padding: 1rem 0; overflow-y: auto; overflow-x: hidden; list-style: none;
}
.nav-section {
    padding: 1.25rem 1.25rem 0.5rem; font-size: 0.65rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted);
    white-space: nowrap; overflow: hidden; position: relative;
}
.nav-section span { display: inline-block; transition: opacity var(--transition-normal); }
.sidebar.collapsed .nav-section { padding: 1rem 0.75rem 0.5rem; text-align: center; }
.sidebar.collapsed .nav-section span { opacity: 0; position: absolute; pointer-events: none; }
.sidebar.collapsed .nav-section::before {
    content: ''; display: block; width: 20px; height: 1px;
    background: var(--border); margin: 0 auto;
}

.nav-item {
    display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 1.25rem;
    color: var(--text-secondary); text-decoration: none; cursor: pointer;
    transition: all var(--transition-fast); white-space: nowrap; overflow: hidden;
}
.sidebar.collapsed .nav-item { justify-content: center; padding: 0.7rem; }
.nav-item:hover, .nav-item.active { background: rgba(99,102,241,0.1); color: var(--primary-light); }
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item span { transition: opacity var(--transition-normal); }
.sidebar.collapsed .nav-item span { opacity: 0; width: 0; overflow: hidden; }

.main-content {
    flex: 1; margin-left: 240px; padding: 2rem; min-height: 100vh;
    transition: margin-left var(--transition-slow);
}
.sidebar.collapsed ~ .main-content { margin-left: 72px; }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.page-header h2 { font-size: 1.75rem; font-weight: 700; }

/* User info in sidebar */
.user-info { padding: 1rem 1.25rem; border-top: 1px solid var(--border); margin-top: auto; }
.user-info-content { display: flex; align-items: center; gap: 0.75rem; }
.sidebar.collapsed .user-info-content { justify-content: center; }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%; background: var(--primary);
    flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.875rem; color: white; overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-details {
    flex: 1; min-width: 0; overflow: hidden;
    transition: opacity var(--transition-normal);
}
.sidebar.collapsed .user-details { opacity: 0; width: 0; display: none; }
.user-details .name { font-size: 0.875rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-details .role { font-size: 0.75rem; color: var(--text-secondary); }
.user-info .btn-icon {
    background: transparent; border: none; cursor: pointer; color: var(--text-muted);
    padding: 6px; border-radius: var(--radius-sm); transition: all var(--transition-fast);
}
.user-info .btn-icon:hover { color: var(--text-primary); background: var(--bg-input); }
.sidebar.collapsed .user-info .btn-icon { display: none; }

/* Sidebar version stamp */
.sidebar-version { text-align: center; font-size: 0.65rem; color: var(--text-muted); padding: 0.5rem 0; letter-spacing: 0.08em; opacity: 0.5; }
.sidebar.collapsed .sidebar-version { display: none; }

/* Page sections */
.page-section { display: none; }
.page-section.active { display: block; }

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--bg-card); border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle); box-shadow: var(--shadow);
    transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}
.card:hover {
    box-shadow: 0 8px 16px -4px rgba(0,0,0,0.3);
}
.card-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.card-header h3 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 1.25rem; overflow-x: auto; }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.625rem 1.25rem; border: none; border-radius: var(--radius-md);
    font-size: 0.875rem; font-weight: 500; font-family: var(--font-sans);
    cursor: pointer; transition: all var(--transition-fast); text-decoration: none;
}
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-primary:disabled { background: var(--text-muted); cursor: not-allowed; transform: none; }
.btn-secondary { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--error); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-input); color: var(--text-primary); }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ============================================
   FORMS
   ============================================ */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block; margin-bottom: 0.5rem; font-size: 0.85rem;
    font-weight: 500; color: var(--text-secondary);
}
.form-input, .form-select {
    width: 100%; padding: 0.625rem 0.875rem; background: var(--bg-input);
    border: 1px solid var(--border); border-radius: var(--radius-md);
    color: var(--text-primary); font-size: 0.9rem; font-family: var(--font-sans);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    color-scheme: dark;
}
select.form-input option, .form-select option {
    background: var(--bg-card); color: var(--text-primary);
}
.form-input:focus, .form-select:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}
.form-input::placeholder { color: var(--text-muted); }

/* ============================================
   TABLES
   ============================================ */
.data-table { width: 100%; border-collapse: collapse; table-layout: auto; }
.data-table th, .data-table td {
    padding: 0.6rem 0.65rem; text-align: left; border-bottom: 1px solid var(--border);
}
.data-table th {
    font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--text-muted); background: var(--bg-input);
    white-space: nowrap;
}
.data-table tbody tr { transition: background var(--transition-fast); }
.data-table tbody tr:hover { background: var(--bg-input); }
.data-table td { font-size: 0.9rem; }
.data-table td:first-child, .data-table td:nth-child(2) { white-space: normal; word-break: break-word; }

/* ============================================
   BADGES
   ============================================ */
.badge {
    display: inline-flex; align-items: center; padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full); font-size: 0.75rem; font-weight: 600;
    transition: all var(--transition-fast);
}
.badge-primary { background: rgba(99,102,241,0.2); color: var(--primary-light); }
.badge-success { background: rgba(34,197,94,0.2); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.2); color: var(--warning); }
.badge-error { background: rgba(239,68,68,0.2); color: var(--error); }
.badge-info { background: rgba(56,189,248,0.2); color: #38bdf8; }
.badge-muted { background: rgba(148,163,184,0.15); color: var(--text-muted); }

/* ============================================
   MODALS
   ============================================ */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px); z-index: 200; display: none;
}
.modal-overlay.active { display: block; }
.modal {
    position: fixed; top: 50%; left: 50%;
    transform: translate(-50%,-50%) scale(0.95);
    background: var(--bg-card); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); width: 100%; max-width: 450px;
    z-index: 201; opacity: 0; visibility: hidden;
    transition: all var(--transition-normal);
}
.modal.active { opacity: 1; visibility: visible; transform: translate(-50%,-50%) scale(1); }
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.1rem; font-weight: 600; }
.modal-close {
    background: none; border: none; font-size: 1.5rem; color: var(--text-muted);
    cursor: pointer; padding: 0; line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 1.25rem; }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 0.75rem;
    padding: 1rem 1.25rem; border-top: 1px solid var(--border);
}

/* ============================================
   TOAST
   ============================================ */
.toast-container {
    position: fixed; bottom: 24px; right: 24px; z-index: 300;
    display: flex; flex-direction: column; gap: 10px;
}
.toast {
    background: var(--bg-card); border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg); border-left: 4px solid var(--primary);
    min-width: 300px; max-width: 400px; overflow: hidden;
    animation: toast-in 0.3s ease forwards;
}
.toast.hiding { animation: toast-out 0.3s ease forwards; }
@keyframes toast-in { from { transform: translateX(calc(100% + 2rem)); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toast-out { from { transform: translateX(0); opacity: 1; } to { transform: translateX(calc(100% + 2rem)); opacity: 0; } }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--error); }
.toast-content { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.toast-message { flex: 1; font-size: 0.85rem; line-height: 1.4; }
.toast-close {
    flex-shrink: 0; background: none; border: none; color: var(--text-muted);
    cursor: pointer; padding: 2px; border-radius: var(--radius-sm);
}
.toast-close:hover { color: var(--text-primary); }

/* ============================================
   PROFILE
   ============================================ */
.profile-grid { display: grid; grid-template-columns: 280px 1fr; gap: 20px; }
.profile-avatar {
    width: 120px; height: 120px; border-radius: 50%; background: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 48px; font-weight: 700; color: white; margin: 0 auto 20px;
    overflow: hidden;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-info-row {
    display: flex; justify-content: space-between; padding: 12px 0;
    border-bottom: 1px solid var(--border-subtle);
}
.profile-info-label { color: var(--text-muted); font-size: 0.85rem; }
.profile-info-value { font-size: 0.85rem; font-weight: 500; }

/* ============================================
   STAT MINI CARDS
   ============================================ */
.stat-mini {
    background: var(--bg-input); border-radius: var(--radius-md);
    padding: 14px 20px; text-align: center; min-width: 90px; flex: 1;
}
.stat-mini-value { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); }
.stat-mini-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-card); }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .sidebar { width: 72px; }
    .sidebar .logo-text, .sidebar .nav-item span { opacity: 0; width: 0; }
    .sidebar .nav-section { padding: 1rem 0.75rem 0.5rem; text-align: center; }
    .sidebar .nav-section span { opacity: 0; position: absolute; pointer-events: none; }
    .sidebar .nav-item { justify-content: center; padding: 0.7rem; }
    .sidebar-toggle { display: none; }
    .main-content { margin-left: 72px; padding: 1rem; }
    .profile-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .auth-card { padding: 28px; }
    .code-input { width: 40px; height: 48px; font-size: 20px; }
}

/* ============================================
   AI BADGE, COLOR SWATCH, LEVEL BADGE
   ============================================ */

.ai-badge { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; }
.ai-loading { display: inline-flex; align-items: center; gap: 8px; }
.ai-loading .spinner-sm {
    width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.1);
    border-top-color: var(--primary); border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.color-swatch {
    width: 24px; height: 24px; border-radius: 50%; display: inline-block;
    border: 2px solid rgba(255,255,255,0.1); vertical-align: middle;
}

.level-badge {
    display: inline-block; padding: 2px 8px; border-radius: 10px;
    font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}

/* ============================================
   HEALTH COCKPIT
   ============================================ */

.health-overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}

.health-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.health-card:hover { border-color: var(--primary); box-shadow: 0 8px 16px -4px rgba(0,0,0,0.3); }

.health-card-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(255,255,255,0.04);
    display: flex;
    align-items: center;
    justify-content: center;
}

.health-card-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.health-card-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.health-card-value {
    font-size: 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.health-status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 6px currentColor;
}

.health-desktop-summary {
    display: flex;
    gap: 20px;
}
@media (max-width: 600px) {
    .health-desktop-summary { flex-direction: column; }
}

/* Services */
.health-services-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.health-service-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.health-service-card:hover { box-shadow: 0 8px 16px -4px rgba(0,0,0,0.3); }
.health-service-card.health-service-healthy { border-left: 3px solid #22c55e; }
.health-service-card.health-service-degraded { border-left: 3px solid #f59e0b; }
.health-service-card.health-service-down { border-left: 3px solid #ef4444; }

.health-service-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.health-service-header strong {
    font-size: 0.95rem;
}

.health-service-badge {
    font-size: 0.72rem;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: auto;
}
.health-service-badge.healthy { background: rgba(34,197,94,0.15); color: #22c55e; }
.health-service-badge.degraded { background: rgba(245,158,11,0.15); color: #f59e0b; }
.health-service-badge.down { background: rgba(239,68,68,0.15); color: #ef4444; }

.health-service-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Log Viewer */
.health-log-viewer {
    background: #0c0e14;
    border: 1px solid var(--border);
    border-radius: 10px;
    max-height: 520px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    line-height: 1.65;
}

.health-log-empty {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
}

.health-log-line {
    padding: 6px 14px;
    display: flex;
    align-items: baseline;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    flex-wrap: wrap;
}
.health-log-line:hover { background: rgba(255,255,255,0.02); }
.health-log-line.error { background: rgba(239,68,68,0.06); }
.health-log-line.warn { background: rgba(245,158,11,0.04); }

.health-log-time {
    color: #6b7280;
    flex-shrink: 0;
    min-width: 70px;
}

.health-log-level {
    font-weight: 700;
    flex-shrink: 0;
    min-width: 65px;
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 4px;
    text-align: center;
}
.health-log-level.error { color: #ef4444; background: rgba(239,68,68,0.12); }
.health-log-level.warn { color: #f59e0b; background: rgba(245,158,11,0.12); }
.health-log-level.info { color: #22c55e; background: rgba(34,197,94,0.12); }

.health-log-src {
    color: #8b5cf6;
    flex-shrink: 0;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.health-log-msg {
    color: #e2e8f0;
    flex: 1;
    word-break: break-word;
}

.health-log-endpoint {
    color: #06b6d4;
    font-size: 0.72rem;
    flex-shrink: 0;
}

.health-log-filter {
    font-size: 0.78rem;
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}
.health-log-filter.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Errors & Analysis */
.health-error-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-left: 3px solid #ef4444;
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    transition: box-shadow var(--transition-fast);
}
.health-error-card:hover { box-shadow: 0 8px 16px -4px rgba(0,0,0,0.3); }

.health-error-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.health-error-msg {
    font-size: 0.88rem;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.5;
}

.health-error-tb summary {
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    margin-bottom: 6px;
}
.health-error-tb pre {
    background: #0c0e14;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
    color: #e2e8f0;
    white-space: pre-wrap;
}

.health-analysis {
    margin-top: 12px;
    border: 1px solid rgba(99,102,241,0.25);
    border-radius: 8px;
    overflow: hidden;
}

.health-analysis-header {
    background: rgba(99,102,241,0.08);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
}

.health-analysis-body {
    padding: 14px;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.health-severity {
    font-size: 0.68rem;
    padding: 2px 8px;
    border-radius: 5px;
    font-weight: 700;
    text-transform: uppercase;
    color: #fff;
    letter-spacing: 0.5px;
}

.spinner-sm {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

