/* ════════════════════════════════════════════════════════════════════════
   Safety AI — admin dashboard design system
   Clean white professional UI. Brand colours sampled from the Applivity logo
   (server/app/static/img/applivity-logo.png), never invented:
     blue   #1D67AC  — primary nav / actions / links
     orange #F4793B  — accent / warning / stale / unknown
     red    #EF4A37  — violation / revoked / error
   Green (#15915B) is semantic (live/compliant/healthy); the logo has no green.
   ════════════════════════════════════════════════════════════════════════ */

:root {
  --brand-blue: #1d67ac;
  --brand-blue-700: #155a98;
  --brand-blue-50: #eaf2fa;
  --brand-orange: #f4793b;
  --brand-orange-50: #fdeee6;
  --brand-red: #ef4a37;
  --brand-red-50: #fdebe9;
  --ok: #15915b;
  --ok-50: #e6f4ee;
  --warn: #f4793b;
  --warn-50: #fdeee6;

  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e4e8ef;
  --border-strong: #d3d9e3;
  --text: #1a2230;
  --text-2: #45506a;
  --muted: #6b7688;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 8px 28px rgba(16, 24, 40, 0.14);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 244px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 650; color: var(--text); }

::selection { background: var(--brand-blue-50); }

/* ── App shell ─────────────────────────────────────────────────────────── */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 24px 18px 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand img { width: 84px; height: 84px; border-radius: 18px; object-fit: cover; flex: 0 0 auto; box-shadow: var(--shadow); }
.sidebar-brand .brand-name { font-size: 16px; font-weight: 750; letter-spacing: 0.1px; line-height: 1.2; }
.sidebar-brand .brand-sub { font-size: 12px; color: var(--brand-blue); font-weight: 600; margin-top: -4px; }
.brand-workspace-row { display: flex; justify-content: center; padding: 14px 18px 0; }
.brand-workspace {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 650;
}
.brand-workspace .nav-ico { width: 13px; height: 13px; flex: 0 0 auto; color: var(--muted); }
.brand-workspace span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.sidebar-nav { padding: 12px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--muted); padding: 12px 12px 9px; font-weight: 700; }
.nav-section-center { text-align: center; }
.nav-section-plain { text-transform: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 550;
  font-size: 13.5px;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item .nav-ico { width: 18px; height: 18px; flex: 0 0 auto; color: currentColor; }
.nav-item.active { background: var(--brand-blue-50); color: var(--brand-blue-700); font-weight: 650; }
.nav-item.active .nav-ico { color: var(--brand-blue); }
.nav-item .nav-badge {
  margin-left: auto; min-width: 20px; height: 19px; padding: 0 6px; border-radius: 10px;
  background: var(--brand-red); color: #fff; font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
}
.sidebar-foot .brand-name { font-size: 15px; font-weight: 750; letter-spacing: 0.1px; }
.sidebar-foot .brand-sub { font-size: 12px; color: var(--brand-blue); font-weight: 600; }
.powered-row {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
}
.powered-by { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; }
.powered-row img { height: 17px; width: auto; object-fit: contain; }

/* ── Main column ───────────────────────────────────────────────────────── */

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 60px;
  flex: 0 0 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .page-title { font-size: 17px; font-weight: 700; }
.topbar .page-title small { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.admin-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.admin-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--brand-blue);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}

.content { padding: 22px 24px 40px; flex: 1; }
.content-narrow { max-width: 880px; }

/* ── Buttons ───────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: inherit; font-size: 13.5px; font-weight: 600; line-height: 1;
  padding: 9px 15px; border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; transition: background 0.12s, border-color 0.12s, opacity 0.12s; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: 2px; }
.btn-primary { background: var(--brand-blue); color: #fff; }
.btn-primary:hover { background: var(--brand-blue-700); }
.btn-ghost { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--surface); color: var(--brand-red); border-color: #f3c3bd; }
.btn-danger:hover { background: var(--brand-red); color: #fff; border-color: var(--brand-red); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-icon { width: 16px; height: 16px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ── Cards / panels ────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 14.5px; font-weight: 650; }
.card-head .sub { font-size: 12px; color: var(--muted); font-weight: 500; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.cc-layout { display: grid; grid-template-columns: 1fr 360px; gap: 18px; align-items: start; }

/* ── Stat tiles ────────────────────────────────────────────────────────── */

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px;
}
.stat .stat-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; display: flex; align-items: center; gap: 7px; }
.stat .stat-value { font-size: 27px; font-weight: 720; line-height: 1.1; letter-spacing: -0.5px; }
.stat .stat-foot { font-size: 12px; color: var(--muted); }
.stat .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-ok { background: var(--ok); } .dot-warn { background: var(--warn); }
.dot-danger { background: var(--brand-red); } .dot-muted { background: var(--border-strong); }
.dot-blue { background: var(--brand-blue); }
.stat.accent-blue { border-top: 3px solid var(--brand-blue); }
.stat.accent-green { border-top: 3px solid var(--ok); }
.stat.accent-orange { border-top: 3px solid var(--brand-orange); }
.stat.accent-red { border-top: 3px solid var(--brand-red); }

/* ── Chips / badges ────────────────────────────────────────────────────── */

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 650; line-height: 1.5; white-space: nowrap;
}
.chip .chip-dot { width: 7px; height: 7px; border-radius: 50%; }
.chip-live { background: var(--ok-50); color: #0f6e43; } .chip-live .chip-dot { background: var(--ok); }
.chip-offline { background: #eef1f5; color: var(--muted); } .chip-offline .chip-dot { background: var(--border-strong); }
.chip-revoked { background: var(--brand-red-50); color: #c5331f; } .chip-revoked .chip-dot { background: var(--brand-red); }
.chip-open { background: var(--brand-red-50); color: #c5331f; } .chip-open .chip-dot { background: var(--brand-red); }
.chip-closed { background: #eef1f5; color: var(--muted); } .chip-closed .chip-dot { background: var(--border-strong); }
.chip-warn { background: var(--warn-50); color: #b95a1a; } .chip-warn .chip-dot { background: var(--warn); }
.chip-type { background: var(--brand-orange-50); color: #b95a1a; font-family: ui-monospace, "Cascadia Code", monospace; }

/* pulsing live dot */
.chip-live .chip-dot { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(21,145,91,0.4); } 50% { box-shadow: 0 0 0 4px rgba(21,145,91,0); } }

/* ── Tables ────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--muted); font-weight: 700; padding: 11px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); position: sticky; top: 0;
}
table.data tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text-2); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: var(--brand-blue-50); }
table.data td.actions { text-align: right; white-space: nowrap; }
.mono { font-family: ui-monospace, "Cascadia Code", "Consolas", monospace; font-size: 12.5px; }
.fp { font-family: ui-monospace, "Cascadia Code", "Consolas", monospace; font-size: 12.5px; color: var(--text); }
.cell-strong { color: var(--text); font-weight: 600; }
.cell-muted { color: var(--muted); }
.empty-row td { text-align: center; color: var(--muted); padding: 28px 16px; }

/* ── Empty states ──────────────────────────────────────────────────────── */

.ico { width: 22px; height: 22px; flex: 0 0 auto; }
.qr-empty .ico { width: 34px; height: 34px; color: var(--border-strong); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state .ico { width: 40px; height: 40px; margin: 0 auto 12px; color: var(--border-strong); }
.empty-state h3 { font-size: 14px; color: var(--text-2); margin-bottom: 4px; }
.empty-state p { font-size: 13px; margin: 0; }

/* ── Video grid (Command Center live feeds) ────────────────────────────── */

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 14px;
  align-items: start;
}
.video-grid[data-count="1"] { grid-template-columns: minmax(260px, min(100%, 560px)); }
.video-grid[data-count="1"] .video-tile[data-orientation="portrait"] { max-width: 340px; }
.video-tile {
  --feed-aspect: 16 / 9;
  position: relative;
  isolation: isolate;
  background: #07111f;
  border: 1px solid rgba(211,217,227,0.82);
  border-radius: var(--radius-sm);
  aspect-ratio: var(--feed-aspect);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: zoom-in;
  transition: border-color 0.14s, box-shadow 0.14s, transform 0.14s;
}
.video-tile:hover { border-color: #aeb9c8; box-shadow: 0 8px 24px rgba(16,24,40,0.14); transform: translateY(-1px); }
.video-tile:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: 3px; }
.video-tile canvas { width: 100%; height: 100%; display: block; object-fit: contain; background: #050b14; }
.video-tile .tile-label,
.video-tile .tile-meta {
  position: absolute; left: 0; right: 0; color: #fff; pointer-events: none;
  font-family: ui-monospace, "Cascadia Code", monospace;
  text-shadow: 0 1px 2px rgba(0,0,0,0.55);
}
.video-tile .tile-label {
  bottom: 19px;
  background: linear-gradient(transparent, rgba(0,0,0,0.74));
  font-size: 12px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 26px 12px 0;
}
.video-tile .tile-meta {
  bottom: 6px;
  color: rgba(255,255,255,0.74);
  font-size: 10.5px;
  padding: 0 12px;
}
.video-tile .tile-status,
.feed-modal .tile-status {
  background: rgba(11,18,32,0.82); color: #cdd5e0; font-size: 11px; font-weight: 650;
  border-radius: 20px; padding: 3px 9px 3px 7px; pointer-events: none;
  display: inline-flex; align-items: center; gap: 6px; backdrop-filter: blur(2px);
}
.video-tile .tile-status { position: absolute; top: 8px; right: 8px; }
.video-tile .tile-status::before,
.feed-modal .tile-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.video-tile[data-feed-state="live"] .tile-status,
.feed-modal[data-feed-state="live"] .tile-status { color: #4ade80; }
.video-tile[data-feed-state="stale"] .tile-status,
.feed-modal[data-feed-state="stale"] .tile-status { color: #fb7185; }
.video-tile[data-feed-state="connecting"] .tile-status,
.feed-modal[data-feed-state="connecting"] .tile-status { color: #fbbf72; }
.video-tile .tile-open {
  position: absolute; top: 8px; left: 8px; width: 28px; height: 28px;
  border: 1px solid rgba(255,255,255,0.26); border-radius: 6px;
  background: rgba(11,18,32,0.74); pointer-events: none; backdrop-filter: blur(2px);
}
.video-tile .tile-open::before,
.video-tile .tile-open::after {
  content: ""; position: absolute; width: 8px; height: 8px; border-color: #fff; border-style: solid;
}
.video-tile .tile-open::before { top: 7px; right: 7px; border-width: 1px 1px 0 0; }
.video-tile .tile-open::after { bottom: 7px; left: 7px; border-width: 0 0 1px 1px; }
.video-grid:empty { display: none; }
body.feed-modal-open { overflow: hidden; }
.feed-modal[hidden] { display: none; }
.feed-modal {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center;
  padding: 24px;
}
.feed-modal-backdrop {
  position: absolute; inset: 0; border: 0; background: rgba(16,24,40,0.66); cursor: zoom-out;
}
.feed-modal-panel {
  position: relative; z-index: 1; max-width: 96vw; max-height: 96vh;
  background: #07111f; border: 1px solid rgba(255,255,255,0.16); border-radius: var(--radius-sm);
  box-shadow: 0 24px 80px rgba(0,0,0,0.42); padding: 12px; color: #fff;
  display: flex; flex-direction: column; gap: 10px;
}
.feed-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-width: 0; }
.feed-modal-title { min-width: 0; }
.feed-modal-title h3 {
  color: #fff; font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.feed-modal-title span { display: block; color: rgba(255,255,255,0.68); font-size: 11.5px; font-family: ui-monospace, "Cascadia Code", monospace; }
.feed-modal-controls { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.feed-modal .tile-status { position: static; }
.feed-modal-close {
  width: 30px; height: 30px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08); color: #fff; cursor: pointer; font-size: 17px; line-height: 1;
}
.feed-modal-close:hover { background: rgba(255,255,255,0.16); }
.feed-modal-canvas {
  display: block; width: auto; height: auto; max-width: min(92vw, 1220px); max-height: calc(100vh - 132px);
  border-radius: 6px; background: #050b14;
}

/* ── Live violations rail ──────────────────────────────────────────────── */

.rail { display: flex; flex-direction: column; gap: 0; max-height: 72vh; overflow-y: auto; }
/* Rail row = clickable detail button + a separate delete button (no nested buttons). */
.viol-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--border); }
.viol-row .viol-item { border-bottom: none; flex: 1; min-width: 0; }
.viol-del {
  flex: 0 0 auto; background: none; border: none; border-left: 1px solid var(--border);
  color: var(--muted); cursor: pointer; padding: 0 13px; display: flex; align-items: center;
  transition: background 0.1s, color 0.1s;
}
.viol-del:hover { background: var(--brand-red-50); color: var(--brand-red); }
.viol-item {
  display: flex; gap: 11px; padding: 11px 14px; border-bottom: 1px solid var(--border);
  cursor: pointer; background: none; border-left: none; border-right: none; border-top: none;
  width: 100%; text-align: left; align-items: center; transition: background 0.1s;
}
.viol-item:hover { background: var(--brand-blue-50); }
.viol-item:first-child { border-top: none; }
.viol-thumb {
  width: 56px; height: 42px; border-radius: 6px; object-fit: cover; flex: 0 0 auto;
  background: #0b1220; border: 1px solid var(--border);
}
.viol-thumb.placeholder { display: flex; align-items: center; justify-content: center; color: var(--border-strong); }
.viol-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.viol-meta .line1 { display: flex; align-items: center; gap: 7px; }
.viol-meta .vtype { font-weight: 650; font-size: 13px; color: var(--text); }
.viol-meta .line2 { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.viol-meta .fp-small { font-family: ui-monospace, monospace; }
.viol-time { font-size: 11px; color: var(--muted); white-space: nowrap; flex: 0 0 auto; }

/* ── Drawer (violation / device detail) ────────────────────────────────── */

.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(16,24,40,0.42); z-index: 40;
  opacity: 0; visibility: hidden; transition: opacity 0.2s;
}
.drawer-backdrop.open { opacity: 1; visibility: visible; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 480px; max-width: 92vw;
  background: var(--surface); box-shadow: var(--shadow-lg); z-index: 41;
  transform: translateX(100%); transition: transform 0.22s ease; display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
#drawer-content { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.drawer-head h2 { font-size: 16px; }
.drawer-close { background: none; border: none; cursor: pointer; color: var(--muted); padding: 6px; border-radius: 6px; display: flex; }
.drawer-close:hover { background: var(--surface-2); color: var(--text); }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; min-height: 0; }

.evidence {
  width: 100%; max-height: 220px; object-fit: contain;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: #0b1220; display: block; margin-bottom: 0;
}
/* Wraps the evidence <img> so an absolutely-positioned <canvas> can sit exactly on
   top of it. Both share position/size/object-fit — the browser's own contain-fit
   layout keeps them aligned; the canvas's backing store is sized to the image's
   natural dimensions in JS (ui.js renderEvidenceBbox), never computed by hand. */
.evidence-wrap { position: relative; margin-bottom: 6px; }
.evidence-bbox-canvas {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  object-fit: contain; pointer-events: none;
}
.evidence-note { font-size: 11.5px; color: var(--muted); margin: 0 0 18px; display: flex; align-items: flex-start; gap: 6px; }
.note-ico { width: 14px; height: 14px; flex-shrink: 0; margin-top: 1px; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.detail-grid .dl { background: var(--surface); padding: 11px 13px; }
.detail-grid .dl .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
.detail-grid .dl .v { font-size: 13.5px; color: var(--text); font-weight: 550; }
.detail-grid .dl.full { grid-column: 1 / -1; }

.section-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); font-weight: 700; margin: 22px 0 10px; }

/* ── QR provisioning panel ─────────────────────────────────────────────── */

.qr-panel { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.qr-frame { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; box-shadow: var(--shadow); }
.qr-frame img { display: block; width: 220px; height: 220px; image-rendering: pixelated; }
.qr-empty {
  width: 250px; height: 250px; border: 2px dashed var(--border-strong); border-radius: var(--radius-sm);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted);
}
.qr-steps { display: flex; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 2px; flex-wrap: wrap; justify-content: center; }
.qr-step { display: inline-flex; align-items: center; gap: 6px; }
.qr-step .n { width: 18px; height: 18px; border-radius: 50%; background: var(--brand-blue-50); color: var(--brand-blue-700); font-weight: 700; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; }
.qr-token { font-family: ui-monospace, monospace; font-size: 11px; color: var(--muted); word-break: break-all; max-width: 280px; }
.qr-token-row { display: flex; align-items: center; gap: 6px; }

/* ── Info tooltip (hover OR click/tap/keyboard-focus, no JS) ─────────────── */

.info-wrap { position: relative; display: inline-flex; align-items: center; vertical-align: middle; margin-left: 5px; cursor: help; outline: none; }
.info-wrap .info-ico { width: 13px; height: 13px; color: var(--muted); flex: 0 0 auto; }
.info-wrap:hover .info-ico, .info-wrap:focus .info-ico { color: var(--brand-blue); }
.info-wrap .info-tip {
  position: absolute; bottom: calc(100% + 7px); left: 50%; transform: translateX(-50%);
  width: 230px; background: var(--text); color: #fff; font-size: 11.5px; font-weight: 500;
  line-height: 1.45; text-align: left; padding: 9px 11px; border-radius: 7px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.2); z-index: 60;
  opacity: 0; visibility: hidden; transition: opacity .12s ease; pointer-events: none;
}
.info-wrap .info-tip::after {
  content: ""; position: absolute; top: 100%; left: 50%; margin-left: -5px;
  border: 5px solid transparent; border-top-color: var(--text);
}
.info-wrap.tip-below .info-tip { bottom: auto; top: calc(100% + 7px); }
.info-wrap.tip-below .info-tip::after { top: auto; bottom: 100%; margin-left: -5px; border-top-color: transparent; border-bottom-color: var(--text); }
.info-wrap:hover .info-tip, .info-wrap:focus .info-tip, .info-wrap:focus-within .info-tip { opacity: 1; visibility: visible; }

/* ── Verdict strip (Performance tab — one status an operator reads first) ── */

.verdict-strip { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 20px; border-radius: var(--radius-sm); border: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.verdict-strip.v-ok { background: var(--ok-50); border-color: #bfe3d1; }
.verdict-strip.v-warn { background: var(--warn-50); border-color: #f6d3bd; }
.verdict-strip.v-off { background: var(--surface-2); }
.verdict-status { display: flex; align-items: center; gap: 9px; font-size: 16px; font-weight: 700; white-space: nowrap; }
.verdict-status .v-ico { width: 20px; height: 20px; flex: 0 0 auto; }
.v-ok .verdict-status { color: var(--ok); }
.v-warn .verdict-status { color: #b95a1a; }
.v-off .verdict-status { color: var(--muted); }
.verdict-numbers { display: flex; gap: 26px; flex-wrap: wrap; }
.verdict-numbers .vn { text-align: left; }
.verdict-numbers .vn-label { font-size: 10.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 2px; }
.verdict-numbers .vn-value { font-size: 16px; font-weight: 700; color: var(--text); }
.verdict-detail { font-size: 12px; color: var(--muted); margin: -12px 0 16px; }

/* ── Health metrics ────────────────────────────────────────────────────── */

.card-body h3 { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); margin: 0 0 10px; }
.health-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.metric { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 15px; background: var(--surface); }
.metric .m-label { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }
.m-ico { width: 16px; height: 16px; flex: 0 0 auto; color: var(--brand-blue); }
.metric .m-value { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.metric .m-value.sm { font-size: 15px; font-weight: 650; }
.metric .m-foot { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.metric.todo { border-style: dashed; background: var(--surface-2); }
.badge-todo { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--brand-orange); background: var(--brand-orange-50); padding: 1px 6px; border-radius: 4px; }

/* ── Forms ─────────────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field input {
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; font-family: inherit;
}
.field input:focus { outline: none; border-color: var(--brand-blue); box-shadow: 0 0 0 3px var(--brand-blue-50); }

.note {
  display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 12.5px; line-height: 1.5;
  background: var(--brand-blue-50); color: #1d4e7a; border: 1px solid #cfe2f3;
}
.note.warn { background: var(--warn-50); color: #8a4514; border-color: #f6d3bd; }
.note .note-ico { flex: 0 0 auto; width: 17px; height: 17px; margin-top: 1px; }
.note code { background: rgba(0,0,0,0.05); padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }

/* ── Login ─────────────────────────────────────────────────────────────── */

.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background:
    radial-gradient(1100px 520px at 50% -10%, var(--brand-blue-50), transparent 60%),
    var(--bg);
}
.login-card {
  width: 380px; max-width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-lg); padding: 32px 30px 22px;
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 22px; text-align: center; }
.login-brand img { width: 56px; height: 56px; border-radius: 12px; }
.login-brand h1 { font-size: 19px; }
.login-brand .subtitle { font-size: 13px; color: var(--muted); margin: 2px 0 0; }
.login-card .btn-primary { width: 100%; padding: 11px; margin-top: 4px; }
.login-error {
  background: var(--brand-red-50); color: #c5331f; border: 1px solid #f3c3bd;
  border-radius: var(--radius-sm); padding: 9px 12px; font-size: 13px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.login-note {
  background: var(--brand-blue-50); color: #1d4e7a; border: 1px solid #cfe2f3;
  border-radius: var(--radius-sm); padding: 9px 12px; font-size: 13px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.login-foot { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border); }
.login-foot .powered-by { letter-spacing: 0.5px; }
.login-foot img { height: 17px; }

/* ── Evidence-degradation banner (Phase 9B step 7a) ──────────────────────
   Two distinct severities, matching this file's existing semantic palette:
   orange = an active, resolving condition (DB currently unreachable, still
   retrying); red = a fact that already happened and can't un-happen (some
   evidence really may not have been saved). Stack, don't merge — they have
   different lifecycles (orange clears on recovery; red persists all run). */
.evidence-banner-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.evidence-banner {
  border-radius: var(--radius-sm); padding: 11px 16px; font-size: 13.5px;
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.evidence-banner-active {
  background: var(--brand-orange-50); color: #9a4a12; border: 1px solid #f6c9a3;
}
.evidence-banner-loss {
  background: var(--brand-red-50); color: #c5331f; border: 1px solid #f3c3bd;
}
.evidence-banner-since { opacity: 0.75; font-size: 12.5px; }

/* Stream-capacity usage bar (2026-07-22) — "headsets in use / configured limit"
   on the Performance tab. Rendered only when a limit is actually set; an
   uncapped server shows no bar, because a fraction of "no limit" is meaningless
   and a full-looking bar would be a lie. Turns red at the limit, where new
   headsets are being refused (close code 4407). */
.cap-bar {
  height: 6px; border-radius: 999px; background: var(--border);
  overflow: hidden; margin: 8px 0 2px;
}
.cap-bar-fill {
  height: 100%; border-radius: 999px; background: var(--brand-blue);
  transition: width 240ms ease;
}
.cap-bar-full { background: #c5331f; }

/* ── Misc utilities ────────────────────────────────────────────────────── */

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.section-gap { margin-top: 18px; }
.hidden { display: none !important; }
.flash-new { animation: flashnew 1.4s ease; }
@keyframes flashnew { 0% { background: var(--brand-orange-50); } 100% { background: transparent; } }

/* ── Responsive (laptop → tablet) ──────────────────────────────────────── */

@media (max-width: 1100px) {
  .cc-layout { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: sticky; top: 0; z-index: 30;
    flex-direction: row; align-items: center; border-right: none; border-bottom: 1px solid var(--border);
    overflow-x: auto;
  }
  .sidebar-brand { flex-direction: row; border-bottom: none; border-right: 1px solid var(--border); padding: 8px 14px; white-space: nowrap; }
  .sidebar-brand img { width: 38px; height: 38px; border-radius: 9px; }
  .sidebar-brand .brand-name, .sidebar-brand .brand-sub, .brand-workspace-row { display: none; }
  .sidebar-nav { flex-direction: row; flex: 1; padding: 8px; gap: 4px; }
  .nav-section { display: none; }
  .nav-item { width: auto; white-space: nowrap; }
  .nav-item .nav-label { display: inline; }
  .sidebar-foot { display: none; }
  .drawer { width: 100%; }
  .stat-row { grid-template-columns: 1fr 1fr; }
}
