:root {
  --bg: #0b1020; --card: #141b30; --line: #24304f; --text: #e8ecf6; --muted: #8e9ab8;
  --accent: #5b8cff; --accent2: #3a6cf0; --ok: #2fbf71; --bad: #ff5c6c; --live: #ff3b4e;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
header.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px;
  border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: .3px; display: flex; align-items: center; gap: 8px; color: var(--text); }
.brand img { width: 22px; height: 22px; }
nav a, nav button.link { margin-left: 14px; color: var(--muted); font-size: 15px; }
button.link { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; }
main { max-width: 980px; margin: 0 auto; padding: 22px 18px 40px; }
main.narrow { max-width: 420px; padding-top: 8vh; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px; margin-bottom: 18px; }
h1 { font-size: 24px; margin: 0 0 6px; }
h2 { font-size: 18px; margin: 0 0 12px; }
p.sub { color: var(--muted); margin: 0 0 20px; }
label { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 6px; }
input[type=text], input[type=password] { width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: #0e1426; color: var(--text); font-size: 16px; }
input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px;
  border-radius: 10px; border: 1px solid var(--line); background: #1b2440; color: var(--text);
  font-size: 15px; font-weight: 600; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent2); }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; margin-top: 16px; }
.btn:disabled { opacity: .5; cursor: default; }
.or { text-align: center; color: var(--muted); font-size: 13px; margin: 18px 0 2px; }
.msg { margin-top: 14px; font-size: 14px; min-height: 0; }
.msg.error { color: var(--bad); }
.msg.ok { color: var(--ok); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.hidden { display: none !important; }
ul.keys { list-style: none; padding: 0; margin: 0 0 14px; }
ul.keys li { display: flex; justify-content: space-between; align-items: center; padding: 10px 0;
  border-bottom: 1px solid var(--line); }
ul.keys small { color: var(--muted); display: block; }

/* Kamera */
.camgrid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 760px) { .camgrid { grid-template-columns: 1fr; } }
.videobox { position: relative; background: #000; border-radius: 16px; overflow: hidden; aspect-ratio: 3/4;
  border: 1px solid var(--line); }
@media (min-width: 761px) { .videobox { aspect-ratio: 4/3; } }
.videobox video, .videobox img { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.badge { position: absolute; top: 12px; left: 12px; background: rgba(0,0,0,.6); padding: 5px 10px;
  border-radius: 999px; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.badge .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.badge.live .dot { background: var(--live); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.badge.right { left: auto; right: 12px; }
.qr { background: #fff; border-radius: 14px; padding: 10px; width: 100%; max-width: 300px; margin: 0 auto 12px; display: block; }
.qr img { width: 100%; display: block; }
.linkline { font-size: 12px; color: var(--muted); word-break: break-all; text-align: center; margin-bottom: 12px; }
.center { text-align: center; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.controls .btn { flex: 1 1 auto; }
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 14px; color: var(--muted); text-align: center; padding: 20px; }
.viewer main { max-width: 1100px; }
.viewer .videobox { aspect-ratio: auto; height: calc(100vh - 170px); min-height: 280px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 10px; }
