/* ==================== SytronSAS - School Safety AI Dashboard ==================== */
:root {
    /* Dark theme (default) */
    --bg-primary: #0f1117;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #13131f;
    --bg-card: #12121e;
    --bg-sidebar: #0d0d15;
    --bg-input: #1a1a2e;
    --border-color: #2a2a3e;
    --border-light: #1e1e30;
    --text-primary: #d6d6d6;
    --text-secondary: #7e7ea0;
    --text-muted: #606876;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-bg: rgba(99, 102, 241, 0.1);
    --success: #22c55e;
    --success-hover: #16a34a;
    --success-bg: rgba(34, 197, 94, 0.1);
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --critical: #dc2626;
    --purple: #a78bfa;
    --font-family: 'Inter', 'Ubuntu', 'Cantarell', 'Noto Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --radius: 10px;
    --radius-sm: 6px;
    --sidebar-width: 240px;
    --topbar-height: 50px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --transition: all 0.2s ease;
}

/* ==================== Light Theme ==================== */
[data-theme="light"] {
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f8f9fa;
    --bg-card: #ffffff;
    --bg-sidebar: #1a1a2e;
    --bg-input: #f0f2f5;
    --border-color: #d1d5db;
    --border-light: #e5e7eb;
    --text-primary: #1a2230;
    --text-secondary: #5e6573;
    --text-muted: #8e95a1;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-bg: rgba(79, 70, 229, 0.1);
    --success: #059669;
    --success-hover: #047857;
    --success-bg: rgba(5, 150, 105, 0.1);
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --danger-bg: rgba(220, 38, 38, 0.1);
    --warning: #d97706;
    --warning-bg: rgba(217, 119, 6, 0.1);
    --critical: #b91c1c;
    --purple: #7c3aed;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
[data-theme="light"] .sidebar { background: #1a1a2e; border-right-color: #2a2a3e; }
[data-theme="light"] .sidebar .nav-item { color: #e0e0f0; }
[data-theme="light"] .sidebar .nav-item:hover { background: rgba(255, 255, 255, 0.05); color: #e0e0e0; }
[data-theme="light"] .sidebar .nav-item.active { color: #818cf8; background: rgba(99, 102, 241, 0.1); }
[data-theme="light"] .sidebar .sidebar-brand h2 { color: #818cf8; }
[data-theme="light"] .sidebar .sidebar-brand span { color: #6b7280; }
[data-theme="light"] .sidebar .sidebar-footer { color: #6b7280; border-color: #2a2a3e; }
[data-theme="light"] .sidebar .sidebar-brand { border-bottom-color: #2a2a3e; }
[data-theme="light"] .sidebar .nav-section-label { color: #6b7280; }
[data-theme="light"] .user-btn:hover { background: rgba(0, 0, 0, 0.05); }
[data-theme="light"] .user-dropdown a:hover { background: rgba(0, 0, 0, 0.05); }
[data-theme="light"] .data-table tr:hover td { background: var(--accent-bg); }
[data-theme="light"] ::-webkit-scrollbar-track { background: #f0f2f5; }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #c0c0c0; }
[data-theme="light"] .modal-close { color: #6b7280; }

/* ==================== Snow White Theme ==================== */
[data-theme="snow-white"] {
    --bg-primary: #f8f9fc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f3f8;
    --bg-card: #ffffff;
    --bg-sidebar: #1e1e2f;
    --bg-input: #f1f3f8;
    --border-color: #e2e6ef;
    --border-light: #edf0f7;
    --text-primary: #141726;
    --text-secondary: #4e556c;
    --text-muted: #7d849a;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-bg: rgba(99, 102, 241, 0.08);
    --success: #10b981;
    --success-hover: #059669;
    --success-bg: rgba(16, 185, 129, 0.08);
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-bg: rgba(239, 68, 68, 0.08);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.08);
    --critical: #dc2626;
    --purple: #8b5cf6;
    --shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
}
[data-theme="snow-white"] .sidebar { background: #1e1e2f; border-right-color: #2a2a3e; }
[data-theme="snow-white"] .sidebar .nav-item { color: #e0e0f0; }
[data-theme="snow-white"] .sidebar .nav-item:hover { background: rgba(255, 255, 255, 0.05); color: #e0e0e0; }
[data-theme="snow-white"] .sidebar .nav-item.active { color: #818cf8; background: rgba(99, 102, 241, 0.12); }
[data-theme="snow-white"] .sidebar .sidebar-brand h2 { color: #818cf8; }
[data-theme="snow-white"] .sidebar .sidebar-brand span { color: #6b7280; }
[data-theme="snow-white"] .sidebar .sidebar-footer { color: #6b7280; border-color: #2a2a3e; }
[data-theme="snow-white"] .sidebar .sidebar-brand { border-bottom-color: #2a2a3e; }
[data-theme="snow-white"] .sidebar .nav-section-label { color: #6b7280; }

/* ==================== Charcoal Theme ==================== */
[data-theme="charcoal"] {
    --bg-primary: #1c1c1c;
    --bg-secondary: #2a2a2a;
    --bg-tertiary: #222222;
    --bg-card: #252525;
    --bg-sidebar: #141414;
    --bg-input: #2a2a2a;
    --border-color: #3a3a3a;
    --border-light: #333333;
    --text-primary: #dedede;
    --text-secondary: #8f8f8f;
    --text-muted: #6d6d6d;
    --accent: #f97316;
    --accent-hover: #ea580c;
    --accent-bg: rgba(249, 115, 22, 0.1);
    --success: #2ed573;
    --success-hover: #26b85f;
    --success-bg: rgba(46, 213, 115, 0.1);
    --danger: #ff6b6b;
    --danger-hover: #ee5a24;
    --danger-bg: rgba(255, 107, 107, 0.1);
    --warning: #ffa502;
    --warning-bg: rgba(255, 165, 2, 0.1);
    --critical: #ee5a24;
    --purple: #a29bfe;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
[data-theme="charcoal"] .sidebar { background: #141414; border-right-color: #2a2a2a; }
[data-theme="charcoal"] .sidebar .nav-item.active { color: #f97316; background: rgba(249, 115, 22, 0.1); }
[data-theme="charcoal"] .sidebar .sidebar-brand h2 { color: #f97316; }

/* ==================== Steel Grey Theme ==================== */
[data-theme="steel-grey"] {
    --bg-primary: #e8ecef;
    --bg-secondary: #f5f7f9;
    --bg-tertiary: #edf0f3;
    --bg-card: #f5f7f9;
    --bg-sidebar: #2c3e50;
    --bg-input: #e8ecef;
    --border-color: #cfd8dc;
    --border-light: #dde3e8;
    --text-primary: #253646;
    --text-secondary: #49616d;
    --text-muted: #6c848f;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-bg: rgba(59, 130, 246, 0.08);
    --success: #27ae60;
    --success-hover: #219a52;
    --success-bg: rgba(39, 174, 96, 0.08);
    --danger: #e74c3c;
    --danger-hover: #c0392b;
    --danger-bg: rgba(231, 76, 60, 0.08);
    --warning: #f39c12;
    --warning-bg: rgba(243, 156, 18, 0.08);
    --critical: #c0392b;
    --purple: #9b59b6;
    --shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
}
[data-theme="steel-grey"] .sidebar { background: #2c3e50; border-right-color: #34495e; }
[data-theme="steel-grey"] .sidebar .nav-item { color: #f0f3f5; }
[data-theme="steel-grey"] .sidebar .nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #ecf0f1; }
[data-theme="steel-grey"] .sidebar .nav-item.active { color: #3b82f6; background: rgba(59, 130, 246, 0.15); }
[data-theme="steel-grey"] .sidebar .sidebar-brand h2 { color: #3b82f6; }
[data-theme="steel-grey"] .sidebar .sidebar-brand span { color: #7f8c8d; }
[data-theme="steel-grey"] .sidebar .sidebar-footer { color: #7f8c8d; border-color: #34495e; }
[data-theme="steel-grey"] .sidebar .sidebar-brand { border-bottom-color: #34495e; }
[data-theme="steel-grey"] .sidebar .nav-section-label { color: #7f8c8d; }

/* ==================== Corporate Theme ==================== */
[data-theme="corporate"] {
    --bg-primary: #f5f7fb;
    --bg-secondary: #ffffff;
    --bg-tertiary: #eef1f6;
    --bg-card: #ffffff;
    --bg-sidebar: #0f1f3d;
    --bg-input: #f8fafc;
    --border-color: #e2e8f0;
    --border-light: #e2e8f0;
    --text-primary: #212d42;
    --text-secondary: #596980;
    --text-muted: #8797ac;
    --accent: #4338ca;
    --accent-hover: #3730a3;
    --accent-bg: rgba(67, 56, 202, 0.08);
    --success: #16a34a;
    --success-hover: #15803d;
    --success-bg: rgba(22, 163, 74, 0.08);
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --danger-bg: rgba(220, 38, 38, 0.08);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.08);
    --critical: #b91c1c;
    --purple: #6366f1;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}
[data-theme="corporate"] .sidebar { background: #0f1f3d; }
[data-theme="corporate"] .sidebar .nav-item { color: rgba(255, 255, 255, 0.85); }
[data-theme="corporate"] .sidebar .nav-item:hover { background: rgba(255, 255, 255, 0.07); color: #ffffff; }
[data-theme="corporate"] .sidebar .nav-item.active { color: #ffffff; background: #4338ca; }
[data-theme="corporate"] .sidebar .sidebar-brand h2 { color: #ffffff; }
[data-theme="corporate"] .sidebar .sidebar-brand span { color: #a0aec0; }
[data-theme="corporate"] .sidebar .sidebar-footer { color: #a0aec0; border-color: rgba(255, 255, 255, 0.1); }
[data-theme="corporate"] .sidebar .nav-section-label { color: rgba(255, 255, 255, 0.45); }
[data-theme="corporate"] .sidebar .sidebar-brand { border-bottom-color: rgba(255, 255, 255, 0.1); }
[data-theme="corporate"] .topbar { background: #ffffff; color: #27344a; border-bottom: 1px solid #e2e8f0; }
[data-theme="corporate"] .topbar .topbar-title { color: #27344a; }
[data-theme="corporate"] .card { border-radius: 12px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); }
[data-theme="corporate"] .card:hover { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08); }

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

body {
    font-family: var(--font-family);
    font-size: 15px;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    line-height: 1.5;
}

/* ==================== Scrollbar ==================== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-card); }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ==================== App Layout ==================== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ==================== Sidebar ==================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
    height: var(--topbar-height);
}

.sidebar-brand img {
    height: 34px;
    width: 34px;
    object-fit: contain;
    border-radius: 6px;
    flex-shrink: 0;
}

.sidebar-brand h2 {
    font-size: 1.15em;
    color: var(--accent);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    line-height: 1.2;
}

.sidebar-brand span {
    font-size: 0.6em;
    color: var(--text-muted);
    display: block;
    margin-top: 1px;
}

.sidebar-nav {
    flex: 1;
    padding: 8px;
    overflow-y: auto;
}

/* Legacy class support */
.nav-menu {
    flex: 1;
    padding: 8px;
    overflow-y: auto;
    list-style: none;
    display: flex;
    flex-direction: column;
}

.nav-section-label {
    display: flex;
    align-items: center;
    font-size: 0.72em;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    padding: 14px 12px 4px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.82em;
    font-weight: 500;
    transition: all 0.15s;
    margin-bottom: 2px;
    letter-spacing: 0.01em;
    cursor: pointer;
}

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

.nav-item.active {
    color: var(--accent);
    background: var(--accent-bg);
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 14px;
}

.badge {
    font-size: 0.7em;
    padding: 2px 7px;
    border-radius: 3px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.badge-accent { background: var(--accent-bg); color: var(--accent); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-incidents { background: rgba(249, 115, 22, 0.15); color: #f97316; }

.sidebar-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--border-color);
    font-size: 0.68em;
    color: var(--text-muted);
    text-align: center;
}

.system-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82em;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* ==================== Status Dot ==================== */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    background: var(--text-muted);
}

.status-dot.online, .status-dot.on { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline, .status-dot.off { background: var(--danger); box-shadow: 0 0 6px var(--danger); }

/* ==================== Top Bar ==================== */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.topbar-title {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
}

.menu-toggle svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    flex-shrink: 0;
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
}

.alert-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--danger);
    font-weight: 600;
    font-size: 0.85em;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.time-display {
    color: var(--text-secondary);
    font-size: 0.82em;
    font-weight: 500;
}

/* ==================== User Menu ==================== */
.user-menu {
    position: relative;
}

.user-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 4px 14px;
    cursor: pointer;
    font-size: 0.78em;
    font-family: var(--font-family);
    transition: all 0.2s;
}

.user-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent);
}

.user-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 150px;
    display: none;
    z-index: 200;
}

.user-dropdown.active { display: block; }

.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: var(--text-primary);
    background: none;
    text-decoration: none;
    font-size: 0.82em;
    transition: all 0.15s;
}

.user-dropdown a svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.user-dropdown a:hover { background: rgba(255, 255, 255, 0.06); }
.user-dropdown a:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.user-dropdown a:last-child { border-radius: 0 0 var(--radius) var(--radius); }

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

.user-dropdown a.danger { color: var(--danger); }
.user-dropdown a.danger:hover { background: var(--danger-bg); }

/* ==================== Main Content ==================== */
.main-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-y: auto;
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

.page-content {
    flex: 1;
    padding: 18px 22px;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    animation: fadeIn 0.3s ease;
}

.page { display: none; padding: 18px 22px; animation: fadeIn 0.3s ease; }
.page.active { display: block; }

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

.page-actions {
    margin-bottom: 16px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ==================== Stats Grid ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.stat-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.stat-cameras .stat-icon { background: rgba(99, 102, 241, 0.15); color: var(--accent); }
.stat-active .stat-icon { background: var(--danger-bg); color: var(--danger); }
.stat-today .stat-icon { background: var(--warning-bg); color: var(--warning); }
.stat-critical .stat-icon { background: rgba(220, 38, 38, 0.15); color: var(--critical); }

.stat-value {
    font-size: 1.5em;
    font-weight: 700;
    line-height: 1;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.72em;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 3px;
}

/* ==================== Active Alerts Banner ==================== */
.active-alerts-banner {
    background: var(--danger-bg);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 20px;
    animation: alertPulse 3s infinite;
}

@keyframes alertPulse {
    0%, 100% { border-color: rgba(239, 68, 68, 0.3); }
    50% { border-color: rgba(239, 68, 68, 0.7); }
}

.alert-banner-header {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--danger);
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 0.9em;
}

.alert-banner-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.alert-banner-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.2);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.82em;
}

.severity-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.72em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.4;
    white-space: nowrap;
}

.severity-critical { background: rgba(220, 38, 38, 0.15); color: #ef4444; border: 1px solid rgba(220, 38, 38, 0.3); }
.severity-high     { background: rgba(245, 158, 11, 0.15); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.3); }
.severity-warning  { background: rgba(251, 191, 36, 0.12); color: #eab308; border: 1px solid rgba(251, 191, 36, 0.25); }

/* ==================== Charts ==================== */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.chart-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.chart-card.wide {
    grid-column: 1 / -1;
}

.chart-card h3 {
    font-size: 0.88em;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* ==================== Cards ==================== */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
}

.card-header h3 {
    font-size: 1em;
    font-weight: 700;
    color: var(--text-primary);
}

/* ==================== Tables ==================== */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85em;
    min-width: 480px;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.78em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

.data-table tr:hover td { background: var(--accent-bg); }

.data-table .status-active {
    color: var(--danger);
    font-weight: 600;
    font-size: 0.82em;
    text-transform: capitalize;
}

.data-table .status-resolved {
    color: var(--success);
    font-size: 0.82em;
    text-transform: capitalize;
}

/* ==================== Buttons ==================== */
.btn {
    padding: 7px 18px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.82em;
    font-family: var(--font-family);
    letter-spacing: 0.01em;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    color: var(--text-primary);
    background: var(--border-color);
    white-space: nowrap;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }

.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: var(--success-hover); }

.btn-warning { background: var(--warning); border-color: var(--warning); color: #000; }
.btn-warning:hover:not(:disabled) { background: #d97706; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    box-shadow: none;
}
.btn-outline:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.btn-sm { padding: 5px 12px; font-size: 0.75em; }
.btn-icon { padding: 6px 10px; font-size: 14px; }

/* ==================== Forms ==================== */
.form-control, .form-input, .form-select {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.88em;
    font-family: var(--font-family);
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus, .form-input:focus, .form-select:focus {
    border-color: var(--accent);
}

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

.form-group label, .form-label {
    display: block;
    font-size: 0.82em;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* ==================== Filter Bar ==================== */
.filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-bar .form-control {
    min-width: 140px;
}

/* ==================== Camera Grid ==================== */
.camera-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
    gap: 14px;
}

.camera-feed-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.camera-feed-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
}

.camera-feed-header .cam-name {
    font-weight: 600;
    font-size: 0.88em;
}

.camera-feed-header .cam-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75em;
    color: var(--text-secondary);
}

.camera-feed-body {
    position: relative;
    aspect-ratio: 16/9;
    background: #000;
}

.camera-feed-body img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.camera-feed-body .no-feed {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.85em;
}

.camera-feed-actions {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid var(--border-color);
}

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

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

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 92%;
    max-width: 540px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.6);
    animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

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

.modal-header h3 {
    font-size: 1em;
    color: var(--accent);
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: #888;
    font-size: 1.4em;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover { color: var(--danger); }

.modal-body { padding: 16px 18px; }

.modal-footer {
    padding: 12px 18px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ==================== Toast ==================== */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px 18px;
    min-width: 280px;
    max-width: 420px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: toastIn 0.3s ease-out;
    pointer-events: auto;
    font-size: 0.85em;
}

.toast.critical { border-left: 3px solid var(--critical); }
.toast.high { border-left: 3px solid var(--warning); }
.toast.warning { border-left: 3px solid #fbbf24; }
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast-icon { font-size: 1.1em; margin-top: 2px; flex-shrink: 0; }
.toast.critical .toast-icon { color: var(--critical); }
.toast.high .toast-icon { color: var(--warning); }
.toast.warning .toast-icon { color: #fbbf24; }
.toast.success .toast-icon { color: var(--success); }

.toast-content { flex: 1; }
.toast-title { font-weight: 600; font-size: 0.88em; margin-bottom: 2px; }
.toast-message { font-size: 0.78em; color: var(--text-secondary); }

/* ==================== Config ==================== */
.config-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.config-tabs::-webkit-scrollbar { display: none; }

.config-tab {
    padding: 8px 18px;
    font-size: 0.85em;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
    font-family: var(--font-family);
}

.config-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.config-tab:hover:not(.active) {
    color: var(--text-primary);
}

.config-panel { display: none; }
.config-panel.active { display: block; }

.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 12px;
}

.config-event-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 12px;
}

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

.config-event-header .event-name {
    font-weight: 600;
    font-size: 0.82em;
}

.toggle-switch {
    position: relative;
    width: 40px;
    height: 22px;
}

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

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border-color);
    border-radius: 11px;
    cursor: pointer;
    transition: background 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
}

.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

.config-event-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.config-event-controls label {
    font-size: 0.7em;
    color: var(--text-muted);
}

.config-event-controls select {
    padding: 4px 8px;
    font-size: 0.78em;
}

/* ==================== Ticket Status ==================== */
.ticket-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.7em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.ticket-status-open { background: var(--critical); color: white; }
.ticket-status-acknowledged { background: var(--warning); color: #000; }
.ticket-status-investigating { background: #f97316; color: white; }
.ticket-status-resolved { background: var(--success); color: white; }
.ticket-status-closed { background: var(--text-muted); color: white; }

.ticket-step {
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 0.7em;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    text-transform: capitalize;
}

.ticket-step-done {
    background: var(--accent-bg);
    color: var(--accent);
}

.ticket-step-current {
    background: var(--accent);
    color: white;
    font-weight: 700;
}

/* ==================== Pagination ==================== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 0;
}

.pagination button {
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.82em;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
}

.pagination button:hover { background: var(--accent); color: #fff; }
.pagination button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pagination button:disabled { opacity: 0.4; cursor: default; }

/* ==================== Logs ==================== */
.log-container {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
}

.log-table {
    font-size: 0.78em;
}

.log-table td {
    padding: 5px 10px;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    vertical-align: top;
}

.log-table td:first-child {
    white-space: nowrap;
    color: var(--text-muted);
}

.log-table td:last-child {
    word-break: break-all;
}

.log-level-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.7em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.log-level-DEBUG { background: rgba(100, 116, 139, 0.3); color: #94a3b8; }
.log-level-INFO { background: rgba(99, 102, 241, 0.2); color: #818cf8; }
.log-level-WARNING { background: var(--warning-bg); color: #fbbf24; }
.log-level-ERROR { background: var(--danger-bg); color: #f87171; }
.log-level-CRITICAL { background: rgba(220, 38, 38, 0.3); color: #fca5a5; }

.sys-log-output {
    font-family: 'Courier New', monospace;
    font-size: 0.72em;
    line-height: 1.6;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-all;
    padding: 14px;
    min-height: 200px;
    max-height: 500px;
    overflow-y: auto;
}

/* ==================== Settings ==================== */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 14px;
}

.settings-info-grid,
#models-info-grid,
#storage-info-grid,
#db-info-grid,
#processing-info-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.85em;
    transition: background 0.15s;
}

.info-row:hover { background: var(--accent-bg); }
.info-row:last-child { border-bottom: none; }

.info-label {
    color: var(--text-secondary);
    font-size: 0.88em;
    font-weight: 500;
}

.info-value {
    color: var(--text-primary);
    font-size: 0.88em;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    overflow-wrap: break-word;
    word-break: break-word;
    min-width: 0;
}

.model-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82em;
}

.model-status .dot-ok { color: var(--success); }
.model-status .dot-missing { color: var(--danger); }

.storage-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}

.storage-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--purple));
    border-radius: 3px;
    transition: width 0.5s ease;
}

.storage-bar-fill.warning { background: linear-gradient(90deg, var(--warning), var(--danger)); }

/* ==================== Theme Selector ==================== */
.theme-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 8px 0;
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    background: var(--bg-input);
    min-width: 140px;
}

.theme-option:hover { border-color: var(--text-secondary); }
.theme-option.active { border-color: var(--accent); background: var(--accent-bg); }
.theme-option input[type="radio"] { display: none; }

.theme-swatch { display: flex; gap: 3px; flex-shrink: 0; }
.theme-swatch-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
}
.theme-option-label { font-size: 0.85em; font-weight: 500; color: var(--text-primary); }

/* ==================== Login Page ==================== */
/* Login styles are in login.css */

/* ==================== Sidebar Overlay (Mobile) ==================== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay.active { display: block; }

/* ==================== Toggle Switch ==================== */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

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

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

.switch-slider::before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.2s;
}

.switch input:checked + .switch-slider { background: var(--accent); }
.switch input:checked + .switch-slider::before { transform: translateX(18px); }

/* ==================== Grid Helpers ==================== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

/* ==================== Empty State ==================== */
.empty-state {
    padding: 40px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85em;
}

/* ==================== Responsive ==================== */
@media (max-width: 1200px) {
    .page-content { max-width: 100%; }
}

/* ==================== RBAC: Camera Checklist & Badge Variants ==================== */
.camera-checklist {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
    padding: 8px 0;
}
.camera-check-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85em;
}
.camera-check-item:hover { background: var(--bg-tertiary); }

.badge-accent  { background: var(--accent-bg, rgba(99,102,241,0.15)); color: var(--accent); }
.badge-warning { background: var(--warning-bg, rgba(245,158,11,0.15)); color: var(--warning, #f59e0b); }
.badge-success { background: var(--success-bg, rgba(34,197,94,0.15)); color: var(--success, #22c55e); }

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .main-area, .main-content { margin-left: 0; }
    .menu-toggle { display: flex; }
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; gap: 12px; }
    .form-row { grid-template-columns: 1fr; }
    .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .toast { min-width: 0; max-width: calc(100vw - 32px); }
    .page-content { padding: 14px 16px; }
    .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .charts-grid { grid-template-columns: 1fr; }
    .camera-grid { grid-template-columns: 1fr; }
    .config-grid { grid-template-columns: 1fr; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; gap: 12px; }
    .filter-bar { flex-direction: column; align-items: stretch; }
}

@media (max-width: 600px) {
    .page-content { padding: 10px 12px; }
    .topbar { padding: 0 10px; }
    .topbar-title { font-size: 0.88em; }
    .user-btn span { display: none; }
    .user-btn { padding: 5px 8px; }
    .card { padding: 14px; }
    .card-header { font-size: 0.88em; margin-bottom: 10px; padding-bottom: 8px; }
    .btn { padding: 7px 14px; font-size: 0.75em; }
    .btn-sm { padding: 3px 6px; font-size: 0.68em; }
    .modal { width: 96%; }
    .modal-body { padding: 14px; }
    .stat-card { padding: 10px 8px; }
    .stat-icon { width: 36px; height: 36px; font-size: 15px; }
    .config-tab { padding: 8px 14px; font-size: 0.8em; }
    .data-table { min-width: 380px; }
    .data-table th, .data-table td { padding: 8px 10px; font-size: 0.78em; }
    .badge { font-size: 0.65em; padding: 2px 6px; }
    .theme-options { gap: 8px; }
    .theme-option { min-width: 130px; padding: 6px 10px; }
}

@media (max-width: 400px) {
    .page-content { padding: 8px; }
    .card { padding: 12px; }
    .card-header { font-size: 0.82em; }
    .info-row { flex-wrap: wrap; gap: 2px; font-size: 0.8em; }
    .modal { width: 100%; margin: 8px; border-radius: 8px; }
    .topbar-title { font-size: 0.82em; }
    .btn { font-size: 0.72em; }
    .data-table { min-width: 320px; }
    .data-table th, .data-table td { padding: 6px 8px; font-size: 0.72em; }
    .theme-option { min-width: 100%; }
}
