/* SENTINEL web — paleta OEM del JmevLauncher.
   cyan #00D4FF · verde #00FF88 · azul #0066FF · fondo #000A14 · glow #001835 */

:root {
  --cyan: #00D4FF;
  --green: #00FF88;
  --blue: #0066FF;
  --bg: #000A14;
  --bg-glow: #001835;
  --bg-card: rgba(0, 24, 53, 0.62);
  --bg-card-strong: rgba(0, 24, 53, 0.88);
  --line: rgba(0, 212, 255, 0.32);
  --line-soft: rgba(0, 212, 255, 0.16);
  --txt: #E6F4FF;
  --txt-mute: #8FB3D9;
  --warn: #FFB020;
  --crit: #FF3860;
  /* Velocidad histórica */
  --v-yellow:    #FFD93D; /* ≤30 km/h */
  --v-green:     #00C853; /* 30–60 */
  --v-lime:      #76FF03; /* 60–75 */
  --v-orange:    #FFB020; /* 75–90 */
  --v-red:       #FF3860; /* 90+ */
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overscroll-behavior: none; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--txt);
  overflow: hidden;
  position: fixed;            /* bloquea el rubber-band/scroll de página en mobile */
  inset: 0;
  width: 100%;
  -webkit-font-smoothing: antialiased;
}

/* 100dvh: alto real del viewport (sin pelearse con la barra del navegador en mobile) */
#app { height: 100%; height: 100dvh; display: flex; flex-direction: column; }

/* ============ Top bar ============ */
.topbar {
  position: relative;
  z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  background: linear-gradient(180deg, rgba(0,10,20,0.9) 0%, rgba(0,10,20,0.55) 80%, rgba(0,10,20,0) 100%);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  font-weight: 700; letter-spacing: 0.18em; font-size: 14px;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(0,212,255,0.55);
}
.brand-status { font-size: 11px; transition: color .2s; }
.brand-status[data-state="on"]  { color: var(--green); text-shadow: 0 0 8px rgba(0,255,136,0.7); }
.brand-status[data-state="off"] { color: #555; }
.brand-status[data-state="bad"] { color: var(--crit); }

.tabs { display: flex; gap: 6px; }
.tab {
  appearance: none; border: 1px solid var(--line-soft);
  background: transparent; color: var(--txt-mute);
  padding: 7px 16px; font: inherit; font-size: 12px; letter-spacing: 0.14em;
  border-radius: 999px; cursor: pointer; transition: all .15s;
  font-weight: 600;
}
.tab.is-active {
  color: var(--bg); background: var(--cyan);
  box-shadow: 0 0 12px rgba(0,212,255,0.55);
  border-color: var(--cyan);
}

.btn-ghost {
  appearance: none; border: 1px solid var(--line-soft); background: transparent;
  color: var(--txt-mute); font: inherit; font-size: 11px; letter-spacing: 0.14em;
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
  font-weight: 600;
}
.btn-ghost:hover { color: var(--cyan); border-color: var(--cyan); }
.logout-form { margin: 0; }

/* ============ Map ============ */
.map-stage { position: relative; flex: 1; min-height: 0; }
#map { position: absolute; inset: 0; background: var(--bg); touch-action: none; }

/* ============ Banner GPS ============ */
.gps-banner {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 4;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px;
  background: var(--bg-card-strong);
  border: 1px solid var(--warn);
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  max-width: calc(100vw - 32px);
}
.gps-banner.hidden { display: none; }
.gps-banner-icon {
  font-size: 22px; color: var(--warn);
  animation: pulse 1.6s infinite ease-in-out;
}
.gps-banner-text {
  display: flex; flex-direction: column; gap: 2px;
  font-size: 13px;
}
.gps-banner-text strong {
  color: var(--warn); letter-spacing: 0.05em;
}
.gps-banner-text span {
  color: var(--txt-mute); font-size: 11px;
}
@keyframes pulse { 50% { opacity: 0.35; } }

/* ============ Side panel ============ */
.side-panel {
  position: absolute; top: 16px; right: 16px;
  width: 340px; max-width: calc(100vw - 32px);
  max-height: calc(100% - 32px);
  background: var(--bg-card);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  display: flex; flex-direction: column; gap: 14px;
  overflow-y: auto; z-index: 6;
  box-shadow: 0 6px 28px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.04);
}
.side-panel.hidden { display: none; }

/* ============ Bottom-sheet / nav (estructura mobile) ============
   En DESKTOP el sheet es transparente: `display:contents` disuelve los wrappers
   y los .side-panel vuelven a flotar con sus reglas absolutas de arriba.
   La barra inferior, el grip y el botón de recentrado no existen en desktop. */
.sheet, .sheet-body { display: contents; }
.sheet-grip { display: none; }
.bottomnav { display: none; }
.recenter { display: none; }

/* Live panel */
.hero { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.speed-block { display: flex; align-items: baseline; gap: 8px; }
.speed-num {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 60px; font-weight: 700; line-height: 1;
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(0,212,255,0.45);
}
.speed-unit { color: var(--txt-mute); font-size: 13px; letter-spacing: 0.16em; font-weight: 600; }
.speed-limit {
  min-width: 48px; min-height: 48px;
  border-radius: 50%;
  border: 3px solid var(--crit);
  background: #fff; color: #000;
  display: none;
  align-items: center; justify-content: center;
  font-weight: 800; font-size: 19px;
  font-family: ui-monospace, monospace;
}
.speed-limit.shown { display: flex; }

.row.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.row.chips.small .chip { font-size: 10px; padding: 4px 9px; }
.chip {
  font-size: 11px; letter-spacing: 0.1em;
  padding: 5px 10px; border-radius: 999px;
  background: var(--bg-glow); border: 1px solid var(--line-soft);
  color: var(--txt-mute);
  font-weight: 600;
}
.chip[data-gear="D"] { color: var(--green); border-color: rgba(0,255,136,0.6); }
.chip[data-gear="R"] { color: var(--warn); border-color: rgba(255,176,32,0.6); }
.chip[data-gear="N"] { color: var(--cyan); }
.chip[data-turn="ACTIVE"] { color: var(--green); border-color: var(--green); }
.chip[data-turn="HAZARD"] { color: var(--crit); border-color: var(--crit); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

.grid-2 {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.cell {
  background: rgba(0,10,20,0.55);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex; flex-direction: column; align-items: flex-start;
}
.cell-lbl { font-size: 10px; letter-spacing: 0.12em; color: var(--txt-mute); text-transform: uppercase; }
.cell-val {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 22px; font-weight: 600; color: var(--txt);
  margin-top: 2px;
}
.cell-suf { font-size: 10px; color: var(--txt-mute); margin-top: -2px; }

.road-line {
  font-size: 14px; color: var(--txt); border-top: 1px solid var(--line-soft);
  padding-top: 10px; display: flex; gap: 8px; align-items: baseline;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.road-icon { color: var(--cyan); font-weight: 700; }

.alerts { display: flex; flex-direction: column; gap: 4px; }
.alert {
  font-size: 11px; letter-spacing: 0.1em; font-weight: 600;
  padding: 7px 10px; border-radius: 8px;
  background: rgba(255,56,96,0.18); color: var(--crit);
  border: 1px solid rgba(255,56,96,0.45);
}
.alert.warn {
  background: rgba(255,176,32,0.16); color: var(--warn);
  border-color: rgba(255,176,32,0.45);
}

/* ============ Panel historial ============ */
.history-toolbar { display: flex; gap: 8px; align-items: center; }
.history-toolbar select {
  flex: 1;
  background: var(--bg-glow); color: var(--txt);
  border: 1px solid var(--line-soft); border-radius: 10px;
  padding: 9px 11px; font: inherit; font-size: 13px;
}
.trip-list { display: flex; flex-direction: column; gap: 6px; max-height: 38vh; overflow-y: auto; }
.trip-card {
  padding: 11px 13px; border-radius: 12px;
  background: rgba(0,10,20,0.55); border: 1px solid var(--line-soft);
  cursor: pointer; transition: all .15s;
}
.trip-card:hover, .trip-card.is-active {
  border-color: var(--cyan);
  background: rgba(0,40,80,0.55);
}
.trip-card .tc-time { font-family: ui-monospace, monospace; font-size: 13px; color: var(--cyan); font-weight: 600; }
.trip-card .tc-meta { font-size: 11px; color: var(--txt-mute); margin-top: 5px;
                       display: flex; gap: 12px; flex-wrap: wrap; }
.trip-card .tc-meta strong { color: var(--txt); font-weight: 700; }

.trip-detail {
  font-size: 12px; color: var(--txt);
  display: flex; flex-direction: column; gap: 8px;
}
.trip-detail .row-stats {
  display: flex; flex-wrap: wrap; gap: 14px;
}
.trip-detail .row-stats span strong { color: var(--cyan); }
.trip-detail .stops-count { color: var(--txt-mute); }

/* timeline de paradas P1, P2… */
.trip-detail .timeline {
  display: flex; flex-direction: column; gap: 4px;
  margin-top: 2px;
}
.trip-detail .tl-row {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center;
  gap: 10px; padding: 5px 9px; border-radius: 9px;
  background: rgba(120,90,200,0.10); border: 1px solid rgba(179,136,255,0.22);
  cursor: pointer; transition: background .15s;
}
.trip-detail .tl-row:hover { background: rgba(120,90,200,0.22); }
.trip-detail .tl-p {
  font-weight: 800; font-size: 12px; color: #fff; text-align: center;
  background: #7b4ddb; border-radius: 6px; padding: 2px 0;
}
.trip-detail .tl-time { font-family: ui-monospace, monospace; font-size: 12px; color: var(--txt-mute); }
.trip-detail .tl-dur { font-size: 12px; font-weight: 700; color: var(--txt); }

.legend-speed {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 8px;
  font-size: 10px; letter-spacing: 0.06em;
  color: var(--txt-mute);
}
.legend-speed-bar {
  display: flex; height: 8px; border-radius: 4px; overflow: hidden;
  border: 1px solid var(--line-soft);
}
.legend-speed-bar > span { flex: 1; }
.legend-speed-labels {
  display: flex; justify-content: space-between;
  font-family: ui-monospace, monospace;
}

.hint { color: var(--txt-mute); font-size: 12px; text-align: center; }

.imu-rd-t { font-family: ui-monospace, monospace; font-weight: 700; color: var(--txt); }
.imu-rd { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.imu-rd::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--c); display: inline-block;
}
.imu-rd b { color: var(--txt); font-variant-numeric: tabular-nums; }

/* ============ Dock IMU (timeline horizontal abajo) ============ */
.imu-dock {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; flex-direction: column;
  background: var(--bg-card-strong);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 -8px 30px rgba(0,0,0,0.55);
}
.imu-dock.hidden { display: none; }
.imu-dock.collapsed .imu-dock-body { display: none; }
.imu-dock-head {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 10px 6px 14px; border-bottom: 1px solid var(--line-soft);
}
.imu-dock-title { font-size: 12px; font-weight: 800; color: var(--txt); white-space: nowrap; }
.imu-dock .imu-readout {
  flex: 1; min-width: 0; min-height: 14px; font-size: 11px; color: var(--txt-mute);
  display: flex; flex-wrap: nowrap; gap: 3px 9px; align-items: center; overflow: hidden;
}
/* botón ocultar/mostrar = punto rojo estilo macOS (× al hover) */
.imu-dock-toggle {
  flex: 0 0 auto; width: 14px; height: 14px; padding: 0; border-radius: 50%;
  background: #ff5f57; border: 1px solid rgba(0,0,0,0.30); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s;
}
.imu-dock-toggle:hover { background: #ff7b74; }
.imu-dock-toggle span {
  width: 8px; height: 8px; opacity: 0; transition: opacity .12s;
  background:
    linear-gradient(#5a0f0a, #5a0f0a) center/8px 1.4px no-repeat,
    linear-gradient(#5a0f0a, #5a0f0a) center/1.4px 8px no-repeat;
  transform: rotate(45deg);
}
.imu-dock-toggle:hover span { opacity: 1; }
.imu-dock-body { display: flex; min-height: 0; }
.imu-gutter {
  flex: 0 0 58px; display: flex; flex-direction: column;
  border-right: 1px solid var(--line-soft); background: rgba(0,10,22,0.45);
}
.imu-gut-strip {
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 3px 5px; border-top: 1px solid var(--line-soft); overflow: hidden;
}
.imu-gut-title { font-size: 10px; font-weight: 700; color: var(--txt); line-height: 1.15; }
.imu-gut-title span { color: var(--txt-mute); font-weight: 500; margin-left: 2px; }
.imu-gut-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--c); margin-left: 3px; vertical-align: middle;
}
.imu-gut-vals {
  display: flex; flex-direction: column; justify-content: space-between; flex: 1;
  font-size: 9px; color: var(--txt-mute); font-family: ui-monospace, monospace;
  text-align: right;
}
.imu-scroll { flex: 1; min-width: 0; overflow-x: auto; overflow-y: hidden; position: relative; }
.imu-track { position: relative; height: 100%; }
.imu-rows { position: relative; }
.imu-row { position: relative; }
.imu-row-ruler { border-bottom: 1px solid var(--line-soft); background: rgba(0,10,22,0.35); }
.imu-tile { position: absolute; top: 0; display: block; touch-action: none; }
.imu-cursor {
  position: absolute; top: 0; width: 1px; pointer-events: none;
  background: rgba(255,255,255,0.55); z-index: 3;
}
.imu-clip {
  position: absolute; top: 2px; transform: translateX(-50%);
  width: 16px; height: 16px; padding: 0;
  font-size: 8px; line-height: 16px; text-align: center;
  color: #001018; background: var(--cyan); border: none; border-radius: 4px;
  cursor: pointer; z-index: 4; box-shadow: 0 1px 5px rgba(0,0,0,0.6);
}
.imu-clip.is-cabin { background: #B388FF; color: #fff; }
.imu-clip:hover { background: #fff; color: var(--bg); transform: translateX(-50%) scale(1.15); }

/* ============ Modal de clip de video ============ */
.clip-modal {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.72); backdrop-filter: blur(4px);
}
.clip-modal.hidden { display: none; }
.clip-modal-box {
  width: min(900px, 92vw); background: var(--bg-card-strong);
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  box-shadow: 0 12px 48px rgba(0,0,0,0.6);
}
.clip-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 14px; border-bottom: 1px solid var(--line-soft);
  font-size: 13px; color: var(--txt);
}
.clip-modal-head button { font-size: 20px; line-height: 1; padding: 0 8px; }
.clip-modal video { width: 100%; max-height: 72vh; display: block; background: #000; }

/* ============ Mobile — rediseño bottom-sheet (2026-06-11) ============
   Mapa full-screen de fondo + sheet arrastrable (3 alturas) + barra inferior.
   JS mantiene --sheet-vis (alto visible del sheet, px) p/ padding del mapa y
   posición del botón de recentrado. */
@media (max-width: 640px) {
  /* ---- Topbar slim, flotando sobre el mapa ---- */
  .topbar {
    position: absolute; top: 0; left: 0; right: 0; z-index: 7;
    padding: calc(var(--safe-top) + 9px) 12px 14px;
    background: linear-gradient(180deg, rgba(0,8,16,0.94) 0%, rgba(0,8,16,0.55) 55%, rgba(0,8,16,0) 100%);
    border-bottom: none;
  }
  .topbar .tabs { display: none; }          /* navega la barra inferior */
  .brand-mark { font-size: 13px; }
  .topbar-actions { gap: 6px; }
  .btn-ghost { padding: 6px 11px; font-size: 10px; }

  .gps-banner { top: calc(var(--safe-top) + 46px); padding: 9px 13px; font-size: 12px; }

  /* ---- Botón de recentrado (flota arriba del sheet) ---- */
  .recenter {
    position: absolute; right: 14px; z-index: 7;
    bottom: calc(var(--sheet-vis, 120px) + 14px);
    width: 46px; height: 46px; border-radius: 50%; padding: 0;
    background: var(--bg-card-strong); border: 1px solid var(--line);
    color: var(--cyan); font-size: 22px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5); cursor: pointer;
    transition: bottom .28s cubic-bezier(.22,.61,.36,1);
  }
  .recenter.hidden { display: none; }

  /* ---- Bottom-sheet ----
     Alto = --sheet-h (px, lo fija el JS por snap). bottom = 0, o el alto del dock
     IMU cuando está abierto, así el sheet se apoya POR ENCIMA del dock sin taparlo. */
  .sheet {
    display: flex; flex-direction: column;
    position: absolute; left: 0; right: 0; bottom: 0;
    height: var(--sheet-h, 50%);
    max-height: 100%;
    background: var(--bg-card-strong);
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    border-top: 1px solid var(--line);
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.6);
    transition: height .30s cubic-bezier(.22,.61,.36,1), bottom .30s cubic-bezier(.22,.61,.36,1);
    z-index: 8; touch-action: none; will-change: height;
  }
  .sheet.dragging { transition: none; }
  /* cuando el dock IMU está abierto, el sheet se apoya por encima de él */
  body.imu-open .sheet { bottom: var(--imu-h, 210px); }

  .sheet-grip {
    flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 7px;
    padding: 9px 16px 8px; cursor: grab; touch-action: none;
  }
  .sheet-grip:active { cursor: grabbing; }
  .sheet-grip-bar { width: 42px; height: 4px; border-radius: 2px; background: var(--line);
                    flex: 0 0 auto; }
  .sheet-peek {
    width: 100%; min-height: 16px; text-align: center; font-size: 12.5px;
    color: var(--txt-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-weight: 600; letter-spacing: .02em;
  }
  .sheet-peek b { color: var(--cyan); font-variant-numeric: tabular-nums; }

  .sheet-body {
    display: block; flex: 1 1 auto; min-height: 0; overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 2px 15px calc(18px + env(safe-area-inset-bottom, 0px));
  }

  /* paneles dentro del sheet: estáticos, full-width, sin su caja flotante */
  .side-panel {
    position: static; width: auto; max-width: none; max-height: none;
    border: none; border-radius: 0; padding: 0; gap: 16px;
    background: none; backdrop-filter: none; -webkit-backdrop-filter: none;
    box-shadow: none; overflow: visible;
  }
  .speed-num { font-size: 52px; }
  .trip-list { max-height: none; }            /* el sheet ya scrollea */

  /* ---- Barra de navegación inferior ---- */
  .bottomnav {
    display: flex; flex: 0 0 auto; z-index: 10;
    background: rgba(0,8,16,0.97);
    border-top: 1px solid var(--line-soft);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .navbtn {
    flex: 1; appearance: none; border: none; background: none; color: var(--txt-mute);
    padding: 8px 0 7px; font: inherit; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    transition: color .15s;
  }
  .navbtn-ic { font-size: 19px; line-height: 1; }
  .navbtn-lbl { font-size: 10px; letter-spacing: .03em; font-weight: 600; }
  .navbtn.is-active { color: var(--cyan); }
  .navbtn.is-active .navbtn-ic { text-shadow: 0 0 12px rgba(0,212,255,0.65); }

  /* ---- Dock IMU: full-width abajo, por encima de la barra ---- */
  .imu-dock { left: 0; right: 0; z-index: 6; }
  .imu-dock .imu-readout { flex-wrap: wrap; }

  /* ---- VIDEOS: el sheet (en full) muestra player + grilla; no pisamos el layout ---- */
  body.view-videos #map { display: block; }   /* el mapa queda detrás del sheet */
  body.view-videos #videos-panel {
    position: static; inset: auto; width: auto; max-width: none; max-height: none;
    border: none; border-radius: 0; padding: 0; background: none;
  }
  body.view-videos #vid-list {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
    max-height: none; overflow: visible; align-content: start;
  }
  #videos-panel #vid-player { max-height: 38vh; aspect-ratio: 16 / 9; }

  /* ---- Modal de dispositivos = hoja inferior ---- */
  .dev-modal { align-items: flex-end; padding: 0; }
  .dev-modal-box { max-width: none; border-radius: 18px 18px 0 0; max-height: 86vh;
                   overflow-y: auto;
                   padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
  .dev-modal-box::before { display: block; width: 40px; height: 4px; border-radius: 2px;
                           background: var(--line); margin: 0 auto 14px; }
  .clip-modal-box { width: 96vw; }
}

/* ============ Login ============ */
.login-body {
  /* destraba el lock global del body (el login sí debe poder scrollear si no entra) */
  position: static; overflow-y: auto; height: auto;
  display: flex; align-items: center; justify-content: center;
  min-height: 100dvh; padding: 20px 16px; background:
    radial-gradient(ellipse at 30% 20%, rgba(0,102,255,0.18), transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(0,255,136,0.12), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 360px; padding: 32px 28px;
  background: var(--bg-card-strong);
  border: 1px solid var(--line);
  border-radius: 22px;
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
}
.login-header { text-align: center; margin-bottom: 24px; }
.logo-mark {
  font-weight: 700; letter-spacing: 0.32em; font-size: 18px;
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(0,212,255,0.55);
}
.logo-sub { font-size: 10px; letter-spacing: 0.4em; color: var(--txt-mute); margin-top: 6px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 10px; letter-spacing: 0.18em; color: var(--txt-mute); text-transform: uppercase; }
.field input {
  background: rgba(0,0,0,0.35); color: var(--txt);
  border: 1px solid var(--line-soft); border-radius: 10px;
  padding: 12px 14px; font: inherit; font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  outline: none; border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0,212,255,0.18);
}
.btn-primary {
  appearance: none; border: none; cursor: pointer;
  margin-top: 6px; padding: 12px 16px; border-radius: 10px;
  background: linear-gradient(90deg, var(--cyan), var(--green));
  color: var(--bg); font: inherit; font-size: 13px; font-weight: 700;
  letter-spacing: 0.18em;
  box-shadow: 0 0 18px rgba(0,212,255,0.35);
}
.btn-primary:hover { filter: brightness(1.08); }
.login-error { color: var(--crit); font-size: 12px; min-height: 1em; margin: 0; text-align: center; }

/* ============ Videos ============ */
/* DESKTOP: pantalla completa fuera del mapa. En MOBILE el panel vive dentro del
   sheet (ver bloque mobile) → estas reglas se acotan a ≥641px para no pisarlo. */
@media (min-width: 641px) {
  body.view-videos #map { display: none; }
  body.view-videos .gps-banner { display: none; }
  body.view-videos #videos-panel {
    position: absolute; inset: 0;
    width: auto; max-width: none; max-height: none;
    border: none; border-radius: 0;
    background: linear-gradient(180deg, var(--bg-glow) 0%, var(--bg) 60%);
    padding: 16px 24px 24px;
    gap: 14px;
  }
  body.view-videos #vid-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 10px; max-height: none; flex: 1 1 auto; overflow-y: auto;
    align-content: start;
  }
}
#videos-panel #vid-player {
  width: 100%; max-width: 920px; max-height: 56vh;
  margin: 0 auto; aspect-ratio: 16 / 9;
  background: #000; border: 1px solid var(--line); border-radius: 12px;
  flex: 0 0 auto;
}
.vid-dl {
  margin-left: auto; color: var(--cyan); text-decoration: none;
  font-size: 13px; padding: 0 4px;
}
.vid-dl:hover { color: var(--green); }

/* ---- Passkeys: botón huella/PIN en login + bloque ---- */
.pk-block { margin-top: 18px; }
.pk-block.hidden { display: none; }
.pk-divider { display: flex; align-items: center; gap: 10px; margin: 14px 0;
  color: var(--txt-mute); font-size: 12px; letter-spacing: .12em; }
.pk-divider::before, .pk-divider::after { content: ""; flex: 1; height: 1px;
  background: var(--line-soft); }
.btn-passkey { appearance: none; width: 100%; display: inline-flex; align-items: center;
  justify-content: center; gap: 10px; padding: 13px 16px; border-radius: 14px;
  border: 1px solid var(--cyan);
  background: linear-gradient(180deg, rgba(0,212,255,0.16), rgba(0,212,255,0.06));
  color: var(--cyan); font-weight: 700; font-size: 14.5px; letter-spacing: .01em;
  cursor: pointer; transition: all .15s;
  box-shadow: 0 0 0 0 rgba(0,212,255,0.0), inset 0 1px 0 rgba(255,255,255,0.06); }
.btn-passkey:hover { background: linear-gradient(180deg, rgba(0,212,255,0.26), rgba(0,212,255,0.12));
  box-shadow: 0 6px 20px rgba(0,212,255,0.22), inset 0 1px 0 rgba(255,255,255,0.08); }
.btn-passkey:active { transform: translateY(1px); }
.btn-passkey:disabled { opacity: .5; cursor: default; }
.btn-passkey svg { width: 20px; height: 20px; flex: 0 0 auto; }
.pk-ic { font-size: 17px; line-height: 1; }

/* handle del bottom-sheet (solo mobile, vía media query) */
.dev-modal-box::before { content: ""; display: none; }

/* ---- Topbar: agrupar acciones ---- */
.topbar-actions { display: flex; align-items: center; gap: 8px; }
#open-devices { font-size: 16px; line-height: 1; padding: 6px 9px; }

/* ---- Modal de dispositivos vinculados ---- */
.dev-modal { position: fixed; inset: 0; z-index: 40; display: flex;
  align-items: center; justify-content: center; padding: 16px;
  background: rgba(0,6,14,0.72); backdrop-filter: blur(3px); }
.dev-modal.hidden { display: none; }
.dev-modal-box { width: 100%; max-width: 460px; background: var(--bg-card-strong);
  border: 1px solid var(--line); border-radius: 16px; padding: 18px 18px 20px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.5); }
.dev-modal-head { display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; letter-spacing: .04em; margin-bottom: 10px; color: var(--txt); }
.dev-hint { font-size: 12.5px; color: var(--txt-mute); line-height: 1.5; margin: 0 0 14px; }
.dev-hint strong { color: var(--cyan); }
.dev-msg { font-size: 12.5px; margin: 10px 2px 0; min-height: 16px; }
.dev-msg.ok { color: var(--green); }
.dev-msg.err { color: var(--crit); }
.dev-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex;
  flex-direction: column; gap: 8px; max-height: 46vh; overflow-y: auto; }
.dev-empty { color: var(--txt-mute); font-size: 13px; padding: 10px 2px; }
.dev-item { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: 11px;
  background: rgba(0,24,53,0.5); }
.dev-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dev-label { font-weight: 600; color: var(--txt); font-size: 13.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev-meta { font-size: 11px; color: var(--txt-mute); }
.dev-revoke { appearance: none; flex-shrink: 0; border: 1px solid var(--crit);
  background: transparent; color: var(--crit); padding: 6px 12px; border-radius: 9px;
  font-size: 12px; font-weight: 600; cursor: pointer; transition: all .15s; }
.dev-revoke:hover { background: var(--crit); color: #fff; }
.dev-reg-row { display: flex; flex-direction: column; gap: 8px; }
.dev-input { appearance: none; width: 100%; padding: 10px 12px; border-radius: 11px;
  border: 1px solid var(--line-soft); background: rgba(0,10,22,0.5); color: var(--txt);
  font: inherit; font-size: 13px; }
.dev-input:focus { outline: none; border-color: var(--cyan); }
.dev-input::placeholder { color: var(--txt-mute); }

/* Actividad reciente (audit log) */
.dev-activity { margin-top: 16px; border-top: 1px solid var(--line-soft); padding-top: 12px; }
.dev-activity-head { font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--txt-mute); margin-bottom: 8px; }
.dev-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column;
  gap: 4px; max-height: 32vh; overflow-y: auto; }
.dev-log-item { display: flex; flex-direction: column; gap: 1px; padding: 6px 10px;
  border-radius: 9px; background: rgba(0,24,53,0.4); border-left: 2px solid var(--line-soft); }
.dev-log-item.ok { border-left-color: var(--green); }
.dev-log-item.err { border-left-color: var(--crit); }
.dev-log-item.warn { border-left-color: var(--warn); }
.dev-log-ev { font-size: 12.5px; color: var(--txt); font-weight: 600; }
.dev-log-meta { font-size: 10.5px; color: var(--txt-mute); font-variant-numeric: tabular-nums; }
