*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0f0f0f;
    --surface: #1a1a1a;
    --border: #2a2a2a;
    --accent: #3b82f6;
    --text: #e5e5e5;
    --muted: #666;
    --sidebar-w: 220px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: Arial, sans-serif;
    font-size: 14px;
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: 1rem;
}

.brand-icon { font-size: 1.4rem; }

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 6px;
    color: var(--muted);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: var(--border); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item.logout { color: #f87171; }
.nav-item.logout:hover { background: #450a0a; }

.sidebar-footer { padding: 12px 8px; border-top: 1px solid var(--border); }

/* ── Main ── */
.main-wrapper {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.page-title { font-size: 1.1rem; font-weight: 600; }

.content { padding: 24px; }

/* ── Stats ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-label { font-size: 0.75rem; color: var(--muted); }

/* ── Camera grid ── */
.section-title { font-size: 0.9rem; font-weight: 600; color: var(--muted); margin-bottom: 14px; text-transform: uppercase; letter-spacing: 0.5px; }

.camera-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    gap: 16px;
}

.camera-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.cam-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
}

.cam-name { font-size: 0.85rem; font-weight: 600; }

.cam-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--muted);
}
.cam-dot.live { background: #4ade80; }

.camera-card img {
    display: block;
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: contain;
    background: #000;
}

/* ── Login ── */
body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 36px 32px;
    width: 100%;
    max-width: 380px;
}

.login-brand {
    text-align: center;
    margin-bottom: 28px;
}
.login-brand span { font-size: 2rem; display: block; margin-bottom: 8px; }
.login-brand h2 { font-size: 1.1rem; }

.login-form { display: flex; flex-direction: column; gap: 16px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.8rem; color: var(--muted); }
.form-group input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
}
.form-group input:focus { border-color: var(--accent); }

.btn-primary {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 11px;
    font-size: 0.95rem;
    cursor: pointer;
    margin-top: 4px;
}
.btn-primary:hover { opacity: 0.9; }

.login-error {
    background: #450a0a;
    color: #f87171;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 0.85rem;
    margin-bottom: 12px;
}
.login-success {
    background: #052e16;
    color: #4ade80;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 0.85rem;
    margin-bottom: 12px;
}

.topbar { display: flex; align-items: center; justify-content: space-between; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.role-badge { background: var(--accent); color: #fff; font-size: 0.7rem; padding: 3px 10px; border-radius: 10px; font-weight: 700; }
.sidebar-section-label { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); padding: 14px 16px 4px; }
