/* iCam AI web interface */
:root {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-2: #cbd5e1;
  --primary: #2563eb;
  --primary-2: #1d4ed8;
  --primary-soft: #dbeafe;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --violet: #7c3aed;
  --sidebar: #0b1220;
  --sidebar-2: #111a2e;
  --sidebar-text: #aab6ca;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .25);
  --sev-low: #0ea5e9;
  --sev-medium: #f59e0b;
  --sev-high: #ef4444;
  --sev-critical: #9f1239;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0 0 8px; }
code, .mono { font-family: Consolas, "SF Mono", Menlo, monospace; font-size: 12.5px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- boot / login ---------- */
.boot { min-height: 100vh; display: grid; place-content: center; gap: 14px; color: var(--muted); text-align: center; }
.boot-logo { width: 48px; height: 48px; margin: 0 auto; border-radius: 12px; background: url(/favicon.svg) center/cover; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 20% -10%, #1e3a8a 0%, transparent 60%), var(--sidebar); }
.login-card { width: 100%; max-width: 400px; background: var(--panel); border-radius: 14px; padding: 32px 28px; box-shadow: var(--shadow-lg); }
.login-card .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-card .brand img { width: 40px; height: 40px; }
.login-card .brand b { font-size: 20px; }
.login-card .brand span { display: block; color: var(--muted); font-size: 12.5px; }
.login-foot { margin-top: 18px; color: var(--muted); font-size: 12px; text-align: center; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 40; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; }
.side-brand img { width: 32px; height: 32px; }
.side-brand b { font-size: 16px; display: block; }
.side-brand span { font-size: 11.5px; color: var(--sidebar-text); }
.nav-group { padding: 10px 10px 4px; }
.nav-group-title { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: #6b7a93; padding: 6px 10px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--sidebar-text);
  font-weight: 500; text-decoration: none !important; }
.nav-item svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav-item:hover { background: var(--sidebar-2); color: #fff; }
.nav-item.active { background: #1e293b; color: #fff; box-shadow: inset 3px 0 0 var(--primary); }
.nav-item .count { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 20px; padding: 1px 6px; border-radius: 10px; text-align: center; }
.side-foot { margin-top: auto; padding: 14px 18px; font-size: 11.5px; color: #6b7a93; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 58px; display: flex; align-items: center; gap: 12px; padding: 0 22px; background: var(--panel);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
.topbar .menu-btn { display: none; }
.topbar .org-switch { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar .org-switch select { max-width: 280px; font-weight: 600; }
.topbar .org-name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 4px; border-radius: 20px; cursor: pointer;
  border: 1px solid var(--border); background: var(--panel); }
.user-chip:hover { background: var(--panel-2); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 12px; flex: none; }
.user-chip .who { line-height: 1.15; }
.user-chip .who b { display: block; font-size: 12.5px; }
.user-chip .who span { font-size: 11px; color: var(--muted); }
.menu-pop { position: absolute; right: 16px; top: 54px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-lg); min-width: 220px; padding: 6px; z-index: 60; }
.menu-pop button, .menu-pop a { display: flex; width: 100%; gap: 8px; align-items: center; text-align: left; padding: 8px 10px; border: 0;
  background: none; border-radius: 6px; font: inherit; color: var(--text); cursor: pointer; text-decoration: none; }
.menu-pop button:hover, .menu-pop a:hover { background: var(--panel-2); }

.banner { display: flex; align-items: center; gap: 10px; padding: 9px 22px; font-size: 13px; background: var(--warn-soft); color: #92400e;
  border-bottom: 1px solid #fde68a; }
.banner a { color: #92400e; font-weight: 600; text-decoration: underline; }

.content { padding: 22px; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .titles { flex: 1; min-width: 220px; }
.page-head .titles p { color: var(--muted); margin: 4px 0 0; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }

/* ---------- building blocks ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-h h2 { flex: 1; }
.card-b { padding: 16px; }
.card-b.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.auto-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }

.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -.01em; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.alert .value { color: var(--danger); }
.kpi.good .value { color: var(--ok); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--border-2); background: var(--panel); color: var(--text); font: 600 13.5px/1 inherit; cursor: pointer;
  white-space: nowrap; text-decoration: none !important; }
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--panel-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { background: #b91c1c; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: rgba(15, 23, 42, .06); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.icon { width: 36px; padding: 0; }
.btn.sm.icon { width: 30px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 11.5px;
  font-weight: 650; background: #eef2f7; color: var(--text-2); white-space: nowrap; }
.badge.blue { background: var(--primary-soft); color: #1e40af; }
.badge.green { background: var(--ok-soft); color: #166534; }
.badge.red { background: var(--danger-soft); color: #991b1b; }
.badge.amber { background: var(--warn-soft); color: #92400e; }
.badge.violet { background: #ede9fe; color: #5b21b6; }
.badge.dark { background: #1e293b; color: #fff; }
.sev { color: #fff; }
.sev.low { background: var(--sev-low); }
.sev.medium { background: var(--sev-medium); }
.sev.high { background: var(--sev-high); }
.sev.critical { background: var(--sev-critical); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: #94a3b8; flex: none; }
.dot.online { background: var(--ok); box-shadow: 0 0 0 3px rgba(22, 163, 74, .15); }
.dot.offline, .dot.error { background: var(--danger); box-shadow: 0 0 0 3px rgba(220, 38, 38, .15); }
.dot.never, .dot.unknown, .dot.disabled { background: #94a3b8; }

/* forms */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=time],
input[type=tel], input[type=url], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--border-2); border-radius: 8px; background: #fff; color: var(--text);
  font: inherit; outline: none; min-width: 0; }
textarea { height: auto; min-height: 72px; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters select, .filters input { width: auto; min-width: 140px; height: 34px; }
.filters input[type=search] { min-width: 200px; }

.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cbd5e1; border-radius: 22px; transition: .15s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%;
  transition: .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(16px); }
.switch input:disabled + span { opacity: .5; cursor: not-allowed; }

.seg { display: inline-flex; border: 1px solid var(--border-2); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 0 12px; height: 32px; font: 600 12.5px inherit; color: var(--text-2); cursor: pointer;
  border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--primary); color: #fff; }
.seg button.on.armed { background: var(--danger); }
.seg button.on.disarmed { background: #475569; }
.seg button:disabled { cursor: not-allowed; opacity: .7; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button, .tabs a { border: 0; background: none; padding: 10px 12px; font: 600 13.5px inherit; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none !important; }
.tabs button.on, .tabs a.on { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .n { font-size: 11px; background: #eef2f7; color: var(--text-2); border-radius: 9px; padding: 1px 6px; margin-left: 4px; }

/* tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650;
  padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--panel-2); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #f8fafc; }

/* lists */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); min-width: 0; }
.list-item:last-child { border-bottom: 0; }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { background: #f8fafc; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.thumb { width: 120px; aspect-ratio: 16 / 9; border-radius: 6px; background: #0f172a center/cover no-repeat; flex: none; overflow: hidden; position: relative; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.sm { width: 84px; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

/* snapshots with overlays */
.snap { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #0f172a; border-radius: 8px; overflow: hidden; user-select: none; }
.snap img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; display: block; }
.snap svg.ov { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.snap .box-label { position: absolute; transform: translateY(-100%); background: #ef4444; color: #fff; font-size: 11px; font-weight: 700;
  padding: 1px 5px; border-radius: 3px 3px 3px 0; white-space: nowrap; pointer-events: none; }
.snap .box-label.vehicle { background: #f59e0b; }
.snap .nofeed { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: #94a3b8; font-size: 13px; padding: 12px; }
.snap .tag { position: absolute; left: 8px; bottom: 8px; background: rgba(15, 23, 42, .75); color: #fff; font-size: 11.5px; padding: 3px 8px;
  border-radius: 6px; }
.snap .handle { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #fff; border: 2px solid #0f172a;
  cursor: grab; z-index: 3; }
.snap .handle.first { background: #22c55e; }
.snap .pt-label { position: absolute; transform: translate(8px, -22px); background: #0f172a; color: #fff; font-size: 11px; font-weight: 700;
  padding: 0 5px; border-radius: 4px; pointer-events: none; z-index: 3; }
.snap.drawing { cursor: crosshair; }
.snap .side-label { position: absolute; transform: translate(-50%, -50%); width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; background: #16a34a; border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .4); pointer-events: none; z-index: 2; }
.snap .side-label.b { background: #0f172a; }

.cam-card { overflow: hidden; display: flex; flex-direction: column; cursor: pointer; text-decoration: none !important; color: inherit; }
.cam-card .snap { border-radius: 0; }
.cam-card .meta { padding: 10px 12px; display: flex; gap: 8px; align-items: center; }
.cam-card .meta .grow { flex: 1; min-width: 0; }
.cam-card .meta b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cam-card:hover { border-color: var(--border-2); box-shadow: 0 4px 14px rgba(15, 23, 42, .08); }

/* use-case picker */
.uc-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.uc { border: 1.5px solid var(--border); border-radius: 10px; padding: 12px; cursor: pointer; background: #fff; text-align: left; font: inherit;
  color: inherit; display: flex; flex-direction: column; gap: 4px; }
.uc:hover { border-color: var(--border-2); }
.uc.on { border-color: var(--primary); background: #eff6ff; box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.uc[disabled] { cursor: not-allowed; opacity: .62; background: var(--panel-2); }
.uc b { font-size: 13.5px; }
.uc span { font-size: 12.5px; color: var(--muted); }
.section-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 14px 0 8px; }

.step-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px; background: var(--panel-2); }
.step-card + .step-card { margin-top: 10px; }
.step-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.step-num { width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 14px; background: #eef2f7; font-size: 12.5px;
  font-weight: 600; color: var(--text-2); }
.chip button { border: 0; background: none; padding: 0; cursor: pointer; color: var(--muted); font-size: 14px; line-height: 1; }
.policy-flow { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; }
.policy-flow .pstep { flex: 1 1 180px; border: 1px solid var(--border); border-radius: 8px; padding: 10px; background: var(--panel-2); }
.policy-flow .pstep .when { font-size: 11.5px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .04em; }
.policy-flow .arrow { align-self: center; color: var(--muted); }

/* schedule bars */
.week { display: grid; grid-template-columns: 36px 1fr; gap: 3px 8px; align-items: center; font-size: 11.5px; color: var(--muted); }
.week .bar { position: relative; height: 12px; background: #eef2f7; border-radius: 3px; overflow: hidden; }
.week .bar i { position: absolute; top: 0; bottom: 0; background: var(--primary); opacity: .85; }
.week-scale { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin: 4px 0 0 44px; }
.day-row { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: start; padding: 8px 0; border-bottom: 1px solid var(--border); }
.day-row:last-child { border-bottom: 0; }
.range { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.range input { width: 110px; }

/* charts */
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-size: 10.5px; fill: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.hbars { display: flex; flex-direction: column; gap: 9px; }
.hbar .top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 3px; gap: 8px; }
.hbar .top span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: 8px; background: #eef2f7; border-radius: 4px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--primary); border-radius: 4px; }
.heat { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; }
.heat div { aspect-ratio: 1; border-radius: 3px; background: #eef2f7; }
.heat-scale { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; font-size: 10px; color: var(--muted); text-align: center; margin-top: 4px; }

/* alert detail */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.timeline li::after { content: ""; position: absolute; left: 8.5px; top: 16px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline .t { font-size: 11.5px; color: var(--muted); }
.timeline li.kind-acknowledged::before, .timeline li.kind-resolved::before, .timeline li.kind-recovered::before { background: var(--ok); }
.timeline li.kind-escalated::before { background: var(--warn); }
.timeline li.kind-false_alarm::before, .timeline li.kind-suppressed::before { background: #64748b; }
.timeline li.kind-note::before { background: var(--violet); }
dl.facts { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; margin: 0; font-size: 13px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.alert-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.notice { padding: 10px 12px; border-radius: 8px; background: var(--primary-soft); color: #1e3a8a; font-size: 13px; }
.notice.amber { background: var(--warn-soft); color: #92400e; }
.notice.gray { background: #eef2f7; color: var(--text-2); }
.notice.green { background: var(--ok-soft); color: #166534; }
.tf-setup .qr { width: 200px; max-width: 70%; margin: 0 auto; }
.tf-setup .qr svg { display: block; width: 100%; height: auto; border-radius: 6px; }
.tf-setup .key { font-family: ui-monospace, Consolas, monospace; font-size: 13px; color: var(--text); word-break: break-all; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; padding: 12px; border-radius: 8px; background: #0f172a; }
.codes code { color: #e2e8f0; font-size: 15px; letter-spacing: .04em; text-align: center; }
.login-card .tf-wide { max-width: 460px; }
.secret span { word-break: break-all; }
.secret { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-radius: 8px; background: #0f172a; color: #e2e8f0;
  font-family: Consolas, monospace; font-size: 13px; overflow-wrap: anywhere; }
.secret span { flex: 1; min-width: 0; }
pre.code { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 12px; margin: 0; }

/* modal & toasts */
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: grid; place-items: center; padding: 16px; z-index: 100;
  animation: fade .12s ease-out; }
.modal { background: var(--panel); border-radius: 12px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex;
  flex-direction: column; box-shadow: var(--shadow-lg); }
.modal.wide { max-width: 820px; }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-h h2 { flex: 1; }
.modal-b { padding: 18px; overflow-y: auto; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 10px; z-index: 200; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: #0f172a; color: #fff; padding: 11px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13.5px;
  display: flex; gap: 10px; align-items: flex-start; animation: fade .15s ease-out; }
.toast.error { background: #7f1d1d; }
.toast.ok { background: #14532d; }
.toast .x { margin-left: auto; background: none; border: 0; color: #cbd5e1; cursor: pointer; font-size: 16px; line-height: 1; }
.toast.alert-toast { background: #fff; color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--danger); cursor: pointer; }
.toast.alert-toast .thumb { width: 96px; }
.toast.alert-toast b { display: block; }
.toast.alert-toast .x { color: var(--muted); }

/* icons & live grid */
svg.icon { flex: none; }
.chip svg.icon, .badge svg.icon { width: 13px; height: 13px; }
.avatar svg.icon, .menu-pop svg.icon, .notice svg.icon, .banner svg.icon { width: 16px; height: 16px; }
.notice svg.icon, .banner svg.icon { vertical-align: -3px; }
.org-switch svg.icon { color: var(--muted); }
.list-item > svg.icon { color: var(--muted); }
.page-head .actions select { width: auto; min-width: 150px; }
.spacer { flex: 1; }
.live-grid { display: grid; gap: 14px; }
.cam-wrap { position: relative; min-width: 0; }
.cam-wrap > .cam-card { height: 100%; }
.tile-tools { position: absolute; top: 8px; right: 8px; z-index: 3; display: flex; gap: 6px; max-width: calc(100% - 64px); }
.tile-tools .btn { background: rgba(15, 23, 42, .78); color: #fff; border-color: transparent; }
.tile-tools .live-btn:hover { background: #dc2626; color: #fff; }
.tile-tools .q-btn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tile-tools .q-btn:hover { background: #2563eb; color: #fff; }
.tile-tools .q-btn.busy { background: rgba(180, 83, 9, .9); }
.snap img.live-ov { z-index: 1; object-fit: contain; background: #0f172a; opacity: 0; transition: opacity .3s; }
.snap img.live-ov.on { opacity: 1; }
.snap.is-live .tag { z-index: 2; }
.snap.is-live::after { content: 'LIVE'; position: absolute; left: 8px; top: 8px; z-index: 2; background: #dc2626; color: #fff;
  font-size: 10.5px; font-weight: 800; letter-spacing: .05em; padding: 1px 6px; border-radius: 4px; }
.live-player { aspect-ratio: auto; min-height: 240px; }
.live-player img { position: static; width: 100%; height: auto; max-height: 72vh; object-fit: contain; visibility: hidden; }
.live-pill { display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 4px; background: #dc2626; color: #fff;
  font-size: 11px; font-weight: 800; letter-spacing: .05em; vertical-align: middle; }
.live-grid.c1 { grid-template-columns: minmax(0, 1fr); max-width: 1100px; }
.live-grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.live-grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.live-grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
details summary { list-style-position: inside; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .cols-main, .cols-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; transform: translateX(-100%); transition: transform .18s ease;
    box-shadow: var(--shadow-lg); }
  .shell.nav-open .sidebar { transform: translateX(0); }
  .shell.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 35; }
  .topbar { padding: 0 16px; }
  .topbar .menu-btn { display: inline-flex; }
  .user-chip .who { display: none; }
  .content { padding: 16px; }
  .cols-2, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .banner { padding: 9px 16px; }
  .topbar .org-switch select { max-width: 170px; }
  dl.facts { grid-template-columns: 110px 1fr; }
  .live-grid.c3, .live-grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .thumb { width: 92px; }
  .list-item { padding: 10px 12px; }
  .hide-sm { display: none !important; }
  .kpi .value { font-size: 22px; }
  .page-head h1 { font-size: 19px; }
  .filters select, .filters input, .filters input[type=search] { min-width: 0; flex: 1 1 140px; }
  .live-grid.c2, .live-grid.c3, .live-grid.c4 { grid-template-columns: minmax(0, 1fr); }
  .page-head .actions select { min-width: 0; }
  .list-item .title, .list-item .sub { white-space: normal; }
}
@media print {
  .sidebar, .topbar, .banner, .page-head .actions, .filters, #toasts { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
