/* Camera wall — dark NOC theme, sized for a wall display but usable on a laptop. */
:root {
  --bg: #0b0f14;
  --panel: #121820;
  --panel-2: #172029;
  --line: #22303d;
  --line-soft: #1a242e;
  --txt: #e6edf3;
  --muted: #8b9aa9;
  --dim: #5f7181;
  --accent: #35a7ff;
  --ok: #3fbf7f;
  --warn: #f0b429;
  --bad: #f2555a;
  --solar: #ffc453;
  --radius: 10px;
  --tile-gap: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font: 14px/1.45 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- top bar ---------- */
.top {
  display: flex; align-items: center; gap: 18px;
  height: 56px; padding: 0 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: .2px; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 10px var(--accent); }
.brand small { color: var(--dim); font-weight: 400; margin-left: 6px; }

.stats { display: flex; gap: 8px; margin-left: 4px; flex-wrap: wrap; }
.stat {
  display: flex; align-items: baseline; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 5px 10px; border-radius: 7px; white-space: nowrap;
}
.stat b { font-size: 15px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.stat.ok b { color: var(--ok); }
.stat.bad b { color: var(--bad); }
.stat.warn b { color: var(--warn); }

.spacer { flex: 1; }

.controls { display: flex; align-items: center; gap: 8px; }
.seg { display: flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button {
  background: none; border: 0; padding: 6px 11px; color: var(--muted); font-size: 12.5px;
}
.seg button.on { background: var(--accent); color: #04121f; font-weight: 600; }
.seg button:hover:not(.on) { background: #1e2a36; color: var(--txt); }

.icon-btn {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px;
  padding: 6px 11px; color: var(--muted); font-size: 12.5px;
}
.icon-btn:hover { color: var(--txt); border-color: #2d3f4f; }
.icon-btn.on { background: var(--accent); color: #04121f; border-color: var(--accent); font-weight: 600; }

/* ---------- banner ---------- */
.banner {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; font-size: 12.5px;
  background: #1d1a10; border-bottom: 1px solid #3a3116; color: #e7cf94;
}
.banner b { color: #ffd98a; }
.banner.hide { display: none; }

/* ---------- grid ---------- */
.wrap { height: calc(100% - 56px); display: flex; flex-direction: column; }
.wrap.with-banner { height: calc(100% - 56px - 36px); }

.grid {
  flex: 1; display: grid; gap: var(--tile-gap); padding: var(--tile-gap);
  overflow: auto; align-content: start;
}
.grid.c1 { grid-template-columns: 1fr; }
.grid.c2 { grid-template-columns: repeat(2, 1fr); }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid.c3, .grid.c4 { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- tile ---------- */
.tile {
  position: relative; background: #000; border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9;
  cursor: pointer; transition: border-color .15s, transform .12s;
}
.tile:hover { border-color: var(--accent); }
.tile.offline { border-color: #3a2226; }
.tile.selected { outline: 2px solid var(--accent); outline-offset: -2px; }
.tile canvas, .tile video, .tile img.feed {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
}

.tile .veil {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px;
  background: repeating-linear-gradient(45deg, #0d1218, #0d1218 10px, #0f151c 10px, #0f151c 20px);
  color: var(--dim); font-size: 13px; text-align: center; padding: 12px;
}
.tile .veil b { color: var(--bad); font-size: 13px; letter-spacing: .3px; }

/* tile chrome */
.t-top, .t-bot {
  position: absolute; left: 0; right: 0; display: flex; align-items: center;
  gap: 8px; padding: 7px 9px; pointer-events: none; font-size: 11.5px;
}
.t-top { top: 0; background: linear-gradient(180deg, rgba(0,0,0,.72), transparent); }
.t-bot { bottom: 0; background: linear-gradient(0deg, rgba(0,0,0,.75), transparent); }

.t-name { font-weight: 600; font-size: 12.5px; text-shadow: 0 1px 3px #000; }
.t-site { color: #b9c6d2; font-size: 11px; text-shadow: 0 1px 3px #000; }

.live {
  display: inline-flex; align-items: center; gap: 5px; font-size: 10px;
  letter-spacing: .8px; font-weight: 700; color: #ff6b6b;
}
.live i { width: 6px; height: 6px; border-radius: 50%; background: #ff4d4f; animation: pulse 1.8s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
.live.off { color: var(--dim); }
.live.off i { background: var(--dim); animation: none; }

/* health chips on the tile */
.chips { display: flex; gap: 7px; margin-left: auto; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-variant-numeric: tabular-nums; font-size: 11px;
  color: #cfdae4; text-shadow: 0 1px 3px #000;
}
.chip.ok { color: #7fe0ae; }
.chip.warn { color: #ffd166; }
.chip.bad { color: #ff8a8d; }

/* battery glyph */
.bat { position: relative; width: 22px; height: 11px; border: 1.5px solid currentColor;
  border-radius: 2.5px; display: inline-block; }
.bat::after { content: ""; position: absolute; right: -4px; top: 3px; width: 2px; height: 5px;
  background: currentColor; border-radius: 0 1px 1px 0; }
.bat i { position: absolute; inset: 1.5px; width: var(--lv, 50%); background: currentColor; border-radius: 1px; display: block; }

/* signal bars */
.sig { display: inline-flex; align-items: flex-end; gap: 1.5px; height: 11px; }
.sig s { width: 3px; background: currentColor; opacity: .25; border-radius: .5px; text-decoration: none; }
.sig s.on { opacity: 1; }
.sig s:nth-child(1) { height: 3px; } .sig s:nth-child(2) { height: 5.5px; }
.sig s:nth-child(3) { height: 8px; } .sig s:nth-child(4) { height: 11px; }

/* ---------- health table ---------- */
.health { flex: 1; overflow: auto; padding: 12px 16px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  position: sticky; top: 0; background: var(--bg); z-index: 1; }
tbody tr:hover { background: var(--panel); cursor: pointer; }
td.num { font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; }
.pill.up { background: rgba(63,191,127,.15); color: var(--ok); }
.pill.down { background: rgba(242,85,90,.15); color: var(--bad); }
.bar { width: 90px; height: 6px; background: #1e2a36; border-radius: 4px; overflow: hidden; display: inline-block;
  vertical-align: middle; margin-right: 8px; }
.bar i { display: block; height: 100%; border-radius: 4px; }

/* ---------- expanded view ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(4,7,10,.82); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 24px;
}
.modal.hide { display: none; }
.sheet {
  width: min(1180px, 100%); max-height: 100%; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  display: flex; flex-direction: column;
}
.sheet-top { display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--line); }
.sheet-top h2 { margin: 0; font-size: 15px; font-weight: 650; }
.sheet-top .sub { color: var(--muted); font-size: 12px; }
.sheet-body { display: flex; gap: 16px; padding: 16px; overflow: auto; }
@media (max-width: 860px) { .sheet-body { flex-direction: column; } }
.stage { flex: 1; min-width: 0; }
.stage .screen { position: relative; background: #000; border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden; aspect-ratio: 16/9; }
.stage .screen canvas, .stage .screen video, .stage .screen img.feed {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }

.side { width: 290px; flex-shrink: 0; display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 860px) { .side { width: auto; } }

.card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.card h3 { margin: 0 0 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--muted); font-weight: 600; }

.kv { display: flex; justify-content: space-between; align-items: center; padding: 5px 0;
  font-size: 12.5px; border-bottom: 1px solid var(--line-soft); }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; font-variant-numeric: tabular-nums; }

/* PTZ pad */
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.pad button {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  height: 42px; display: flex; align-items: center; justify-content: center;
  color: var(--txt); font-size: 16px; user-select: none;
}
.pad button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pad button:active:not(:disabled) { background: var(--accent); color: #04121f; }
.pad button:disabled { opacity: .3; cursor: not-allowed; }
.pad .home { font-size: 13px; }

.zoom-row { display: flex; gap: 6px; margin-bottom: 10px; }
.zoom-row button { flex: 1; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; height: 34px; }
.zoom-row button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.zoom-row button:disabled { opacity: .3; cursor: not-allowed; }

.speed { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.speed input { flex: 1; accent-color: var(--accent); }

.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.presets button { background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 10px; font-size: 12px; }
.presets button:hover { border-color: var(--accent); color: var(--accent); }

.ptz-note { font-size: 11.5px; color: var(--dim); margin-top: 8px; line-height: 1.4; }
.ptz-log { font-size: 11px; color: var(--accent); min-height: 15px; margin-top: 6px;
  font-variant-numeric: tabular-nums; }

.events li { list-style: none; display: flex; justify-content: space-between; gap: 8px;
  font-size: 12px; padding: 4px 0; border-bottom: 1px solid var(--line-soft); }
.events { margin: 0; padding: 0; max-height: 160px; overflow: auto; }
.events b { font-weight: 600; }
.events .k-humanoid { color: var(--warn); }
.events .k-motion { color: var(--accent); }
.events .k-pir { color: var(--muted); }

.x { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 20px; line-height: 1; }
.x:hover { color: var(--txt); }

.empty { padding: 40px; text-align: center; color: var(--dim); }

/* ---------- sign-in gate (this subdomain holds its own LinkEye cookie) ---------- */
.gate {
  position: fixed; inset: 0; z-index: 90;
  background: radial-gradient(1200px 600px at 50% -10%, #16202b, var(--bg) 70%);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.gate.hide { display: none; }
.gate-box {
  width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 26px; display: flex; flex-direction: column; gap: 11px;
  box-shadow: 0 24px 70px rgba(0,0,0,.55);
}
.gate-box p { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.gate-box input {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; color: var(--txt); font: inherit; outline: none;
}
.gate-box input:focus { border-color: var(--accent); }
.gate-box button {
  margin-top: 4px; background: var(--accent); border: 0; border-radius: 8px;
  padding: 11px; color: #04121f; font-weight: 650;
}
.gate-box button:disabled { opacity: .6; cursor: default; }
.gate-err { color: var(--bad); font-size: 12.5px; min-height: 16px; }

/* ---------- connect / provider configuration ---------- */
.sheet.cfg { width: min(760px, 100%); }
.cfg-body { padding: 16px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }

.src-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 700px) { .src-pick { grid-template-columns: 1fr; } }
.src {
  display: block; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; cursor: pointer; transition: border-color .15s;
}
.src:hover { border-color: #2d3f4f; }
.src.on { border-color: var(--accent); background: #15222e; }
.src input { display: none; }
.src b { display: block; font-size: 13px; margin-bottom: 4px; }
.src span { color: var(--muted); font-size: 11.5px; line-height: 1.4; display: block; }

.pane { display: flex; flex-direction: column; gap: 12px; }
.pane.hide { display: none; }

.note {
  background: #15202b; border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 10px 12px; color: var(--muted); font-size: 12.5px; line-height: 1.5;
}

.field { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 0; }
.field.hide, .row.hide { display: none; }
.field label, .cfg-body > label, .adv label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600;
}
.field input, .field select, .cfg-body textarea, .adv textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; color: var(--txt); font: inherit; outline: none; width: 100%;
}
.cfg-body textarea, .adv textarea {
  font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; resize: vertical;
}
.field input:focus, .field select:focus, textarea:focus { border-color: var(--accent); }
.field input.bad, textarea.bad { border-color: var(--bad); }
.row { display: flex; gap: 10px; }
@media (max-width: 620px) { .row { flex-direction: column; } }

.adv { border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: var(--panel-2); }
.adv summary { cursor: pointer; padding: 11px 0; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.adv summary:hover { color: var(--txt); }
.adv[open] { padding-bottom: 12px; }
.adv p { font-size: 12px; color: var(--dim); line-height: 1.5; margin: 0 0 10px; }
.adv code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }
.adv label { display: block; margin: 10px 0 5px; }

.sheet-foot {
  display: flex; align-items: center; gap: 8px; padding: 12px 16px;
  border-top: 1px solid var(--line); background: var(--panel-2);
}
button.primary {
  background: var(--accent); border: 0; border-radius: 8px; padding: 9px 18px;
  color: #04121f; font-weight: 650;
}
button.primary:disabled { opacity: .55; cursor: default; }
button.ghost {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 14px; color: var(--txt); font-size: 13px;
}
button.ghost:hover { border-color: var(--accent); color: var(--accent); }
button.ghost:disabled { opacity: .5; cursor: default; }

.test-out:empty, .probe-out:empty { display: none; }
.test-out, .probe-out {
  border-radius: 8px; padding: 11px 13px; font-size: 12.5px; line-height: 1.55;
  border: 1px solid var(--line); background: var(--panel-2);
}
.probe-out { margin-top: 10px; }
.test-out.good { border-color: #2c6b4c; background: #12241b; }
.test-out.bad { border-color: #6b2f33; background: #241315; }
.test-out.warn { border-color: #6b5a22; background: #241f12; }
.test-out b { display: block; margin-bottom: 5px; }
.test-out ul, .probe-out ul { margin: 6px 0 0; padding-left: 18px; }
.test-out li, .probe-out li { margin: 2px 0; }
.test-out code, .probe-out code {
  background: #0b1016; padding: 1px 5px; border-radius: 4px;
  font-size: 11.5px; word-break: break-all;
}
.muted { color: var(--muted); }
