/* one dark theme, control room style */
:root {
  color-scheme: light;

  /* navy and white theme */
  --navy: #0b1f4b;
  --navy-deep: #07163a;
  --navy-hover: rgba(255, 255, 255, 0.08);
  --navy-active: rgba(255, 255, 255, 0.16);

  /* surfaces */
  --page: #f3f5fa;
  --surface: #ffffff;
  --surface-raised: #f3f5fa;
  --border: #dde2ee;
  --grid: #e6eaf3;
  --axis: #b8c0d4;

  /* text */
  --text: #0b1f4b;
  --text-secondary: #3c4a6b;
  --text-muted: #6b7692;

  /* accent and chart series */
  --accent: #1d4ed8;
  --series-in: #1d4ed8;
  --series-out: #e0701a;

  /* status, always with icon and word */
  --good: #0f9d3a;
  --warning: #d98a00;
  --critical: #c62f2f;
  --critical-text: #b42323;

  --radius: 10px;
  --sidebar-width: 230px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--page);
}

h1, h2, h3, p { margin: 0; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--text-muted); }

/* ---------- app shell ---------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  flex: 0 0 var(--sidebar-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 20px 12px;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #ffffff;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-size: 14px; font-weight: 600; line-height: 1.25; }
.brand-mark { flex: none; }
.brand-mark { width: 24px; height: 24px; color: #ffffff; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
}
.nav-link svg { width: 18px; height: 18px; }
.nav-link:hover { background: var(--navy-hover); color: #ffffff; }
.nav-link.active { background: var(--navy-active); color: #ffffff; font-weight: 600; box-shadow: inset 3px 0 0 #ffffff; }

.sidebar-foot { margin-top: auto; padding: 0 10px; font-size: 12px; color: rgba(255, 255, 255, 0.6); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-title { margin-right: auto; min-width: 0; }
.topbar-title h1 { font-size: 18px; font-weight: 600; }
.topbar-title p { font-size: 13px; color: var(--text-muted); }
.clock { font-size: 13px; color: var(--text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }

.content { padding: 20px 24px 32px; }

/* ---------- layout ---------- */

.dashboard { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 3fr); gap: 16px; align-items: start; }
.column { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.card { box-shadow: 0 1px 2px rgba(11, 31, 75, 0.05); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 12px; }
.card-head h2 { font-size: 15px; font-weight: 600; margin-right: auto; }
.card-note { font-size: 12px; color: var(--text-muted); }
.empty { color: var(--text-muted); font-size: 13px; padding: 4px 0; }

/* ---------- status badge ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.badge svg { width: 12px; height: 12px; color: var(--critical-text); stroke-width: 2.6; }
.badge.online { color: var(--text); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--good); animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

/* ---------- live video ---------- */

.video-wrap { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 8px; overflow: hidden; }
.video-wrap img { width: 100%; height: 100%; object-fit: contain; display: block; }
.video-offline {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  background: #111110;
  color: var(--text-secondary);
}
.video-offline svg { width: 40px; height: 40px; color: var(--text-muted); margin-bottom: 4px; }
.video-wrap.is-offline .video-offline { display: flex; }
.video-wrap.is-offline img { visibility: hidden; }

/* ---------- stat tiles ---------- */

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile {
  box-shadow: 0 1px 2px rgba(11, 31, 75, 0.05);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.tile-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.tile-value { font-size: 30px; font-weight: 600; line-height: 1.15; }
.tile-note { font-size: 12px; color: var(--text-muted); }

.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.swatch.series-in { background: var(--series-in); }
.swatch.series-out { background: var(--series-out); }

/* ---------- traffic chart ---------- */

.chart { --plot-height: 180px; }
.chart-top { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 12px; }
.legend { display: flex; gap: 16px; margin: 0 auto 0 0; padding: 0; list-style: none; font-size: 13px; color: var(--text-secondary); }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend strong { color: var(--text); font-weight: 600; }

.plot-area { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 8px; }
.y-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: var(--plot-height);
  /* centre each number on its line */
  margin: -8px 0;
  font-size: 11px;
  line-height: 16px;
  text-align: right;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.plot { position: relative; height: var(--plot-height); min-width: 0; }
.gridlines { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; }
.gridlines span { height: 1px; background: var(--grid); }
.gridlines span:last-child { background: var(--axis); }

.columns { position: absolute; inset: 0; display: flex; }
.hour { position: relative; flex: 1; min-width: 0; display: flex; justify-content: center; outline: none; }
.hour:hover, .hour:focus-visible { background: rgba(11, 31, 75, 0.06); }
.bars { display: flex; align-items: flex-end; justify-content: center; gap: 2px; width: 100%; height: 100%; padding: 0 2px; }
.bar { flex: 1; max-width: 10px; min-height: 0; border-radius: 4px 4px 0 0; }
.bar.series-in { background: var(--series-in); }
.bar.series-out { background: var(--series-out); }

.tooltip {
  position: absolute;
  z-index: 2;
  top: 4px;
  left: calc(50% + 12px);
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  pointer-events: none;
}
.tooltip.left { left: auto; right: calc(50% + 12px); }
.tooltip strong { color: var(--text); }
.tooltip span { display: flex; align-items: center; gap: 6px; }
.hour:hover .tooltip, .hour:focus-visible .tooltip { display: flex; }

.x-axis { grid-column: 2; display: flex; margin-top: 6px; font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.x-axis span { flex: 1; text-align: center; min-width: 0; }

.table-view { margin-top: 12px; font-size: 13px; color: var(--text-secondary); }
.table-view summary { cursor: pointer; color: var(--text-muted); font-size: 12px; }
.table-view table { margin-top: 8px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table-view th, .table-view td { padding: 4px 24px 4px 0; text-align: left; border-bottom: 1px solid var(--grid); }
.table-view th { color: var(--text-muted); font-weight: 500; }

/* ---------- activity feed ---------- */

.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--grid); font-size: 13px; }
.activity li:last-child { border-bottom: 0; }
.kind {
  flex: 0 0 96px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}
.kind svg { width: 14px; height: 14px; color: var(--warning); }
.kind.alert { color: var(--text); }
.activity-text { flex: 1; min-width: 0; color: var(--text); }
.thumb { flex: none; line-height: 0; }
.thumb img { width: 64px; height: 36px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); }
.thumb:hover img { border-color: var(--accent); }
.activity time { flex: none; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ---------- zones ---------- */

.zone-summary { list-style: none; margin: 0; padding: 0; }
.zone-summary li { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; padding: 8px 0; border-bottom: 1px solid var(--grid); }
.zone-summary li:last-child { border-bottom: 0; }
.zone-name { font-weight: 600; margin-right: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 2px 8px; border: 1px solid var(--border); border-radius: 999px; font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.chip.muted { color: var(--text-muted); }

.zone-card { padding: 12px; margin-bottom: 12px; background: var(--surface-raised); border: 1px solid var(--border); border-radius: 8px; }
.zone-card:last-child { margin-bottom: 0; }
.zone-card header { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.zone-card h3 { font-size: 14px; font-weight: 600; }
.zone-card header .button { margin-left: auto; }

.rule-list { list-style: none; margin: 0 0 12px; padding: 0; }
.rule-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--grid); font-size: 13px; }


/* picture with drawing layer on top */
.snapshot-wrap { position: relative; line-height: 0; background: #000; border-radius: 8px; overflow: hidden; }
.snapshot-wrap img { width: 100%; height: auto; display: block; }
.snapshot-wrap canvas { position: absolute; inset: 0; cursor: crosshair; }
.snapshot-wrap.no-picture { aspect-ratio: 16 / 9; }
.snapshot-error { position: absolute; inset: auto 0 12px 0; text-align: center; line-height: 1.4; font-size: 13px; color: var(--text-muted); pointer-events: none; }

/* ---------- forms and buttons ---------- */

.toolbar, .form-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.form-row label { font-size: 13px; color: var(--text-secondary); }

input, select {
  font: inherit;
  padding: 7px 10px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
}
input::placeholder { color: var(--text-muted); }
input[type="number"] { width: 120px; }
input:focus-visible, select:focus-visible, .button:focus-visible, .nav-link:focus-visible, .hour:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.button {
  display: inline-flex;
  align-items: center;
  font: inherit;
  padding: 7px 12px;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.button:hover { border-color: var(--axis); }
.button.primary { background: var(--navy); border-color: var(--navy); color: #ffffff; font-weight: 600; }
.button.primary:hover { filter: brightness(1.1); }
.button.danger { color: var(--critical-text); }
.button.small { padding: 3px 10px; font-size: 12px; }
.button:disabled { opacity: 0.45; cursor: not-allowed; }

.error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text);
  background: rgba(198, 47, 47, 0.08);
  border: 1px solid var(--critical);
  border-radius: 8px;
}
.error svg { width: 16px; height: 16px; flex: none; color: var(--critical-text); }

/* ---------- collapsible sidebar ---------- */

.collapse-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 9px 10px;
  font: inherit;
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  cursor: pointer;
}
.collapse-btn:hover { background: var(--navy-hover); color: #ffffff; }
.collapse-btn:focus-visible { outline: 2px solid #ffffff; outline-offset: 1px; }
.collapse-btn svg { width: 18px; height: 18px; flex: none; transition: transform 0.2s ease; }
.collapse-btn + .sidebar-foot { margin-top: 0; }
.sidebar { transition: flex-basis 0.2s ease; overflow: hidden; }

.sidebar-collapsed .sidebar { flex-basis: 68px; padding-left: 10px; padding-right: 10px; }
.sidebar-collapsed .brand { justify-content: center; padding: 0; }
.sidebar-collapsed .brand-text,
.sidebar-collapsed .nav-link span,
.sidebar-collapsed .collapse-btn span,
.sidebar-collapsed .sidebar-foot { display: none; }
.sidebar-collapsed .nav-link,
.sidebar-collapsed .collapse-btn { justify-content: center; }
.sidebar-collapsed .collapse-btn svg { transform: rotate(180deg); }

/* ---------- analytics page ---------- */

.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--navy);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(11, 31, 75, 0.05);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.kpi:hover, .kpi:focus-within {
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(11, 31, 75, 0.18);
  border-color: var(--axis);
}
@media (prefers-reduced-motion: reduce) { .kpi { transition: none; } .kpi:hover { transform: none; } }
.kpi-alert { border-top-color: var(--critical); }
.kpi-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
.kpi-value { font-size: 24px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-of { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.kpi-note { font-size: 11px; color: var(--text-muted); }

.analytics-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.span-2 { grid-column: 1 / -1; }

.bar-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.bar-list li { display: grid; grid-template-columns: 90px minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: 13px; }
.bar-track { height: 10px; background: var(--grid); border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--navy); border-radius: 999px; }
.bar-num { font-variant-numeric: tabular-nums; font-weight: 600; }

.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; font-weight: 600; font-size: 12px; color: var(--text-muted); padding: 8px 12px 8px 0; border-bottom: 1px solid var(--border); }
.data-table td { padding: 8px 12px 8px 0; border-bottom: 1px solid var(--grid); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tr:last-child td { border-bottom: 0; }

/* ---------- small screens ---------- */

@media (max-width: 1000px) {
  .dashboard { grid-template-columns: 1fr; }
  .analytics-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .app { flex-direction: column; }
  .sidebar { position: static; flex: none; height: auto; flex-direction: row; align-items: center; gap: 12px; padding: 10px 12px; }
  .brand span, .sidebar-foot, .collapse-btn { display: none; }
  .nav { flex-direction: row; }
  .topbar { position: static; padding: 12px 16px; flex-wrap: wrap; }
  .content { padding: 16px; }
  .clock { display: none; }
}

/* ---------- sidebar polish ---------- */

.sidebar { gap: 18px; padding: 22px 14px 16px; box-shadow: 4px 0 24px rgba(7, 22, 58, 0.25); }
.brand { padding: 0 6px 18px; border-bottom: 1px solid rgba(255, 255, 255, 0.12); }
.brand-mark { width: 38px; height: 38px; padding: 8px; background: rgba(255, 255, 255, 0.12); border-radius: 10px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 16px; letter-spacing: 0.01em; }
.brand-text small { font-size: 11px; font-weight: 500; color: rgba(255, 255, 255, 0.65); }
.nav-heading { padding: 0 10px; font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(255, 255, 255, 0.45); }
.nav { gap: 6px; }
.nav-link { padding: 11px 12px; border-radius: 10px; transition: background 0.15s ease, transform 0.15s ease, color 0.15s ease; }
.nav-link:hover { transform: translateX(3px); }
.nav-link.active { background: #ffffff; color: var(--navy); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25); }
.nav-link.active svg { color: var(--navy); }
.collapse-btn { margin-top: auto; justify-content: flex-start; border-radius: 10px; }
.sidebar-foot { padding: 10px 10px 0; border-top: 1px solid rgba(255, 255, 255, 0.12); }

.sidebar-collapsed .brand { padding-bottom: 14px; }
.sidebar-collapsed .brand-mark { width: 40px; height: 40px; }
.sidebar-collapsed .nav-heading,
.sidebar-collapsed .nav-text { display: none; }
.sidebar-collapsed .nav-link:hover { transform: none; }
@media (prefers-reduced-motion: reduce) { .nav-link, .sidebar { transition: none; } .nav-link:hover { transform: none; } }

/* ---------- table pop up ---------- */

.table-open { margin-top: 12px; }
.modal {
  width: min(560px, calc(100vw - 32px));
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(7, 22, 58, 0.35);
}
.modal::backdrop { background: rgba(7, 22, 58, 0.55); backdrop-filter: blur(2px); }
.modal[open] { display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; color: #ffffff; background: var(--navy); border-radius: 13px 13px 0 0; }
.modal-head h2 { font-size: 16px; font-weight: 600; }
.modal-close { display: grid; place-items: center; width: 30px; height: 30px; color: #ffffff; background: transparent; border: 0; border-radius: 8px; cursor: pointer; }
.modal-close:hover { background: var(--navy-active); }
.modal-close svg { width: 18px; height: 18px; }
.modal-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 12px 20px 0; font-size: 13px; color: var(--text-secondary); }
.modal-tools select { padding: 4px 8px; margin-left: 6px; }
.check { display: inline-flex; align-items: center; gap: 6px; }
.modal .table-scroll { padding: 8px 20px 0; max-height: 52vh; overflow-y: auto; }
.modal .data-table th { position: sticky; top: 0; background: var(--surface); }
.modal .data-table tfoot td { font-weight: 700; border-top: 2px solid var(--axis); border-bottom: 0; }
.modal-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 20px 18px; font-size: 13px; }
.pager { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- activity log table ---------- */

.log-scroll { max-height: 440px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.log-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.log-table th {
  position: sticky; top: 0; z-index: 1;
  padding: 10px 12px; text-align: left;
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: #ffffff; background: var(--navy);
}
.log-table td { padding: 8px 12px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
.log-table tbody tr:nth-child(even) { background: #f8f9fd; }
.log-table tbody tr { transition: background 0.12s ease; }
.log-table tbody tr:hover { background: #e8eefc; }
.log-table tbody tr:last-child td { border-bottom: 0; }
.log-table .num { text-align: right; }
.log-table tr.is-alert td:first-child { box-shadow: inset 3px 0 0 var(--critical); }
.log-time { white-space: nowrap; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.log-text { color: var(--text); }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill svg { width: 12px; height: 12px; stroke-width: 2.4; }
.pill-in { color: #1d4ed8; background: rgba(29, 78, 216, 0.10); }
.pill-out { color: #b45309; background: rgba(224, 112, 26, 0.14); }
.pill-alert { color: var(--critical-text); background: rgba(198, 47, 47, 0.10); }
.pill-event { color: var(--text-secondary); background: var(--grid); }

.log-empty { display: none; padding: 16px; text-align: center; color: var(--text-muted); }

/* filter by hiding rows, works after every refresh */
.log[data-filter="alert"] tbody tr:not([data-group="alert"]),
.log[data-filter="in"] tbody tr:not([data-group="in"]),
.log[data-filter="out"] tbody tr:not([data-group="out"]) { display: none; }

.segmented { display: inline-flex; padding: 3px; background: var(--grid); border-radius: 9px; }
.seg { font: inherit; font-size: 12px; padding: 4px 11px; color: var(--text-secondary); background: transparent; border: 0; border-radius: 7px; cursor: pointer; }
.seg:hover { color: var(--text); }
.seg.is-on { color: #ffffff; background: var(--navy); }
.seg:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- camera top row: tiles beside zones ---------- */

.top-row { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 3fr); gap: 16px; align-items: stretch; margin-bottom: 16px; }
.top-row > .card { margin: 0; max-height: 210px; overflow-y: auto; }
.top-row .tiles { height: 100%; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) { .top-row { grid-template-columns: 1fr; } .top-row .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- camera page v2: compact top row, log under video ---------- */

.top-row { align-items: stretch; gap: 14px; }
.top-row .tiles { gap: 10px; align-items: stretch; }
.top-row .tile { justify-content: center; padding: 10px 14px; gap: 1px; }
.top-row .tile-label { font-size: 12px; }
.top-row .tile-value { font-size: 24px; line-height: 1.15; }
.top-row .tile-note { font-size: 11px; }
.top-row > .card { max-height: 150px; padding: 12px 16px; }
.top-row .card-head { margin-bottom: 6px; }
.top-row .zone-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 20px; }
.top-row .zone-summary li { padding: 5px 0; flex-wrap: nowrap; }
.top-row .zone-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* one wide column: video, then log */
.dashboard.stacked { grid-template-columns: minmax(0, 1fr); }
.video-wrap { max-height: 520px; margin: 0 auto; }
@media (max-width: 1000px) { .top-row .zone-summary { grid-template-columns: 1fr; } .top-row > .card { max-height: 220px; } }

/* ---------- activity log v2: fixed columns, paging ---------- */

.log-scroll { max-height: none; }
.log .table-scroll { border: 1px solid var(--border); border-radius: 10px; overflow-x: auto; }
.log-table { table-layout: fixed; min-width: 560px; }
.log-table col.c-time { width: 130px; }
.log-table col.c-event { width: 120px; }
.log-table col.c-snap { width: 110px; }
.log-table th, .log-table td { text-align: left; }
.log-table th.center, .log-table td.center { text-align: center; }
.log-table td { height: 48px; }
.log-table .thumb { display: inline-block; vertical-align: middle; }
.log-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.log-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 12px; }
.log-size { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.log-size select { padding: 4px 8px; }
.log-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; font-size: 13px; }

/* in and out are plain black text, only alerts keep a badge */
.pill-in, .pill-out, .pill-event { padding: 0; font-weight: 500; color: var(--text); background: none; }

/* narrower tiles, wider zones, tiles aligned from the top */
.top-row { grid-template-columns: minmax(0, 11fr) minmax(0, 10fr); }
.top-row .tile { justify-content: flex-start; padding: 12px 14px; }
.top-row .zone-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1000px) { .top-row { grid-template-columns: 1fr; } }

/* tiles: same swatch on every label, content centred, one-line notes */
.swatch.series-net { background: var(--navy); }
.swatch.series-view { background: var(--good); }
.top-row .tile { justify-content: center; gap: 2px; }
.top-row .tile-label { min-height: 18px; }
.top-row .tile-value { min-height: 28px; }
.top-row .tile-note { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* log table: one font size, tidy column widths, text on one baseline */
.log-table { font-size: 14px; }
.log-table col.c-time { width: 150px; }
.log-table col.c-event { width: 100px; }
.log-table col.c-snap { width: 120px; }
.log-table th, .log-table td { padding-left: 16px; padding-right: 16px; vertical-align: middle; }
.log-table .pill-in, .log-table .pill-out, .log-table .pill-event { font-size: 14px; font-weight: 600; letter-spacing: 0; }
.log-time { font-weight: 400; }

/* ---------- zones page, management panel ---------- */

.zones-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 1000px) { .zones-layout { grid-template-columns: 1fr; } }

.zstats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.zstat { display: flex; flex-direction: column; padding: 10px 14px; background: var(--surface-raised); border: 1px solid var(--border); border-left: 3px solid var(--navy); border-radius: 8px; }
.zstat-num { font-size: 22px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.zstat-label { font-size: 12px; color: var(--text-muted); }
.zstat-warn { border-left-color: var(--warning); }
.zstat-warn .zstat-num { color: var(--warning); }

.zone-tools { display: flex; gap: 8px; margin-bottom: 12px; }
.zone-search { flex: 1; min-width: 0; }

.zone-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px 16px; text-align: center; color: var(--text-muted); border: 1px dashed var(--axis); border-radius: 10px; }
.zone-empty svg { width: 36px; height: 36px; color: var(--navy); }
.zone-empty strong { color: var(--text); }

.zone-items { display: flex; flex-direction: column; gap: 10px; }
.zone { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 1px 2px rgba(11, 31, 75, 0.05); transition: box-shadow 0.15s ease, border-color 0.15s ease; }
.zone:hover { border-color: var(--axis); box-shadow: 0 4px 14px rgba(11, 31, 75, 0.10); }
.zone[open] { border-color: var(--navy); }
.zone[hidden] { display: none; }
.zone summary { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; list-style: none; }
.zone summary::-webkit-details-marker { display: none; }
.zone summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 10px; }
.zone-dot { width: 10px; height: 10px; flex: none; border-radius: 3px; background: #e07b00; }
.zone-title { display: flex; flex-direction: column; min-width: 0; margin-right: auto; }
.zone-title strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zone-title small { font-size: 12px; color: var(--text-muted); }
.zone-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.zone-caret { width: 18px; height: 18px; flex: none; color: var(--text-muted); transition: transform 0.2s ease; }
.zone[open] .zone-caret { transform: rotate(180deg); }

.status { padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status-on { color: #0b6b2b; background: rgba(15, 157, 58, 0.12); }
.status-off { color: var(--text-secondary); background: var(--grid); }
.status-warn { color: #8a5a00; background: rgba(217, 138, 0, 0.16); }

.zone-body { padding: 4px 14px 14px; border-top: 1px solid var(--grid); }
.zone-sub { margin: 14px 0 8px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }

.rule-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rule-table th { text-align: left; padding: 6px 8px; font-size: 11px; font-weight: 600; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.rule-table td { padding: 8px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
.rule-table .center { text-align: center; width: 44px; }
.rule-type { font-weight: 600; }

.icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; color: var(--text-muted); background: transparent; border: 1px solid transparent; border-radius: 8px; cursor: pointer; }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--surface-raised); border-color: var(--border); }
.icon-btn.danger:hover { color: var(--critical-text); background: rgba(198, 47, 47, 0.08); border-color: rgba(198, 47, 47, 0.3); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.rule-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.rule-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-secondary); }
.rule-form select, .rule-form input { width: 100%; }
.rule-form input:disabled { background: var(--surface-raised); color: var(--text-muted); cursor: not-allowed; }
@media (max-width: 560px) { .rule-form { grid-template-columns: 1fr; } }

.zone-actions { display: flex; justify-content: flex-end; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--grid); }
.zone-nomatch { padding: 12px 0; }

/* zones page v2: draw area fits the screen, zone list underneath */
.zones-layout { grid-template-columns: minmax(0, 1fr); }
.zones-layout .snapshot-wrap {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
}
.zones-layout .snapshot-wrap img {
  width: auto;
  max-width: 100%;
  /* leave room for header, toolbar and save row */
  max-height: calc(100vh - 290px);
  min-height: 240px;
}
.zones-layout .snapshot-wrap.no-picture {
  width: min(100%, calc((100vh - 290px) * 16 / 9));
}
.zones-layout .toolbar, .zones-layout .form-row { justify-content: center; }

/* zone marking tile beside the picture, zone list underneath */
.zones-layout { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
.zones-layout .zones-col { grid-column: 1 / -1; }
.zones-layout .snapshot-wrap img { max-height: calc(100vh - 190px); }
.zones-layout .snapshot-wrap.no-picture { width: min(100%, calc((100vh - 190px) * 16 / 9)); }
.marking { position: sticky; top: 76px; }
.marking-steps { margin: 0 0 14px; padding-left: 18px; font-size: 13px; color: var(--text-secondary); display: flex; flex-direction: column; gap: 4px; }
.marking-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.marking-form { display: flex; flex-direction: column; gap: 6px; padding-top: 14px; border-top: 1px solid var(--grid); }
.marking-form label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.marking-form input { width: 100%; }
.marking-form .button { justify-content: center; margin-top: 6px; }
@media (max-width: 1000px) { .zones-layout { grid-template-columns: 1fr; } .marking { position: static; } }

/* zone marking tile: same height as the draw card, more detail */
.zones-layout { align-items: stretch; }
.zones-layout .zones-col { align-self: start; }
.marking-col { display: flex; }
.marking-col .marking { position: static; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.marking-meta { margin: -4px 0 12px; font-size: 12px; color: var(--text-muted); }

.checklist { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.checklist li { display: flex; align-items: center; gap: 10px; }
.tick { position: relative; flex: none; width: 18px; height: 18px; border: 2px solid var(--axis); border-radius: 50%; transition: background 0.15s ease, border-color 0.15s ease; }
.checklist li.is-done { color: var(--text); }
.checklist li.is-done .tick { background: var(--good); border-color: var(--good); }
.checklist li.is-done .tick::after { content: ""; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px; border: solid #ffffff; border-width: 0 2px 2px 0; transform: rotate(45deg); }

.marking-sub { margin: 16px 0 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.corner-list { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 80px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-raised); }
.corner-list li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 12px; font-size: 13px; border-bottom: 1px solid var(--grid); }
.corner-list li:last-child { border-bottom: 0; }
.corner-xy { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.corner-list .corner-empty { justify-content: center; color: var(--text-muted); padding: 14px 12px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 12px; color: var(--text-secondary); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-new { background: #1d6fe0; }
.legend-saved { background: #e07b00; }
.marking-tip { margin-top: 8px; font-size: 12px; color: var(--text-muted); }

.marking-form { margin-top: 14px; }
input.is-invalid { border-color: var(--critical); }

/* marking tile never taller than the draw card, list scrolls inside */
.zones-layout { grid-template-columns: minmax(0, 1fr) 300px; }
.marking-col { position: relative; min-height: 520px; }
.marking-col .marking { position: absolute; inset: 0; flex: none; overflow: hidden; padding: 14px 16px; }
.marking-col .corner-list { flex: 1 1 0; min-height: 0; }
.marking-col .checklist { gap: 6px; margin-bottom: 10px; }
.marking-col .marking-tools { margin-bottom: 4px; }
.marking-col .marking-form { margin-top: 12px; padding-top: 12px; }
@media (max-width: 1000px) {
  .marking-col { min-height: 0; }
  .marking-col .marking { position: static; }
  .marking-col .corner-list { flex: none; min-height: 80px; max-height: 160px; }
}

/* both tiles fill the same row height exactly */
.zones-layout > .column:not(.zones-col) { align-self: stretch; }
.zones-layout > .column:not(.zones-col) > .card { height: 100%; }
.zones-layout > .column:first-child .snapshot-wrap { margin-top: 4px; }

/* picture sits in the middle of the draw card, both ways */
.zones-layout > .column:first-child > .card { display: flex; flex-direction: column; }
.zones-layout > .column:first-child .snapshot-wrap { margin: auto; }

/* v3: both tiles share one fixed, shorter height */
.zones-layout { --tile-h: clamp(460px, calc(100vh - 220px), 540px); }
.zones-layout > .column:not(.zones-col) { height: var(--tile-h); min-height: 0; align-self: start; }
.zones-layout > .column:not(.zones-col) > .card { height: 100%; }
.marking-col { min-height: 0; }
.zones-layout .snapshot-wrap img { max-height: calc(var(--tile-h) - 110px); min-height: 0; }
.zones-layout .snapshot-wrap.no-picture { width: min(100%, calc((var(--tile-h) - 110px) * 16 / 9)); }
@media (max-width: 1000px) {
  .zones-layout > .column:not(.zones-col) { height: auto; }
  .zones-layout .snapshot-wrap img { max-height: 60vh; }
}

/* ---------- module screens: picker, status, live player ---------- */

.topbar-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 14px; }
.picker { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.picker select { max-width: 220px; }
.camera-status { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.camera-status .status { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.video-wrap iframe { width: 100%; height: 100%; border: 0; display: block; }
.video-wrap.is-offline iframe { visibility: hidden; }

.module-data { display: flex; flex-direction: column; gap: 16px; margin-bottom: 16px; }
.module-data .analytics-grid { margin: 0; }
.tiles.wide { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) { .tiles.wide { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile-alert { border-top: 3px solid var(--critical); }
.tile-alert .tile-value { color: var(--critical-text); }
.tile-time { font-size: 20px; line-height: 1.7; }

.notice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.module-data > .error, .module-data > .notice { margin: 0; }
.log-table col.c-act { width: 130px; }

/* ---------- evacuation: who is where ---------- */

.run-bar { display: block; height: 6px; margin-bottom: 12px; }
.roll { list-style: none; margin: 0; padding: 0; }
.roll li { padding: 10px 0; border-bottom: 1px solid var(--grid); }
.roll li:last-child { border-bottom: 0; }
.roll-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin-bottom: 6px; font-size: 13px; }
.last-run { margin-top: 10px; }

/* ---------- face recognition: people ---------- */

.people-card { margin-top: 16px; }
.person-form { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: 10px; align-items: end; margin-bottom: 14px; }
.person-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-secondary); }
.person-form input, .person-form select { width: 100%; }
@media (max-width: 800px) { .person-form { grid-template-columns: 1fr; } }
#face-task:not(:empty) { margin-bottom: 14px; }
#face-task .error { margin-bottom: 0; }
.people-table td { vertical-align: middle; }
.photo-form { display: flex; align-items: center; gap: 8px; }
.photo-form input[type="file"] { max-width: 230px; padding: 4px 6px; font-size: 12px; }
.photo-chip { display: inline-flex; align-items: center; gap: 2px; }
.photo-chip .icon-btn { width: 20px; height: 20px; padding: 2px; }
.photo-chip .icon-btn svg { width: 12px; height: 12px; }

/* ---------- zones: extra fields per shape ---------- */

.marking-extra { display: flex; flex-direction: column; gap: 6px; }
.marking-extra[hidden] { display: none; }
.marking-form select { width: 100%; }

/* long evacuation text may wrap inside tables */
.data-table .status { white-space: normal; display: inline-block; }

/* ---------- overview v2: module cards, paged alert list ---------- */

.module-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
@media (max-width: 1100px) { .module-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.module-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  color: var(--text);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--navy);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(11, 31, 75, 0.05);
}
.module-card:hover { border-color: var(--axis); border-left-color: var(--accent); }
.module-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.module-card.is-alert { border-left-color: var(--critical); }
.module-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; }
.module-card-head small { font-size: 11px; font-weight: 400; color: var(--text-muted); white-space: nowrap; }
.module-card-value { font-size: 22px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.module-card-value small { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.module-card.is-alert .module-card-value { color: var(--critical-text); }
.module-card-note { font-size: 12px; color: var(--text-muted); }

/* chart and alert list are one row: same height, pager pinned to the bottom */
.analytics-grid { align-items: stretch; }
.analytics-grid > .card { display: flex; flex-direction: column; }
.analytics-grid > .card > .chart { flex: 1; }
.paged-card .bar-list { flex: 1; justify-content: flex-start; gap: 0; }
.paged-card .bar-list li { grid-template-columns: 130px minmax(0, 1fr) 36px 84px; padding: 11px 0; border-bottom: 1px solid var(--grid); }
.paged-card .bar-list li[hidden] { display: none; }
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-num { text-align: right; }
.bar-open { font-size: 12px; text-align: right; color: var(--text-muted); white-space: nowrap; }
.bar-open.has-open { color: var(--critical-text); font-weight: 600; }
.paged-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; font-size: 13px; }
.paged-foot .pager { align-items: center; gap: 8px; }

/* ---------- log table v3: event is plain text, columns do not collide ---------- */

.log-table col.c-time { width: 140px; }
.log-table col.c-event { width: 160px; }
.log-table col.c-snap { width: 120px; }
.log-table col.c-act { width: 150px; }
.log-table .pill { padding: 0; background: none; font-size: 14px; font-weight: 600; letter-spacing: 0; }
.log-table .pill-alert { color: var(--critical-text); }
.log-table td { overflow: hidden; text-overflow: ellipsis; }
.data-table .chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }

/* ---------- module screen order: tiles, video, details, log ---------- */

.module-stack { display: flex; flex-direction: column; gap: 16px; }
.module-stack .module-data { margin-bottom: 0; }
.module-stack .module-data:empty { display: none; }

/* ---------- long menu names wrap; five module cards ---------- */

.nav-link { align-items: flex-start; }
.nav-link svg { flex: none; margin-top: 1px; }
.nav-text { white-space: normal; line-height: 1.3; }
.topbar-title h1 { line-height: 1.25; }
.module-cards { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1300px) { .module-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 800px) { .module-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.module-card-head { align-items: flex-start; }

/* ---------- status tile and evidence picture ---------- */

.tile-good .tile-value { color: var(--good); }
.tile-good { border-top: 3px solid var(--good); }
.evidence { display: block; line-height: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #000; }
.evidence img { width: 100%; max-height: 300px; object-fit: contain; display: block; }
.evidence-text { margin-top: 8px; font-size: 13px; color: var(--text-secondary); }

/* ---------- cameras screen ---------- */

.camera-table td { vertical-align: middle; }
.source-text { display: inline-block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.row-actions { white-space: nowrap; }
.row-actions .button { margin-left: 4px; }
.camera-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; align-items: end; }
.camera-form > label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-secondary); }
.camera-form > label[hidden] { display: none; }
.camera-form input[type="text"], .camera-form input[type="number"], .camera-form select { width: 100%; }
.camera-flags { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; }
.camera-flags legend { padding: 0 6px; font-size: 12px; color: var(--text-secondary); }
.camera-flags .check { font-size: 13px; color: var(--text); }
.camera-form-foot { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
@media (max-width: 800px) { .camera-form { grid-template-columns: 1fr; } }
#camera-error .error { margin-bottom: 12px; }

/* ---------- videos screen ---------- */

.upload-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.upload-form input[type="file"] { flex: 1; min-width: 240px; max-width: 520px; }
.upload-note { margin-top: 10px; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }
.video-table td { vertical-align: middle; }
.video-cell { display: flex; align-items: center; gap: 12px; }
.video-thumb { flex: none; width: 96px; height: 54px; object-fit: cover; background: #000; border: 1px solid var(--border); border-radius: 6px; }
.video-thumb-empty { display: inline-block; background: var(--grid); }
.video-error-text { display: inline-block; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#video-error .error { margin-bottom: 12px; }
.player-modal { width: min(960px, 92vw); padding: 0; }
.player-modal video { display: block; width: 100%; max-height: 76vh; background: #000; border-radius: 0 0 13px 13px; }

/* ---------- edit forms: zones, rules, people ---------- */

.form-buttons { display: inline-flex; gap: 6px; align-items: center; }
.rule-actions { white-space: nowrap; }
.rule-form { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.rule-form .form-buttons { align-self: end; }
.zone-actions { gap: 8px; }
.marking-form #cancel-edit { justify-content: center; margin-top: 0; }
.camera-rules-title { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--grid); }
.camera-rule { margin-top: 10px; padding: 12px; background: var(--surface-raised); border: 1px solid var(--border); border-radius: 8px; }
.rule-hint { font-size: 12px; align-self: end; padding-bottom: 8px; }
.person-form { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) auto; }

/* ---------- log out, in the side menu ---------- */

.logout-form { margin-top: auto; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, 0.12); display: flex; flex-direction: column; gap: 2px; }
.logout-user { padding: 0 12px; font-size: 12px; color: rgba(255, 255, 255, 0.6); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-btn { width: 100%; font: inherit; text-align: left; background: transparent; border: 0; cursor: pointer; }
.logout-form + .collapse-btn { margin-top: 6px; }
.sidebar-collapsed .logout-btn { justify-content: center; }

/* ---------- login page ---------- */

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(160deg, var(--navy-deep) 0%, var(--navy) 55%, #16357a 100%); }
.login-card { width: min(400px, 100%); padding: 32px 28px 28px; background: var(--surface); border-radius: 16px; box-shadow: 0 24px 60px rgba(4, 12, 34, 0.45); }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 22px; text-align: center; }
.login-mark { width: 52px; height: 52px; padding: 12px; margin-bottom: 8px; color: #ffffff; background: var(--navy); border-radius: 14px; }
.login-brand h1 { font-size: 20px; font-weight: 700; }
.login-brand p { font-size: 13px; color: var(--text-muted); }
.login-form { display: flex; flex-direction: column; gap: 6px; }
.login-form label { margin-top: 8px; font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.login-form input { width: 100%; padding: 10px 12px; font-size: 15px; }
.password-field { position: relative; }
.password-field input { padding-right: 64px; }
.password-toggle { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); padding: 5px 9px; font: inherit; font-size: 12px; font-weight: 600; color: var(--accent); background: transparent; border: 0; border-radius: 6px; cursor: pointer; }
.password-toggle:hover { background: var(--surface-raised); }
.password-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.login-submit { justify-content: center; margin-top: 18px; padding: 11px 12px; font-size: 15px; }
.login-card .error { margin-bottom: 4px; }

/* ---------- log out, top right ---------- */

.topbar-user { display: inline-flex; align-items: center; gap: 10px; padding-left: 14px; border-left: 1px solid var(--border); white-space: nowrap; }
.topbar-user-name { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); }
.topbar-user svg { width: 15px; height: 15px; }
.topbar-user .button { gap: 6px; padding: 5px 11px; }
@media (max-width: 700px) { .topbar-user-name { display: none; } }
