:root {
  color-scheme: dark;
  --bg-0: #060910;
  --bg-1: #0f1626;
  --bg-2: #0e1628;
  --glass: rgba(34, 211, 238, 0.045);
  --glass-border: rgba(56, 189, 248, 0.16);
  --text-0: #e9fbff;
  --text-1: #8fa3c7;
  --text-2: #51628a;
  --accent: #38bdf8;
  --accent-2: #22d3ee;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 16px;
  --font-display: "Orbitron", "Share Tech Mono", monospace;
  --font-mono: "Share Tech Mono", "Consolas", monospace;
}

* { box-sizing: border-box; }
/* Guarantees the hidden attribute always wins over any class's own
   `display` (e.g. .btn, .modal-overlay) regardless of CSS specificity -
   without this, toggling `.hidden = true` on an element whose class sets
   `display` explicitly silently does nothing. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 800px at 10% -10%, #102445 0%, var(--bg-0) 55%),
    radial-gradient(900px 700px at 110% 10%, #0b2e3a 0%, var(--bg-0) 60%),
    repeating-linear-gradient(to bottom, rgba(34, 211, 238, 0.035) 0px, rgba(34, 211, 238, 0.035) 1px, transparent 1px, transparent 3px),
    var(--bg-0);
  color: var(--text-0);
  font-family: var(--font-mono);
  min-height: 100vh;
}

/* Fixed, always-on CRT scanline wash + corner vignette - decorative only,
   so it stays out of the way of every real element (and clicks). */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 3000;
  background: repeating-linear-gradient(
    0deg, rgba(0,0,0,0.12) 0px, rgba(0,0,0,0.12) 1px,
    transparent 1px, transparent 3px
  );
  mix-blend-mode: overlay;
  animation: scanFlicker 7s linear infinite;
}
body::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 2999;
  box-shadow: inset 0 0 160px rgba(0,0,0,0.55);
}

body { padding: 20px 28px 48px; }

a { color: var(--accent-2); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,0.02); }
::-webkit-scrollbar-thumb { background: rgba(34, 211, 238, 0.3); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(34, 211, 238, 0.5); background-clip: padding-box; }

/* ---------- Header ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 22px;
  animation: dropIn 0.5s ease both;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.55), 0 0 28px rgba(34, 211, 238, 0.4);
  animation: pulse 2.6s ease-in-out infinite;
}

.brand h1 {
  font-family: var(--font-display);
  font-size: 19px;
  margin: 0;
  letter-spacing: 1.8px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-2);
  text-shadow: 0 0 12px rgba(34, 211, 238, 0.5);
  animation: statusGlitch 5s infinite;
}

.brand .sub { font-size: 12px; color: var(--text-1); margin-top: 2px; letter-spacing: 0.4px; }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.status-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  font-size: 12.5px;
  letter-spacing: 0.3px;
  backdrop-filter: blur(10px);
}

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-2); position: relative; }
.dot.online { background: var(--good); box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6); animation: pulse 2s infinite; }
.dot.offline { background: var(--bad); }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55); }
  70% { box-shadow: 0 0 0 9px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: var(--text-0);
  font-family: var(--font-mono);
  font-size: 13px; font-weight: 550;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: transform 0.12s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.btn:hover { background: rgba(34, 211, 238, 0.1); border-color: rgba(34, 211, 238, 0.4); box-shadow: 0 0 16px rgba(34, 211, 238, 0.2); }
.btn:active { transform: scale(0.96); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #04111f; font-weight: 700; }
.btn.primary:hover { box-shadow: 0 0 10px rgba(34, 211, 238, 0.5), 0 6px 26px rgba(34, 211, 238, 0.4); }
.btn.danger { background: linear-gradient(135deg, #f87171, #ef4444); border-color: transparent; color: #220606; font-weight: 700; }
.btn.danger:hover { box-shadow: 0 0 10px rgba(248, 113, 113, 0.5), 0 6px 26px rgba(248, 113, 113, 0.35); }
.btn.good { background: linear-gradient(135deg, #34d399, #10b981); border-color: transparent; color: #04120b; font-weight: 700; }
.btn.good:hover { box-shadow: 0 0 10px rgba(52, 211, 153, 0.5), 0 6px 26px rgba(52, 211, 153, 0.35); }
.btn.warn { background: linear-gradient(135deg, #fbbf24, #f59e0b); border-color: transparent; color: #241a02; font-weight: 700; }
.btn.warn:hover { box-shadow: 0 0 10px rgba(251, 191, 36, 0.5), 0 6px 26px rgba(251, 191, 36, 0.35); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---------- Grid layout ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 18px;
}

.card {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px -18px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(34, 211, 238, 0.04) inset;
  animation: rise 0.55s cubic-bezier(.2,.7,.3,1) both;
  min-width: 0;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.card:hover { border-color: rgba(34, 211, 238, 0.3); box-shadow: 0 10px 30px -18px rgba(0, 0, 0, 0.6), 0 0 22px -6px rgba(34, 211, 238, 0.25); }
/* HUD-style corner brackets */
.card::before, .card::after {
  content: ""; position: absolute; width: 14px; height: 14px; pointer-events: none;
  border-color: rgba(34, 211, 238, 0.5);
}
.card::before { top: -1px; left: -1px; border-top: 2px solid; border-left: 2px solid; border-top-left-radius: 6px; }
.card::after { bottom: -1px; right: -1px; border-bottom: 2px solid; border-right: 2px solid; border-bottom-right-radius: 6px; }

.card h2 {
  font-family: var(--font-display);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 600;
  color: var(--accent-2);
  text-shadow: 0 0 8px rgba(34, 211, 238, 0.35);
  margin: 0 0 14px;
  display: flex; align-items: center; gap: 8px;
}
.card h2 .ic { font-size: 15px; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes dropIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

.span-8 { grid-column: span 8; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-3 { grid-column: span 3; }
.span-12 { grid-column: span 12; }

@media (max-width: 1100px) {
  .span-8, .span-6, .span-4, .span-3 { grid-column: span 12; }
}

/* ---------- Map ---------- */
#map {
  width: 100%;
  height: 420px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.08), 0 0 30px -10px rgba(34, 211, 238, 0.25);
}

/* ---------- Value tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tiles.cols-2 { grid-template-columns: repeat(2, 1fr); }
.tiles.cols-4 { grid-template-columns: repeat(4, 1fr); }

.tile {
  background: rgba(34, 211, 238, 0.025);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 12px 14px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.tile:hover { border-color: rgba(34, 211, 238, 0.35); box-shadow: 0 0 16px -4px rgba(34, 211, 238, 0.3); }
.tile .label { font-size: 11px; letter-spacing: 0.6px; text-transform: uppercase; color: var(--text-1); margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; }
.tile .value { font-family: var(--font-display); font-size: 24px; font-weight: 650; letter-spacing: 0.3px; font-variant-numeric: tabular-nums; transition: color 0.3s ease; }
.tile .value .unit { font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--text-1); margin-left: 3px; text-transform: none; }
.tile.flash .value { animation: flash 0.5s ease; }
@keyframes flash { 0% { color: var(--accent-2); text-shadow: 0 0 10px rgba(34, 211, 238, 0.8); } 100% { color: var(--text-0); text-shadow: none; } }

.badge {
  font-family: var(--font-mono);
  font-size: 10px; letter-spacing: 0.4px; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(255,255,255,0.06); color: var(--text-1);
  border: 1px solid transparent;
}
.badge.good { background: rgba(52, 211, 153, 0.12); color: var(--good); border-color: rgba(52, 211, 153, 0.3); }
.badge.warn { background: rgba(251, 191, 36, 0.12); color: var(--warn); border-color: rgba(251, 191, 36, 0.3); }
.badge.bad { background: rgba(248, 113, 113, 0.12); color: var(--bad); border-color: rgba(248, 113, 113, 0.3); }

/* ---------- Compass (Motion card - direction of travel) ---------- */
.compass-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 6px 0 18px;
}

.compass {
  position: relative;
  width: 148px; height: 148px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 38%, #1b2847 0%, #0d1428 72%, #0a0e17 100%);
  border: 1px solid var(--glass-border);
  box-shadow:
    inset 0 2px 10px rgba(0,0,0,0.55),
    inset 0 0 0 7px rgba(255,255,255,0.025),
    0 0 26px -6px rgba(56, 189, 248, 0.25);
}

.compass-ticks { position: absolute; inset: 0; }
.compass-ticks .tick {
  position: absolute;
  left: 50%; top: 4px;
  width: 2px; height: 10px;
  background: var(--text-2);
  transform-origin: 1px 70px; /* rotates around the compass center (148/2 - 4) */
}
.compass-ticks .tick.n { transform: translateX(-50%) rotate(0deg); background: var(--bad); height: 13px; width: 2.5px; }
.compass-ticks .tick.ne { transform: translateX(-50%) rotate(45deg); }
.compass-ticks .tick.e  { transform: translateX(-50%) rotate(90deg); }
.compass-ticks .tick.se { transform: translateX(-50%) rotate(135deg); }
.compass-ticks .tick.s  { transform: translateX(-50%) rotate(180deg); }
.compass-ticks .tick.sw { transform: translateX(-50%) rotate(225deg); }
.compass-ticks .tick.w  { transform: translateX(-50%) rotate(270deg); }
.compass-ticks .tick.nw { transform: translateX(-50%) rotate(315deg); }

.compass-letter {
  position: absolute;
  font-size: 11.5px; font-weight: 700;
  color: var(--text-1);
  letter-spacing: 0.5px;
}
.compass-letter.n { top: 15px; left: 50%; transform: translateX(-50%); color: var(--bad); }
.compass-letter.e { right: 14px; top: 50%; transform: translateY(-50%); }
.compass-letter.s { bottom: 15px; left: 50%; transform: translateX(-50%); }
.compass-letter.w { left: 14px; top: 50%; transform: translateY(-50%); }

.compass-needle {
  position: absolute; left: 50%; top: 50%;
  width: 0; height: 0;
  transform: translate(-50%, -50%) rotate(0deg);
  transition: transform 0.5s cubic-bezier(.2,.7,.3,1);
}
.needle-fore, .needle-aft {
  position: absolute; left: 50%;
  width: 0; height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  transform: translateX(-50%);
}
.needle-fore {
  top: -52px;
  border-bottom: 52px solid var(--accent);
  filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.65));
}
.needle-aft {
  top: 0;
  border-top: 40px solid #3a4668;
}

.compass-hub {
  position: absolute; left: 50%; top: 50%;
  width: 12px; height: 12px; margin: -6px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #c7d2fe 40%, #6366f1 100%);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.6);
}

.compass-readout {
  display: flex; align-items: baseline; gap: 8px;
}
.compass-readout span:first-child { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.compass-readout .cardinal {
  font-size: 12px; font-weight: 650; color: var(--accent-2);
  background: rgba(34, 211, 238, 0.12);
  padding: 2px 9px; border-radius: 999px;
}

/* ---------- Collapsible card section ---------- */
.collapsible-header {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.chevron { transition: transform 0.25s ease; color: var(--text-1); font-size: 14px; }
.collapsible-header.collapsed .chevron { transform: rotate(-90deg); }

.collapsible-body {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.3s cubic-bezier(.2,.7,.3,1);
}
.collapsible-body.collapsed { grid-template-rows: 0fr; }
.collapsible-inner { overflow: hidden; min-height: 0; }

/* ---------- Signal meter ---------- */
.meter { height: 6px; border-radius: 4px; background: rgba(255,255,255,0.08); overflow: hidden; margin-top: 8px; }
.meter-fill { height: 100%; border-radius: 4px; background: var(--good); transition: width 0.5s cubic-bezier(.2,.7,.3,1), background 0.4s ease; }

.sync-progress { margin-top: 12px; }
.sync-progress .meter { margin-top: 0; }
.sync-progress .meter-fill { background: linear-gradient(90deg, var(--accent), var(--accent-2)); box-shadow: 0 0 8px rgba(34, 211, 238, 0.5); }
.sync-progress-label { font-size: 11px; color: var(--text-1); margin-top: 5px; letter-spacing: 0.4px; font-variant-numeric: tabular-nums; }

/* ---------- Attitude indicator (artificial horizon) ---------- */
.attitude-wrap { display: flex; gap: 18px; align-items: center; justify-content: center; flex-wrap: wrap; }

.attitude {
  width: 150px; height: 150px;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  border: 3px solid rgba(255,255,255,0.14);
  box-shadow: inset 0 0 24px rgba(0,0,0,0.5), 0 0 0 6px rgba(255,255,255,0.025);
  background: #0a0e17;
}
.attitude-horizon {
  position: absolute;
  left: -50%; top: -50%;
  width: 200%; height: 200%;
  background: linear-gradient(to bottom, #2563eb 0%, #1d4ed8 48%, #3b2412 52%, #92591f 100%);
  transition: transform 0.35s cubic-bezier(.2,.7,.3,1);
  transform-origin: center;
}
.attitude-horizon::after {
  content: "";
  position: absolute; left: 0; right: 0; top: 50%;
  height: 2px; background: rgba(255,255,255,0.65);
}
.attitude-fixed {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.attitude-fixed::before {
  content: "";
  width: 56px; height: 2px; background: #f8fafc;
  box-shadow: 0 0 6px rgba(0,0,0,0.6);
}
.attitude-fixed::after {
  content: "";
  position: absolute;
  width: 8px; height: 8px; border-radius: 50%;
  background: #fbbf24;
  box-shadow: 0 0 6px rgba(0,0,0,0.6);
}
.attitude-label { text-align: center; font-size: 12px; color: var(--text-1); margin-top: 8px; }
.attitude-label b { color: var(--text-0); font-size: 14px; }

.compass {
  width: 130px; height: 130px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.14);
  background: radial-gradient(circle at 50% 42%, #16213f 0%, #0a0e17 75%);
  position: relative;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.55);
}
.compass .ticks { position: absolute; inset: 0; }
.compass .n-label { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 700; color: var(--bad); }
.compass .needle {
  position: absolute; left: 50%; top: 50%;
  width: 3px; height: 50px;
  background: linear-gradient(to top, var(--accent) 0%, var(--accent) 50%, var(--bad) 50%, var(--bad) 100%);
  transform-origin: bottom center;
  transform: translate(-50%, -100%) rotate(0deg);
  transition: transform 0.35s cubic-bezier(.2,.7,.3,1);
  border-radius: 3px;
}
.compass .hub { position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px; border-radius: 50%; background: #e2e8f0; }

/* ---------- Camera panel ---------- */
.camera-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.interval-input {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 7px 12px;
}
.interval-input input {
  width: 64px;
  background: transparent;
  border: none;
  color: var(--text-0);
  font-size: 14px;
  outline: none;
}
.interval-input span { color: var(--text-1); font-size: 12.5px; }

.photo-preview {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  font-size: 13px;
  margin-bottom: 12px;
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; animation: fadeIn 0.4s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.gallery img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition: transform 0.15s ease;
}
.gallery img:hover { transform: scale(1.05); }

/* ---------- Chart ---------- */
.chart-wrap { height: 220px; position: relative; }

/* ---------- Footer ---------- */
.footer {
  margin-top: 26px;
  text-align: center;
  color: var(--text-2);
  font-size: 12px;
}

/* Google Maps "Recenter" control */
.recenter-btn {
  margin-bottom: 20px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

/* ---------- WiFi network list ---------- */
.wifi-network-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
  max-height: 340px;
  overflow-y: auto;
}

.wifi-network-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(34,211,238,0.025);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  animation: rise 0.3s ease both;
  transition: border-color 0.2s ease;
}
.wifi-network-row:hover { border-color: rgba(34, 211, 238, 0.3); }

.wifi-network-row .signal-icon {
  width: 22px; height: 16px;
  display: flex; align-items: flex-end; gap: 2px;
  flex-shrink: 0;
}
.wifi-network-row .signal-icon i {
  flex: 1;
  background: var(--text-2);
  border-radius: 1px;
}
.wifi-network-row .signal-icon i:nth-child(1) { height: 25%; }
.wifi-network-row .signal-icon i:nth-child(2) { height: 50%; }
.wifi-network-row .signal-icon i:nth-child(3) { height: 75%; }
.wifi-network-row .signal-icon i:nth-child(4) { height: 100%; }
.wifi-network-row.sig-good .signal-icon i { background: var(--good); }
.wifi-network-row.sig-ok .signal-icon i:nth-child(-n+3) { background: var(--warn); }
.wifi-network-row.sig-weak .signal-icon i:nth-child(-n+1) { background: var(--bad); }

.wifi-network-row .ssid { flex: 1; min-width: 0; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wifi-network-row .sec-badge { font-size: 10.5px; color: var(--text-1); white-space: nowrap; }

.wifi-password-row { display: flex; gap: 8px; align-items: center; flex: 1; min-width: 220px; }
.wifi-password-row input {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--text-0);
  font-size: 13px;
  outline: none;
}
.wifi-password-row input:focus { border-color: var(--accent); }

/* ---------- Nav tabs ---------- */
.nav-tabs {
  display: flex;
  gap: 4px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 4px;
  backdrop-filter: blur(10px);
}
.nav-tab {
  border: none;
  background: transparent;
  color: var(--text-1);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-weight: 550;
  padding: 8px 16px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.nav-tab:hover { color: var(--text-0); }
.nav-tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04111f;
  font-weight: 700;
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.4);
}

/* ---------- Pages ---------- */
.page { animation: pageIn 0.35s cubic-bezier(.2,.7,.3,1) both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Trip control bar (Live page) ---------- */
.trip-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 18px;
  padding: 18px 22px;
}
.trip-bar-left { display: flex; align-items: center; gap: 14px; }
.trip-bar-dot {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--text-2);
  flex-shrink: 0;
}
.trip-bar-dot.recording {
  background: var(--bad);
  box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.6);
  animation: pulseRed 1.6s infinite;
}
@keyframes pulseRed {
  0% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.55); }
  70% { box-shadow: 0 0 0 10px rgba(248, 113, 113, 0); }
  100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0); }
}
.trip-bar-title { font-family: var(--font-display); font-size: 16px; font-weight: 650; letter-spacing: 0.5px; }
.trip-bar-sub { font-size: 12.5px; color: var(--text-1); margin-top: 2px; }
.trip-bar-right { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.trip-bar-stats { display: flex; gap: 24px; }
.trip-bar-stats > div { text-align: right; }
.trip-bar-stats span { display: block; font-family: var(--font-display); font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--accent-2); text-shadow: 0 0 8px rgba(34, 211, 238, 0.35); }
.trip-bar-stats label { display: block; font-size: 10px; color: var(--text-1); text-transform: uppercase; letter-spacing: 0.8px; margin-top: 1px; }

/* ---------- Trips page layout ---------- */
.trips-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
  align-items: start;
}
@media (max-width: 900px) {
  .trips-layout { grid-template-columns: 1fr; }
}

.trip-list-panel, .trip-detail-panel {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 18px;
  backdrop-filter: blur(14px);
}
.trip-detail-panel { min-height: 480px; }

.panel-title {
  font-family: var(--font-display);
  font-size: 12px; text-transform: uppercase; letter-spacing: 2px;
  font-weight: 600;
  color: var(--accent-2);
  text-shadow: 0 0 8px rgba(34, 211, 238, 0.35);
  margin: 0 0 14px;
}
.trip-list-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 14px;
}
.trip-list-panel-header .panel-title { margin-bottom: 0; }
.trip-list-panel-header .btn { padding: 6px 12px; font-size: 12px; }

.trip-list { display: flex; flex-direction: column; gap: 10px; max-height: 70vh; overflow-y: auto; }

.trip-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 13px 15px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
  animation: rise 0.35s ease both;
}
.trip-card:hover { background: rgba(34,211,238,0.06); border-color: rgba(34,211,238,0.3); transform: translateY(-1px); }
.trip-card.selected { border-color: var(--accent-2); box-shadow: 0 0 0 1px var(--accent-2), 0 0 20px -6px rgba(34,211,238,0.55); }
.trip-card .name { font-weight: 600; font-size: 14.5px; margin-bottom: 3px; }
.trip-card .date { font-size: 11.5px; color: var(--text-1); margin-bottom: 9px; }
.trip-card .stats { display: flex; gap: 14px; font-size: 11.5px; color: var(--text-1); }
.trip-card .stats b { color: var(--text-0); font-weight: 600; }
.trip-card .recording-badge { display: inline-flex; align-items: center; gap: 5px; color: var(--bad); font-size: 11px; font-weight: 600; margin-bottom: 6px; }
.trip-card .recording-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--bad); animation: pulseRed 1.6s infinite; }

/* ---------- Trip detail ---------- */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 4px;
  padding: 60px 20px;
  color: var(--text-1);
  font-size: 13.5px;
}
.empty-icon { font-size: 34px; margin-bottom: 8px; opacity: 0.6; }
.empty-sub { color: var(--text-2); font-size: 12px; }

.trip-detail-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; gap: 12px;
  margin-bottom: 18px;
}
.trip-detail-title { font-family: var(--font-display); font-size: 19px; font-weight: 650; letter-spacing: 0.4px; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  border: none; background: transparent; cursor: pointer;
  font-size: 14px; opacity: 0.6; padding: 2px 4px; border-radius: 6px;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.icon-btn:hover { opacity: 1; background: rgba(255,255,255,0.08); }

/* ---------- Offline banner ---------- */
.offline-banner {
  display: flex; align-items: center; gap: 12px;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 12px;
  padding: 13px 18px;
  margin-bottom: 18px;
  font-size: 13.5px;
  color: #fecaca;
  animation: rise 0.35s ease both;
}
.offline-banner .ic { font-size: 18px; }
.offline-banner b { color: #fff; }
#offlineLastSeen { color: #fda4a4; margin-left: 4px; }
.trip-detail-sub { font-size: 12.5px; color: var(--text-1); margin-top: 3px; }

#tripDetailMap {
  width: 100%; height: 340px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(5, 8, 15, 0.65);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
  padding: 20px;
}
.modal-card {
  background: rgba(10, 16, 28, 0.92);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 16px;
  padding: 26px 28px;
  width: 100%; max-width: 400px;
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.08), 0 0 50px -12px rgba(34, 211, 238, 0.35), 0 30px 60px -20px rgba(0,0,0,0.7);
  animation: rise 0.3s cubic-bezier(.2,.7,.3,1) both;
}
.modal-card h3 {
  font-family: var(--font-display);
  margin: 0 0 8px; font-size: 16px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--accent-2);
  text-shadow: 0 0 10px rgba(34, 211, 238, 0.4);
}
.modal-card p { margin: 0 0 16px; font-size: 13px; color: var(--text-1); line-height: 1.5; }
.modal-card input {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 11px 14px;
  color: var(--text-0);
  font-size: 14px;
  outline: none;
  box-sizing: border-box;
}
.modal-card input:focus { border-color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.gps-gate-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text-1);
  margin-top: 14px;
  padding: 9px 12px;
  background: rgba(255,255,255,0.03);
  border-radius: 9px;
}

/* ---------- Device sequence (shutdown / restart cyberpunk overlay) ---------- */
.device-sequence-overlay {
  position: fixed; inset: 0;
  background: radial-gradient(900px 600px at 50% 30%, #0c1830 0%, #030508 70%);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.25s ease;
  padding: 20px;
  overflow: hidden;
}
.device-sequence-scanlines {
  position: absolute; inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg, rgba(255,255,255,0.035) 0px, rgba(255,255,255,0.035) 1px,
    transparent 1px, transparent 3px
  );
  animation: scanFlicker 6s linear infinite;
  mix-blend-mode: overlay;
}
@keyframes scanFlicker {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 0.85; }
  52% { opacity: 0.4; }
}
.device-sequence-card {
  position: relative;
  width: 100%; max-width: 460px;
  background: rgba(7, 12, 22, 0.88);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 14px;
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.08), 0 0 60px -10px rgba(34, 211, 238, 0.35),
              0 30px 70px -20px rgba(0,0,0,0.7);
  padding: 26px 26px 22px;
  text-align: center;
  font-family: "Consolas", "SFMono-Regular", Menlo, monospace;
  animation: rise 0.35s cubic-bezier(.2,.7,.3,1) both;
}
.device-core { position: relative; width: 84px; height: 84px; margin: 4px auto 14px; }
.device-core-ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(56, 189, 248, 0.25);
  border-top-color: var(--accent-2);
  border-right-color: var(--accent-2);
  animation: coreSpin 2.2s linear infinite;
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.45);
}
.device-core-dot {
  position: absolute; top: 50%; left: 50%;
  width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 16px 4px rgba(34, 211, 238, 0.65);
  animation: pulse 1.4s ease-in-out infinite;
}
.device-core.spinning .device-core-ring { animation-duration: 0.5s; }
.device-core.dead .device-core-ring { animation: none; border-color: rgba(248, 113, 113, 0.3); border-top-color: var(--bad); box-shadow: 0 0 14px rgba(248, 113, 113, 0.4); }
.device-core.dead .device-core-dot { background: var(--bad); box-shadow: 0 0 12px 3px rgba(248, 113, 113, 0.5); animation: none; opacity: 0.6; }
.device-core.alive .device-core-ring { animation-duration: 3.5s; border-top-color: var(--good); border-right-color: var(--good); box-shadow: 0 0 18px rgba(52, 211, 153, 0.45); }
.device-core.alive .device-core-dot { background: var(--good); box-shadow: 0 0 16px 4px rgba(52, 211, 153, 0.6); }
@keyframes coreSpin { to { transform: rotate(360deg); } }
.device-sequence-title {
  font-size: 13px; letter-spacing: 4px; font-weight: 700;
  color: var(--accent-2);
  text-shadow: 0 0 12px rgba(34, 211, 238, 0.6);
  margin-bottom: 14px;
}
.device-sequence-log {
  height: 150px; overflow-y: auto;
  text-align: left;
  font-size: 12.5px; line-height: 1.9;
  color: #8be9ff;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(56, 189, 248, 0.15);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
}
.device-sequence-line { animation: terminalLineIn 0.25s ease both; text-shadow: 0 0 6px rgba(34, 211, 238, 0.35); }
@keyframes terminalLineIn { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: translateX(0); } }
.device-sequence-barTrack {
  height: 5px; border-radius: 3px; overflow: hidden;
  background: rgba(255,255,255,0.06);
  margin-bottom: 14px;
}
.device-sequence-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.6);
  transition: width 0.3s ease;
}
.device-sequence-status {
  font-size: 15px; font-weight: 700; letter-spacing: 2px;
  color: var(--accent-2);
  text-shadow: 0 0 14px rgba(34, 211, 238, 0.55);
  margin-bottom: 14px;
  animation: statusGlitch 2.4s infinite;
}
.device-sequence-status.offline { color: var(--bad); text-shadow: 0 0 14px rgba(248, 113, 113, 0.55); animation: none; }
.device-sequence-status.online { color: var(--good); text-shadow: 0 0 14px rgba(52, 211, 153, 0.55); animation: none; }
.device-sequence-status.pending { animation: statusGlitch 1.1s infinite; }
@keyframes statusGlitch {
  0%, 92%, 100% { opacity: 1; transform: translateX(0); }
  93% { opacity: 0.7; transform: translateX(-1px); }
  95% { opacity: 1; transform: translateX(1px); }
  97% { opacity: 0.8; transform: translateX(0); }
}
#deviceSequenceCloseBtn { width: 100%; }
