:root {
  --bg: #0b1220;
  --bg-soft: #111a2e;
  --panel: #15203a;
  --panel-2: #1b2944;
  --border: #243556;
  --text: #e8eefc;
  --muted: #93a3c4;
  --brand: #2f6df6;
  --brand-2: #1b4fd1;
  --accent: #38d39f;
  --danger: #ef5468;
  --warn: #f5b042;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: radial-gradient(1200px 600px at 80% -10%, #16213c 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: rgba(13, 20, 36, 0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.brand .logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}
.brand .logo svg { width: 20px; height: 20px; }
.brand small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }

.topbar-actions { display: flex; align-items: center; gap: 14px; }
.who { color: var(--muted); font-size: 14px; }
.who b { color: var(--text); }

/* ---- Layout ---- */
.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 22px 60px;
}
.center-wrap {
  min-height: calc(100vh - 0px);
  display: grid;
  place-items: center;
  padding: 24px;
}

/* ---- Cards ---- */
.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 18px;
  gap: 12px;
}
.section-head h1, .section-head h2 { margin: 0; }
.subtitle { color: var(--muted); margin: 4px 0 0; }

/* ---- Buttons ---- */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .05s ease, background .15s ease, border-color .15s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn:hover { border-color: #34507f; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); border-color: transparent; }
.btn-primary:hover { filter: brightness(1.07); }
.btn-danger { background: transparent; border-color: #4a2730; color: var(--danger); }
.btn-danger:hover { background: rgba(239,84,104,.12); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 6px 10px; font-size: 13px; }

/* ---- Forms ---- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.input {
  width: 100%;
  padding: 12px 14px;
  background: #0e1729;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,109,246,.18); }

/* ---- Auth ---- */
.auth-card { width: 100%; max-width: 410px; }
.auth-head { text-align: center; margin-bottom: 22px; }
.auth-head .logo-lg {
  width: 60px; height: 60px; margin: 0 auto 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  display: grid; place-items: center; box-shadow: var(--shadow);
}
.auth-head .logo-lg svg { width: 34px; height: 34px; }
.auth-head h1 { margin: 0; font-size: 22px; }
.auth-head p { color: var(--muted); margin: 6px 0 0; }
.switch-line { text-align: center; color: var(--muted); margin-top: 16px; font-size: 14px; }

/* ---- Camera tiles ---- */
.cam-tile { overflow: hidden; padding: 0; }
.cam-video-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #05070d;
  display: grid;
  place-items: center;
}
.cam-video-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-placeholder { color: var(--muted); text-align: center; padding: 20px; font-size: 14px; }
.cam-meta { padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cam-meta h3 { margin: 0; font-size: 16px; }
.cam-actions { display: flex; gap: 8px; }

/* ---- Badges / status ---- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.badge.online { color: var(--accent); border-color: rgba(56,211,159,.4); background: rgba(56,211,159,.08); }
.badge.online .dot { background: var(--accent); box-shadow: 0 0 0 3px rgba(56,211,159,.18); }
.badge.offline .dot { background: var(--muted); }
.badge.live { color: #fff; background: var(--danger); border-color: transparent; }
.badge.live .dot { background: #fff; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ---- Alerts ---- */
.alert {
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14px;
  margin-bottom: 14px;
  border: 1px solid transparent;
  display: none;
}
.alert.show { display: block; }
.alert-error { background: rgba(239,84,104,.12); border-color: rgba(239,84,104,.4); color: #ffb6c0; }
.alert-ok { background: rgba(56,211,159,.12); border-color: rgba(56,211,159,.4); color: #aef0d6; }
.alert-info { background: rgba(47,109,246,.12); border-color: rgba(47,109,246,.4); color: #bcd2ff; }

/* ---- Empty state ---- */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 50px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ---- Table ---- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; }
.table tr:hover td { background: rgba(255,255,255,.02); }

.tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.tab { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); cursor: pointer; color: var(--muted); font-size: 14px; }
.tab.active { background: var(--panel-2); color: var(--text); border-color: #34507f; }

.footer-note { color: var(--muted); font-size: 12px; text-align: center; margin-top: 28px; }

.viewer-stage {
  background: #05070d;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16/9;
  display: grid; place-items: center;
}
.viewer-stage video { width: 100%; height: 100%; object-fit: contain; background: #000; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 16px; }

.hint { color: var(--muted); font-size: 13px; }
.kbd { font-family: ui-monospace, Menlo, Consolas, monospace; background: #0e1729; border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; }

@media (max-width: 560px) {
  .topbar { padding: 12px 14px; }
  .container { padding: 18px 14px 48px; }
  .who .full { display: none; }
}
