/* AnomaAI design system — premium operations SaaS.
   Palette promoted from the existing vision portal; tokens enable theming. */

:root {
  --color-primary: #2a6df4;
  --color-primary-hover: #1d57d0;
  --color-primary-soft: #eef4ff;
  --color-ink: #1c2430;
  --color-ink-secondary: #46556b;
  --color-muted: #6b7a90;
  --color-faint: #8894a6;
  --color-canvas: #f6f8fb;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-border-strong: #d0d7e3;
  --color-success: #1c7a42;
  --color-success-soft: #e6f6ec;
  --color-warning: #8a5c00;
  --color-warning-soft: #fff5e0;
  --color-danger: #a3262b;
  --color-danger-soft: #fdeaea;
  --color-info-soft: #eef4ff;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(28, 36, 48, 0.04);
  --shadow-md: 0 4px 12px rgba(28, 36, 48, 0.06);
  --shadow-lg: 0 12px 32px rgba(28, 36, 48, 0.08);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --text-xs: 11px;
  --text-sm: 12px;
  --text-md: 13px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 32px;

  --sidebar-width: 240px;
  --topbar-height: 56px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--color-ink);
  background: var(--color-canvas);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ---- App shell ---- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  /* auto (not 1fr): 1fr + sticky sidebar has trapped page scroll in Chromium */
  grid-template-rows: var(--topbar-height) auto;
  min-height: 100vh;
}
.app-shell.login-shell {
  display: block;
  min-height: 100vh;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  height: var(--topbar-height);
  padding: 0 var(--space-5);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar-brand {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--color-ink);
  text-decoration: none;
}
.topbar-brand:hover { text-decoration: none; }
.topbar-brand .subtitle {
  font-weight: 500;
  font-size: var(--text-sm);
  color: var(--color-muted);
}
.topbar-meta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-muted);
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.topbar-user .role-pill {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--color-primary-soft);
  color: #24457f;
}

.sidebar {
  grid-row: 2;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: var(--space-4) var(--space-3) var(--space-6);
  overflow-y: auto;
  position: sticky;
  top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
}
.nav-group { margin-bottom: var(--space-5); }
.nav-group-label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-faint);
  padding: 0 var(--space-2);
  margin-bottom: var(--space-2);
}
.nav-link {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--color-ink-secondary);
  font-size: var(--text-md);
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 2px;
}
.nav-link:hover {
  background: var(--color-canvas);
  color: var(--color-ink);
  text-decoration: none;
}
.nav-link.active {
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 600;
}
.nav-link.admin-link { color: var(--color-muted); font-size: var(--text-sm); }

.main {
  grid-row: 2;
  padding: var(--space-5) var(--space-6) var(--space-7);
  min-width: 0;
  overflow: visible;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.page-header h1 {
  margin: 0 0 var(--space-1);
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.page-header .page-desc {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-base);
  max-width: 640px;
}
.page-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.breadcrumb {
  font-size: var(--text-sm);
  color: var(--color-faint);
  margin-bottom: var(--space-2);
}
.breadcrumb a { color: var(--color-muted); }

.app-footer {
  margin-top: var(--space-7);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
  color: var(--color-faint);
  font-size: var(--text-sm);
}

/* ---- Components ---- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.card h3, .card .card-title {
  margin: 0 0 var(--space-3);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

.kpi, .stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.kpi .label, .stat-card .label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
}
.kpi .value, .stat-card .value {
  font-size: var(--text-2xl);
  font-weight: 700;
  margin: var(--space-2) 0 var(--space-1);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.kpi .basis, .stat-card .basis {
  font-size: var(--text-sm);
  color: var(--color-faint);
  line-height: 1.4;
}
.kpi.unmeasured .value, .stat-card.unmeasured .value {
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--color-faint);
}
.kpi.band-ok .value { color: var(--color-success); }
.kpi.band-warn .value { color: var(--color-warning); }
.kpi.band-bad .value { color: var(--color-danger); }
.kpi.mini { padding: var(--space-3); }
.kpi.mini .value { font-size: var(--text-xl); }

table.data-table, table {
  border-collapse: collapse;
  width: 100%;
  background: var(--color-surface);
  font-size: var(--text-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
th, td {
  border-bottom: 1px solid var(--color-border);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}
th {
  background: #f1f4f9;
  font-weight: 600;
  color: var(--color-ink-secondary);
  font-size: var(--text-sm);
}
tbody tr:hover { background: #fafcff; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; }

.pill {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
}
.pill.completed, .pill.yes, .pill.resolved, .pill.confirmed {
  background: var(--color-success-soft); color: var(--color-success);
}
.pill.running, .pill.pending, .pill.investigating, .pill.warn {
  background: var(--color-warning-soft); color: var(--color-warning);
}
.pill.failed, .pill.danger, .pill.suspicious {
  background: var(--color-danger-soft); color: var(--color-danger);
}
.pill.no, .pill.muted {
  background: #f1f3f7; color: var(--color-muted);
}

.banner {
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: var(--space-4);
  font-size: var(--text-base);
}
.banner.warn { background: #fff8e8; border: 1px solid #f0d9a0; color: #7a5a10; }
.banner.info { background: var(--color-info-soft); border: 1px solid #cddcfb; color: #24457f; }
.banner.danger { background: var(--color-danger-soft); border: 1px solid #f0c4c6; color: var(--color-danger); }
.banner.success { background: var(--color-success-soft); border: 1px solid #b7e4c7; color: var(--color-success); }

.empty-state {
  text-align: center;
  padding: var(--space-7) var(--space-5);
  background: var(--color-surface);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  color: var(--color-muted);
}
.empty-state strong {
  display: block;
  font-size: var(--text-lg);
  color: var(--color-ink);
  margin-bottom: var(--space-2);
}
.empty-state p { margin: 0 0 var(--space-4); max-width: 420px; margin-left: auto; margin-right: auto; }

.skeleton {
  background: linear-gradient(90deg, #eef1f6 25%, #f7f9fc 50%, #eef1f6 75%);
  background-size: 200% 100%;
  animation: skeleton-shine 1.2s ease-in-out infinite;
  border-radius: var(--radius-sm);
  height: 14px;
}
@keyframes skeleton-shine {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

button, .btn, input[type=submit] {
  font: inherit;
  background: var(--color-primary);
  color: #fff;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: var(--text-md);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
}
button:hover, .btn:hover, input[type=submit]:hover {
  background: var(--color-primary-hover);
  text-decoration: none;
  color: #fff;
}
button.secondary, .btn.secondary {
  background: var(--color-surface);
  color: var(--color-ink-secondary);
  border: 1px solid var(--color-border-strong);
}
button.secondary:hover, .btn.secondary:hover {
  background: var(--color-canvas);
  color: var(--color-ink);
}
button.danger, .btn.danger {
  background: var(--color-surface);
  color: var(--color-danger);
  border: 1px solid #f0c4c6;
}
button.ghost, .btn.ghost {
  background: transparent;
  color: var(--color-primary);
  border: 0;
  padding: 8px 10px;
}
.ghost-link { color: var(--color-primary); text-decoration: none; font-size: var(--text-base); white-space: nowrap; }

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], input[type=url], select, textarea {
  font: inherit;
  padding: 8px 12px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-ink);
  width: 100%;
  max-width: 420px;
}
label { display: block; font-size: var(--text-sm); font-weight: 600; color: var(--color-ink-secondary); margin-bottom: 4px; }
.form-row { margin-bottom: var(--space-4); }
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
  margin-bottom: var(--space-4);
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.muted { color: var(--color-muted); font-size: var(--text-md); }
.mono { font-family: var(--font-mono); font-size: var(--text-sm); }
.hidden { display: none !important; }

/* Outcome of a form submission, outside the login card. */
.flash {
  padding: var(--space-3);
  margin-bottom: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: var(--text-md);
}
.flash.error {
  border-color: #f0c2c2;
  background: #fdf2f2;
  color: #8c1c1c;
}

/* A one-time invitation link, sized to be selected and copied whole. */
.invite-link {
  padding: var(--space-3);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-canvas);
  word-break: break-all;
  user-select: all;
}
.section-title {
  margin: var(--space-5) 0 var(--space-3);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--color-ink-secondary);
  font-size: var(--text-sm);
}

/* ---- Login ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background:
    radial-gradient(ellipse at top left, #e8f0ff 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, #f0f4fa 0%, transparent 50%),
    var(--color-canvas);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-lg);
}
.login-card h1 {
  margin: 0 0 4px;
  font-size: var(--text-2xl);
}
.login-card .login-sub {
  margin: 0 0 var(--space-5);
  color: var(--color-muted);
  font-size: var(--text-base);
}
.login-card .error {
  background: var(--color-danger-soft);
  color: var(--color-danger);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-4);
  font-size: var(--text-md);
}
.login-card button { width: 100%; justify-content: center; margin-top: var(--space-2); }
.login-card .login-footer {
  margin-top: var(--space-5);
  text-align: center;
  color: var(--color-faint);
  font-size: var(--text-sm);
}

/* ---- Vision / viewer (migrated from _vision_style) ---- */
.vision-chip {
  display: inline-flex; align-items: center; gap: 8px; margin: 0 0 16px;
  padding: 8px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  border: 1px solid #cddcfb; background: #eef4ff; color: #24457f;
}
.vision-chip.ready { border-color: #b7e4c7; background: #e6f6ec; color: #1c7a42; }
.vision-chip-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .85; }
.vision-chip.preparing .vision-chip-dot { animation: vision-pulse 1.2s ease-in-out infinite; }
.vision-chip-progress { font-weight: 500; opacity: .8; }
@keyframes vision-pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

.stages { font-size: 12px; color: #52627a; }
.stages span {
  display: inline-block; background: #fff; border: 1px solid #e2e8f0;
  border-radius: 999px; padding: 3px 10px; margin: 0 4px 6px 0;
}
.bar { height: 8px; background: #e7ecf4; border-radius: 4px; overflow: hidden; max-width: 320px; }
.bar > div { height: 100%; background: var(--color-primary); }

.viewer-top { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.viewer-layout {
  display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.9fr);
  gap: 16px; align-items: start;
}
@media (max-width: 980px) { .viewer-layout { grid-template-columns: 1fr; } }
.viewer-stage { padding: 12px; }
.stage-wrap {
  position: relative; background: #0b1220; border-radius: 10px; overflow: hidden;
  overscroll-behavior: auto;
}
.stage-media { position: relative; background: #0b1220; }
.stage-media video {
  display: block; width: 100%; max-height: 70vh; background: #0b1220;
  object-fit: contain; position: relative; z-index: 1;
}
/* Overlays sit above the frame but NEVER capture clicks (Play / scrubber). */
.stage-media canvas,
.stage-media .live-preview,
.stage-media .stage-empty,
.stage-media .hud {
  position: absolute; left: 0; right: 0; pointer-events: none;
}
.stage-media canvas {
  top: 0; bottom: 54px; width: 100%; height: auto; z-index: 2; background: transparent;
}
/* Corner PIP only — never a full-bleed black sheet over the video. */
.live-preview {
  left: auto; right: 10px; top: 10px; bottom: auto;
  width: min(28%, 220px); height: auto; max-height: 28%;
  object-fit: contain; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.22); background: rgba(8, 14, 24, 0.55);
  z-index: 3; overflow-anchor: none; box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}
.live-preview.hidden { display: none !important; content: none; }
.hud {
  left: 10px; right: auto; bottom: 62px; z-index: 4;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.hud span {
  background: rgba(8, 14, 24, 0.72); color: #e8eef8; border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600;
}
.stage-empty {
  inset: 0 0 54px 0; z-index: 3; display: flex; align-items: center;
  justify-content: center; padding: 24px; text-align: center;
  background: rgba(8, 14, 24, 0.72); color: #e8eef8;
}
.stage-actions {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 10px 4px 0;
}
.stage-actions .muted { font-size: 12px; }
.stage-empty strong { display: block; font-size: 15px; margin-bottom: 6px; }
.stage-empty span { display: block; font-size: 12px; opacity: .85; line-height: 1.45; }

.timeline-panel { margin-top: 14px; }
.timeline-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.timeline-track {
  position: relative; height: 18px; border-radius: 999px; background: #e7ecf4;
  overflow: visible; margin-bottom: 10px;
}
.timeline-progress {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  background: linear-gradient(90deg, #2a6df4, #39c6ff); border-radius: 999px;
}
.timeline-marker {
  position: absolute; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px;
  border: 0; border-radius: 50%; background: #ff8c00; cursor: pointer; z-index: 2;
}
.timeline-list { max-height: 220px; overflow: auto; display: grid; gap: 6px; }
.timeline-row {
  display: grid; grid-template-columns: 54px 1fr; gap: 2px 10px; text-align: left;
  border: 1px solid #e2e8f0; background: #fff; border-radius: 8px; padding: 8px 10px; cursor: pointer;
}
.timeline-row strong { grid-column: 2; }
.timeline-row .muted { grid-column: 2; }

.viewer-side { display: grid; gap: 12px; }
.side-card { margin: 0; }
.side-label {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: #6b7a90; margin-bottom: 8px;
}
.insight-headline { font-size: 15px; line-height: 1.45; margin-bottom: 8px; }
.kpi-compact { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.track-list { display: flex; flex-wrap: wrap; gap: 8px; }
.track-chip {
  border: 1px solid #d7e0ef; background: #f7faff; border-radius: 999px;
  padding: 6px 10px; cursor: pointer; font-size: 12px;
}
.track-chip.active { border-color: #2a6df4; background: #eaf1ff; color: #1d4fbf; }
img.thumb { width: 96px; border-radius: 4px; border: 1px solid #e2e8f0; display: block; }
ul.tight { margin: 6px 0; padding-left: 20px; }
ul.tight li { margin: 3px 0; line-height: 1.45; }

/* Session story (timeline) */
.session-story { display: grid; gap: var(--space-3); }
.session-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.session-card h3 { margin: 0 0 var(--space-2); font-size: var(--text-lg); text-transform: none; letter-spacing: 0; color: var(--color-ink); }
.session-metrics {
  display: flex; flex-wrap: wrap; gap: var(--space-3);
  margin: var(--space-3) 0;
  font-size: var(--text-sm);
  color: var(--color-muted);
}
.session-metrics strong { color: var(--color-ink); font-variant-numeric: tabular-nums; }
.event-steps { list-style: none; margin: 0; padding: 0; }
.event-steps li {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: var(--space-3);
  padding: 8px 0;
  border-top: 1px solid var(--color-border);
  font-size: var(--text-md);
}
.event-steps li:first-child { border-top: 0; }
.event-steps .t { color: var(--color-muted); font-variant-numeric: tabular-nums; }

/* Dock board */
.dock-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-3); }
.dock-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-decoration: none;
  color: inherit;
  transition: box-shadow .15s, border-color .15s;
}
.dock-tile:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}
.dock-tile h3 { margin: 0 0 6px; font-size: var(--text-lg); text-transform: none; letter-spacing: 0; color: var(--color-ink); }

/* ---- First-run experience ---------------------------------------------- */

/* A contextual tip. Deliberately quiet: it explains a surface to somebody
   seeing it for the first time and must not compete with the data on it. */
.tip {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: 0 0 var(--space-4);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--color-canvas);
  border: 1px solid var(--color-border);
  color: var(--color-ink-secondary);
  font-size: var(--text-md);
  max-width: 720px;
}
.tip-mark {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--color-primary-soft);
  color: #24457f;
  font-size: 11px;
  font-weight: 700;
  font-style: italic;
  line-height: 16px;
  text-align: center;
}

/* Sample data must be recognisable at a glance wherever it appears, so the
   banner and the row badge share one colour and one wording. */
.demo-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: #fff5e0;
  border: 1px solid #f0d9a0;
  color: #7a5a10;
  font-size: var(--text-md);
}
.demo-banner strong { font-weight: 700; }
.demo-banner form { margin: 0; }
.demo-banner button {
  background: transparent;
  border: 1px solid #d9b978;
  color: #7a5a10;
  padding: 4px 10px;
  font-size: var(--text-sm);
}
.demo-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: #fff5e0;
  border: 1px solid #f0d9a0;
  color: #7a5a10;
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
}

/* An empty state sitting inside a table, so a list page never renders column
   headers over nothing at all. */
.empty-row td { padding: 0 !important; border: 0 !important; background: transparent; }
.empty-row .empty-state { border: 0; border-radius: 0; padding: var(--space-6) var(--space-4); }

.setup-card, .health-card { max-width: 720px; }
.setup-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  margin-bottom: var(--space-3);
}
.setup-card-head h2 {
  margin: 0 0 2px;
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.setup-card-head p { margin: 0; font-size: var(--text-md); }
.setup-percent {
  flex: none;
  font-size: var(--text-xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-primary);
}
.setup-percent.ok { color: var(--color-success); }
.setup-bar { max-width: none; margin-bottom: var(--space-4); }

.setup-steps, .health-list { list-style: none; margin: 0; padding: 0; }
.setup-steps li, .health-list li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: 8px 0;
  border-top: 1px solid var(--color-border);
  font-size: var(--text-md);
}
.setup-steps li:first-child, .health-list li:first-child { border-top: 0; }
.setup-mark, .health-mark {
  flex: none;
  width: 18px;
  text-align: center;
  font-weight: 700;
  color: var(--color-faint);
}
.setup-steps li.done .setup-mark { color: var(--color-success); }
.setup-body, .health-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.setup-body strong, .health-body strong { font-weight: 600; }
.setup-steps li.done .setup-body strong { color: var(--color-muted); font-weight: 500; }
.setup-card .btn { margin-top: var(--space-4); }

.health-list li.ok .health-mark { color: var(--color-success); }
.health-list li.warn .health-mark { color: var(--color-warning); }
.health-list li.bad .health-mark { color: var(--color-danger); }
.health-state {
  flex: none;
  align-self: center;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-faint);
}
.health-list li.ok .health-state { color: var(--color-success); }
.health-list li.bad .health-state { color: var(--color-danger); }

/* ---- Guided setup wizard ---- */
.wizard-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
}
@media (max-width: 900px) { .wizard-layout { grid-template-columns: 1fr; } }
.wizard-rail { list-style: none; margin: 0; padding: 0; font-size: var(--text-md); }
.wizard-rail li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 7px 10px;
  border-radius: var(--radius-md);
  color: var(--color-muted);
}
.wizard-rail li.current { background: var(--color-primary-soft); color: #24457f; font-weight: 600; }
.wizard-rail li.past { color: var(--color-ink-secondary); }
.wizard-rail .n {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-canvas);
  border: 1px solid var(--color-border-strong);
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.wizard-rail li.current .n { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.wizard-rail li.past .n { background: var(--color-success-soft); border-color: #b7e4c7; color: var(--color-success); }
.wizard-panel h2 { margin: 0 0 var(--space-2); font-size: var(--text-xl); letter-spacing: -0.01em; }
.wizard-panel .lede { margin: 0 0 var(--space-4); color: var(--color-muted); max-width: 620px; }
.wizard-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}
.wizard-actions .leave { margin-left: auto; font-size: var(--text-md); color: var(--color-muted); }
.wizard-list { margin: 0 0 var(--space-4); padding-left: var(--space-5); color: var(--color-ink-secondary); }
.wizard-list li { margin-bottom: var(--space-2); }

/* ---- First AI event ---- */
.celebrate {
  max-width: 620px;
  margin: var(--space-6) auto;
  padding: var(--space-7) var(--space-5);
  text-align: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.celebrate-mark { font-size: 44px; line-height: 1; margin-bottom: var(--space-3); }
.celebrate h1 { margin: 0 0 var(--space-3); font-size: var(--text-2xl); }
.celebrate p { margin: 0 auto var(--space-4); max-width: 420px; color: var(--color-ink-secondary); }
.celebrate .btn { margin-top: var(--space-2); }

/* Responsive shell */
@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-height) auto auto;
  }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-3);
  }
  .nav-group { margin: 0; display: flex; flex-wrap: wrap; gap: 2px; align-items: center; }
  .nav-group-label { display: none; }
  .main { padding: var(--space-4); }
}

/* Print / shareable report */
@media print {
  .sidebar, .topbar, .page-actions, .filter-bar form button, .no-print { display: none !important; }
  .app-shell { display: block; }
  .main { padding: 0; }
  .card, .kpi, .stat-card, .session-card { box-shadow: none; break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}

/* ---- Camera Fleet zero-friction ---- */
.connect-hero {
  max-width: 560px;
  margin: var(--space-7) auto;
  text-align: center;
  padding: var(--space-7) var(--space-5);
}
.connect-hero-kicker {
  margin: 0 0 var(--space-2);
  color: var(--color-muted);
  font-size: var(--text-sm);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.connect-hero-title {
  margin: 0 0 var(--space-3);
  font-size: var(--text-3xl);
  font-weight: 650;
  letter-spacing: -0.02em;
}
.connect-hero-copy {
  margin: 0 0 var(--space-6);
  color: var(--color-ink-secondary);
  font-size: var(--text-lg);
}
.connect-hero-cta {
  display: inline-block;
  padding: 14px 28px;
  font-size: var(--text-lg);
  border-radius: var(--radius-md);
}

.connect-steps ol {
  display: flex;
  gap: var(--space-3);
  list-style: none;
  margin: 0 0 var(--space-6);
  padding: 0;
  flex-wrap: wrap;
}
.connect-steps li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-muted);
  font-size: var(--text-sm);
}
.connect-steps li span {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-border);
  color: var(--color-ink);
  font-weight: 600;
}
.connect-steps li.is-active { color: var(--color-ink); font-weight: 600; }
.connect-steps li.is-active span { background: var(--color-primary); color: #fff; }
.connect-steps li.is-done span { background: var(--color-success-soft); color: var(--color-success); }

.connect-panel { display: none; }
.connect-panel.is-active { display: block; }
.connect-heading {
  margin: 0 0 var(--space-3);
  font-size: var(--text-xl);
  font-weight: 650;
}

.connect-methods {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
}
.connect-method {
  text-align: left;
  padding: var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  position: relative;
}
.connect-method:hover:not(:disabled) {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}
.connect-method strong { display: block; margin-bottom: var(--space-2); font-size: var(--text-lg); }
.connect-method p { margin: 0; color: var(--color-ink-secondary); font-size: var(--text-md); }
.connect-method.is-recommended { border-color: var(--color-primary); background: var(--color-primary-soft); }
.connect-method.is-disabled,
.connect-method:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}
.connect-badge {
  display: inline-block;
  margin-bottom: var(--space-2);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--color-primary);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 600;
}
.connect-badge.muted { background: var(--color-border-strong); color: var(--color-ink); }

.connect-status {
  margin: var(--space-4) 0;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-info-soft);
}
.connect-status.is-ok { background: var(--color-success-soft); color: var(--color-success); }
.connect-status.is-bad { background: var(--color-danger-soft); color: var(--color-danger); }
.connect-status.is-pending { background: var(--color-info-soft); color: var(--color-ink); }
.connect-status p { margin: var(--space-2) 0 0; color: inherit; }
.connect-meta { margin: var(--space-3) 0; }

.discover-grid {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-4);
}
.discover-card {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  cursor: pointer;
}
.discover-card:has(input:checked) {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
}
.discover-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  margin-top: var(--space-2);
  color: var(--color-muted);
  font-size: var(--text-sm);
}
.inline { display: inline-flex; align-items: center; gap: var(--space-2); }

.connect-success {
  max-width: 520px;
  margin: var(--space-6) auto;
  text-align: center;
}
.connect-success-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-4);
  border-radius: 50%;
  background: var(--color-success-soft);
  color: var(--color-success);
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.connect-success-actions {
  justify-content: center;
  flex-wrap: wrap;
}

.camera-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-4);
}
.camera-card {
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.camera-card.is-disabled { opacity: 0.55; }
.camera-card-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  background:
    linear-gradient(145deg, #1c2430 0%, #2a3a52 55%, #1c2430 100%);
  color: rgba(255,255,255,0.75);
  text-decoration: none;
}
.camera-card-preview:hover { text-decoration: none; filter: brightness(1.08); }
.camera-card-preview-label { font-size: var(--text-sm); letter-spacing: 0.06em; text-transform: uppercase; }
.camera-card-body { padding: var(--space-4); }
.camera-card-top {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.camera-card-name {
  font-weight: 650;
  color: var(--color-ink);
  text-decoration: none;
}
.camera-card-name:hover { color: var(--color-primary); }
.camera-card-loc { margin: 0 0 var(--space-1); font-size: var(--text-md); }
.camera-card-meta { margin: 0 0 var(--space-3); font-size: var(--text-sm); }
.camera-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
}

.health-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.health-dot.health-healthy { background: #22a35a; box-shadow: 0 0 0 3px var(--color-success-soft); }
.health-dot.health-warning { background: #e0a100; box-shadow: 0 0 0 3px var(--color-warning-soft); }
.health-dot.health-offline { background: #c0392b; box-shadow: 0 0 0 3px var(--color-danger-soft); }

/* DockVisit session timeline (derived from Business Events — display only) */
.dock-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 12px 0;
}
.dock-timeline-step {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: stretch;
}
.dock-timeline-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.dock-timeline-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-primary, #2a6df4);
  margin-top: 4px;
  flex-shrink: 0;
}
.dock-timeline-dot.inferred { background: #8aa0bc; }
.dock-timeline-line {
  width: 2px;
  flex: 1;
  min-height: 18px;
  background: #d5deea;
}
.dock-timeline-body { padding-bottom: 14px; }
.dock-timeline-body strong { display: block; }
.invest-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 20px;
}
.evidence-thumb {
  width: 120px;
  height: 68px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}
