/* ==========================================================================
   SKYNET — shared theme (ported verbatim from the VV Games launcher palette).
   Gunmetal surfaces, cyan primary / orange status, sharp corners, CRT scanlines,
   crisp-edge pixel art. This file is the single source of visual truth; every
   component builds on these tokens and primitives. Do not fork the palette.
   ========================================================================== */
:root {
  --cyan: #34e2ea; --cyan-rgb: 52, 226, 234;
  --orange: #ff9422; --orange-rgb: 255, 148, 34;
  --accent2: #12a3b5;
  --bg: #0a0d0f; --bg2: #0e1214;
  --panel: #12181b; --panel2: #171f23; --panel3: #1f292e;
  --surface-deep: #060809;
  --border: #29343a; --border-soft: #1b2327; --border-strong: #3a4a52;
  --text: #e9eff1; --dim: #97a6ac; --faint: #626f76;
  --danger: #ff6b6b; --success: #34d399; --warn: #f5b34a;
  --cyan-glow: 0 0 0 1.5px rgba(var(--cyan-rgb), .75), 0 0 15px rgba(var(--cyan-rgb), .42);
  --orange-glow: 0 0 0 1.5px rgba(var(--orange-rgb), .7), 0 0 15px rgba(var(--orange-rgb), .4);
  --dur-fast: .12s; --dur: .22s;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; max-width: 100%; overflow-x: hidden; }

body {
  background:
    repeating-linear-gradient(180deg, rgba(255,255,255,.008) 0 1px, transparent 1px 3px),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  min-height: 100vh;
}
/* Fixed CRT scanline overlay on top of everything */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 99; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.14) 0 1px, transparent 1px 3px);
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

/* ---- Wordmark (8-bit pixel, jittery — same style as VV // Games) -------- */
.brand { display: inline-flex; align-items: center; }
.sk-pixmark {
  height: 20px; display: inline-block; fill: #eafcff; shape-rendering: crispEdges;
  transform: translate(var(--lx, 0), var(--ly, 0));
  filter:
    drop-shadow(calc(-1px * var(--sp, 0)) 0 rgba(var(--cyan-rgb), .9))
    drop-shadow(calc(1px * var(--sp, 0)) 0 rgba(var(--orange-rgb), .8))
    drop-shadow(0 0 calc(1px * var(--gl, 0)) rgba(var(--cyan-rgb), .55));
}
@media (prefers-reduced-motion: reduce) {
  .sk-pixmark { transform: none;
    filter: drop-shadow(-1px 0 rgba(var(--cyan-rgb), .8)) drop-shadow(1px 0 rgba(var(--orange-rgb), .7)); }
}

/* ---- Panels / surfaces ------------------------------------------------- */
.panel { background: var(--panel); border: 1px solid var(--border-soft); }
.panel-deep { background: var(--surface-deep); border: 1px solid var(--border-soft); }

/* ---- Buttons ----------------------------------------------------------- */
.btn, .tbtn {
  background: #0b0e14; color: var(--text);
  border: 1px solid rgba(var(--cyan-rgb), .28); border-radius: 0;
  padding: 7px 12px; font-size: 12px; font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase; cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(var(--cyan-rgb), .05);
  transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease, color var(--dur-fast) ease;
}
.btn:hover, .tbtn:hover { border-color: rgba(var(--cyan-rgb), .85); box-shadow: var(--cyan-glow); }
.btn:active, .tbtn:active { filter: brightness(.85); }
.btn.active, .tbtn.active { color: var(--cyan); border-color: var(--cyan); }
.btn.primary { color: var(--cyan); border-color: rgba(var(--cyan-rgb), .6); }
.btn.warn { color: var(--orange); border-color: rgba(var(--orange-rgb), .5); }
.btn.danger { color: var(--danger); border-color: rgba(255,107,107,.45); }
.btn:disabled { opacity: .4; cursor: default; box-shadow: none; }

/* Icon-only toolbar button (e.g. Carousel) */
.tbtn-icon { padding: 6px 9px; display: inline-flex; align-items: center; justify-content: center; }
.tbtn-icon .sk-ico { display: inline-flex; }

/* LED-style square toggle (used for record pause/resume, live/dvr) */
.led {
  width: 34px; height: 34px; border: none; border-radius: 3px; background: #0b0e14;
  color: var(--orange); box-shadow: inset 0 0 0 2px currentColor; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
.led.active { color: var(--cyan); }
.led:hover { box-shadow: inset 0 0 0 2px currentColor, 0 0 12px -2px currentColor; }

/* ---- Inputs ------------------------------------------------------------ */
input[type=text], input[type=password], select {
  background: #0b0e14; color: var(--text);
  border: 1px solid rgba(var(--cyan-rgb), .28); border-radius: 0;
  padding: 9px 12px; font-size: 14px; font-family: inherit; outline: none;
  transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
input:focus, select:focus { border-color: var(--cyan); box-shadow: var(--cyan-glow); }
select { text-transform: uppercase; font-size: 12px; letter-spacing: .05em; }
label { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .14em; }

/* ---- Micro-labels ------------------------------------------------------ */
.sub { color: var(--cyan); font-size: 9px; text-transform: uppercase; letter-spacing: .12em; }
.sub b { color: var(--orange); font-weight: 700; }
.dim { color: var(--dim); } .faint { color: var(--faint); }
.tabnum { font-variant-numeric: tabular-nums; }

/* ---- Toast ------------------------------------------------------------- */
#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(80px);
  background: var(--panel2); border: 1px solid var(--cyan); color: var(--text);
  padding: 10px 16px; font-size: 13px; z-index: 200; opacity: 0;
  transition: transform var(--dur) ease, opacity var(--dur) ease; pointer-events: none;
  max-width: 80vw;
}
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
#toast.err { border-color: var(--danger); color: #ffd7d7; }

/* ---- App shell layout -------------------------------------------------- */
#login-view, #app-view { min-height: 100vh; }
.hidden { display: none !important; }

.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 16px 26px; border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, var(--bg2), transparent);
  position: sticky; top: 0; z-index: 20;
}
.topbar .spacer { flex: 1; }
.topbar nav { display: flex; gap: 6px; }

main { padding: 22px 26px 60px; }

/* ---- Modal ------------------------------------------------------------- */
#modal-root:empty { display: none; }
.modal-scrim {
  position: fixed; inset: 0; z-index: 150; display: flex; align-items: center; justify-content: center;
  background: rgba(4,6,8,.78); backdrop-filter: blur(3px);
}
.modal {
  background: var(--panel); border: 1px solid var(--border-strong); box-shadow: var(--cyan-glow);
  padding: 26px 28px; width: min(420px, 92vw); display: flex; flex-direction: column; gap: 14px;
}
.modal h2 { margin: 0; font-size: 15px; letter-spacing: .1em; text-transform: uppercase; color: var(--cyan); }
.modal .row { display: flex; flex-direction: column; gap: 6px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }

/* ---- Mobile: fit to width, no horizontal scroll ------------------------ */
@media (max-width: 640px) {
  body { font-size: 14px; }
  .topbar { padding: 10px 12px; gap: 8px; flex-wrap: wrap; position: static; }
  .topbar nav { gap: 4px; }
  .topbar .spacer { flex-basis: 100%; order: 5; height: 0; }
  .btn, .tbtn { padding: 6px 9px; font-size: 11px; }
  main { padding: 12px 10px 44px; }
  .sk-pixmark { height: 17px; }
  #app-view, #login-view, main, .topbar, .sk-grid, .sk-grid-row { max-width: 100%; }
  .sk-tile { max-width: 100%; }
}

/* ── Ops / health detail popup (SkynetStatus) ─────────────────────────────── */
.sk-status-wrap { position: relative; display: inline-flex; }
.sk-status-pop {
  position: absolute; top: calc(100% + 8px); left: 0;
  width: 300px; max-width: min(92vw, 340px); z-index: 60;
  background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 12px 13px 13px;
  box-shadow: 0 10px 34px rgba(0,0,0,.55), var(--cyan-glow);
  font-size: 12.5px; color: var(--text);
  animation: sk-st-in var(--dur-fast) ease;
}
@keyframes sk-st-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.sk-st-title {
  font-family: ui-monospace, monospace; font-size: 11px; letter-spacing: .18em;
  color: var(--cyan); text-transform: uppercase; margin-bottom: 9px;
}
.sk-st-sub {
  font-family: ui-monospace, monospace; font-size: 9.5px; letter-spacing: .16em;
  color: var(--faint); text-transform: uppercase;
  margin: 11px 0 5px; padding-top: 8px; border-top: 1px solid var(--border-soft);
}
.sk-st-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 3px 0; }
.sk-st-k { display: inline-flex; align-items: center; gap: 7px; color: var(--dim); min-width: 0; }
.sk-st-v { color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sk-st-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--faint); }
.sk-st-recording { background: var(--success); box-shadow: 0 0 7px rgba(52,211,153,.7); }
.sk-st-stale { background: var(--warn); box-shadow: 0 0 7px rgba(245,179,74,.6); }
.sk-st-paused { background: var(--faint); }
.sk-st-txt-recording { color: var(--success); }
.sk-st-txt-stale { color: var(--warn); }
.sk-st-txt-paused { color: var(--faint); }
.sk-st-bar { height: 6px; border-radius: 3px; background: var(--panel3); overflow: hidden; margin: 5px 0 2px; }
.sk-st-bar-fill { height: 100%; background: var(--cyan); border-radius: 3px; transition: width var(--dur) ease; }
.sk-st-bar-fill.warn { background: var(--warn); }
.sk-st-bar-fill.crit { background: var(--danger); }
@media (max-width: 560px) { .sk-status-pop { left: auto; right: 0; } }
