/* ============================================================
   TCSS Design System — Global Styles
   ============================================================ */

:root {
  /* Background layers */
  --bg-base:      #070b14;
  --bg-surface:   #0b1120;
  --bg-elevated:  #0f1729;
  --bg-overlay:   #142038;
  --bg-hover:     rgba(255, 255, 255, 0.035);
  --bg-active:    rgba(14, 165, 233, 0.07);

  /* Borders */
  --border:       #182135;
  --border-muted: #0f1729;
  --border-focus: rgba(14, 165, 233, 0.5);

  /* Text — tiers stay bright→dim, but muted/subtle were too low-contrast on
     the dark-blue surface (~3.9:1 and ~1.8:1) to read as caption text. Bumped
     one slate step each: muted #64748b→#94a3b8 (~7.3:1), subtle #334155→#64748b
     (~3.9:1). */
  --text:         #cbd5e1;
  --text-strong:  #e2e8f0;
  --text-muted:   #94a3b8;
  --text-subtle:  #64748b;

  /* Accent — sky blue */
  --accent:       #0ea5e9;
  --accent-light: #38bdf8;
  --accent-dim:   rgba(14, 165, 233, 0.12);
  --accent-glow:  rgba(14, 165, 233, 0.25);

  /* Semantic */
  --success:      #22c55e;
  --success-dim:  rgba(34, 197, 94, 0.1);
  --warning:      #f59e0b;
  --warning-dim:  rgba(245, 158, 11, 0.1);
  --error:        #ef4444;
  --error-dim:    rgba(239, 68, 68, 0.1);

  /* Severity */
  --sev-critical: #dc2626;
  --sev-high:     #ea580c;
  --sev-medium:   #d97706;
  --sev-low:      #16a34a;
  --sev-info:     #0284c7;

  /* Sidebar */
  --sidebar-w:    240px;
  --sidebar-col:  64px;
  --topbar-h:     52px;

  /* Radii */
  --r-sm:   4px;
  --r:      6px;
  --r-lg:   10px;
  --r-xl:   14px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow:    0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);

  /* Typography */
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  /* Transitions */
  --ease: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: 200ms cubic-bezier(0, 0, 0.2, 1);

  /* ── Responsive design tokens ──────────────────────────────
     Breakpoints are duplicated in src/hooks/useBreakpoint.ts;
     keep both in sync when changing.
       phone:   < 768  (the only breakpoint historically tested)
       tablet:  768  – 1023
       desktop: 1024 – 1399
       wide:    >= 1400
     We use max-width queries to match the existing codebase
     convention (the legacy media queries at the bottom of this
     file are also max-width). ───────────────────────────── */
  --bp-phone:    480px;
  --bp-tablet:   768px;
  --bp-desktop:  1024px;
  --bp-wide:     1400px;

  /* Spacing scale — page padding, gaps, card padding all
     pull from these so phones get tighter layouts for free. */
  --space-xs:   4px;
  --space-sm:   8px;
  --space-md:  12px;
  --space-lg:  16px;
  --space-xl:  20px;
  --space-2xl: 24px;

  /* Typography scale */
  --font-xs:   10px;
  --font-sm:   11px;
  --font-md:   12px;
  --font-lg:   13px;
  --font-xl:   15px;
  --font-2xl:  18px;
  --font-3xl:  24px;

  /* Minimum tap target for any control on a touch device */
  --tap-min:   44px;
}

/* On phones, tighten the spacing/typography scale so page
   chrome stops eating screen real estate. */
@media (max-width: 767px) {
  :root {
    --space-lg:  12px;
    --space-xl:  14px;
    --space-2xl: 16px;
    --font-xl:   14px;
    --font-2xl:  16px;
    --font-3xl:  20px;
  }
}

/* ── Reset ───────────────────────────────────────────────── */

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

html, body, #root {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-light); }

img, svg { display: block; }

/* ── Scrollbars ──────────────────────────────────────────── */

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #1e2d45; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #2a3d5a; }

/* ── Buttons (reset) ─────────────────────────────────────── */

button {
  font-family: var(--font);
  font-size: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
  border-radius: var(--r);
  line-height: 1;
  transition: background var(--ease), color var(--ease), border-color var(--ease), opacity var(--ease);
}

button:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* ── Form elements ───────────────────────────────────────── */

input, select, textarea {
  font-family: var(--font);
  font-size: 12px;
  background: var(--bg-surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 6px 10px;
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
  width: 100%;
}

input[type="checkbox"], input[type="radio"] {
  width: auto;
  padding: 0;
  border: none;
  background: none;
  flex-shrink: 0;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

/* ── Typography ──────────────────────────────────────────── */

h1, h2, h3, h4, h5, h6 { color: var(--text-strong); font-weight: 600; line-height: 1.3; }

/* ── Utility classes ─────────────────────────────────────── */

.tcss-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--ease), border-color var(--ease), color var(--ease);
}
.tcss-btn:hover { background: var(--bg-overlay); border-color: #253554; color: var(--text-strong); }
.tcss-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.tcss-btn-primary:hover { background: var(--accent-light); border-color: var(--accent-light); }
.tcss-btn-danger { background: var(--error-dim); border-color: rgba(239,68,68,0.3); color: var(--error); }
.tcss-btn-danger:hover { background: rgba(239,68,68,0.2); }
.tcss-btn-sm { padding: 4px 10px; font-size: 11px; }

.tcss-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
}

.tcss-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.tcss-card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tcss-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.tcss-table th {
  padding: 8px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.tcss-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-muted);
  color: var(--text);
  vertical-align: middle;
}

.tcss-table tr:last-child td { border-bottom: none; }
.tcss-table tbody tr:hover td { background: var(--bg-hover); }

.tcss-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge-critical { background: rgba(220,38,38,0.15); color: #fca5a5; border: 1px solid rgba(220,38,38,0.25); }
.badge-high     { background: rgba(234,88,12,0.15);  color: #fdba74; border: 1px solid rgba(234,88,12,0.25); }
.badge-medium   { background: rgba(217,119,6,0.15);  color: #fcd34d; border: 1px solid rgba(217,119,6,0.25); }
.badge-low      { background: rgba(22,163,74,0.15);  color: #86efac; border: 1px solid rgba(22,163,74,0.25); }
.badge-info     { background: rgba(2,132,199,0.15);  color: #7dd3fc; border: 1px solid rgba(2,132,199,0.25); }
.badge-online   { background: rgba(34,197,94,0.12);  color: #4ade80; border: 1px solid rgba(34,197,94,0.2); }
.badge-offline  { background: rgba(239,68,68,0.12);  color: #f87171; border: 1px solid rgba(239,68,68,0.2); }

.tcss-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: var(--r-full);
  font-size: 10px;
  font-weight: 500;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.tcss-stat {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.03em;
  line-height: 1;
}

.tcss-label {
  font-size: 10px;
  font-weight: 600;
  /* Caption labels: use --text-muted (~7.3:1), not --text-subtle — at 10px
     uppercase the faintest tier is unreadable on the dark-blue surface. */
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tcss-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

.tcss-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 13px;
}

.tcss-empty svg { opacity: 0.3; }

.dot-online  { width: 7px; height: 7px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.dot-offline { width: 7px; height: 7px; border-radius: 50%; background: var(--error);   flex-shrink: 0; }
.dot-warn    { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); flex-shrink: 0; }

/* Pulse animation for active alarms */
@keyframes pulse-ring {
  0%   { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(2.2); }
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slide-in {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.anim-fade-in { animation: fade-in 200ms ease-out both; }

/* Tabs */
.tcss-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 3px;
}

.tcss-tab {
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
  white-space: nowrap;
}

.tcss-tab:hover { color: var(--text); background: var(--bg-hover); }
.tcss-tab.active { background: var(--bg-overlay); color: var(--text-strong); font-weight: 600; }

/* Filter bar */
.tcss-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 0;
}

/* Progress/bar chart */
.tcss-bar-track {
  height: 6px;
  background: var(--bg-overlay);
  border-radius: var(--r-full);
  overflow: hidden;
}
.tcss-bar-fill {
  height: 100%;
  border-radius: var(--r-full);
  transition: width 0.4s var(--ease-out);
}

/* Mono text */
.mono { font-family: var(--font-mono); font-size: 11px; }

/* Truncate */
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Page layout */
.page {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  padding: 20px 24px;
  gap: 20px;
  min-height: 0;
}

.page-fill {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Section header inside a page */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* Grid layouts */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }

@media (max-width: 1400px) { .grid-4 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 750px)  { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

/* Placeholder loading shimmer */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-elevated) 50%, var(--bg-surface) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: var(--r);
}

/* ── LiveView component ──────────────────────────────────── */
.live-view {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: #000;
}
.live-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
}
.live-view-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-strong);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.live-view-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.video-container {
  flex: 1;
  min-height: 0;
  position: relative;
  background: #000;
  overflow: hidden;
}
.video-container video,
.video-container img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

/* Compact mode — fills the parent container (position: relative) */
.live-view-compact {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #000;
}
.live-view-compact video,
.live-view-compact img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.compact-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 6px 8px;
  z-index: 1;
  pointer-events: none;
}
.compact-name {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 75%;
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 3px;
}
.status-dot.playing    { background: var(--success); box-shadow: 0 0 5px rgba(34,197,94,0.6); }
.status-dot.connecting { background: var(--warning); }
.status-dot.error      { background: var(--error); }
.status-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--r-full);
  letter-spacing: 0.04em;
}
.status-badge.playing    { background: var(--success-dim); color: var(--success); border: 1px solid rgba(34,197,94,0.25); }
.status-badge.connecting { background: var(--warning-dim); color: var(--warning); border: 1px solid rgba(245,158,11,0.25); }
.status-badge.error      { background: var(--error-dim);   color: var(--error);   border: 1px solid rgba(239,68,68,0.25); }

/* ── NOC video slot ──────────────────────────────────────── */
.noc-slot {
  position: relative;
  overflow: hidden;
  background: #000;
  border: 1px solid #111;
  cursor: pointer;
  user-select: none;
  transition: border-color var(--ease), box-shadow var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}
.noc-slot:hover { border-color: #253554; }
.noc-slot.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 12px rgba(14,165,233,0.2);
}
.noc-slot.drag-over {
  border-color: var(--accent);
  background: var(--bg-active);
  box-shadow: 0 0 0 2px var(--accent), inset 0 0 20px rgba(14,165,233,0.08);
}
.noc-slot .slot-expand-hint {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--r-sm);
  padding: 3px 7px;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.04em;
  opacity: 0;
  transition: opacity 150ms;
  pointer-events: none;
}
.noc-slot:hover .slot-expand-hint { opacity: 1; }

/* Hide the LiveView compact-overlay camera name in slots — the bottom bar handles it */
.noc-slot .compact-overlay .compact-name { display: none; }
.noc-slot .compact-overlay { justify-content: flex-end; padding: 6px 8px; }

/* ── Modal overlay ───────────────────────────────────────── */
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.noc-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(5px);
  animation: fade-in 160ms ease-out both;
}
.noc-modal {
  width: min(1160px, 96vw);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: 0 32px 80px rgba(0,0,0,0.75), 0 0 0 1px rgba(255,255,255,0.04);
  display: flex;
  flex-direction: column;
  animation: modal-in 200ms cubic-bezier(0.16,1,0.3,1) both;
}

/* ── Asset list camera row ───────────────────────────────── */
.asset-row {
  padding: 7px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: grab;
  border-bottom: 1px solid var(--border-muted);
  border-left: 2px solid transparent;
  transition: background var(--ease), border-color var(--ease);
}
.asset-row:active { cursor: grabbing; }
.asset-row:hover { background: var(--bg-hover); }
.asset-row.active {
  background: var(--bg-active);
  border-left-color: var(--accent);
}

/* ── Severity color tokens ───────────────────────────────── */
.text-critical { color: #fca5a5; }
.text-high     { color: #fdba74; }
.text-medium   { color: #fcd34d; }
.text-low      { color: #86efac; }
.text-info     { color: #7dd3fc; }
.text-success  { color: #4ade80; }
.text-error    { color: #f87171; }
.text-accent   { color: var(--accent); }
.text-muted    { color: var(--text-muted); }
.text-strong   { color: var(--text-strong); }

/* Login page — hide hero panel on narrow viewports */
@media (max-width: 900px) {
  .login-hero { display: none !important; }
}

/* ════════════════════════════════════════════════════════════
   Responsive utility classes
   ────────────────────────────────────────────────────────────
   These let inline-style page components opt into responsive
   behavior without writing custom media queries. The class
   names are explicit about *which* breakpoint they target so
   it's obvious at a glance what happens on which device.
   ════════════════════════════════════════════════════════════ */

/* ── Visibility ─────────────────────────────────────────────
   .hide-phone        — hidden < 768px
   .show-phone-only   — visible only < 768px
   .hide-tablet-down  — hidden < 1024px (phones AND tablets)
   .hide-desktop-up   — hidden >= 1024px */
@media (max-width: 767px) {
  .hide-phone { display: none !important; }
}
@media (min-width: 768px) {
  .show-phone-only { display: none !important; }
}
@media (max-width: 1023px) {
  .hide-tablet-down { display: none !important; }
}
@media (min-width: 1024px) {
  .hide-desktop-up { display: none !important; }
}

/* ── Layout transforms ──────────────────────────────────────
   .stack-on-phone — turn a flex/grid row into a column on
                     phones, with each child taking full width.
                     Useful for two-pane page layouts that must
                     reflow into a single column.
   .stack-on-tablet — same idea but kicks in below 1024px so
                     tablet portrait gets stacked too. */
@media (max-width: 767px) {
  .stack-on-phone {
    display: flex !important;
    flex-direction: column !important;
  }
  .stack-on-phone > * { width: 100% !important; min-width: 0 !important; }
}
@media (max-width: 1023px) {
  .stack-on-tablet {
    display: flex !important;
    flex-direction: column !important;
  }
  .stack-on-tablet > * { width: 100% !important; min-width: 0 !important; }
}

/* ── Horizontal overflow guards ─────────────────────────────
   .scroll-x-on-phone — wrap any fixed-width table or grid in
                        this on phones it scrolls horizontally
                        instead of breaking the page layout. */
@media (max-width: 767px) {
  .scroll-x-on-phone {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ── Touch-friendly tap targets ─────────────────────────────
   Anything an officer / field user must tap should clear the
   44×44 px minimum. Apply to icon buttons & nav controls. */
.tap-target {
  min-height: var(--tap-min);
  min-width:  var(--tap-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Modal width responsive helper ──────────────────────────
   The .noc-modal class already uses min(1160px, 96vw); this
   helper provides smaller defaults for narrower dialogs. */
.modal-sm  { width: min(420px,  96vw) !important; }
.modal-md  { width: min(640px,  96vw) !important; }
.modal-lg  { width: min(960px,  96vw) !important; }
.modal-xl  { width: min(1280px, 96vw) !important; }

/* ── Page padding shrinks on phones ─────────────────────────
   The .page utility already exists (line ~393); we tighten it
   on small screens so the content gets more room. */
@media (max-width: 767px) {
  .page {
    padding: var(--space-md) var(--space-md);
    gap: var(--space-md);
  }
  .tcss-card { padding: var(--space-md); }
}

/* ── Section header wraps cleanly on phones ──────────────── */
@media (max-width: 767px) {
  .section-header { gap: var(--space-sm); }
}

/* ── Filter bars on phones ──────────────────────────────────
   .tcss-filter-bar already uses flex-wrap; add some breathing
   room so dropdowns/inputs don't crowd each other. */
@media (max-width: 767px) {
  .tcss-filter-bar { gap: var(--space-sm); padding: var(--space-sm) 0; }
  .tcss-filter-bar > * { flex: 1 1 auto; min-width: 0; }
  .tcss-filter-bar input,
  .tcss-filter-bar select {
    min-height: 36px; /* easier to tap, still compact */
  }
}

/* ── Form inputs get a touch-friendly minimum on phones ──── */
@media (max-width: 767px) {
  input, select, textarea {
    font-size: 14px; /* prevents iOS auto-zoom on focus (< 16px triggers it) */
    padding: 8px 10px;
  }
}

/* ── Buttons get larger tap area on phones ──────────────── */
@media (max-width: 767px) {
  .tcss-btn { padding: 8px 14px; font-size: 13px; min-height: 36px; }
  .tcss-btn-sm { padding: 6px 10px; font-size: 12px; min-height: 32px; }
}

/* ── Drop the .grid-auto min-column on phones ─────────────
   The 220px minmax inherits desktop assumptions; on phones,
   stack single column to avoid 180px-wide unreadable cards. */
@media (max-width: 480px) {
  .grid-auto { grid-template-columns: 1fr; }
}

/* ── Stat numbers shrink on phones ──────────────────────── */
@media (max-width: 767px) {
  .tcss-stat { font-size: 22px; }
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0a0a0a;
  --bg-2: #111;
  --bg-3: #1a1a1a;
  --border: #222;
  --text: #e0e0e0;
  --text-dim: #888;
  --accent: #4fc3f7;
  --accent-hover: #29b6f6;
  --danger: #ef5350;
  --success: #4caf50;
  --warn: #ff9800;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ── Header ─────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 48px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-logo {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
}

.app-name {
  font-size: 13px;
  color: var(--text-dim);
}

.version {
  font-size: 11px;
  color: #555;
  background: var(--bg-3);
  padding: 2px 8px;
  border-radius: 4px;
}

/* ── Tab navigation ──────────────────────────── */
.tab-nav {
  display: flex;
  gap: 4px;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 6px 16px;
  font-size: 13px;
  cursor: pointer;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.tab-btn:hover {
  color: var(--text);
  background: var(--bg-3);
}

.tab-btn.active {
  color: var(--accent);
  background: #4fc3f715;
  font-weight: 600;
}

/* ── Layout ──────────────────────────────────── */
.app-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.sidebar {
  width: 260px;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
}

.main-content {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #555;
  font-size: 15px;
}

/* ── Alarm badge on tab ──────────────────────── */
.alarm-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ── SSE live status ─────────────────────────── */
.sse-status {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

.sse-status.live { color: var(--success); }
.sse-status.connecting { color: var(--warn); }
.sse-status.offline { color: #555; }

/* ── Stream Manager ──────────────────────────── */
.stream-manager-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.stream-manager-header h2 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
}

.btn-add {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.btn-add:hover { background: #4fc3f720; }

.add-stream-form {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  border-bottom: 1px solid var(--border);
}

.add-stream-form input {
  background: var(--bg-3);
  border: 1px solid #333;
  color: var(--text);
  padding: 7px 10px;
  border-radius: 4px;
  font-size: 12px;
}

.add-stream-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.error { color: var(--danger); font-size: 12px; }

.btn-primary {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 7px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
}

.btn-primary:hover { background: var(--accent-hover); }

.stream-list { list-style: none; }

.stream-item {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #161616;
}

.stream-name {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
}

.stream-name:hover { background: #1a1a2e; color: var(--accent); }

.btn-remove {
  background: none;
  border: none;
  color: #444;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
}

.btn-remove:hover { color: var(--danger); }

.no-streams {
  padding: 20px 14px;
  color: #555;
  font-size: 12px;
  text-align: center;
}

/* ── Live View ───────────────────────────────── */
.live-view {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.live-view-compact {
  position: relative;
  width: 100%;
  height: 100%;
}

.live-view-compact video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

.compact-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.7), transparent);
  z-index: 2;
  pointer-events: none;
}

.compact-name {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.status-dot.connecting { background: var(--warn); }
.status-dot.playing { background: var(--success); }
.status-dot.error { background: var(--danger); }

.live-view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}

.live-view-header h3 {
  font-size: 14px;
  font-weight: 500;
}

.live-view-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge.connecting { background: #ff980020; color: var(--warn); }
.status-badge.playing { background: #4caf5020; color: var(--success); }
.status-badge.error { background: #ef535020; color: var(--danger); }

.live-view-controls select {
  background: var(--bg-3);
  border: 1px solid #333;
  color: var(--text);
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 12px;
}

.video-container {
  flex: 1;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.video-container video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ── Video Grid ──────────────────────────────── */
.video-grid-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  /* Must be able to shrink below its content's intrinsic width — the playback
     footer bar (timeline + tools) would otherwise push the wrapper wide and
     blow out the grid's 1fr columns. */
  min-width: 0;
  padding: 12px;
  gap: 10px;
}

.grid-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.grid-size-btn {
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.grid-size-btn:hover { border-color: var(--accent); color: var(--text); }
.grid-size-btn.active { background: #4fc3f720; border-color: var(--accent); color: var(--accent); }
/* Icon-only variant — tighter, square-ish; label lives in the tooltip. */
.grid-size-btn.icon { padding: 6px 9px; }

/* Custom-split editor: a thin accent line, shown only on the hovered cell's
   mergeable edge. Clean at rest; clicking it merges. */
.merge-handle {
  background: var(--accent);
  border-radius: 999px;
  opacity: 0.85;
  box-shadow: 0 0 6px rgba(79, 195, 247, 0.7);
  transition: opacity 0.12s;
  z-index: 3;
}
.merge-handle:hover { opacity: 1; }

/* Segmented group for the 1×1…6×6 sizes — reads as one control, not 6 boxes. */
.grid-seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.grid-seg .grid-size-btn {
  border: none;
  border-right: 1px solid var(--border);
  border-radius: 0;
}
.grid-seg .grid-size-btn:last-child { border-right: none; }

.grid-hint {
  margin-left: 10px;
  font-size: 11px;
  color: #444;
}

.grid-container {
  display: grid;
  grid-template-columns: repeat(var(--grid-cols), 1fr);
  /* Rows share the available height so the whole grid fits without scrolling. */
  grid-template-rows: repeat(var(--grid-rows, 1), 1fr);
  gap: 4px;
  flex: 1;
  min-height: 0;
}

/* Whole-grid fullscreen (⛶): the wrapper (grid + playback footer bar) fills the
   screen so the Playback transport stays visible. Grid keeps its 1fr tracks. */
.video-grid-wrapper:fullscreen {
  width: 100vw;
  height: 100vh;
  background: #000;
  box-sizing: border-box;
}

.grid-fs-footer {
  flex-shrink: 0;
  min-width: 0;
  overflow: hidden;
}

.grid-cell {
  position: relative;
  background: #050505;
  border: 2px solid transparent;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s;
  min-height: 0;
  min-width: 0;
  /* Cells fill their grid track (rows/cols are 1fr) so the grid fits the
     container height — no per-cell aspect-ratio forcing overflow. */
}

.grid-cell:hover { border-color: #333; }
.grid-cell.selected { border-color: var(--accent); }

/* Repositioning: make the whole filled tile the drag source. Without disabling
   drag on the inner <video>/<img>, the media hijacks the gesture (an <img> is
   draggable by default) and the cell's draggable never fires. */
.grid-cell[draggable="true"] { cursor: grab; }
.grid-cell[draggable="true"]:active { cursor: grabbing; }
.grid-cell img,
.grid-cell video {
  -webkit-user-drag: none;
  user-select: none;
}

/* Grip cue (visual only — the cell handles the actual drag). */
.cell-grip {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: rgba(0,0,0,0.6);
  color: #aaa;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  z-index: 10;
  pointer-events: none;
}
.grid-cell:hover .cell-grip { display: flex; }

/* Marks a tile that's a periodic snapshot rather than live video. */
.snapshot-badge {
  position: absolute;
  bottom: 4px;
  left: 4px;
  z-index: 2;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(0,0,0,0.6);
  color: #cbd5e1;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  pointer-events: none;
}
.grid-cell.drag-over {
  border-color: var(--accent);
  background: rgba(14,165,233,0.08);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.cell-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #333;
  font-size: 12px;
}

.grid-cell.selected .cell-empty {
  color: var(--accent);
  background: #4fc3f708;
}

.cell-clear {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.6);
  border: none;
  color: #aaa;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  z-index: 10;
  display: none;
}

.grid-cell:hover .cell-clear { display: flex; align-items: center; justify-content: center; }
.cell-clear:hover { color: var(--danger); }

/* ── PTZ Controls ────────────────────────────── */
.ptz-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.ptz-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  align-self: flex-start;
}

.ptz-pad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.ptz-row {
  display: flex;
  gap: 2px;
  align-items: center;
}

.ptz-btn {
  background: var(--bg-3);
  border: 1px solid #333;
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
  transition: background 0.1s;
}

.ptz-btn:hover { background: #2a2a2a; border-color: #444; }
.ptz-btn:active { background: #4fc3f730; }
.ptz-stop { color: var(--text-dim); font-size: 12px; }

.ptz-zoom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.ptz-zoom-label {
  font-size: 10px;
  color: #444;
  letter-spacing: 1px;
}

.ptz-feedback {
  font-size: 11px;
  color: var(--warn);
}

/* ── Timeline Playback ───────────────────────── */
.playback-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 12px;
  gap: 10px;
}

.playback-controls-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.playback-label {
  font-size: 12px;
  color: var(--text-dim);
}

.playback-select {
  background: var(--bg-3);
  border: 1px solid #333;
  color: var(--text);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 13px;
  min-width: 180px;
}

.btn-refresh {
  background: var(--bg-3);
  border: 1px solid #333;
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

.btn-refresh:hover { color: var(--text); }
.btn-refresh:disabled { opacity: 0.5; cursor: not-allowed; }

.playback-error { color: var(--danger); font-size: 13px; }

.playback-main {
  display: flex;
  flex: 1;
  gap: 12px;
  min-height: 0;
}

.playback-player {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.playback-video {
  width: 100%;
  flex: 1;
  background: #000;
  border-radius: 6px;
  min-height: 0;
  object-fit: contain;
}

.playback-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-dim);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.segment-codec {
  background: var(--bg-3);
  padding: 1px 6px;
  border-radius: 3px;
}

.playback-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: #444;
  font-size: 14px;
  background: #050505;
  border-radius: 6px;
}

.playback-timeline {
  width: 280px;
  overflow-y: auto;
  background: var(--bg-2);
  border-radius: 6px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.timeline-empty {
  padding: 20px;
  color: #444;
  font-size: 13px;
  text-align: center;
}

.timeline-day { border-bottom: 1px solid var(--border); }

.timeline-date {
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: #0d0d0d;
}

.timeline-segments {
  display: flex;
  flex-direction: column;
}

.timeline-segment {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: none;
  border: none;
  border-bottom: 1px solid #161616;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}

.timeline-segment:hover { background: #1a1a2e; }
.timeline-segment.active { background: #4fc3f715; border-left: 3px solid var(--accent); }

.seg-time { font-size: 12px; font-weight: 500; flex: 1; }
.seg-dur { font-size: 11px; color: var(--text-dim); }
.seg-size { font-size: 11px; color: #555; }

/* ── Alarm Panel ─────────────────────────────── */
.alarm-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 12px;
  gap: 10px;
}

.alarm-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.alarm-title {
  font-size: 14px;
  font-weight: 600;
}

.alarm-filters { display: flex; gap: 4px; }

.filter-btn {
  background: var(--bg-3);
  border: 1px solid #333;
  color: var(--text-dim);
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.filter-btn:hover { color: var(--text); }
.filter-btn.active { background: #4fc3f720; border-color: var(--accent); color: var(--accent); }

.alarm-error { color: var(--danger); font-size: 13px; }

.alarm-empty {
  color: #444;
  font-size: 14px;
  text-align: center;
  padding: 40px;
}

.alarm-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  overflow-y: auto;
  flex: 1;
}

.alarm-header-row,
.alarm-row {
  display: grid;
  grid-template-columns: 90px 120px 150px 1fr 160px 110px 120px;
  align-items: center;
  padding: 8px 12px;
  gap: 8px;
  font-size: 12px;
}

.alarm-header-row {
  background: #0d0d0d;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.alarm-row { border-bottom: 1px solid #161616; }
.alarm-row:hover { background: #111; }

.sev-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sev-badge.critical { background: #ef535030; color: var(--danger); }
.sev-badge.high { background: #ff572230; color: #ff5722; }
.sev-badge.medium { background: #ff980030; color: var(--warn); }
.sev-badge.low { background: #4caf5020; color: var(--success); }
.sev-badge.info { background: #4fc3f720; color: var(--accent); }

.alarm-camera { font-size: 12px; }
.alarm-type { font-size: 12px; text-transform: capitalize; }
.alarm-msg { font-size: 12px; color: var(--text-dim); }
.alarm-time { font-size: 11px; color: #555; }

.status-chip {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  text-transform: capitalize;
}

.status-chip.triggered { background: #ff572230; color: #ff5722; }
.status-chip.acknowledged { background: #ff980020; color: var(--warn); }
.status-chip.resolved { background: #4caf5020; color: var(--success); }

.alarm-actions { display: flex; gap: 4px; }

.alarm-btn {
  padding: 3px 10px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
}

.alarm-btn.ack { background: #ff980030; color: var(--warn); }
.alarm-btn.ack:hover { background: #ff980060; }
.alarm-btn.resolve { background: #4caf5020; color: var(--success); }
.alarm-btn.resolve:hover { background: #4caf5040; }

/* ── Event Review ────────────────────────────── */
.event-review {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 12px;
  gap: 10px;
}

.er-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.er-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  overflow-y: auto;
  flex: 1;
}

.er-header,
.er-row {
  display: grid;
  grid-template-columns: 160px 120px 160px 120px 90px 100px 80px;
  align-items: center;
  padding: 7px 12px;
  gap: 8px;
  font-size: 12px;
}

.er-header {
  background: #0d0d0d;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.er-row { border-bottom: 1px solid #161616; }
.er-row:hover { background: #111; }

.er-row.sev-critical { border-left: 3px solid var(--danger); }
.er-row.sev-high { border-left: 3px solid #ff5722; }
.er-row.sev-medium { border-left: 3px solid var(--warn); }
.er-row.sev-low { border-left: 3px solid var(--success); }

.er-time { font-size: 11px; color: #777; }
.er-camera { font-size: 12px; }
.er-type { font-size: 12px; font-weight: 500; text-transform: capitalize; }
.er-object { font-size: 12px; color: var(--text-dim); }
.er-conf { font-size: 12px; color: #777; }
.er-zone { font-size: 12px; color: #555; }
.er-feedback { display: flex; gap: 4px; }
.er-empty { padding: 30px; text-align: center; color: #444; font-size: 13px; }

.fb-btn {
  background: none;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  font-size: 13px;
  opacity: 0.5;
  transition: opacity 0.15s, border-color 0.15s;
}

.fb-btn:hover { opacity: 1; }
.fb-btn.active-up { opacity: 1; border-color: var(--success); background: #4caf5015; }
.fb-btn.active-down { opacity: 1; border-color: var(--danger); background: #ef535015; }

/* ── Responsive "card" tables ──────────────────────────────────────────────
   Add class `tcss-table-cards` to a <table> and a data-label="…" to each <td>.
   Under 768px the wide table reflows into stacked label/value cards so it stays
   legible on phones (field/patrol staff) instead of overflowing horizontally. */
@media (max-width: 767px) {
  table.tcss-table-cards thead {
    position: absolute; width: 1px; height: 1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  table.tcss-table-cards tr {
    display: block; margin-bottom: 10px;
    border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
    background: var(--bg-surface);
  }
  table.tcss-table-cards td {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 7px 12px; border: none; border-bottom: 1px solid var(--border);
    text-align: right;
  }
  table.tcss-table-cards td:last-child { border-bottom: none; }
  table.tcss-table-cards td::before {
    content: attr(data-label); font-weight: 600;
    color: var(--text-muted); text-align: left; white-space: nowrap;
  }
}
