* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
    background: #0f172a;
    color: #e2e8f0;
}

/* ---- Login page ---- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-box {
    background: #1e293b;
    padding: 32px;
    border-radius: 14px;
    width: 90%;
    max-width: 340px;
    box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.login-box h1 { margin: 0 0 20px; font-size: 22px; text-align: center; }
.login-box label { display: block; font-size: 13px; margin-bottom: 4px; color: #94a3b8; }
.login-box input {
    width: 100%; padding: 10px 12px; margin-bottom: 16px;
    border-radius: 8px; border: 1px solid #334155; background: #0f172a; color: #fff;
}
.login-box button {
    width: 100%; padding: 12px; border: none; border-radius: 8px;
    background: #3b82f6; color: #fff; font-size: 15px; cursor: pointer;
}
.login-box button:hover { background: #2563eb; }
.login-box .error { color: #f87171; font-size: 14px; margin-bottom: 12px; }
.login-box .hint { font-size: 12px; color: #64748b; text-align: center; margin-top: 14px; }

/* ---- Top bar ---- */
.topbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 20px; background: #1e293b; border-bottom: 1px solid #334155;
    flex-wrap: wrap; gap: 10px;
}
.topbar h1 { font-size: 18px; margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.username { font-size: 13px; color: #94a3b8; }
.btn-ghost {
    color: #93c5fd; text-decoration: none; font-size: 14px;
    padding: 6px 10px; border: 1px solid #334155; border-radius: 6px;
}
.btn-ghost:hover { background: #334155; }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 8px; padding: 16px 20px 0; flex-wrap: wrap; }
.tab-btn {
    background: #1e293b; color: #cbd5e1; border: 1px solid #334155;
    padding: 8px 16px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.tab-btn.active { background: #3b82f6; border-color: #3b82f6; color: #fff; }
.tab-panel { display: none; padding: 16px 20px 40px; }
.tab-panel.active { display: block; }

/* ---- Camera grid ---- */
.camera-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}
.camera-tile {
    background: #1e293b; border-radius: 10px; overflow: hidden; cursor: pointer;
    border: 1px solid #334155; position: relative;
}
.camera-tile img { width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover; background: #000; }
.camera-label {
    display: block; padding: 8px 10px; font-size: 13px; color: #cbd5e1;
    background: #0f172a;
}

/* ---- Lightbox ---- */
.lightbox {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.9);
    z-index: 999; align-items: center; justify-content: center; flex-direction: column;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 95vw; max-height: 85vh; border-radius: 8px; }
.lightbox-label { color: #fff; margin-top: 12px; font-size: 15px; }
.lightbox-close {
    position: absolute; top: 16px; right: 24px; font-size: 32px; color: #fff;
    cursor: pointer;
}

/* ---- Empty state ---- */
.empty-state { text-align: center; padding: 60px 20px; color: #94a3b8; }
.empty-state .btn { margin-top: 12px; display: inline-block; }

/* ---- Admin panel ---- */
.admin-wrap { max-width: 800px; margin: 0 auto; padding: 20px; }
.panel {
    background: #1e293b; border: 1px solid #334155; border-radius: 10px;
    padding: 18px 20px; margin-bottom: 20px;
}
.panel h2 { margin: 0 0 14px; font-size: 16px; }
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.inline-form label { display: block; font-size: 12px; color: #94a3b8; margin-bottom: 4px; }
.inline-form input {
    padding: 9px 10px; border-radius: 6px; border: 1px solid #334155;
    background: #0f172a; color: #fff; font-size: 14px;
}
.url-input { min-width: 280px; flex: 1; }
.add-camera-form { margin-top: 14px; }

.btn {
    background: #3b82f6; color: #fff; border: none; padding: 9px 16px;
    border-radius: 6px; cursor: pointer; font-size: 14px; text-decoration: none;
}
.btn:hover { background: #2563eb; }
.btn-small { padding: 6px 10px; font-size: 13px; border-radius: 5px; border: none; background: #3b82f6; color: #fff; cursor: pointer; }
.btn-danger { background: #ef4444; color: #fff; border: none; padding: 9px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.btn-danger:hover { background: #dc2626; }

.cam-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.cam-table td, .cam-table th { padding: 6px 4px; text-align: left; font-size: 13px; }
.cam-table th { color: #94a3b8; border-bottom: 1px solid #334155; }
.cam-table input { width: 100%; padding: 6px 8px; border-radius: 5px; border: 1px solid #334155; background: #0f172a; color: #fff; }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }

.flash { background: #14532d; color: #bbf7d0; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }

@media (max-width: 600px) {
    .topbar { flex-direction: column; align-items: flex-start; }
}
