/* SentinelCV — precision ops console.
   Cool graphite structure, teal instrument accent, paper ink.
   Type: Syne (brand) / Sora (body) / JetBrains Mono (telemetry). */

:root {
  --bg: #070B12;
  --bg-deep: #04070C;
  --panel: rgba(14, 20, 32, 0.82);
  --panel-solid: #0E1420;
  --panel-raise: #131B2B;
  --line: rgba(120, 150, 190, 0.14);
  --line-bright: rgba(140, 180, 220, 0.28);
  --ink: #E8EDF5;
  --muted: #7F8FA8;
  --accent: #36D6C3;
  --accent-hot: #6EE7D8;
  --accent-dim: rgba(54, 214, 195, 0.12);
  --amber: var(--accent);
  --amber-hot: var(--accent-hot);
  --amber-dim: var(--accent-dim);
  --up: #5FE0A5;
  --stale: #E0C06A;
  --down: #F07178;
  --font-display: "Syne", sans-serif;
  --font-body: "Sora", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --radius: 2px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.bg-atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 90% 55% at 12% -10%, rgba(54, 214, 195, 0.09), transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 0%, rgba(70, 110, 180, 0.08), transparent 50%),
    linear-gradient(180deg, #0A101A 0%, var(--bg) 42%, #060910 100%),
    repeating-linear-gradient(
      -12deg,
      transparent 0,
      transparent 11px,
      rgba(120, 150, 190, 0.025) 11px,
      rgba(120, 150, 190, 0.025) 12px
    );
}
.bg-atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.45'/%3E%3C/svg%3E");
  opacity: 0.035;
  pointer-events: none;
  mix-blend-mode: overlay;
}

.shell { max-width: 1480px; margin: 0 auto; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: #04120F;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}
.skip-link:focus { left: 0; }

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

button { touch-action: manipulation; font: inherit; }
button:active { transform: scale(0.985); }

.eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--accent);
  text-transform: uppercase;
}

/* ---------- Header ---------- */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.75rem;
  border-bottom: 1px solid var(--line);
  background: rgba(4, 7, 12, 0.72);
  backdrop-filter: blur(14px) saturate(1.2);
  position: sticky;
  top: 0;
  z-index: 10;
  animation: fade-down 0.6s var(--ease) both;
}

.brand { display: flex; align-items: center; gap: 0.9rem; }

.brand-mark {
  width: 36px;
  height: 36px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(var(--line-bright) 1px, transparent 1px) center / 100% 50% no-repeat,
    linear-gradient(90deg, var(--line-bright) 1px, transparent 1px) center / 50% 100% no-repeat,
    radial-gradient(circle at center, rgba(54, 214, 195, 0.12), transparent 70%);
}
.brand-mark .sweep {
  position: absolute;
  inset: 0;
  background: conic-gradient(from 0deg, rgba(54, 214, 195, 0.45), transparent 65deg, transparent);
  animation: sweep 4s linear infinite;
}
@keyframes sweep { to { transform: rotate(360deg); } }
@keyframes fade-down {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

h1 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  line-height: 1;
  color: var(--ink);
}

.subtitle {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 0.58rem;
  letter-spacing: 0.2em;
  margin-top: 0.28rem;
  display: block;
}

.header-right { display: flex; align-items: center; gap: 0.65rem; }

.clock {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--accent-hot);
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  background: var(--bg-deep);
  border-radius: var(--radius);
}

.badge {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: var(--radius);
  text-transform: uppercase;
}
.badge.mock { border-color: rgba(224, 192, 106, 0.45); color: var(--stale); background: rgba(224, 192, 106, 0.06); }
.badge.live { border-color: rgba(54, 214, 195, 0.5); color: var(--accent-hot); background: var(--accent-dim); }

/* ---------- Stats ---------- */

#stats-bar {
  display: flex;
  gap: 0.75rem;
  margin: 1.35rem 1.75rem 0;
  flex-wrap: wrap;
  animation: fade-up 0.7s var(--ease) 0.08s both;
}

.stat-tile {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 1rem 1.25rem 1.05rem;
  min-width: 160px;
  flex: 0 0 auto;
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  transition: border-color 0.2s ease;
}
.stat-tile:hover { border-color: var(--line-bright); }
.stat-tile.wide { flex: 1 1 280px; }

.stat-eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.stat-value {
  display: block;
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--accent-hot);
  letter-spacing: 0.04em;
}

.stat-labels { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.15rem; }
.chip {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 0.22rem 0.55rem;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--panel-raise);
  border-radius: var(--radius);
}

/* ---------- Live device camera ---------- */

#live-section {
  padding: 1.1rem 1.75rem 0;
  animation: fade-up 0.7s var(--ease) 0.14s both;
}

#live-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  background:
    linear-gradient(105deg, var(--accent-dim), transparent 55%),
    var(--panel);
  border: 1px solid var(--line-bright);
  border-left: 3px solid var(--accent);
  padding: 1.15rem 1.4rem;
  flex-wrap: wrap;
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
}
#live-cta strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-top: 0.25rem;
}
#live-cta p {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 0.3rem;
  max-width: 48ch;
}

#live-btn {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: #04120F;
  background: var(--accent);
  border: none;
  padding: 0.85rem 1.6rem;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 0.15s ease, transform 0.15s ease;
}
#live-btn:hover {
  background: var(--accent-hot);
  transform: translateY(-1px);
}

#live-panel {
  margin-top: 1rem;
  background: var(--panel);
  border: 1px solid var(--line-bright);
  max-width: 720px;
  border-radius: var(--radius);
  overflow: hidden;
}
#live-video { width: 100%; height: 100%; object-fit: cover; display: block; }

#live-flip, #live-stop {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  background: transparent;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  border-radius: var(--radius);
}
#live-flip { margin-left: 0.8rem; color: var(--accent); border: 1px solid var(--accent); }
#live-flip:hover { background: var(--accent-dim); }
#live-stop { margin-left: 0.4rem; color: var(--down); border: 1px solid var(--down); }
#live-stop:hover { background: rgba(240, 113, 120, 0.1); }

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1rem;
  padding: 1.2rem 1.75rem;
  align-items: start;
  animation: fade-up 0.75s var(--ease) 0.2s both;
}
@media (max-width: 980px) { .layout { grid-template-columns: 1fr; } }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

main {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}

/* ---------- Camera cards ---------- */

.camera {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.2s ease, transform 0.25s var(--ease);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(8px);
  animation: rise 0.55s var(--ease) both;
}
.camera:nth-child(1) { animation-delay: 0.08s; }
.camera:nth-child(2) { animation-delay: 0.16s; }
.camera:nth-child(3) { animation-delay: 0.24s; }
.camera:nth-child(4) { animation-delay: 0.32s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

@media (min-width: 1120px) {
  .camera:first-child { grid-column: span 2; }
}

.camera::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: radial-gradient(200px circle at var(--mx, 50%) var(--my, 50%),
    rgba(54, 214, 195, 0.1), transparent 60%);
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}
.camera:hover::before { opacity: 1; }
.camera > * { position: relative; z-index: 1; }
.camera:hover { border-color: var(--line-bright); }

.cam-header {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 0.95rem;
  font-size: 0.8rem;
  font-weight: 500;
  border-bottom: 1px solid var(--line);
  background: rgba(4, 7, 12, 0.35);
}

.health-dot {
  width: 7px;
  height: 7px;
  background: var(--muted);
  flex-shrink: 0;
  border-radius: 50%;
}
.health-dot.up { background: var(--up); animation: pulse-up 2.4s infinite; }
.health-dot.stale { background: var(--stale); }
.health-dot.down { background: var(--down); animation: pulse-down 1.1s infinite; }
@keyframes pulse-up {
  0%, 100% { box-shadow: 0 0 0 0 rgba(95, 224, 165, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(95, 224, 165, 0); }
}
@keyframes pulse-down {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240, 113, 120, 0.45); }
  50% { box-shadow: 0 0 0 4px rgba(240, 113, 120, 0); }
}

.cam-age {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.68rem;
  font-family: var(--font-mono);
}

.cam-speeds {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-left: 0.4rem;
  margin-right: 0.4rem;
  max-width: 55%;
}
.speed-pill {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.04em;
  padding: 0.18rem 0.4rem;
  border: 1px solid var(--line);
  background: var(--bg-deep);
  color: var(--muted);
  border-radius: var(--radius);
  white-space: nowrap;
}
.speed-pill strong {
  color: var(--ink);
  font-weight: 600;
  margin-left: 0.15rem;
}
.speed-pill .unit {
  margin-left: 0.1rem;
  opacity: 0.7;
}
.speed-pill.free { border-color: rgba(95, 224, 165, 0.45); color: var(--up); }
.speed-pill.free strong { color: var(--up); }
.speed-pill.moderate { border-color: rgba(224, 192, 106, 0.5); color: var(--stale); }
.speed-pill.moderate strong { color: var(--stale); }
.speed-pill.slow { border-color: rgba(240, 113, 120, 0.5); color: var(--down); }
.speed-pill.slow strong { color: var(--down); }

.frame-wrap { position: relative; aspect-ratio: 16 / 9; background: var(--bg-deep); }
.frame-wrap::before, .frame-wrap::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  z-index: 2;
  pointer-events: none;
}
.frame-wrap::before {
  top: 10px; left: 10px;
  border-top: 1.5px solid var(--accent);
  border-left: 1.5px solid var(--accent);
}
.frame-wrap::after {
  bottom: 10px; right: 10px;
  border-bottom: 1.5px solid var(--accent);
  border-right: 1.5px solid var(--accent);
}

.frame { width: 100%; height: 100%; object-fit: cover; display: block; }
.overlay { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }

.overlay rect {
  fill: rgba(54, 214, 195, 0.06);
  stroke: var(--accent);
  stroke-width: 0.003;
}
.overlay text {
  fill: var(--accent-hot);
  font-size: 0.026px;
  font-family: var(--font-mono);
  paint-order: stroke;
  stroke: rgba(4, 7, 12, 0.88);
  stroke-width: 0.005;
}

.frame:not([src]) { display: none; }
.acquiring {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(105deg, var(--bg-deep) 40%, #0D1522 50%, var(--bg-deep) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.8s linear infinite;
}
.acquiring span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.28em;
  animation: blink 2s steps(2) infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.no-signal {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.015) 0 2px, transparent 2px 4px),
    rgba(4, 7, 12, 0.9);
}
.no-signal span {
  color: var(--down);
  font-family: var(--font-mono);
  letter-spacing: 0.35em;
  font-size: 0.8rem;
  animation: blink 1.6s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0.35; } }
.hidden { display: none !important; }

.cam-detections {
  padding: 0.6rem 0.95rem 0.7rem;
  font-size: 0.68rem;
  color: var(--muted);
  font-family: var(--font-mono);
  min-height: 2.1rem;
  border-top: 1px solid var(--line);
  background: rgba(4, 7, 12, 0.25);
}

/* ---------- Event log ---------- */

#event-log {
  background: var(--panel);
  border: 1px solid var(--line);
  position: sticky;
  top: 78px;
  max-height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
}

.log-header {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  padding: 0.75rem 0.95rem;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--line);
  background: rgba(4, 7, 12, 0.45);
}
.log-header .eyebrow { display: inline; }

#log-entries {
  list-style: none;
  overflow-y: auto;
  padding: 0.45rem 0;
  font-family: var(--font-mono);
  font-size: 0.66rem;
}
#log-entries li {
  padding: 0.36rem 0.95rem;
  color: var(--muted);
  border-left: 2px solid transparent;
  animation: slide-in 0.3s ease;
}
#log-entries li .t { color: #55657E; margin-right: 0.5rem; }
#log-entries li.detection { border-left-color: var(--accent); color: var(--ink); }
#log-entries li.warn { border-left-color: var(--down); color: var(--down); }
@keyframes slide-in {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Footer ---------- */

footer {
  display: flex;
  align-items: baseline;
  gap: 1.2rem;
  flex-wrap: wrap;
  margin: 0 1.75rem;
  padding: 1.25rem 0 1.8rem;
  border-top: 1px solid var(--line);
  font-size: 0.72rem;
  color: var(--muted);
}
.foot-brand {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--ink);
}
footer a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(54, 214, 195, 0.35);
  margin-left: auto;
  transition: border-color 0.15s ease;
}
footer a:hover { border-bottom-color: var(--accent); }

::-webkit-scrollbar { width: 7px; }
::-webkit-scrollbar-thumb { background: rgba(120, 150, 190, 0.28); border-radius: 2px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 640px) {
  header, #stats-bar, #live-section, .layout, footer {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  #stats-bar, .layout { margin-left: 0; margin-right: 0; }
  footer { margin-left: 1rem; margin-right: 1rem; }
  h1 { font-size: 1.25rem; letter-spacing: 0.1em; }
}
