/* ============================================================
   APEX VISION — Liquid Glass Monochrome
   ============================================================ */

:root {
  /* Monochrome — pure neutral with hairline cool undertone */
  --bg-0: #050507;
  --bg-1: #0a0a0c;
  --bg-2: #111114;
  --ink-100: #ffffff;
  --ink-90: rgba(255, 255, 255, 0.92);
  --ink-85: rgba(255, 255, 255, 0.85);
  --ink-70: rgba(255, 255, 255, 0.7);
  --ink-60: rgba(255, 255, 255, 0.6);
  --ink-50: rgba(255, 255, 255, 0.5);
  --ink-45: rgba(255, 255, 255, 0.45);
  --ink-40: rgba(255, 255, 255, 0.4);
  --ink-30: rgba(255, 255, 255, 0.3);
  --ink-20: rgba(255, 255, 255, 0.2);
  --ink-15: rgba(255, 255, 255, 0.15);
  --ink-08: rgba(255, 255, 255, 0.08);
  --ink-04: rgba(255, 255, 255, 0.04);

  /* Glass surfaces */
  --glass-bg: rgba(255, 255, 255, 0.04);
  --glass-bg-strong: rgba(255, 255, 255, 0.07);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-border-strong: rgba(255, 255, 255, 0.22);
  --glass-highlight: rgba(255, 255, 255, 0.5);
  --glass-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.7), 0 8px 24px -12px rgba(0, 0, 0, 0.5);

  /* Status — still monochromatic, conveyed by lightness */
  --status-live: #ffffff;
  --status-warn: rgba(255, 255, 255, 0.6);
  --status-idle: rgba(255, 255, 255, 0.3);

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;

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

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

html, body {
  height: 100%;
  background: var(--bg-0);
  color: var(--ink-90);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

body {
  position: relative;
  background:
    radial-gradient(ellipse 80% 60% at 20% 0%, rgba(255,255,255,0.04), transparent 60%),
    radial-gradient(ellipse 70% 50% at 90% 100%, rgba(255,255,255,0.03), transparent 60%),
    var(--bg-0);
}

/* Subtle film grain */
body::before {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.06 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: 0.5;
  mix-blend-mode: overlay;
  z-index: 1;
}

#particles {
  position: fixed; inset: 0;
  z-index: 0;
  pointer-events: none;
}

#app { position: relative; z-index: 2; height: 100vh; width: 100vw; }

/* ============================================================
   GLASS PRIMITIVES
   ============================================================ */

.glass {
  position: relative;
  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  overflow: hidden;
}

/* Liquid highlight — a thin top edge + a soft inner sheen */
.glass::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-highlight), transparent);
  z-index: 3;
  pointer-events: none;
}

.glass::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(120% 60% at 50% -20%, rgba(255,255,255,0.10), transparent 55%),
    radial-gradient(80% 40% at 50% 120%, rgba(255,255,255,0.04), transparent 60%);
  pointer-events: none;
  z-index: 1;
}

.glass > * { position: relative; z-index: 2; }

.glass-strong {
  background: var(--glass-bg-strong);
  border-color: var(--glass-border-strong);
}

.glass-flat {
  background: var(--glass-bg);
  backdrop-filter: blur(16px) saturate(130%);
  -webkit-backdrop-filter: blur(16px) saturate(130%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */

.display {
  font-family: var(--font-sans);
  font-weight: 200;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-50);
}

.mono { font-family: var(--font-mono); }

.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ============================================================
   BUTTONS / CONTROLS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font: inherit;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--ink-90);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition: background 180ms, border-color 180ms, transform 180ms;
  user-select: none;
}
.btn:hover { background: var(--glass-bg-strong); border-color: var(--glass-border-strong); }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: rgba(255,255,255,0.92);
  color: #000;
  border-color: rgba(255,255,255,0.95);
}
.btn-primary:hover { background: #fff; }

.btn-icon {
  width: 36px; height: 36px;
  padding: 0;
  justify-content: center;
}

.input {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  font-size: 13px;
  color: var(--ink-90);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 180ms, background 180ms;
}
.input:focus { border-color: var(--glass-border-strong); background: rgba(255,255,255,0.05); }
.input::placeholder { color: var(--ink-30); }

/* ============================================================
   STATUS DOTS
   ============================================================ */

.dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ink-50);
}
.dot.live {
  background: #fff;
  box-shadow: 0 0 0 0 rgba(255,255,255,0.6);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,255,255,0.45); }
  70% { box-shadow: 0 0 0 8px rgba(255,255,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ============================================================
   LAYOUT
   ============================================================ */

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 64px 1fr;
  gap: 14px;
  padding: 14px;
  height: 100vh;
}

.topbar {
  grid-column: 1 / 3;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  height: 64px;
}

.sidebar {
  display: flex; flex-direction: column;
  padding: 18px 12px;
  gap: 4px;
}

.main {
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-70);
  font-size: 13px;
  cursor: pointer;
  transition: background 160ms, color 160ms;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--ink-90); }
.nav-item.active {
  background: rgba(255,255,255,0.07);
  color: var(--ink-100);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -12px; top: 8px; bottom: 8px;
  width: 2px;
  background: #fff;
  border-radius: 2px;
}
.nav-item .icon { width: 16px; height: 16px; opacity: 0.8; flex-shrink: 0; }
.nav-item .badge {
  margin-left: auto;
  padding: 2px 7px;
  font-size: 10px;
  font-family: var(--font-mono);
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  color: var(--ink-70);
}

/* ============================================================
   LOGO
   ============================================================ */

.logo {
  display: flex; align-items: center; gap: 10px;
}
.logo img {
  width: 36px; height: 36px;
  object-fit: cover;
  object-position: center 30%;
  border-radius: 8px;
  /* The uploaded logo is on a black bg already; mix-blend lifts it onto glass */
}
.logo .brand {
  font-weight: 300;
  letter-spacing: 0.32em;
  font-size: 12px;
  text-transform: uppercase;
}
.logo .brand small {
  display: block;
  font-size: 9px;
  letter-spacing: 0.4em;
  color: var(--ink-50);
  margin-top: 2px;
}

/* ============================================================
   LOGIN
   ============================================================ */

.login-stage {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  z-index: 10;
  transition: opacity 600ms ease, transform 600ms ease;
}
.login-stage.hidden {
  opacity: 0;
  transform: scale(1.04);
  pointer-events: none;
}

.login-card {
  width: 380px;
  padding: 38px 36px 32px;
  border-radius: 28px;
  /* Match logo background (rgb 12,12,12) so its black bevel blends in */
  background: rgb(12, 12, 12);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.login-card::after {
  /* Soften the inner sheen so it doesn't reintroduce visible edges */
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(255,255,255,0.06), transparent 55%),
    radial-gradient(80% 40% at 50% 120%, rgba(255,255,255,0.025), transparent 60%);
}

.login-logo {
  display: flex; flex-direction: column; align-items: center;
  margin-bottom: 30px;
}
.login-logo img {
  width: 200px;
  height: auto;
  /* Logo is already on black; it sits naturally on glass */
}

.login-title {
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.5em;
  color: var(--ink-50);
  margin-bottom: 24px;
  text-transform: uppercase;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--ink-50);
  text-transform: uppercase;
  margin-bottom: 6px;
  font-family: var(--font-mono);
}

/* ============================================================
   DASHBOARD
   ============================================================ */

.page {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: grid;
  gap: 14px;
}

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 4px;
}

.page-title {
  font-size: 22px;
  font-weight: 300;
  letter-spacing: -0.01em;
}
.page-sub {
  font-size: 12px;
  color: var(--ink-50);
  margin-top: 2px;
}

/* Dashboard grid */
.grid-dash {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.kpi {
  padding: 18px 18px 16px;
  border-radius: var(--radius-md);
}
.kpi .kpi-label {
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--ink-50);
  text-transform: uppercase;
  font-family: var(--font-mono);
}
.kpi .kpi-value {
  font-size: 32px;
  font-weight: 200;
  margin-top: 8px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.kpi .kpi-delta {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--ink-50);
  margin-top: 4px;
}
.kpi-spark {
  height: 28px;
  margin-top: 8px;
  width: 100%;
  display: block;
}

/* Camera/feed grid */
.feeds {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px;
}

.feed {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition: border-color 200ms;
}
.feed:hover { border-color: var(--glass-border-strong); }

.feed-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
}

.feed-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 10px 12px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,0.5) 0%, transparent 30%, transparent 70%, rgba(0,0,0,0.6) 100%);
}

.feed-top {
  display: flex; justify-content: space-between; align-items: center;
}

.feed-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.15em;
  font-family: var(--font-mono);
  text-transform: uppercase;
}

.feed-bottom {
  display: flex; justify-content: space-between; align-items: flex-end;
}
.feed-name { font-size: 12px; font-weight: 500; letter-spacing: 0.04em; }
.feed-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-70);
  margin-top: 2px;
}

/* Detection bbox */
.bbox {
  position: absolute;
  border: 1px solid rgba(255,255,255,0.85);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
  border-radius: 2px;
}
.bbox::before {
  content: attr(data-label);
  position: absolute;
  top: -18px; left: -1px;
  background: rgba(255,255,255,0.92);
  color: #000;
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 1px 5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Events list */
.events {
  padding: 16px;
  display: flex; flex-direction: column;
  height: 100%;
  min-height: 0;
}
.events-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.events-list {
  flex: 1;
  overflow-y: auto;
  display: flex; flex-direction: column;
  gap: 6px;
  margin: 0 -8px;
  padding: 0 8px;
}

.event {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-radius: 10px;
  transition: background 160ms;
  cursor: pointer;
}
.event:hover { background: rgba(255,255,255,0.04); }
.event-thumb {
  width: 40px; height: 40px;
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border);
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--ink-50);
  letter-spacing: 0.05em;
}
.event-body { min-width: 0; }
.event-title {
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.event-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-50);
  margin-top: 2px;
  letter-spacing: 0.04em;
}
.event-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-50);
  white-space: nowrap;
}

/* Devices */
.devices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.device {
  padding: 18px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 200ms, transform 200ms;
}
.device:hover { transform: translateY(-1px); }

.device-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.device-name { font-size: 14px; font-weight: 500; }
.device-id { font-family: var(--font-mono); font-size: 10px; color: var(--ink-50); margin-top: 2px; }
.device-stats {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
}
.device-stat .label { font-size: 9px; }
.device-stat .val { color: var(--ink-90); margin-top: 2px; font-size: 13px; }

/* Detection / Live view */
.detection-view {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 14px;
  height: 100%;
  min-height: 0;
}
.detection-stage {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--glass-border);
  background: #000;
  min-height: 480px;
}
.detection-side {
  display: flex; flex-direction: column;
  gap: 14px;
  min-height: 0;
}

.timeline {
  height: 56px;
  position: relative;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-border);
  overflow: hidden;
}
.timeline-track {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  left: 0; right: 0;
  height: 2px;
  background: rgba(255,255,255,0.1);
}
.timeline-event {
  position: absolute;
  top: 50%; transform: translate(-50%, -50%);
  width: 2px; height: 24px;
  background: rgba(255,255,255,0.6);
  border-radius: 1px;
}
.timeline-event.alert { height: 32px; background: #fff; }
.timeline-cursor {
  position: absolute;
  top: 4px; bottom: 4px;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 8px rgba(255,255,255,0.6);
}

/* Pillbar — segmented control */
.pillbar {
  display: inline-flex;
  padding: 4px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  gap: 2px;
}
.pillbar button {
  font: inherit;
  font-size: 11px;
  padding: 6px 14px;
  border-radius: 999px;
  background: transparent;
  border: none;
  color: var(--ink-70);
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: background 160ms, color 160ms;
}
.pillbar button:hover { color: var(--ink-100); }
.pillbar button.on {
  background: rgba(255,255,255,0.92);
  color: #000;
}

/* Search */
.search {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  width: 320px;
}
.search input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink-90);
  font: inherit;
  font-size: 12.5px;
}
.search input::placeholder { color: var(--ink-30); }
.search .kbd {
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 2px 6px;
  border: 1px solid var(--glass-border);
  border-radius: 4px;
  color: var(--ink-50);
}

/* Health bars */
.bars {
  display: grid;
  gap: 8px;
}
.bar-row {
  display: grid;
  grid-template-columns: 80px 1fr 50px;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
}
.bar-row .name { color: var(--ink-70); }
.bar-row .val { text-align: right; color: var(--ink-90); }
.bar-track {
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, rgba(255,255,255,0.4), rgba(255,255,255,0.95));
  border-radius: 999px;
  transition: width 600ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Page transitions */
.page-fade-enter {
  animation: fadeIn 360ms ease both;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Section header */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--glass-border);
}
.section-head h3 {
  font-size: 12px; font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-90);
}

/* Loading shimmer line */
.scanline {
  position: absolute; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.7), transparent);
  animation: scan 3.4s linear infinite;
  z-index: 4;
}
@keyframes scan {
  0% { top: 0%; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

/* Settings list */
.setting-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--glass-border);
}
.setting-row:last-child { border-bottom: none; }
.setting-row .meta { color: var(--ink-50); font-size: 11.5px; margin-top: 2px; }

/* Toggle */
.toggle {
  width: 36px; height: 20px;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background 200ms;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: rgba(255,255,255,0.85);
  border-radius: 50%;
  transition: transform 200ms, background 200ms;
}
.toggle.on { background: rgba(255,255,255,0.85); }
.toggle.on::after { transform: translateX(16px); background: #000; }
