/* ═══════════════════════════════════════════════════════
   RedCentinela — Dashboard de seguridad
   Glassmorphism · Dark · Cyan accent
═══════════════════════════════════════════════════════ */

/* ── Variables (compatibilidad hacia atrás) ── */
:root {
  --bg-base:    #060b18;
  --bg-panel:   rgba(10,16,32,0.82);
  --bg-card:    rgba(17,26,46,0.9);
  --bg-hover:   rgba(26,40,68,0.9);
  --border:     rgba(30,50,90,0.7);
  --text-1:     #e2e8f0;
  --text-2:     #7a90b8;
  --text-3:     #3d5070;
  --red:        #ef4444;
  --red-dim:    #7f1d1d;
  --green:      #22c55e;
  --green-dim:  #14532d;
  --yellow:     #f59e0b;
  --yellow-dim: #78350f;
  --blue:       #3b82f6;
  --cyan:       #06b6d4;
  --accent:     #dc2626;
  --radius:     10px;
  --shadow:     0 4px 24px rgba(0,0,0,.6);
  --header-h:   56px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg-base); color: var(--text-1); }
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: rgba(6,182,212,.3); border-radius: 2px; }
.hidden { display: none !important; }

/* ══════════════════════════ HEADER ══════════════════════════ */
#header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
  background: rgba(6,11,24,0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(6,182,212,0.15);
  position: relative;
  z-index: 100;
  flex-shrink: 0;
}

/* Línea de luz en la parte inferior del header */
#header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(6,182,212,.4), rgba(59,130,246,.4), transparent);
}

.hdr-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.logo-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 6px var(--green); }
  50%       { box-shadow: 0 0 14px var(--green), 0 0 28px rgba(34,197,94,.3); }
}

.logo-dot.alerta {
  background: var(--red);
  box-shadow: 0 0 12px var(--red);
  animation: pulseRed 0.6s infinite;
}

@keyframes pulseRed {
  0%, 100% { box-shadow: 0 0 8px var(--red); }
  50%       { box-shadow: 0 0 24px var(--red), 0 0 48px rgba(239,68,68,.5); }
}

.logo-name { font-weight: 800; font-size: 1rem; letter-spacing: .04em; }
.logo-ver  { font-size: .62rem; background: rgba(6,182,212,.12); border: 1px solid rgba(6,182,212,.3); color: var(--cyan); padding: 2px 7px; border-radius: 8px; }

/* ── Stats centrales ── */
.hdr-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(6,182,212,.04);
  border: 1px solid rgba(6,182,212,.12);
  border-radius: 12px;
  padding: 6px 14px;
}

.hdr-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 44px;
}

.hdr-stat-val {
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1;
}

.hdr-stat-lbl {
  font-size: .58rem;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-top: 2px;
}

.hdr-sep {
  width: 1px;
  height: 32px;
  background: var(--border);
  margin: 0 4px;
}

/* Alarma badge en header */
.alarm-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 10px;
  font-size: .78rem;
  font-weight: 700;
  border: 1px solid;
  white-space: nowrap;
}

.alarm-desarmado { background: rgba(100,116,139,.12); border-color: rgba(100,116,139,.3); color: var(--text-2); }
.alarm-armado    { background: rgba(59,130,246,.12);  border-color: rgba(59,130,246,.4);  color: var(--blue); }
.alarm-retardo   { background: rgba(245,158,11,.12);  border-color: rgba(245,158,11,.4);  color: var(--yellow); }
.alarm-alerta    { background: rgba(239,68,68,.18);   border-color: rgba(239,68,68,.5);   color: var(--red); animation: alarmBlink .6s infinite; }

@keyframes alarmBlink { 0%,100%{opacity:1} 50%{opacity:.6} }

/* ── Controles derecha ── */
.hdr-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.net-badge {
  font-size: .72rem;
  padding: 3px 8px;
  background: rgba(6,182,212,.08);
  border: 1px solid rgba(6,182,212,.2);
  border-radius: 8px;
  cursor: default;
}

.hdr-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(17,26,46,.8);
  color: var(--text-1);
  font-size: .88rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}

.hdr-btn:hover  { background: rgba(6,182,212,.15); border-color: var(--cyan); }
.hdr-btn.active { background: rgba(6,182,212,.2);  border-color: var(--cyan); color: var(--cyan); }

.btn-arm, .btn-disarm {
  padding: 6px 14px;
  border-radius: 8px;
  border: none;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
}

.btn-arm   { background: rgba(59,130,246,.2); color: var(--blue); border: 1px solid rgba(59,130,246,.4); }
.btn-arm:hover { background: rgba(59,130,246,.35); }
.btn-disarm { background: rgba(239,68,68,.2); color: var(--red);  border: 1px solid rgba(239,68,68,.4); }
.btn-disarm:hover { background: rgba(239,68,68,.35); }

.ws-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  transition: all .3s;
}
.ws-off { background: var(--text-3); }
.ws-on  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.ws-err { background: var(--red); }

/* ══════════════════════════ LAYOUT 3 COLUMNAS ══════════════════════════ */
#mainLayout {
  height: calc(100vh - var(--header-h));
  display: grid;
  grid-template-columns: 240px 1fr 260px;
  grid-template-rows: 1fr;
  overflow: hidden;
}

/* ── Sidebar izquierda ── */
#sidebar {
  background: var(--bg-panel);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Columna central ── */
#centerCol {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ── Panel derecho ── */
#rightPanel {
  background: var(--bg-panel);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Título de panel genérico ── */
.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-1);
  flex-shrink: 0;
  background: rgba(6,182,212,.03);
}

.badge-count {
  background: rgba(6,182,212,.15);
  color: var(--cyan);
  border: 1px solid rgba(6,182,212,.3);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: .72rem;
  font-weight: 700;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  font-size: .82rem;
  padding: 2px 5px;
  border-radius: 5px;
  transition: color .15s;
}
.icon-btn:hover { color: var(--text-1); }

/* ══════════════════════════ VISTAS ══════════════════════════ */
#viewTabs {
  display: flex;
  background: rgba(6,11,24,.6);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.vtab {
  flex: 1;
  padding: 8px 6px;
  border: none;
  background: none;
  color: var(--text-2);
  font-size: .76rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all .15s;
}

.vtab:hover    { color: var(--text-1); background: rgba(6,182,212,.05); }
.vtab-active   { color: var(--cyan); border-bottom-color: var(--cyan); background: rgba(6,182,212,.08); }

.vista { display: none; flex: 1; overflow: hidden; }
.vista.active-view, #vista-mapa { display: flex; flex-direction: column; }

/* ── Inner panel (cameras / watchlist) ── */
.inner-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ══════════════════════════ GLOBE WRAP ══════════════════════════ */
#globeWrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at center, #0d1b35 0%, #060b18 70%);
}

#map {
  position: absolute;
  inset: 0;
}

/* ── Controles del globo ── */
#mapControls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
}

.map-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(6,182,212,.3);
  background: rgba(6,11,24,.85);
  backdrop-filter: blur(10px);
  color: var(--text-1);
  font-size: .88rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.map-btn:hover { background: rgba(6,182,212,.2); border-color: var(--cyan); transform: scale(1.05); }

/* ── Leyenda ── */
#mapLegend {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: rgba(6,11,24,.8);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  z-index: 10;
}

.leg-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .68rem;
  color: var(--text-2);
}

.leg-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Indicador de riesgo ── */
.riesgo-ind {
  position: absolute;
  bottom: 12px;
  right: 60px;
  z-index: 10;
  background: rgba(6,11,24,.85);
  backdrop-filter: blur(10px);
  border: 2px solid var(--green);
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
}

.riesgo-ind .ri-score { font-size: 1.3rem; font-weight: 800; line-height: 1; }
.riesgo-ind .ri-label { font-size: .6rem; font-weight: 700; text-transform: uppercase; color: var(--text-2); }
.riesgo-ind.riesgo-bajo    { border-color: var(--green); }
.riesgo-ind.riesgo-medio   { border-color: var(--yellow); }
.riesgo-ind.riesgo-alto    { border-color: #f97316; }
.riesgo-ind.riesgo-crítico { border-color: var(--red); }

/* ── Alert overlay ── */
.alert-overlay {
  position: absolute;
  inset: 0;
  background: rgba(127,29,29,.25);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  animation: alertFade .3s ease;
}

@keyframes alertFade { from { opacity: 0; } to { opacity: 1; } }

.alert-box {
  background: rgba(127,29,29,.9);
  border: 2px solid var(--red);
  border-radius: 20px;
  padding: 32px 40px;
  text-align: center;
  box-shadow: 0 0 60px rgba(239,68,68,.5);
}

.alert-pulse {
  font-size: 3rem;
  animation: alertBounce .5s infinite alternate;
}

@keyframes alertBounce { from { transform: scale(1); } to { transform: scale(1.15); } }

.alert-title {
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: .08em;
  color: var(--red);
  margin: 12px 0 6px;
}

.alert-sub { font-size: .85rem; color: rgba(255,255,255,.7); margin-bottom: 18px; }

/* ── Panel de ruta ── */
.ruta-panel {
  position: absolute;
  bottom: 0; right: 0;
  width: 270px;
  background: rgba(6,11,24,.92);
  backdrop-filter: blur(16px);
  border-top-left-radius: 14px;
  border: 1px solid var(--border);
  border-right: none; border-bottom: none;
  z-index: 10;
}

.ruta-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  font-size: .82rem;
  font-weight: 600;
}

.ruta-body   { padding: 10px 14px; max-height: 200px; overflow-y: auto; }
.ruta-hint   { color: var(--text-2); font-size: .8rem; text-align: center; padding: 12px 0; }
.ruta-header { padding: 8px; background: var(--bg-card); border-radius: 8px; margin-bottom: 8px; }
.ruta-nivel  { font-size: .88rem; font-weight: 700; display: block; }
.ruta-meta   { font-size: .72rem; color: var(--text-2); }

.ruta-score-wrap { position: relative; height: 20px; background: var(--bg-card); border-radius: 4px; overflow: hidden; margin-bottom: 8px; display: flex; align-items: center; }
.ruta-score-bar  { position: absolute; left:0;top:0;bottom:0; opacity: .5; transition: width .4s; }
.ruta-score-wrap span { position: relative; font-size: .7rem; padding-left: 8px; font-weight: 600; }

.ruta-factor { font-size: .7rem; color: var(--yellow); background: rgba(245,158,11,.1); padding: 3px 7px; border-radius: 4px; margin-bottom: 4px; border-left: 2px solid var(--yellow); }

/* ══════════════════════════ DEVICE LIST ══════════════════════════ */
.device-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.empty-msg {
  color: var(--text-3);
  font-size: .78rem;
  text-align: center;
  padding: 20px;
}

.device-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: background .15s;
  border-left: 3px solid transparent;
}

.device-item:hover     { background: var(--bg-hover); }
.device-item.presente  { border-left-color: var(--text-3); }
.device-item.autorizado { border-left-color: var(--green); background: rgba(34,197,94,.04); }
.device-item.desconocido{ border-left-color: var(--yellow); background: rgba(245,158,11,.04); }
.device-item.ausente    { opacity: .45; }

.device-icon { font-size: 1.1rem; flex-shrink: 0; }

.device-info { flex: 1; min-width: 0; }
.device-name { font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-meta { display: flex; gap: 6px; font-size: .66rem; color: var(--text-2); margin-top: 2px; }

.rssi-bars { display: flex; align-items: flex-end; gap: 2px; height: 14px; }
.rssi-bar-seg { width: 3px; border-radius: 1px; background: var(--text-3); }
.rssi-bar-seg.active       { background: var(--green); }
.rssi-bar-seg.active.medium { background: var(--yellow); }
.rssi-bar-seg.active.weak   { background: var(--red); }

/* ══════════════════════════ EVENT FEED ══════════════════════════ */
.event-feed {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
}

.event-item {
  display: flex;
  gap: 7px;
  padding: 6px 8px;
  border-radius: 7px;
  margin-bottom: 3px;
  font-size: .74rem;
  border-left: 2px solid var(--text-3);
  animation: slideIn .2s ease;
}

@keyframes slideIn { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:translateY(0); } }

.event-time { color: var(--text-3); white-space: nowrap; font-family: monospace; font-size: .7rem; flex-shrink: 0; }
.event-desc { flex: 1; color: var(--text-2); line-height: 1.4; }

.event-item.info     { border-left-color: var(--text-3); }
.event-item.warning  { border-left-color: var(--yellow); background: rgba(245,158,11,.05); }
.event-item.warning .event-desc { color: var(--yellow); }
.event-item.critical { border-left-color: var(--red); background: rgba(239,68,68,.07); }
.event-item.critical .event-desc { color: #f87171; font-weight: 600; }

/* ══════════════════════════ CAMERAS ══════════════════════════ */
.cam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 12px;
  overflow-y: auto;
  flex: 1;
}

.camara-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.cam-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.cam-nombre { font-size: .78rem; font-weight: 600; }
.cam-badges { display: flex; gap: 4px; }
.cam-badge  { font-size: .62rem; padding: 2px 6px; border-radius: 6px; font-weight: 700; }
.cam-badge.live { background: rgba(239,68,68,.2); color: var(--red); border: 1px solid rgba(239,68,68,.4); }
.cam-badge.off  { background: rgba(100,116,139,.2); color: var(--text-2); }
.cam-badge.fps  { background: rgba(6,182,212,.15); color: var(--cyan); }

.cam-feed {
  height: 160px;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.cam-offline {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-3);
  font-size: .78rem;
}

.cam-offline > div:first-child { font-size: 2rem; }

.cam-footer {
  padding: 5px 12px;
  font-size: .7rem;
  color: var(--text-2);
  border-top: 1px solid var(--border);
}

.cam-det { color: var(--red); font-weight: 600; }

/* ══════════════════════════ POPUP GLOBE ══════════════════════════ */
.globe-popup {
  background: rgba(6,11,24,.95) !important;
  border: 1px solid rgba(6,182,212,.3) !important;
  border-radius: 10px !important;
  color: var(--text-1) !important;
  font-family: 'Segoe UI', system-ui, sans-serif !important;
  font-size: .78rem !important;
  padding: 10px 14px !important;
  min-width: 160px !important;
  box-shadow: 0 8px 32px rgba(0,0,0,.6) !important;
  pointer-events: none !important;
}
.globe-popup .gp-name { font-weight: 700; font-size: .85rem; margin-bottom: 6px; }
.globe-popup .gp-row  { display: flex; justify-content: space-between; gap: 12px; color: var(--text-2); margin-top: 3px; }
.globe-popup .gp-val  { color: var(--text-1); font-weight: 600; }

/* ══════════════════════════ TOASTS ══════════════════════════ */
#toastContainer {
  position: fixed;
  top: 70px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 300px;
}

.toast {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: .82rem;
  font-weight: 500;
  backdrop-filter: blur(12px);
  animation: toastIn .25s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  border: 1px solid;
}

@keyframes toastIn { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:translateX(0); } }

.toast.info    { background: rgba(59,130,246,.85);  border-color: rgba(59,130,246,.5); }
.toast.success { background: rgba(34,197,94,.85);   border-color: rgba(34,197,94,.5); }
.toast.warning { background: rgba(245,158,11,.85);  border-color: rgba(245,158,11,.5); }
.toast.error   { background: rgba(239,68,68,.85);   border-color: rgba(239,68,68,.5); }

/* ══════════════════════════ WATCHLIST ══════════════════════════ */
.wl-stats  { display: flex; border-bottom: 1px solid var(--border); }
.wl-stat   { flex: 1; padding: 12px 8px; text-align: center; border-right: 1px solid var(--border); }
.wl-stat:last-child { border-right: none; }
.wl-stat-val { display: block; font-size: 1.4rem; font-weight: 800; }
.wl-stat-lbl { font-size: .62rem; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.wl-auth  .wl-stat-val { color: var(--green); }
.wl-sosp  .wl-stat-val { color: var(--yellow); }
.wl-negra .wl-stat-val { color: var(--red); }
.wl-actions { display: flex; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.wl-list    { padding: 6px; }
.wl-item    { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; margin-bottom: 4px; background: var(--bg-card); border-left: 3px solid var(--border); animation: slideIn .25s ease; }
.wl-icon    { font-size: 1.2rem; flex-shrink: 0; }
.wl-info    { flex: 1; min-width: 0; }
.wl-nombre  { font-size: .84rem; font-weight: 600; }
.wl-meta    { display: flex; gap: 8px; font-size: .68rem; color: var(--text-3); margin-top: 2px; flex-wrap: wrap; }
.wl-desc    { font-size: .7rem; color: var(--text-2); margin-top: 3px; }
.wl-btns    { display: flex; flex-direction: column; gap: 4px; }

/* ══════════════════════════ MODAL MÓVIL ══════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(8px);
  padding: 20px;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid rgba(6,182,212,.25);
  border-radius: 20px;
  padding: 24px;
  max-width: 340px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.7), 0 0 80px rgba(6,182,212,.06);
}

.modal-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-hdr h3 { font-size: .95rem; font-weight: 700; }

.qr-box {
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
}

.pair-remoto-badge {
  background: rgba(34,197,94,.15); border: 1px solid rgba(34,197,94,.4);
  color: var(--green); border-radius: 8px; padding: 6px 12px;
  font-size: .75rem; font-weight: 600; text-align: center; margin-bottom: 10px;
}
.pair-code { font-size: 2.2rem; font-weight: 900; letter-spacing: .35em; color: var(--cyan); text-align: center; margin-bottom: 4px; }
.pair-url  { font-size: .7rem; color: var(--text-3); word-break: break-all; text-align: center; margin-bottom: 12px; }

.pair-steps { background: rgba(6,11,24,.6); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.pair-step  { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 8px; font-size: .78rem; color: var(--text-2); line-height: 1.5; }
.pair-step:last-child { margin-bottom: 0; }
.step-n { background: var(--blue); color: #fff; border-radius: 50%; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; font-size: .68rem; font-weight: 700; flex-shrink: 0; margin-top: 2px; }

.btn-secondary {
  width: 100%;
  padding: 9px;
  background: rgba(6,182,212,.1);
  border: 1px solid rgba(6,182,212,.3);
  border-radius: 10px;
  color: var(--cyan);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-secondary:hover { background: rgba(6,182,212,.2); }

/* ══════════════════════════ SOS (Fase 7) ══════════════════════════ */
.sos-panel      { padding: 16px; display: flex; flex-direction: column; gap: 12px; flex:1; overflow-y:auto; }
.sos-btn-wrap   { display: flex; justify-content: center; padding: 16px 0; }
.sos-main-btn   { width: 140px; height: 140px; border-radius: 50%; border: 3px solid var(--red); background: radial-gradient(circle,#991b1b,#450a0a); cursor: pointer; font-size: 2.5rem; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 40px rgba(239,68,68,.4), inset 0 0 20px rgba(0,0,0,.5); transition: transform .1s; }
.sos-main-btn:active { transform: scale(.95); }
.sos-main-btn.activo { animation: sosPulse 1s infinite; }
@keyframes sosPulse { 0%,100%{box-shadow:0 0 30px rgba(239,68,68,.4)} 50%{box-shadow:0 0 70px rgba(239,68,68,.9)} }
.sos-countdown-txt  { text-align:center; color: var(--yellow); font-size: .88rem; font-weight: 600; margin-top: -8px; }
.sos-seccion   { background: var(--bg-card); border-radius: 12px; border: 1px solid var(--border); overflow: hidden; }
.sos-row       { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }
.sos-row-label { font-size: .82rem; font-weight: 600; }
.sos-row-sub   { font-size: .7rem; color: var(--text-2); margin-top: 2px; }
.toggle-btn    { background: rgba(6,182,212,.1); border: 1px solid rgba(6,182,212,.25); color: var(--cyan); padding: 5px 12px; border-radius: 8px; font-size: .76rem; font-weight: 700; cursor: pointer; }
.toggle-btn.on { background: rgba(6,182,212,.25); }
.toggle-status { font-size: .65rem; font-weight: 700; padding: 2px 6px; border-radius: 8px; }
.toggle-status.on  { background: rgba(34,197,94,.2); color: var(--green); }
.toggle-status.off { background: rgba(100,116,139,.2); color: var(--text-3); }
.audio-meter   { margin: 0 16px 12px; background: var(--bg-base); border-radius: 4px; height: 20px; overflow: hidden; position: relative; }
.audio-bar     { height: 100%; background: var(--green); transition: width .1s, background .1s; border-radius: 4px; }
.audio-label   { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); font-size: .65rem; color: var(--text-1); mix-blend-mode: difference; }
.safewalk-body { display: flex; align-items: center; gap: 8px; padding: 10px 16px; }
.safewalk-input { width: 65px; background: var(--bg-base); border: 1px solid var(--border); color: var(--text-1); border-radius: 6px; padding: 5px 8px; font-size: .82rem; text-align: center; }
.safewalk-countdown { padding: 4px 16px 10px; font-size: .82rem; color: var(--yellow); font-weight: 600; }
.zonas-list    { padding: 6px 8px; max-height: 200px; overflow-y: auto; }
.zona-item     { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; margin-bottom: 4px; background: var(--bg-card); border-left: 3px solid var(--yellow); }
.zona-icon     { font-size: 1.1rem; flex-shrink: 0; }
.zona-info     { flex: 1; min-width: 0; }
.zona-nombre   { font-size: .8rem; font-weight: 600; }
.zona-meta     { font-size: .68rem; color: var(--text-3); }
.zona-riesgo   { font-size: .72rem; font-weight: 700; color: var(--red); }
.sos-camuflaje { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }

/* ══════════════════════════ GLOBE MARKERS ══════════════════════════ */
.globe-marker-base {
  background: rgba(6,182,212,.15);
  border: 2px solid var(--cyan);
  border-radius: 50%;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  box-shadow: 0 0 20px rgba(6,182,212,.5);
  animation: globePulse 2s infinite;
}

@keyframes globePulse {
  0%,100% { box-shadow: 0 0 12px rgba(6,182,212,.4); }
  50%      { box-shadow: 0 0 30px rgba(6,182,212,.8), 0 0 60px rgba(6,182,212,.3); }
}

.globe-marker-device {
  border-radius: 50%;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
  border: 1px solid rgba(255,255,255,.3);
}

.globe-label {
  color: var(--text-1);
  background: rgba(6,11,24,.85);
  border: 1px solid rgba(6,182,212,.3);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: .7rem;
  white-space: nowrap;
  pointer-events: none;
  backdrop-filter: blur(8px);
}

/* Cursor en modo ruta */
.globe-modo-ruta canvas { cursor: crosshair !important; }

/* Zona label en globo */
.zona-globe-label {
  font-size: .65rem;
  font-weight: 700;
  background: rgba(239,68,68,.85);
  color: #fff;
  padding: 2px 7px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
}

/* ══════════════════════════ CALCULADORA CAMUFLAJE ══════════════════════════ */
.camuflaje-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: #1a1a2e;
  display: flex; align-items: center; justify-content: center;
}
.calculadora {
  width: 280px; background: #16213e; border-radius: 16px; padding: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.8);
}
.calc-display { background: #0f3460; border-radius: 8px; padding: 16px; text-align: right; font-size: 2rem; font-weight: 300; color: #e2e8f0; margin-bottom: 8px; min-height: 60px; word-break: break-all; }
.calc-hint    { font-size: .65rem; color: #334155; text-align: center; margin-bottom: 12px; }
.calc-grid    { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
.calc-grid button { background: #1e293b; border: none; border-radius: 8px; color: #e2e8f0; font-size: 1.1rem; padding: 14px; cursor: pointer; transition: background .15s; }
.calc-grid button:hover  { background: #2d3f5a; }
.calc-grid button:active { background: var(--blue); }
.calc-equal { background: var(--blue) !important; color: #fff !important; }
.span2 { grid-column: span 2; }

/* ══════════════════════════ BOTTOM NAV MÓVIL ══════════════════════════ */
#bottomNav { display: none; }

/* ══════════════════════════ MOBILE PANEL ══════════════════════════ */
.mobile-panel {
  position: fixed;
  inset: 0;
  top: var(--header-h);
  bottom: 60px;
  background: var(--bg-panel);
  z-index: 200;
  display: flex;
  flex-direction: column;
}

/* ══════════════════════════ BUTTONS genéricos ══════════════════════════ */
.btn { padding: 6px 13px; border-radius: 8px; border: none; cursor: pointer; font-size: .78rem; font-weight: 600; transition: all .15s; }
.btn-icon { background: none; border: none; color: var(--text-2); cursor: pointer; font-size: .82rem; padding: 3px 6px; border-radius: 5px; }
.btn-icon:hover { color: var(--text-1); }
.btn-gps  { background: rgba(6,182,212,.1); color: var(--cyan); border: 1px solid rgba(6,182,212,.25); }
.btn-arm  { background: rgba(59,130,246,.2); color: var(--blue); border: 1px solid rgba(59,130,246,.4); }

/* ══════════════════════════ RESPONSIVO MÓVIL ══════════════════════════ */
@media (max-width: 900px) {
  #mainLayout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    position: relative;
  }

  #sidebar, #rightPanel { display: none; }

  #centerCol { grid-column: 1; }

  #bottomNav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: rgba(6,11,24,.97);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    z-index: 200;
  }

  .nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: none;
    background: none;
    color: var(--text-2);
    font-size: .6rem;
    cursor: pointer;
    position: relative;
  }

  .nav-btn span:first-child { font-size: 1.25rem; }
  .nav-btn.nav-active { color: var(--cyan); }

  .nav-sos { color: var(--red) !important; }
  .nav-sos span:first-child { font-size: 1.5rem !important; filter: drop-shadow(0 0 6px rgba(239,68,68,.7)); }

  .nav-badge {
    position: absolute;
    top: 4px; right: calc(50% - 18px);
    background: var(--red);
    color: #fff;
    font-size: .58rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
  }

  #mainLayout { padding-bottom: 60px; }

  .ruta-panel { width: 100%; left: 0; border-radius: 0; border-left: none; }

  #toastContainer { right: 8px; left: 8px; width: auto; top: 65px; }

  .hdr-stats { display: none; }
}

@media (max-width: 600px) {
  .logo-ver { display: none; }
  .net-badge { display: none; }
}

/* ══════════════════════════ BODY SOS activo ══════════════════════════ */
body.sos-activo #header { background: rgba(127,29,29,.95); }
body.sos-activo .logo-dot { background: var(--red); box-shadow: 0 0 14px var(--red); }
