:root {
  --bg: #f4f7fb;
  --bg-2: #e9eff8;
  --panel: #ffffff;
  --card: #ffffff;
  --border: rgba(15, 23, 42, 0.08);
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2f6fed;
  --accent-2: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 16px;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "DM Sans", "Trebuchet MS", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at -5% -10%, #dbe8ff 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 0%, #d8f3ee 0%, transparent 55%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
}

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--panel);
  padding: 18px 16px;
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.2px;
  margin-bottom: 18px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(47, 111, 237, 0.12);
}

.profile {
  background: #f6f8fe;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
}

.profile .role {
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 6px;
  cursor: pointer;
  font-weight: 600;
}

.nav a.active,
.nav a:hover {
  background: rgba(47, 111, 237, 0.1);
  color: var(--accent);
}

/* Main */
.main {
  display: grid;
  grid-template-rows: 64px 1fr;
}

.topbar {
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(6px);
}

.topbar .left,
.topbar .right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search {
  width: 260px;
  background: #f5f7fb;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 12px;
  color: var(--text);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-2);
}

.status-pill .dot {
  width: 8px;
  height: 8px;
  box-shadow: none;
}

.btn {
  border-radius: 12px;
  padding: 9px 14px;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}

.btn.secondary {
  background: #f1f5ff;
  color: var(--accent);
  border-color: rgba(47, 111, 237, 0.2);
}

.btn.danger {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
}

/* Content */
.content {
  padding: 20px;
  overflow-y: auto;
}

h1 {
  margin: 0 0 4px 0;
  font-size: 26px;
}

.subtitle {
  margin: 0 0 18px 0;
  color: var(--muted);
}

.section-title {
  font-weight: 700;
  margin: 8px 0 12px 0;
}

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

.grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.kpi {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi .label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.kpi .value {
  font-size: 20px;
  font-weight: 800;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(47, 111, 237, 0.1);
  color: var(--accent);
}

.chip.warning {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning);
}

.chip.danger {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

.cam {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cam-thumb {
  position: relative;
  height: 140px;
  background: #0f172a;
  border-radius: 14px;
  overflow: hidden;
}

.cam-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.badge.live {
  position: absolute;
  top: 10px;
  left: 10px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 8px;
  font-weight: 700;
}

.cam-title {
  font-weight: 700;
}

.cam-meta {
  color: var(--muted);
  font-size: 12px;
}

.list {
  display: grid;
  gap: 10px;
}

.list .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f7f9fe;
  border: 1px solid var(--border);
}

/* Forms */
label {
  font-weight: 700;
  font-size: 12px;
  color: var(--muted);
}

input,
select {
  width: 100%;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(47, 111, 237, 0.5);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.12);
}

.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 6px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.switch input {
  display: none;
}

.switch .track {
  width: 42px;
  height: 22px;
  border-radius: 999px;
  background: #e2e8f0;
  position: relative;
  transition: all 0.2s ease;
}

.switch .thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
}

.switch input:checked + .track {
  background: rgba(16, 185, 129, 0.2);
}

.switch input:checked + .track .thumb {
  left: 22px;
  background: var(--accent-2);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  padding: 12px 16px;
  background: #0f172a;
  color: #fff;
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.25);
  font-weight: 700;
  z-index: 30;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1100px) {
  .grid.cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid.cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .search {
    width: 100%;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .grid.cols-4,
  .grid.cols-3,
  .grid.cols-2 {
    grid-template-columns: 1fr;
  }
}

.auth-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(900px 600px at 20% 10%, rgba(47, 111, 237, 0.15) 0%, transparent 60%),
    radial-gradient(800px 500px at 90% 0%, rgba(16, 185, 129, 0.15) 0%, transparent 60%),
    rgba(248, 250, 252, 0.9);
  backdrop-filter: blur(6px);
  z-index: 20;
}

.auth-screen.hidden {
  display: none;
}

.auth-card {
  width: min(420px, 92vw);
  background: #ffffff;
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
  border: 1px solid var(--border);
}

.auth-card h2 {
  margin: 6px 0 6px 0;
}

.auth-card form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.auth-card input {
  background: #f8fafc;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.auth-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.app.is-locked {
  filter: blur(6px);
  pointer-events: none;
}

.camera-form {
  display: grid;
  gap: 12px;
}

.camera-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
