:root {
  --bg: #0b0f17; --panel: #121826; --panel-2: #1a2233; --line: #263044;
  --fg: #e6ebf5; --muted: #8e9ab3; --accent: #3b82f6; --accent-fg: #fff;
  --ok: #34d399; --bad: #f87171; --warn: #fbbf24; --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; }
[hidden] { display: none !important; }

.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100%; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 10px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 4px 8px 16px; }
.brand img { width: 30px; height: 30px; }
.nav { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav:hover { background: var(--panel-2); color: var(--fg); }
.nav.on { background: var(--accent); color: var(--accent-fg); }
.nav-sep { margin: 12px 10px 4px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.side .who { margin-top: auto; padding: 10px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.main { padding: 20px 24px 40px; min-width: 0; }
.head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.head .grow { flex: 1; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: auto 0 0 0; height: auto; flex-direction: row; padding: 6px max(6px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); border-right: 0; border-top: 1px solid var(--line); z-index: 20; overflow-x: auto; }
  .side .brand, .nav-sep, .side .who { display: none; }
  .nav { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 10px; white-space: nowrap; }
  .main { padding: 14px 14px 90px; }
}

button, .btn { font: inherit; color: var(--fg); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { border-color: var(--muted); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
button.danger { color: var(--bad); }
button.on { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
input, select { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=checkbox] { width: auto; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--fg); }
.form { display: grid; gap: 12px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hint { color: var(--muted); font-size: 12px; }
.error { color: var(--bad); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 360px; }
.login .brand { padding: 0 0 14px; font-size: 20px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.cam { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--fg); display: block; }
.cam:hover { border-color: var(--accent); }
.thumb { aspect-ratio: 16 / 9; background: #000 center / cover no-repeat; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.cam .meta { padding: 9px 12px; display: flex; align-items: center; gap: 8px; }
.cam .meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }

.player { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; }
.player video { width: 100%; height: 100%; display: block; object-fit: contain; background: #000; }
.player .overlay { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 12px; color: var(--muted); background: rgba(0, 0, 0, .55); pointer-events: none; }
.player .tag { position: absolute; left: 8px; bottom: 8px; background: rgba(0, 0, 0, .6); padding: 2px 8px; border-radius: 6px; font-size: 12px; max-width: calc(100% - 16px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage { max-width: 1100px; }
.tabs { display: flex; gap: 6px; margin: 0 0 12px; flex-wrap: wrap; }

.mosaic { display: grid; gap: 0; align-content: start; background: #000; }
.mosaic .player { border-radius: 0; cursor: pointer; }
.mosaic-state { position: absolute; inset: 10px auto auto 10px; z-index: 2; border: 2px solid rgba(0, 0, 0, .5); }
.mosaic-alert, .mosaic-expand { position: absolute; z-index: 2; display: grid; place-items: center; min-width: 28px; height: 28px; padding: 0 7px; border: 0; border-radius: 7px; color: #fff; background: rgba(10, 18, 30, .78); font-size: 12px; line-height: 1; }
.mosaic-alert { inset: 8px 44px auto auto; background: #d3223e; font-weight: 700; }
.mosaic-alert[hidden] { display: none; }
.mosaic-expand { inset: 8px 8px auto auto; font-size: 18px; opacity: .75; }
.mosaic .player:hover .mosaic-expand, .mosaic-expand:focus-visible { opacity: 1; }
.mosaic .player:fullscreen { width: 100vw; height: 100vh; aspect-ratio: auto; cursor: default; }
.mosaic .player:fullscreen video { object-fit: contain; }

.timeline { position: relative; height: 46px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; margin: 12px 0 4px; cursor: pointer; overflow: hidden; touch-action: none; }
.timeline .rec { position: absolute; top: 0; bottom: 0; min-width: 2px; background: color-mix(in srgb, var(--accent) 55%, transparent); }
.timeline .mark { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--warn) 45%, transparent); pointer-events: none; }
.timeline .cursor { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; pointer-events: none; }
.timeline .hover { position: absolute; top: 2px; transform: translateX(-50%); font-size: 11px; background: #000; padding: 1px 6px; border-radius: 4px; pointer-events: none; }
.hours { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.clock { font-variant-numeric: tabular-nums; font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
.table-wrap { overflow-x: auto; }
.empty { color: var(--muted); padding: 30px 10px; text-align: center; }

dialog { background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 12px; padding: 20px; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto; }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.preview { max-width: 100%; border-radius: 8px; margin-top: 8px; }
.pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; max-height: 300px; overflow: auto; }

#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; max-width: min(360px, calc(100vw - 32px)); }
@media (max-width: 760px) { #toasts { bottom: 84px; } }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; padding: 10px 12px; }
.toast.bad { border-left-color: var(--bad); }

/* Marcas dos módulos (eventos) no alto da linha do tempo; aviso clicável. */
.timeline .evt { position: absolute; top: 0; height: 9px; min-width: 3px; background: var(--warn); border-radius: 0 0 2px 2px; }
a.toast { display: block; color: var(--fg); cursor: pointer; }
