:root {
  --bg: #0f1216;
  --panel: #171c22;
  --panel2: #1e252d;
  --line: #2a323c;
  --text: #e6eaef;
  --muted: #8b96a3;
  --accent: #4da3ff;
  --ok: #3ecf8e;
  --warn: #f5b942;
  --bad: #ff5d5d;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.hidden { display: none !important; }
.center { text-align: center; margin: 16px 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--bad); min-height: 1.2em; margin: 8px 0 0; }
kbd { background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-size: 11px; }

h1, h2, h3 { margin: 0 0 8px; font-weight: 600; }
h2 { font-size: 20px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }

/* Přihlašovací stránka */
.login-screen {
  position: relative; min-height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px 16px; overflow: hidden;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(45,155,255,.30), transparent 60%),
    radial-gradient(900px 500px at 50% 110%, rgba(22,118,251,.22), transparent 60%),
    var(--bg);
}
.login-glow {
  position: absolute; width: 520px; height: 520px; border-radius: 50%;
  top: 50%; left: 50%; transform: translate(-50%, -58%);
  background: radial-gradient(circle, rgba(45,155,255,.22), transparent 68%);
  pointer-events: none;
}
.login-card {
  position: relative; width: 100%; max-width: 360px; padding: 30px 28px 24px;
  background: rgba(23,28,34,.82); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.03) inset;
  text-align: center;
}
.login-logo { display: block; margin: -62px auto 12px; width: 104px; height: 104px; filter: drop-shadow(0 12px 22px rgba(22,118,251,.45)); }
.login-title { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: .01em; }
.login-sub {
  display: inline-block; margin: 6px 0 18px; padding: 2px 10px; font-size: 11px; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; color: var(--accent);
  border: 1px solid rgba(77,163,255,.4); border-radius: 999px; background: rgba(77,163,255,.08);
}
.login-card label { display: block; margin: 12px 0; color: var(--muted); font-size: 12px; text-align: left; }
.login-card input { margin-top: 5px; padding: 10px 12px; }
.login-card .btn.primary { margin-top: 6px; padding: 11px 12px; font-size: 15px; background: linear-gradient(180deg, #3aa0ff, #1676fb); border-color: #1676fb; color: #fff; }
.login-card .btn.primary:hover { filter: brightness(1.08); }
.login-foot { position: relative; margin-top: 22px; font-size: 12px; color: var(--muted); letter-spacing: .04em; }

input, select {
  width: 100%; background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit;
}
input[type=checkbox] { width: auto; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.btn {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 12px; font: inherit; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #04121f; font-weight: 600; width: 100%; }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.danger:hover { background: var(--bad); color: #1a0505; }
.btn.small { padding: 4px 8px; font-size: 12px; }
.btn.big { width: 100%; padding: 12px; font-size: 15px; margin-top: 10px; }
.btn.on { background: var(--ok); border-color: var(--ok); color: #04170e; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.card .btn { margin: 2px 0; }
.card > .btn:not(.big):not(.small) { width: 100%; margin-bottom: 8px; }
.btn-row .btn { flex: 1; width: auto; }

/* Rozložení aplikace */
.app { display: flex; min-height: 100%; }
.sidebar {
  width: 210px; flex: none; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 14px 10px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 16px; }
.brand img { width: 34px; height: 34px; flex: none; }
.brand-name { font-size: 16px; font-weight: 700; line-height: 1.1; }
.brand-sub { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.nav-btn {
  display: block; width: 100%; text-align: left; background: none; color: var(--text);
  border: 0; border-radius: 8px; padding: 9px 12px; font: inherit; cursor: pointer; margin-bottom: 2px;
}
.nav-btn:hover { background: var(--panel2); }
.nav-btn.active { background: var(--accent); color: #04121f; font-weight: 600; }
.sidebar-foot { margin-top: auto; display: grid; gap: 8px; }
.content { flex: 1; padding: 20px; min-width: 0; }

/* Živě */
.live-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.video-wrap { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; }
.video-wrap video { width: 100%; height: 100%; object-fit: contain; display: block; }
.video-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); background: rgba(0,0,0,.55); text-align: center; padding: 16px;
}
.video-overlay.gone { display: none; }
.status-list { list-style: none; margin: 0 0 8px; padding: 0; }
.status-list li { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); flex: none; }
.dot.ok { background: var(--ok); }
.dot.wait { background: var(--warn); }
.dot.bad { background: var(--bad); }
.meter { height: 6px; background: var(--panel2); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.meter > div { height: 100%; width: 0; background: var(--ok); transition: width 60ms linear; }

/* Historie */
.toolbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar h2 { margin: 0 auto 0 0; }
.chips { display: flex; gap: 12px; }
.chips label, label.inline { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.history-list { display: grid; gap: 8px; }
.ev {
  display: grid; grid-template-columns: 128px 1fr auto; gap: 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px;
}
.ev .thumb {
  width: 128px; aspect-ratio: 16 / 9; background: var(--panel2); border-radius: 6px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 22px;
}
.ev .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ev .title { font-weight: 600; }
.ev .when { color: var(--muted); font-size: 12px; }
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); margin-right: 6px; }
.badge.ring { color: var(--warn); }
.badge.nfc { color: var(--accent); }
.badge.face { color: var(--ok); }
.badge.pir { color: var(--muted); }

/* Tabulky, obličeje */
.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.table tr:last-child td { border-bottom: 0; }
.table td.actions { text-align: right; white-space: nowrap; }
.table td.actions .btn { margin-left: 4px; }
.faces-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.face { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.face .ph { aspect-ratio: 1; background: var(--panel2); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 40px; }
.face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.face .info { padding: 8px 10px; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.inline-form input[type=text], .inline-form input:not([type]), .inline-form input[type=password] { width: 180px; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.75); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-box { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; width: min(960px, 100%); }
.modal-box video { width: 100%; max-height: 72vh; background: #000; border-radius: 8px; display: block; }
.modal-title { font-weight: 600; margin: 0 28px 8px 0; }
.modal-close { position: absolute; top: 8px; right: 8px; background: none; border: 0; color: var(--text); font-size: 18px; cursor: pointer; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; z-index: 60; max-width: 90vw; }
.toast.err { border-color: var(--bad); color: var(--bad); }

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; }
  .brand { padding: 0 8px 0 0; }
  .brand-sub { display: none; }
  nav { display: flex; flex-wrap: wrap; }
  .sidebar-foot { margin: 0 0 0 auto; grid-auto-flow: column; align-items: center; }
  .live-grid { grid-template-columns: 1fr; }
  .ev { grid-template-columns: 96px 1fr; }
  .ev .thumb { width: 96px; }
  .ev .ev-actions { grid-column: 1 / -1; }
}
