:root {
  --bg: #0e1014;
  --panel: #161920;
  --panel2: #1d212a;
  --line: #2a2f3a;
  --text: #e5e7eb;
  --muted: #8b93a3;
  --accent: #3d8bfd;
  --rec: #2bb38a;
  --raw: #6b7280;
  --head: #ff4d4f;
  --err: #ff7a7a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 10px; cursor: pointer; }
button:hover { border-color: #3a4150; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.link { background: none; border: none; color: var(--muted); padding: 4px 6px; }
button.link:hover { color: var(--text); }

/* Вход */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-box { width: 100%; max-width: 320px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 24px; display: grid; gap: 14px; }
.login-box h1 { margin: 0 0 4px; font-size: 20px; font-weight: 600; }
.login-box label { display: grid; gap: 6px; color: var(--muted); }
.login-box input { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; }
.login-box button[type=submit] { background: var(--accent); border-color: var(--accent); color: #fff; padding: 9px; font-weight: 600; }
.err { color: var(--err); margin: 0; min-height: 1.4em; }

/* Раскладка */
.app { display: grid; grid-template-columns: 270px 1fr; grid-template-rows: auto 1fr; height: 100%; }
.top { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 600; }
.site { color: var(--muted); font-weight: 400; margin-left: 6px; }
.who { color: var(--muted); display: flex; align-items: center; gap: 6px; }
.side { background: var(--panel); border-right: 1px solid var(--line); overflow: auto; padding: 12px; }
.side-title { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; margin: 16px 4px 6px; }
.main { min-width: 0; overflow: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }

/* Календарь */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cal-head b { font-weight: 600; }
.cal-head button { padding: 2px 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-grid .wd { color: var(--muted); font-size: 11px; padding: 2px 0; }
.cal-grid button { padding: 5px 0; border-radius: 5px; border: 1px solid transparent; background: none; color: #4b5260; cursor: default; }
.cal-grid button.has { color: var(--text); background: var(--panel2); cursor: pointer; }
.cal-grid button.has:hover { border-color: var(--accent); }
.cal-grid button.today { text-decoration: underline; }
.cal-grid button.sel { background: var(--accent); color: #fff; }

/* Камеры */
.cams { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.cams button { width: 100%; text-align: left; background: none; border: 1px solid transparent; padding: 7px 8px; display: grid; }
.cams button:hover { background: var(--panel2); }
.cams button.sel { background: var(--panel2); border-color: var(--accent); }
.cams small { color: var(--muted); }

/* Видео */
.stage { position: relative; background: #000; border-radius: 8px; overflow: hidden; aspect-ratio: 16 / 9; width: 100%;
  max-height: calc(100vh - 260px); }
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; visibility: hidden; }
.stage video.on { visibility: visible; }
.stage:fullscreen { max-height: none; border-radius: 0; }
.osd { position: absolute; left: 10px; top: 8px; font: 600 15px/1 ui-monospace, Consolas, monospace; color: #fff;
  text-shadow: 0 0 3px #000, 0 0 2px #000; pointer-events: none; }
.msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; color: var(--text);
  background: rgba(0, 0, 0, .55); }
.spin { position: absolute; right: 12px; top: 10px; width: 22px; height: 22px; border: 3px solid rgba(255,255,255,.25);
  border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Панель управления */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.grp { display: flex; gap: 4px; align-items: center; }
.bar svg { width: 20px; height: 20px; fill: currentColor; display: block; }
.bar button { padding: 6px 8px; }
.bar button.play { padding: 6px 14px; background: var(--accent); border-color: var(--accent); color: #fff; }
.time { font: 600 16px/1 ui-monospace, Consolas, monospace; min-width: 190px; }
.speeds button { min-width: 42px; padding: 6px 6px; }
.speeds button.sel { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Шкала */
.tl { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.tl canvas { display: block; width: 100%; height: 72px; cursor: pointer; touch-action: none; }
.tl-tools { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 4px; }
.tl-tools button { padding: 2px 10px; }
.zlabel { color: var(--muted); min-width: 70px; text-align: center; }
.hint { color: var(--muted); font-size: 12px; margin: 0; }

@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; height: auto; }
  .side { border-right: none; border-bottom: 1px solid var(--line); }
  .cams { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .main { padding: 10px; }
  .stage { max-height: none; }
  .time { min-width: 0; }
  .hint { display: none; }
}
