:root {
  --bg: #0b0f14;
  --surface: #11161d;
  --surface-2: #161d26;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --fg: #e6edf3;
  --fg-secondary: #aeb9c5;
  --fg-muted: #6b7684;
  --fg-faint: #454f5b;
  --accent: #35b6e8;
  --accent-dim: rgba(53, 182, 232, 0.14);
  --ok: #3fb950;
  --warn: #d29922;
  --err: #f85149;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --radius: 6px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

/* ── login ──────────────────────────────────────────────── */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 320px; background: var(--surface); border: 0.5px solid var(--border); border-radius: 12px;
  padding: 28px 24px; display: flex; flex-direction: column; gap: 14px;
}
.login-cam { width: 34px; height: 34px; margin-bottom: 10px; }
.login-brand { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.login-tagline { font-size: 12px; color: var(--fg-muted); letter-spacing: 0.02em; margin-top: -8px; }
.login-sub { color: var(--fg-muted); font-size: 13px; margin-top: -10px; margin-bottom: 4px; }
.login-field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--fg-muted); }
.login-field input {
  background: var(--bg); border: 0.5px solid var(--border-strong); border-radius: 6px; color: var(--fg);
  padding: 9px 11px; font-size: 14px; outline: none;
}
.login-field input:focus { border-color: var(--accent); }
.login-btn { justify-content: center; padding: 10px; margin-top: 4px; width: 100%; }
.login-error { color: var(--err); font-size: 12px; background: rgba(248,81,73,0.1); padding: 8px 10px; border-radius: 6px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card form[hidden], #pwToggleWrap[hidden] { display: none; }
.login-alt { text-align: center; font-size: 12px; }
.login-alt a { color: var(--accent); text-decoration: none; }
.login-phrase-row { font-size: 12px; color: var(--fg-muted); }
.login-phrase { font-family: var(--mono); color: var(--accent); font-size: 15px; margin-left: 4px; }

/* header user chip + logout */
.user-chip { display: inline-flex; align-items: center; gap: 8px; color: var(--fg-muted); font-size: 12px; }
.user-chip .uname { color: var(--fg-secondary); }
.user-chip .urole {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--accent-dim); color: var(--accent); padding: 2px 6px; border-radius: 4px;
}

/* modal (bandwidth check) */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 200; }
.modal[hidden] { display: none; }
.modal-box { width: 420px; max-width: 92vw; background: var(--surface); border: 0.5px solid var(--border-strong); border-radius: 12px; padding: 20px; }
.modal-title { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.modal-body { color: var(--fg-secondary); font-size: 13px; line-height: 1.55; }
.modal-body b { color: var(--fg); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* role-gated controls (server enforces regardless; this just tidies the UI) */
body:not(.can-admin)   #tabs button[data-view="settings"],
body:not(.can-admin)   #tabs button[data-view="users"],
body:not(.can-mapping) #tabs button[data-view="mappings"],
body:not(.can-platform) #tabs button[data-view="wireguard"],
body:not(.can-admin)   #floorRegen,
body:not(.can-mapping) #floorEdit,
body:not(.can-export)  #tabs button[data-view="jobs"],
body:not(.can-export)  #grab,
body:not(.can-export)  .tile .sel,
body:not(.can-mapping) .tile .edit { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── shell / top bar / tabs ─────────────────────────────── */
.shell { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 24px; height: 52px; padding: 0 16px;
  border-bottom: 0.5px solid var(--border); background: var(--surface); flex: 0 0 auto;
}
.logo { display: flex; align-items: center; gap: 9px; }
.logo-cam { width: 22px; height: 22px; color: var(--accent); flex: 0 0 auto; }
.logo-name { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; }
.logo-sub { color: var(--fg-muted); font-size: 11px; font-family: var(--mono); margin-top: 1px; }
.logo { cursor: pointer; }
.tabs { display: flex; gap: 2px; }
/* the tab strip scrolls (no scrollbar) instead of squeezing the logo/user chip */
.topbar .logo, .topbar .user-chip { flex: 0 0 auto; }
.topbar .tabs { flex: 0 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.topbar .tabs::-webkit-scrollbar { display: none; }
.topbar .tabs button { flex: 0 0 auto; white-space: nowrap; }
.tabs button {
  font: inherit; font-size: 13px; padding: 7px 13px; border-radius: var(--radius);
  border: 0.5px solid transparent; background: none; color: var(--fg-secondary); cursor: pointer;
}
.tabs button:hover { background: var(--surface-2); color: var(--fg); }
.tabs button.active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }

.views { flex: 1; min-height: 0; position: relative; }
.view { display: none; height: 100%; min-height: 0; }
.view.active { display: grid; animation: vfade 0.24s cubic-bezier(0.25,1,0.5,1); }
@keyframes vfade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.view[data-view="wall"] { grid-template-columns: 340px 1fr; }
.view[data-view="all"], .view[data-view="access"],
.view[data-view="activity"], .view[data-view="settings"] { grid-template-columns: 1fr; }

.sidebar {
  border-right: 0.5px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface);
}
.main { display: flex; flex-direction: column; min-height: 0; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: var(--fg-faint); margin-right: 6px; }
.dot.live { background: var(--ok); box-shadow: 0 0 6px var(--ok); }

.toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 0.5px solid var(--border);
}

/* settings sub-sections (NVR configuration / Access mappings) */
.subnav { display: flex; gap: 2px; padding: 8px 16px 0; }
.subnav button {
  font: inherit; font-size: 12px; padding: 5px 11px; border-radius: var(--radius);
  border: 0.5px solid transparent; background: none; color: var(--fg-secondary); cursor: pointer;
}
.subnav button:hover { background: var(--surface-2); color: var(--fg); }
.subnav button.active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }
body:not(.can-admin) .subnav button[data-view="settings"],
body:not(.can-mapping) .subnav button[data-view="mappings"] { display: none; }
.search {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 0.5px solid var(--border);
  border-radius: var(--radius); padding: 7px 10px;
}
.search:focus-within { border-color: var(--border-strong); }
.search input {
  flex: 1; background: none; border: none; color: var(--fg);
  font-size: 13px; outline: none;
}
.search input::placeholder { color: var(--fg-faint); }
.count { color: var(--fg-muted); font-size: 12px; font-family: var(--mono); white-space: nowrap; }

/* ── sidebar sections ───────────────────────────────────── */
.section { border-bottom: 0.5px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.section > h2 {
  margin: 0; padding: 12px 16px 8px; font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-muted);
  display: flex; align-items: center; justify-content: space-between;
}
.section-scroll { overflow-y: auto; padding: 0 8px 8px; }
.ipassan { flex: 1; min-height: 120px; }

/* ── event rows ─────────────────────────────────────────── */
.event {
  padding: 9px 10px; border-radius: var(--radius); cursor: pointer;
  border: 0.5px solid transparent; margin-bottom: 2px;
}
.event:hover { background: var(--surface-2); border-color: var(--border); }
.event.active { background: var(--accent-dim); border-color: var(--accent); }
.event .row1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.event .door { font-weight: 500; font-size: 13px; }
.event .time { font-family: var(--mono); font-size: 11px; color: var(--fg-muted); white-space: nowrap; }
.event .cred { color: var(--fg-secondary); font-size: 12px; margin-top: 2px; }
.badge {
  font-size: 10px; font-family: var(--mono); padding: 1px 6px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: 0.04em; border: 0.5px solid var(--border);
}
.badge.granted { color: var(--ok); border-color: rgba(63,185,80,0.4); }
.badge.denied { color: var(--err); border-color: rgba(248,81,73,0.4); }
.badge.exit_request { color: var(--fg-muted); }
.event .cams { margin-top: 5px; font-size: 11px; color: var(--accent); font-family: var(--mono); }

/* ── jobs ───────────────────────────────────────────────── */
.job { padding: 9px 10px; border-radius: var(--radius); border: 0.5px solid var(--border); margin-bottom: 6px; background: var(--surface-2); }
.job .row1 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.job .label { font-size: 13px; font-weight: 500; }
.job .meta { font-family: var(--mono); font-size: 11px; color: var(--fg-muted); margin-top: 3px; }
.job .state { font-size: 10px; font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.04em; }
.job .state.running { color: var(--warn); }
.job .state.done { color: var(--ok); }
.job a.dl {
  display: inline-block; margin-top: 7px; font-size: 12px; color: var(--accent);
  text-decoration: none; border: 0.5px solid var(--accent); padding: 3px 9px;
  border-radius: 4px;
}
.job a.dl:hover { background: var(--accent-dim); }

/* ── video wall ─────────────────────────────────────────── */
.wall-head {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-bottom: 0.5px solid var(--border);
}
/* rotating mode is a passive monitoring view — hide footage selection/grab */
.view[data-view="wall"].rotating .wall-head { display: none; }
.wall-head .grow { flex: 1; }
.selbar { display: flex; align-items: center; gap: 10px; color: var(--fg-secondary); font-size: 13px; }
.wall { flex: 1; overflow-y: auto; padding: 12px; display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); align-content: start; }

.tile {
  position: relative; aspect-ratio: 4/3; background: #000;
  border: 0.5px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.tile.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tile.highlight { border-color: var(--warn); box-shadow: 0 0 0 2px var(--warn); }
.tile canvas.tile-canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.tile .still { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; background: #000; }
.tile .still.shown { display: block; }
.tile .off {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--fg-faint); font-family: var(--mono); font-size: 11px;
}
.tile .cap {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  padding: 16px 8px 6px; display: flex; justify-content: space-between; align-items: flex-end; gap: 6px;
}
.tile .name { font-size: 12px; font-weight: 500; text-shadow: 0 1px 2px #000; }
.tile .ch { font-family: var(--mono); font-size: 10px; color: var(--fg-muted); }
.tile .sel {
  position: absolute; top: 6px; left: 6px; width: 18px; height: 18px; border-radius: 4px;
  border: 1px solid var(--border-strong); background: rgba(0,0,0,0.5); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 12px; color: transparent;
}
.tile.selected .sel { background: var(--accent); border-color: var(--accent); color: #001018; }
.tile .edit {
  position: absolute; top: 6px; right: 6px; opacity: 0; cursor: pointer;
  background: rgba(0,0,0,0.55); border: 1px solid var(--border-strong); border-radius: 4px;
  font-size: 10px; padding: 2px 6px; color: var(--fg-secondary);
}
.tile:hover .edit { opacity: 1; }

/* ── buttons ────────────────────────────────────────────── */
.btn {
  font: inherit; font-size: 13px; padding: 7px 14px; border-radius: var(--radius);
  border: 0.5px solid var(--border-strong); background: var(--surface-2); color: var(--fg);
  cursor: pointer; transition: background 150ms cubic-bezier(0.25,1,0.5,1);
}
.btn:hover { background: var(--surface); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #00131c; font-weight: 600; }
.btn.primary:hover { background: #4cc4f2; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.dur { width: 56px; background: var(--surface-2); border: 0.5px solid var(--border);
  color: var(--fg); border-radius: 4px; padding: 6px 8px; font-family: var(--mono); }

.empty { color: var(--fg-faint); font-size: 12px; padding: 16px; text-align: center; }

/* ── all-cameras + grid views ───────────────────────────── */
.gridbar { gap: 12px; }
.gridbar .hint { color: var(--fg-muted); font-size: 12px; }
.select {
  background: var(--surface-2); border: 0.5px solid var(--border); color: var(--fg);
  border-radius: 4px; padding: 6px 8px; font: inherit; font-size: 13px;
}
.segmented { display: inline-flex; border: 0.5px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.segmented button {
  font: inherit; font-size: 12px; font-family: var(--mono); padding: 6px 11px; border: none;
  background: var(--surface-2); color: var(--fg-secondary); cursor: pointer; border-right: 0.5px solid var(--border);
}
.segmented button:last-child { border-right: none; }
.segmented button:hover { color: var(--fg); }
.segmented button.active { background: var(--accent); color: #00131c; font-weight: 600; }

.grid { flex: 1; min-height: 0; overflow: hidden; padding: 8px; display: grid; gap: 6px; }
.grid .tile { aspect-ratio: auto; min-height: 0; }
.grid .cell-empty {
  border: 0.5px dashed var(--border); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; color: var(--fg-faint);
  font-family: var(--mono); font-size: 11px;
}
.tile.flash { animation: tileflash 1.2s cubic-bezier(0.25,1,0.5,1); }
@keyframes tileflash { from { box-shadow: 0 0 0 2px var(--accent); } to { box-shadow: 0 0 0 0 transparent; } }
.tile .evt {
  position: absolute; top: 6px; left: 6px; right: 6px; font-size: 10px; font-family: var(--mono);
  background: rgba(0,0,0,0.6); border-radius: 4px; padding: 3px 6px; color: var(--fg-secondary);
  display: flex; justify-content: space-between; gap: 8px; pointer-events: none;
}

/* Access-Grid rolling last-4 ticker (right of Clear). No wrap, no scroll. */
.ticker {
  flex: 1 1 0; min-width: 0; height: 58px; overflow: hidden; margin-left: 4px; padding-left: 12px;
  border-left: 0.5px solid var(--border); display: flex; flex-direction: column; justify-content: center; gap: 2px;
}
.ticker .tk {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: var(--mono); font-size: 11px; color: var(--fg-secondary); line-height: 1.35;
}
.ticker .tk .t { color: var(--accent); }
.ticker .tk .ar { color: var(--fg-faint); }

/* Events log table */
.events-log { flex: 1; min-height: 0; overflow: auto; padding: 12px 16px; }
.evt-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.evt-table th {
  position: sticky; top: 0; background: var(--surface); text-align: left; font-weight: 600;
  color: var(--fg-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 8px 10px; border-bottom: 0.5px solid var(--border); white-space: nowrap;
}
.evt-table td { padding: 7px 10px; border-bottom: 0.5px solid var(--border); vertical-align: top; }
.evt-table tbody tr:hover { background: var(--surface-2); }
.evt-table td.mono { font-family: var(--mono); font-size: 11px; color: var(--fg-secondary); white-space: nowrap; }
.evt-table td .dim { color: var(--fg-faint); }
.badge.neutral { color: var(--fg-muted); }

/* Access mappings page */
.mappings-scroll { flex: 1; min-height: 0; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.map-card { border: 0.5px solid var(--border); border-radius: 8px; background: var(--surface); padding: 12px; }
.map-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.map-door { font-weight: 600; letter-spacing: -0.01em; }
.map-meta { font-family: var(--mono); font-size: 11px; color: var(--fg-muted); white-space: nowrap; }
.map-hint { font-size: 12px; color: var(--fg-muted); margin: 4px 0 10px; }
.map-thumbs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.map-thumb { flex: 0 0 auto; width: 200px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; cursor: pointer; background: #000; transition: border-color 150ms; }
.map-thumb img { display: block; width: 200px; height: 120px; object-fit: cover; }
.map-thumb.noimg img { display: none; }
.map-thumb.noimg::before { content: 'no frame'; display: flex; align-items: center; justify-content: center; height: 120px; color: var(--fg-faint); font-size: 11px; }
.map-thumb-name { padding: 5px 8px; font-size: 11px; color: var(--fg-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-top: 0.5px solid var(--border); }
.map-thumb.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.map-thumb.selected .map-thumb-name { color: var(--accent); }
.map-thumb { position: relative; }
.map-badge { position: absolute; top: 6px; left: 6px; padding: 1px 6px; border-radius: 4px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.02em; color: #001; background: var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,0.5); }
.map-thumb.suggested { border-color: var(--accent); }

/* history / recorded footage */
.history-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 8px 0; }
.hist-range { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.hist-range label { display: flex; gap: 5px; align-items: center; font-size: 12px; color: var(--fg-secondary); }
.hist-range input[type="datetime-local"] { background: var(--bg-elev); color: var(--fg); border: 1px solid var(--border); border-radius: 5px; padding: 4px 6px; font-family: var(--mono); font-size: 12px; }
.history-body { display: flex; gap: 12px; min-height: 0; }
.hist-cams { flex: 0 0 240px; max-height: 60vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; padding: 6px; }
.hist-cams-head { display: flex; gap: 6px; align-items: center; padding: 2px 4px 6px; border-bottom: 0.5px solid var(--border); margin-bottom: 4px; }
.btn.xs { padding: 1px 7px; font-size: 11px; }
.hist-cam { display: flex; gap: 7px; align-items: center; padding: 3px 4px; font-size: 12px; cursor: pointer; border-radius: 4px; }
.hist-cam:hover { background: var(--bg-elev); }
.hist-right { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.hist-tl-bar { display: flex; align-items: center; gap: 6px; padding: 4px 0 6px; }
.hist-tl-bar .grow { flex: 1 1 auto; }
.hist-timeline { flex: 1 1 auto; overflow: auto; max-height: 60vh; border: 1px solid var(--border); border-radius: 6px; }
.tl-row, .tl-axis-row { display: flex; align-items: center; border-bottom: 0.5px solid var(--border); }
.tl-row { padding: 4px 0; }
.tl-name { flex: 0 0 200px; position: sticky; left: 0; z-index: 2; background: var(--bg); padding: 0 8px;
  font-size: 12px; color: var(--fg-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-name .count { color: var(--fg-faint); font-family: var(--mono); font-size: 10px; margin-left: 4px; }
.tl-track { position: relative; height: 22px; background: var(--bg-elev); border-radius: 3px; flex: 0 0 auto; }
.tl-track .seg { position: absolute; top: 3px; bottom: 3px; background: var(--accent); border-radius: 2px; cursor: pointer; opacity: 0.85; min-width: 2px; }
.tl-track .seg:hover { opacity: 1; box-shadow: 0 0 0 1px #fff; z-index: 1; }
.tl-none { color: var(--fg-faint); font-size: 11px; padding-left: 8px; line-height: 22px; }
.tl-axis-row { position: sticky; top: 0; z-index: 3; background: var(--bg); height: 20px; }
.tl-axis { position: relative; height: 20px; flex: 0 0 auto; }
.tl-tick { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--border); }
.tl-tick span { position: absolute; left: 3px; top: 3px; font-size: 10px; color: var(--fg-faint); font-family: var(--mono); white-space: nowrap; }
#segPeek { position: fixed; z-index: 80; display: none; background: var(--surface);
  border: 0.5px solid var(--border-strong); border-radius: 6px; padding: 4px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5); pointer-events: none; width: 248px; }
#segPeek img { display: block; width: 240px; min-height: 100px; height: auto;
  background: #000; border-radius: 4px; }
#segPeek .cap { font-family: var(--mono); font-size: 10px; color: var(--fg-secondary);
  padding: 3px 2px 0; }
.hist-exports { margin-top: 12px; }
.hist-exports-head { font-size: 12px; color: var(--fg-secondary); margin-bottom: 6px; font-weight: 600; }
.hist-jobs { display: flex; flex-direction: column; gap: 6px; }
.hist-jobs .job { border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; }
.job-run { color: var(--accent); font-size: 12px; }
.job-fail { color: var(--danger, #e5484d); font-size: 12px; }

/* by-floor view */
.floor-body { display: flex; gap: 12px; min-height: 0; }
.floor-plan { --fp-h: 80vh; flex: 1 1 auto; min-width: 0; overflow: auto; max-height: var(--fp-h);
  border: 1px solid var(--border); border-radius: 6px; background: #0b0e13; display: flex; }
.floor-img-wrap { position: relative; display: inline-block; margin: auto; }
/* constrain BOTH axes so the plan scales to fit the pane instead of scrolling */
.floor-img-wrap img { display: block; max-width: 100%; max-height: calc(var(--fp-h) - 2px);
  width: auto; height: auto; }
.fmark { position: absolute; width: 13px; height: 13px; margin: -6.5px 0 0 -6.5px;
  border-radius: 50%; background: var(--accent); border: 2px solid #fff; cursor: pointer;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.6); z-index: 1; }
.fmark span { position: absolute; left: 15px; top: -3px; font-size: 10px; font-family: var(--mono);
  color: #fff; background: rgba(0,0,0,0.72); padding: 0 4px; border-radius: 3px; white-space: nowrap;
  pointer-events: none; opacity: 0; }
.fmark:hover span, .fmark.hot span { opacity: 1; }
.fmark.hot { background: #fff; box-shadow: 0 0 0 3px var(--accent); z-index: 3; }
.fmark.planned { background: var(--fg-faint); border-color: var(--fg-faint); opacity: 0.7; }
.fmark.custom { border-color: #ffd166; }              /* manually placed */
#floorEdit.active { border-color: var(--accent); color: var(--accent); }
.floor-plan.editing .fmark { cursor: grab; touch-action: none; }
.floor-plan.editing .fmark.dragging { cursor: grabbing; z-index: 4; }
.floor-plan.editing .fmark span { opacity: 1; }
.floor-cams { flex: 0 0 232px; overflow-y: auto; max-height: 80vh; display: flex;
  flex-direction: column; gap: 6px; }
.floor-cam { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; cursor: pointer; background: #000; }
.floor-cam img { display: block; width: 100%; height: 118px; object-fit: cover; }
.floor-cam.noimg img { display: none; }
.floor-cam.noimg::before { content: 'no signal'; display: flex; align-items: center; justify-content: center;
  height: 118px; color: var(--fg-faint); font-size: 11px; }
.floor-cam-name { padding: 4px 7px; font-size: 11px; color: var(--fg-secondary); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; border-top: 0.5px solid var(--border); }
.floor-cam.hot { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.floor-cam.hot .floor-cam-name { color: var(--accent); }

/* ── home (launcher) ────────────────────────────────────── */
.home-scroll { overflow-y: auto; }
.home-wrap { max-width: 1140px; margin: 0 auto; padding: 44px 40px 56px; width: 100%; }
.home-greet { text-align: center; font-size: 34px; font-weight: 600; letter-spacing: -0.025em; }
.home-meta { text-align: center; margin-top: 9px; color: var(--fg-muted); font-family: var(--mono); font-size: 13px; }
.home-search { max-width: 640px; margin: 26px auto; height: 48px; border-radius: 11px; padding: 0 15px; flex: none; display: flex; }
.home-search input { font-size: 15px; }
.home-kbd { border: 0.5px solid var(--border); border-radius: 5px; padding: 3px 7px; }
.home-pills { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; margin-bottom: 36px; }
.pill { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 0.5px solid var(--border); border-radius: 999px; padding: 8px 15px; font-size: 13px; }
.pill b { color: var(--fg); }
.pill span { color: var(--fg-muted); }
.pill .dot { margin-right: 0; }
.home-ask { text-align: center; color: var(--fg-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em; margin-bottom: 16px; }
.home-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.home-card { display: flex; flex-direction: column; background: var(--surface); border: 0.5px solid var(--border); border-radius: 12px;
  overflow: hidden; color: inherit; cursor: pointer; transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease; }
.home-card:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: 0 10px 30px rgba(0,0,0,0.45); }
.home-card .prev { height: 150px; border-bottom: 0.5px solid var(--border); background: #0b0e13; position: relative; }
.home-card .cbody { padding: 16px 18px 18px; }
.home-card .verb { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--fg-muted); margin-bottom: 7px; }
.home-card .ttl { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 16px; font-weight: 600; color: var(--fg); }
.home-card .ttl svg { color: var(--accent); flex: 0 0 auto; }
.home-card .desc { color: var(--fg-secondary); font-size: 13px; line-height: 1.5; }
.home-jump { display: flex; justify-content: center; align-items: center; gap: 9px; margin-top: 32px; flex-wrap: wrap; }
.home-jump .lbl { color: var(--fg-muted); font-size: 12px; }
@media (max-width: 980px) { .home-cards { grid-template-columns: 1fr; } .home-wrap { padding: 28px 16px 40px; } }

/* overview view */
.ov-pills { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 20px; }

/* users view */
.users-scroll { overflow-y: auto; max-height: 78vh; }
.user-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  border: 0.5px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
  padding: 14px 16px; margin-bottom: 12px; }
.user-form .field { min-width: 180px; }
.user-form-actions { display: flex; gap: 8px; padding-bottom: 1px; }
.users-scroll .user-actions { display: inline-flex; gap: 8px; }
.users-scroll td .you { color: var(--accent); font-family: var(--mono); font-size: 10px; margin-left: 6px; }
.users-scroll td .flagged { color: var(--err); font-size: 10px; font-family: var(--mono); margin-left: 6px;
  border: 0.5px solid rgba(248,81,73,0.4); border-radius: 4px; padding: 0 5px; }

/* session-management modal (spec §11) */
.sess-h { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg-muted);
  margin: 12px 0 6px; font-weight: 600; }
.sess-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 10px;
  padding: 8px 0; border-bottom: 0.5px solid var(--border); }
.sess-row .dim { grid-column: 1; color: var(--fg-faint); font-size: 11px; }
.sess-row button { grid-row: 1 / span 2; }
.you { color: var(--accent); font-family: var(--mono); font-size: 10px; margin-left: 6px; }

/* jobs view */
.jobs-scroll { overflow-y: auto; max-height: 82vh; display: flex; flex-direction: column; gap: 8px; }
.jobs-scroll .job { border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; }
.jobs-scroll .job-del { margin-top: 6px; }
.map-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }

/* All-Cameras list view */
.wall.as-list { display: block; overflow: auto; }
.cam-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cam-table th {
  position: sticky; top: 0; background: var(--surface); text-align: left; font-weight: 600;
  color: var(--fg-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 8px 10px; border-bottom: 0.5px solid var(--border); white-space: nowrap;
}
.cam-table td { padding: 6px 10px; border-bottom: 0.5px solid var(--border); vertical-align: middle; }
.cam-table tbody tr:hover { background: var(--surface-2); }
.cam-table td.mono { font-family: var(--mono); font-size: 11px; color: var(--fg-secondary); }
.cam-table td .dim { color: var(--fg-faint); font-size: 11px; }
.cam-table select, .cam-table input.lvl {
  background: var(--bg); border: 0.5px solid var(--border-strong); border-radius: 5px; color: var(--fg);
  padding: 4px 6px; font-size: 12px; outline: none;
}
.cam-table input.lvl { width: 54px; }
.cam-table select:focus, .cam-table input.lvl:focus { border-color: var(--accent); }
.badge.granted { color: var(--ok); }
.focus-actions { display: inline-flex; gap: 8px; }
#focusHd.active { border-color: var(--accent); color: var(--accent); }

/* ── settings ───────────────────────────────────────────── */
.settings { overflow: hidden; }
.settings-scroll { overflow-y: auto; padding: 20px; width: 100%; }
.settings-scroll h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-muted); margin: 0 0 12px; }
.nvr-card { border: 0.5px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 16px; margin-bottom: 12px; max-width: 1100px; }
.nvr-card h3 { margin: 0 0 12px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.nvr-card h3 .st { font-family: var(--mono); font-size: 11px; }
.nvr-card h3 .st.up { color: var(--ok); }
.nvr-card h3 .st.down { color: var(--err); }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.field label { display: block; font-size: 11px; color: var(--fg-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.field input {
  width: 100%; background: var(--surface-2); border: 0.5px solid var(--border); color: var(--fg);
  border-radius: 4px; padding: 7px 9px; font: inherit; font-size: 13px;
}
.field input:focus { border-color: var(--border-strong); outline: none; }

/* WireGuard admin */
.wg-card { border: 0.5px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 16px; margin-bottom: 12px; max-width: 760px; }
.wg-card h3 { margin: 0 0 12px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.wg-card .field { margin-bottom: 12px; }
.wg-kv { display: flex; gap: 10px; align-items: baseline; margin-bottom: 12px; font-size: 12px; color: var(--fg-secondary); }
.wg-kv code { font-family: var(--mono); word-break: break-all; color: var(--fg); }
.wg-check { display: flex; gap: 8px; align-items: center; margin: 8px 0 12px; font-size: 13px; color: var(--fg-secondary); }
.wg-tabs { margin: 4px 0 10px; }
#wgResultText { width: 100%; box-sizing: border-box; background: var(--surface-2); border: 0.5px solid var(--border); color: var(--fg); border-radius: 4px; padding: 10px; font-family: var(--mono); font-size: 12px; resize: vertical; }
.pill { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 8px; border-radius: 10px; background: var(--surface-2); color: var(--fg-muted); border: 0.5px solid var(--border); }
.pill.ok { background: rgba(63, 185, 80, 0.14); color: var(--ok); border-color: transparent; }
.hint.danger { color: var(--err); }
.settings-actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.settings-scroll h2 { display: flex; align-items: center; gap: 12px; }
.settings-scroll h2 .btn { text-transform: none; letter-spacing: 0; font-size: 12px; padding: 5px 11px; }
.btn.danger { border-color: rgba(248,81,73,0.45); color: var(--err); }
.btn.danger:hover { background: rgba(248,81,73,0.12); }
.test-result { display: inline-flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tb { font-family: var(--mono); font-size: 11px; padding: 3px 8px; border-radius: 4px; border: 0.5px solid var(--border); color: var(--fg-muted); }
.tb.ok { color: var(--ok); border-color: rgba(63,185,80,0.4); }
.tb.bad { color: var(--err); border-color: rgba(248,81,73,0.4); }

/* toast */
.toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
#pauseBanner { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 60;
  background: var(--surface-2); border: 0.5px solid var(--border-strong); border-radius: 8px;
  padding: 8px 14px; font-size: 12px; color: var(--fg-secondary); box-shadow: 0 4px 18px rgba(0,0,0,0.5); }
#pauseBanner[hidden] { display: none; }
.toast {
  background: var(--surface-2); border: 0.5px solid var(--border-strong); border-left: 2px solid var(--ok);
  border-radius: var(--radius); padding: 11px 14px; min-width: 240px; max-width: 340px;
  animation: slidein 200ms cubic-bezier(0.25,1,0.5,1);
}
.toast .t { font-weight: 600; font-size: 13px; }
.toast .b { color: var(--fg-secondary); font-size: 12px; margin-top: 3px; }
.toast a { color: var(--accent); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── focus view ─────────────────────────────────────────── */
.focus {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.8); backdrop-filter: blur(3px);
}
.focus[hidden] { display: none; }
.focus-box {
  width: min(1100px, 92vw); background: var(--surface); border: 0.5px solid var(--border-strong);
  border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column;
}
.focus-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 0.5px solid var(--border); }
.focus-name { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; }
.focus-sub { font-family: var(--mono); font-size: 11px; color: var(--fg-muted); margin-top: 2px; }
.focus-box iframe { width: 100%; aspect-ratio: 16/9; border: none; background: #000; display: block; }
.tile .cap { cursor: pointer; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; border: 2px solid var(--surface); }
::-webkit-scrollbar-track { background: transparent; }

/* ── mobile / phones ───────────────────────────────────────
   Compact scroll-nav, single-column camera views, wrapping toolbars. The stream cap
   (state.maxLive, app.js) keeps only a few tiles live so the list scrolls smoothly. */
@media (max-width: 640px) {
  .topbar { gap: 8px; padding: 0 8px; height: 48px; }
  .logo-sub { display: none; }
  .logo-name { font-size: 14px; white-space: nowrap; }
  .tabs { flex: 1 1 auto; overflow-x: auto; flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex: 0 0 auto; padding: 7px 10px; font-size: 12px; white-space: nowrap; }
  .user-chip .uname, .user-chip .urole { display: none; }
  .user-chip #logoutBtn { padding: 5px 9px; font-size: 12px; }

  /* full-width, single-column camera browsing (Live Wall + All Cameras).
     Block (not grid) layout: a 1-col `1fr` grid + tile aspect-ratio collapses the grid
     rows to ~1px; in normal flow each full-width tile derives its height from 4/3. */
  .view[data-view="wall"] { grid-template-columns: 1fr; }
  .view[data-view="wall"] .sidebar { display: none; }
  .wall { display: block; padding: 8px; }
  .wall .tile { width: 100%; margin-bottom: 8px; }

  /* toolbars wrap instead of overflowing */
  .toolbar { flex-wrap: wrap; padding: 10px; }
  .search { flex: 1 1 100%; }

  /* secondary views: stack their side panels so they're usable */
  .history-body, .floor-body { flex-direction: column; }
  .hist-cams, .floor-cams { flex: 1 1 auto; max-height: 38vh; }
  .floor-plan { --fp-h: 55vh; }
}
