/* Culligan Reverse Portal — design tokens */
:root {
  --culligan-blue: #1B9DE3;
  --culligan-blue-700: #1788C7;
  --culligan-blue-50: #E8F5FD;

  --navy-900: #081B36;
  --navy-800: #0B2545;
  --navy-700: #133462;
  --navy-600: #1E4683;

  --ink-900: #0F172A;
  --ink-800: #1E293B;
  --ink-700: #334155;
  --ink-600: #475569;
  --ink-500: #64748B;
  --ink-400: #94A3B8;
  --ink-300: #CBD5E1;
  --ink-200: #E2E8F0;
  --ink-100: #F1F5F9;
  --ink-50:  #F8FAFC;

  --bg-app: #F4F7FB;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;

  --success: #16A34A;
  --warning: #D97706;
  --danger:  #DC2626;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --shadow-1: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 1px rgba(15, 23, 42, 0.03);
  --shadow-2: 0 4px 12px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-3: 0 12px 32px rgba(15, 23, 42, 0.10), 0 4px 8px rgba(15, 23, 42, 0.04);

  --font-ui: "Inter", "Helvetica Neue", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Menlo", monospace;
}

/* DARK OPS theme */
[data-theme="dark"] {
  --bg-app: #060B16;
  --surface: #0E1628;
  --surface-2: #131F37;
  --border: #1E2D4D;
  --border-strong: #2A3D63;
  --ink-900: #F1F5F9;
  --ink-800: #E2E8F0;
  --ink-700: #CBD5E1;
  --ink-600: #94A3B8;
  --ink-500: #64748B;
  --ink-400: #475569;
  --ink-300: #334155;
  --ink-200: #1E293B;
  --ink-100: #0F172A;
  --ink-50:  #0B1424;
  --navy-800: #1B9DE3;
  --navy-900: #0E1628;
  --shadow-1: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-2: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-3: 0 12px 32px rgba(0,0,0,0.6);
}

/* PURE LIGHT theme — softer, no navy chrome */
[data-theme="light"] {
  --bg-app: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --navy-800: #1B9DE3;
  --navy-900: #1788C7;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg-app);
  color: var(--ink-900);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

.mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1; }

/* ─────────── Buttons ─────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}
.btn-primary {
  background: var(--culligan-blue);
  color: #fff;
  border-color: var(--culligan-blue);
}
.btn-primary:hover { background: var(--culligan-blue-700); border-color: var(--culligan-blue-700); }
.btn-secondary {
  background: var(--surface);
  color: var(--ink-800);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--ink-100); }
.btn-ghost {
  background: transparent;
  color: var(--ink-700);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--ink-100); color: var(--ink-900); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-icon {
  padding: 8px;
  width: 36px; height: 36px;
}

/* ─────────── Inputs ─────────── */
.input-wrap { position: relative; }
.input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--surface);
  color: var(--ink-900);
  transition: all 0.12s ease;
}
.input:focus {
  outline: none;
  border-color: var(--culligan-blue);
  box-shadow: 0 0 0 4px rgba(27, 157, 227, 0.12);
}
.input.with-icon { padding-left: 40px; }
.input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-500);
  pointer-events: none;
}
.label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-800);
  margin-bottom: 6px;
}

/* ─────────── Cards / surfaces ─────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}

/* ─────────── Chips & pills ─────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--ink-100);
  color: var(--ink-700);
  border: 1px solid var(--border);
}
.chip-blue {
  background: var(--culligan-blue-50);
  color: var(--culligan-blue-700);
  border-color: rgba(27, 157, 227, 0.25);
}
[data-theme="dark"] .chip-blue {
  background: rgba(27, 157, 227, 0.15);
  color: #7BC8F0;
}
.chip-region { background: var(--ink-100); color: var(--ink-700); }
.chip-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ─────────── Login backdrop pattern ─────────── */
.login-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 600px at 85% 20%, rgba(27, 157, 227, 0.10), transparent 60%),
    radial-gradient(700px 500px at 10% 90%, rgba(11, 37, 69, 0.08), transparent 60%),
    var(--bg-app);
}

/* Subtle water-ripple SVG accent */
.ripple-line {
  position: absolute;
  pointer-events: none;
  opacity: 0.4;
}

/* ─────────── App chrome ─────────── */
.appbar {
  height: 64px;
  background: var(--navy-800);
  border-bottom: 1px solid var(--navy-700);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 24px;
}
[data-theme="light"] .appbar {
  background: var(--surface);
  color: var(--ink-900);
  border-bottom: 1px solid var(--border);
}
[data-theme="light"] .appbar .brand-mark { color: var(--culligan-blue); }

.brand {
  display: flex; align-items: center; gap: 12px;
  font-weight: 600; font-size: 15px;
  letter-spacing: -0.01em;
}
.brand-divider {
  width: 1px; height: 24px;
  background: rgba(255,255,255,0.18);
}
[data-theme="light"] .brand-divider { background: var(--border); }

.app-title {
  font-size: 14px;
  opacity: 0.85;
  font-weight: 500;
}

/* ─────────── Table / list ─────────── */
.events-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.events-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-500);
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}
.events-table td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 13.5px;
}
.events-table tr.row { cursor: pointer; transition: background 0.1s ease; }
.events-table tr.row:hover td { background: var(--ink-50); }
[data-theme="dark"] .events-table tr.row:hover td { background: var(--surface-2); }
.events-table tr.row.selected td { background: var(--culligan-blue-50); }
[data-theme="dark"] .events-table tr.row.selected td { background: rgba(27, 157, 227, 0.10); }

.thumb {
  width: 96px; height: 56px;
  border-radius: 6px;
  background: var(--ink-200);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.thumb.compact { width: 72px; height: 42px; }
.thumb.large { width: 144px; height: 84px; }

.thumb-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(0,0,0,0.0) 30%, rgba(0,0,0,0.55) 100%);
}
.thumb-duration {
  position: absolute;
  bottom: 4px; right: 4px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.02em;
}
.thumb-novideo {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink-100);
  color: var(--ink-500);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.map-thumb {
  width: 80px; height: 56px;
  border-radius: 6px;
  background:
    repeating-linear-gradient(45deg, #DCE7F4 0 4px, #E8EFF8 4px 8px);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
}
[data-theme="dark"] .map-thumb {
  background: repeating-linear-gradient(45deg, #1A2640 0 4px, #15203A 4px 8px);
}

/* compact, comfortable, spacious densities */
.density-compact .events-table td { padding: 8px 14px; font-size: 13px; }
.density-spacious .events-table td { padding: 18px 14px; }

/* ─────────── Misc ─────────── */
.scroll-area {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-300) transparent;
}
.scroll-area::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll-area::-webkit-scrollbar-thumb { background: var(--ink-300); border-radius: 4px; }
.scroll-area::-webkit-scrollbar-track { background: transparent; }

.divider { height: 1px; background: var(--border); }

.kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  background: var(--ink-100);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--ink-700);
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(2.4); opacity: 0; }
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fadeIn 0.18s ease-out; }

/* ===== Event detail (photo preview) — added by phase 2 ===== */
.event-detail { padding: 24px 32px 64px; max-width: 1280px; margin: 0 auto; }
.event-detail__header { display: flex; align-items: center; gap: 20px; margin-bottom: 20px; }
.event-detail__title h2 { margin: 0; font-size: 22px; font-weight: 600; }
.event-detail__sub { color: var(--text-muted, #94a3b8); font-size: 13px; margin-top: 4px; }

.event-detail__grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}
@media (max-width: 980px) {
  .event-detail__grid { grid-template-columns: 1fr; }
}

.cam-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.cam-pane {
  background: var(--surface-2, #1a2230);
  border: 1px solid var(--border, #2a3548);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
}
.cam-pane__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted, #94a3b8);
  margin-bottom: 8px;
}
.cam-pane__frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cam-pane__img { width: 100%; height: 100%; object-fit: cover; }
.cam-pane__placeholder {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  color: var(--text-muted, #94a3b8);
  text-align: center; padding: 20px;
}
.cam-pane__placeholder-text { font-size: 13px; max-width: 220px; }

.insights {
  background: var(--surface-2, #1a2230);
  border: 1px solid var(--border, #2a3548);
  border-radius: 10px;
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 6px;
}
.insights__header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.insights__header h3 { margin: 0; font-size: 16px; font-weight: 600; }
.insights__row {
  display: flex; justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft, #243044);
  font-size: 13px;
}
.insights__row--stack { flex-direction: column; gap: 4px; align-items: flex-start; }
.insights__label { color: var(--text-muted, #94a3b8); }
.insights__value { font-weight: 500; }
.insights__value--small { font-size: 12px; }
.insights__detector { margin-top: 10px; }
.insights__reason {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  background: var(--surface-3, #0e1421);
  padding: 8px 10px;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 6px 0 0;
  color: var(--text-muted, #94a3b8);
}
.insights__actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.pill {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pill--ok   { background: #064e3b; color: #6ee7b7; }
.pill--info { background: #1e3a8a; color: #93c5fd; }
.pill--warn { background: #78350f; color: #fcd34d; }

.telemetry-strip {
  margin-top: 24px;
  background: var(--surface-2, #1a2230);
  border: 1px solid var(--border, #2a3548);
  border-radius: 10px;
  padding: 16px 18px;
}
.telemetry-strip h4 { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--text-muted, #94a3b8); }
.telemetry-svg { width: 100%; height: 100px; color: #60a5fa; display: block; }
