:root {
  --bg: #0b1220;
  --panel: #131c2e;
  --panel-2: #1a2740;
  --line: #273653;
  --text: #e7eefb;
  --muted: #8fa1bf;
  --accent: #4da3ff;
  --accent-2: #2b6cb0;
  --danger: #ff6b6b;
  --ok: #7ee2a0;
  --warn-bg: rgba(240, 180, 41, 0.12);
  --warn-line: rgba(240, 180, 41, 0.45);
  --warn-text: #ffd479;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 80% -10%, #16233d 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* ── Brand ── */
.brand { display: flex; align-items: center; gap: 0.8rem; }
.brand-mark {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 1.3rem; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 18px rgba(77, 163, 255, 0.35);
}
.brand h1 { margin: 0; font-size: 1.15rem; letter-spacing: 0.02em; }
.brand p { margin: 0; color: var(--muted); font-size: 0.8rem; letter-spacing: 0.14em; text-transform: uppercase; }

/* ── Login page ── */
body.auth { display: grid; place-items: center; padding: 1rem; }

.auth-card {
  width: 100%; max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.auth-card .brand { margin-bottom: 1.6rem; }

form label { display: block; margin: 0.9rem 0 0.3rem; color: var(--muted); font-size: 0.85rem; }
form input, form select {
  width: 100%; padding: 0.7rem 0.85rem;
  background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); font-size: 1rem;
}
form input:focus, form select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(77, 163, 255, 0.2);
}

button {
  width: 100%; margin-top: 1.4rem; padding: 0.75rem;
  border: none; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 1rem; font-weight: 600; cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.error { color: var(--danger); font-size: 0.85rem; margin: 0.9rem 0 0; }
.hint { margin: 1.4rem 0 0; text-align: center; color: var(--muted); font-size: 0.75rem; }

/* ── Top bar ── */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.9rem 1.4rem;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 18, 32, 0.85);
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 5;
}
.user-box { display: flex; align-items: center; gap: 0.9rem; color: var(--muted); font-size: 0.9rem; }
button.ghost, .ghost-link {
  width: auto; margin: 0; padding: 0.45rem 0.9rem;
  background: transparent; border: 1px solid var(--line);
  color: var(--text); border-radius: 10px;
  font-size: 0.85rem; font-weight: 500; cursor: pointer;
  text-decoration: none; display: inline-block;
}
button.ghost:hover, .ghost-link:hover { border-color: var(--accent); }

main { max-width: 1100px; margin: 1.4rem auto; padding: 0 1.2rem; }

/* ── Watch page ── */
.cam-list { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1rem; }
.cam-btn {
  width: auto; margin: 0; padding: 0.55rem 1rem;
  background: var(--panel); border: 1px solid var(--line);
  color: var(--text); border-radius: 999px; font-size: 0.9rem; font-weight: 500;
}
.cam-btn:hover { border-color: var(--accent); }
.cam-btn.active { background: var(--accent-2); border-color: var(--accent); }
.cam-btn.offline { opacity: 0.45; cursor: not-allowed; }

.player-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  min-height: 320px;
  display: grid; place-items: center;
}
.player-wrap video { width: 100%; max-height: 72vh; display: block; background: #000; }
.status { color: var(--muted); padding: 2rem; text-align: center; }

/* ── Admin page ── */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.4rem 1.5rem;
  margin-bottom: 1.2rem;
}
.panel h2 { margin: 0 0 1rem; font-size: 1.05rem; }
.muted { color: var(--muted); font-size: 0.88rem; line-height: 1.5; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.85rem; }

.warn-banner {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  color: var(--warn-text);
  border-radius: 12px;
  padding: 0.8rem 1rem;
  font-size: 0.9rem;
  margin-bottom: 1.2rem;
}

table.users { width: 100%; border-collapse: collapse; }
table.users th, table.users td {
  text-align: left; padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--line); font-size: 0.92rem;
}
table.users th {
  color: var(--muted); font-weight: 600; font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: 0.08em;
}
table.users select {
  padding: 0.35rem 0.5rem; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; color: var(--text);
}
.col-actions { text-align: right !important; white-space: nowrap; }
.col-actions button { margin-left: 0.4rem; }

button.small {
  width: auto; margin: 0; padding: 0.5rem 1rem;
  font-size: 0.88rem; border-radius: 9px;
}
button.ghost-btn {
  background: transparent; border: 1px solid var(--line);
  color: var(--text); font-weight: 500;
}
button.ghost-btn:hover { border-color: var(--accent); filter: none; }
button.danger-btn {
  background: transparent; border: 1px solid rgba(255, 107, 107, 0.55);
  color: var(--danger); font-weight: 500;
}
button.danger-btn:hover { border-color: var(--danger); filter: none; }

.inline-form {
  display: flex; gap: 0.7rem; flex-wrap: wrap;
  align-items: flex-end; margin-top: 1.1rem;
}
.inline-form .field { display: flex; flex-direction: column; gap: 0.25rem; }
.inline-form .field.grow { flex: 1; min-width: 220px; }
.inline-form label { margin: 0; font-size: 0.8rem; }
.inline-form input, .inline-form select { width: 100%; }

.message {
  padding: 0.7rem 0.9rem; border-radius: 10px;
  margin-top: 0.9rem; font-size: 0.88rem;
}
.message.ok { background: rgba(46, 160, 67, 0.15); color: var(--ok); border: 1px solid rgba(46, 160, 67, 0.4); }
.message.err { background: rgba(255, 107, 107, 0.12); color: #ff9c9c; border: 1px solid rgba(255, 107, 107, 0.4); }

#restart-btn { margin-top: 1rem; }
