/* Eagle Vision Security monitoring portal: dark theme.
   Brand: navy #213769 and grey #94959A (logo), blue #046BD2 (website), slate panels. */
@font-face { font-family: Inter; font-weight: 400; font-display: swap; src: url(fonts/inter-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: Inter; font-weight: 500; font-display: swap; src: url(fonts/inter-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: Inter; font-weight: 600; font-display: swap; src: url(fonts/inter-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: Inter; font-weight: 700; font-display: swap; src: url(fonts/inter-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: Montserrat; font-weight: 600; font-display: swap; src: url(fonts/montserrat-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: Montserrat; font-weight: 700; font-display: swap; src: url(fonts/montserrat-latin-700-normal.woff2) format("woff2"); }

:root {
  color-scheme: dark;
  --navy: #213769; --grey: #94959a; --blue: #046bd2; --blue-hover: #045cb4;
  --bg: #0b1220; --bg2: #0f1726; --panel: #1e293b; --panel2: #263548; --line: #334155;
  --text: #e2e8f0; --muted: #94a3b8; --faint: #64748b;
  --ok: #22c55e; --bad: #ef4444; --warn: #f59e0b; --idle: #64748b;
  --tile: #000; --radius: 6px;
}
* { box-sizing: border-box; }
html, body, #app { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 13px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 12px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--blue-hover); }
button.danger { color: var(--bad); }
button.small { padding: 3px 8px; font-size: 12px; }
button.ghost { background: none; border-color: transparent; }
button.ghost:hover { background: var(--panel2); }
button.icon { padding: 4px; width: 28px; height: 28px; justify-content: center; }
button[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #fff; }
svg.i { width: 16px; height: 16px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
input, select, textarea { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 9px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: -1px; border-color: transparent; }
label { display: block; margin: 12px 0 4px; color: var(--muted); font-size: 12px; font-weight: 500; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 13px; margin: 4px 0; font-weight: 400; }
label.check input { width: auto; }
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 8px 10px; border-bottom: 1px solid #1f2b3d; vertical-align: middle; }
tr:hover td { background: #152032; }
td.actions { text-align: right; white-space: nowrap; }
td.actions button { margin-left: 4px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.error { color: var(--bad); min-height: 1.4em; margin-top: 8px; }
.ok { color: var(--ok); }
.spacer { flex: 1; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; background: var(--idle); }
.dot.on { background: var(--ok); box-shadow: 0 0 0 2px #22c55e22; }
.dot.off { background: var(--bad); box-shadow: 0 0 0 2px #ef444422; }
.dot.warn { background: var(--warn); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 1px 8px; border-radius: 999px; font-size: 12px;
  background: var(--panel2); border: 1px solid var(--line); }
.pill.ok { color: var(--ok); border-color: #22c55e55; }
.pill.bad { color: var(--bad); border-color: #ef444455; }
.pill.warn { color: var(--warn); border-color: #f59e0b55; }

/* ---------- login ---------- */
.login-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #213769aa, transparent 70%), var(--bg); }
.login { width: 100%; max-width: 380px; text-align: center; }
.login img { width: 300px; max-width: 90%; margin-bottom: 28px; }
.login form { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 24px; }
.login button.primary { width: 100%; justify-content: center; margin-top: 18px; padding: 9px; }
.login .legal { margin-top: 18px; color: var(--faint); font-size: 12px; }

/* ---------- shell ---------- */
.shell { display: flex; flex-direction: column; height: 100%; }
.topbar { display: flex; align-items: center; gap: 6px; height: 48px; padding: 0 12px; background: var(--bg2);
  border-bottom: 1px solid var(--line); flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: 18px; text-decoration: none; color: var(--text); }
.brand img { height: 26px; }
.brand span { font-family: Montserrat, Inter, sans-serif; font-weight: 700; letter-spacing: .06em; font-size: 13px; text-transform: uppercase; }
.topbar nav { display: flex; gap: 2px; }
.topbar nav a { color: var(--muted); text-decoration: none; padding: 6px 12px; border-radius: var(--radius); font-weight: 500; }
.topbar nav a:hover { color: var(--text); background: var(--panel); }
.topbar nav a.active { color: #fff; background: var(--panel2); }
.clock { font-variant-numeric: tabular-nums; color: var(--muted); padding: 0 10px; }
.usermenu { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 4px); background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 4px; min-width: 180px; z-index: 50; box-shadow: 0 10px 30px #0008; }
.menu button { width: 100%; background: none; border: 0; justify-content: flex-start; }
.menu button:hover { background: var(--panel2); }
.content { flex: 1; min-height: 0; display: flex; }

/* ---------- live ---------- */
.live { flex: 1; display: flex; min-width: 0; }
.side { width: 270px; flex-shrink: 0; background: var(--bg2); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side.collapsed { display: none; }
.side .search { padding: 10px; border-bottom: 1px solid var(--line); }
.tree { flex: 1; overflow-y: auto; padding: 4px 0; min-height: 80px; user-select: none; }
.tree .row { display: flex; align-items: center; gap: 7px; padding: 4px 10px; cursor: pointer; white-space: nowrap; border-left: 2px solid transparent; }
.tree .row:hover { background: var(--panel); }
.tree .row.sel { background: #046bd222; border-left-color: var(--blue); }
.tree .row .name { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.tree .row .count { color: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.tree .row .tw { width: 12px; color: var(--faint); font-size: 10px; text-align: center; flex-shrink: 0; }
.tree .row.l1 { padding-left: 24px; }
.tree .row.l2 { padding-left: 42px; }
.tree .row.site .name { font-weight: 600; }
.tree .row.dragging { opacity: .5; }
.tree .empty { padding: 16px; color: var(--muted); }
.side h4 { margin: 0; padding: 10px 12px 4px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em;
  display: flex; align-items: center; }
.viewlist { max-height: 38%; overflow-y: auto; border-top: 1px solid var(--line); padding-bottom: 8px; flex-shrink: 0; }
.viewlist .sub { padding: 6px 12px 2px; font-size: 11px; color: var(--faint); }
.viewlist .v { display: flex; align-items: center; gap: 7px; padding: 4px 12px 4px 18px; cursor: pointer; }
.viewlist .v:hover { background: var(--panel); }
.viewlist .v.active { background: #046bd222; color: #fff; }
.viewlist .v .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewlist .v .del { visibility: hidden; padding: 0 4px; height: 20px; }
.viewlist .v:hover .del { visibility: visible; }

.stage { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.toolbar { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--line); background: var(--bg2); flex-wrap: wrap; }
.toolbar .viewname { font-weight: 600; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolbar .viewname.dirty::after { content: " •"; color: var(--warn); }
.toolbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.layouts { display: flex; gap: 2px; }
.layouts button { padding: 3px 6px; }
.layouts svg { width: 18px; height: 18px; }
.statusbar { display: flex; gap: 16px; padding: 3px 12px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); background: var(--bg2); }

.grid { flex: 1; min-height: 0; display: grid; gap: 2px; padding: 2px; background: #05080f; }
.tile { position: relative; background: var(--tile); min-width: 0; min-height: 0; overflow: hidden; outline: 1px solid #111827; }
.tile.sel { outline: 2px solid var(--blue); outline-offset: -2px; z-index: 1; }
.tile.drop { outline: 2px dashed var(--warn); outline-offset: -2px; }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.tile evs-video { position: absolute; inset: 0; display: block; }
.tile .bar { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 6px; padding: 4px 6px;
  background: linear-gradient(#000a, #0000); font-size: 12px; pointer-events: none; z-index: 2; text-shadow: 0 1px 2px #000; }
.tile .bar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.tile .bar .site { color: #cbd5e1aa; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .bar .q { margin-left: auto; font-size: 10px; color: #cbd5e1aa; text-transform: uppercase; letter-spacing: .05em; }
.tile .tools { position: absolute; right: 4px; bottom: 4px; display: flex; gap: 3px; opacity: 0; transition: opacity .15s; z-index: 3; }
.tile:hover .tools { opacity: 1; }
.tile .tools button { background: #0f1726d9; border-color: #334155; padding: 3px; width: 26px; height: 26px; justify-content: center; }
.tile .msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--muted); font-size: 12px; text-align: center; padding: 8px; z-index: 1; pointer-events: none; }
.tile .msg strong { color: var(--text); font-weight: 600; }
.tile .msg.bad strong { color: var(--bad); }
.tile .msg.warn strong { color: var(--warn); }
.tile.empty .msg { color: var(--faint); }
.tile.small .bar { font-size: 11px; padding: 2px 4px; }
.tile.small .bar .site, .tile.small .bar .q { display: none; }
.spin { width: 18px; height: 18px; border: 2px solid #ffffff33; border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* expanded single camera (double-click) */
.grid.expanded > .tile:not(.big) { display: none; }
.grid.expanded > .tile.big { grid-area: 1 / 1 / -1 / -1 !important; }

/* full screen / wall windows */
.stage:fullscreen .toolbar, .stage:fullscreen .statusbar { display: none; }
.wall { height: 100%; display: flex; flex-direction: column; }
.wall .toolbar { position: absolute; left: 0; right: 0; top: 0; z-index: 10; transition: opacity .3s; background: #0f1726ee; }
.wall.idle .toolbar { opacity: 0; pointer-events: none; }
.wall.idle { cursor: none; }
.banner { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: #046bd222; border-bottom: 1px solid #046bd255; }

/* ---------- pages (admin) ---------- */
.page { flex: 1; overflow-y: auto; padding: 20px 24px; }
.page h2 { margin: 0 0 4px; font-size: 18px; font-family: Montserrat, Inter, sans-serif; }
.page .lead { color: var(--muted); margin: 0 0 16px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a.active { color: #fff; border-bottom-color: var(--blue); }
.bar2 { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.bar2 input { max-width: 280px; }
.split { display: flex; gap: 16px; min-height: 0; align-items: flex-start; }
.split .list { width: 300px; flex-shrink: 0; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.split .detail { flex: 1; min-width: 0; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 16px 18px; }
.split .list .row { display: flex; align-items: center; gap: 8px; padding: 7px 12px; cursor: pointer; }
.split .list .row:hover { background: var(--panel); }
.split .list .row.sel { background: #046bd222; box-shadow: inset 2px 0 var(--blue); }
.split .list .row.site { font-weight: 600; border-top: 1px solid var(--line); }
.split .list .row.site:first-child { border-top: 0; }
.split .list .row.nvr { padding-left: 26px; }
.split .list .row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.formgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 14px; }
.detail h3 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 10px; }
.detail .acts { display: flex; gap: 8px; margin: 16px 0 6px; flex-wrap: wrap; }
.notice { padding: 10px 12px; border-radius: 6px; background: #f59e0b18; border: 1px solid #f59e0b55; margin: 12px 0; }
.notice.bad { background: #ef444418; border-color: #ef444455; }
.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 12px; max-height: 240px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }

/* ---------- dialogs / toasts ---------- */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 0; width: min(480px, 94vw); box-shadow: 0 20px 60px #000a; }
dialog.wide { width: min(820px, 96vw); }
dialog::backdrop { background: #020617b3; }
dialog header { padding: 14px 18px; font-weight: 600; font-size: 15px; border-bottom: 1px solid var(--line); }
dialog .body { padding: 6px 18px 14px; max-height: 70vh; overflow-y: auto; }
dialog footer { padding: 12px 18px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--blue); padding: 10px 14px; border-radius: 6px;
  box-shadow: 0 8px 24px #0008; max-width: 360px; }
.toast.bad { border-left-color: var(--bad); }
.empty-state { margin: auto; text-align: center; color: var(--muted); padding: 40px; max-width: 460px; }
.empty-state img { width: 90px; opacity: .5; margin-bottom: 12px; }

@media (max-width: 760px) {
  .side { width: 220px; }
  .brand span, .clock { display: none; }
  .split { flex-direction: column; }
  .split .list { width: 100%; }
}
