/* Frost — plataforma de rastreo de activos (BCM)
   Estilo: premium oscuro con glassmorphism sutil.
   Tipografías: Space Grotesk (marca), Inter (UI), JetBrains Mono (datos) */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  color-scheme: dark; /* selects y scrollbars nativos en oscuro */
  --bg: #070a10;
  --surface: #0e131b;
  --surface-2: #141b25;
  --glass: rgba(14, 19, 27, .72);
  --border: rgba(170, 220, 255, .09);
  --border-hi: rgba(170, 220, 255, .18);
  --text: #eef6ff;
  --muted: #93a1b5;
  --accent: #5cc8ff;
  --accent-2: #a5ecff;
  --grad: linear-gradient(100deg, #4aa8ff, #8fe0ff);
  --ok: #3dd68c;
  --warn: #ffb224;
  --bad: #ff6369;
  --font-ui: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-brand: 'Space Grotesk', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --radius: 14px;
  --radius-s: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, .45);
  --ease: .18s cubic-bezier(.4, 0, .2, 1);
}
html, body { height: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { cursor: pointer; font: inherit; transition: all var(--ease); }
h2 { font-family: var(--font-brand); font-weight: 600; letter-spacing: -.01em; }

/* ===== Barra de scroll de marca: delgada, gradiente sutil ===== */
* { scrollbar-width: thin; scrollbar-color: rgba(92, 200, 255, .38) transparent; }
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(92, 200, 255, .45), rgba(165, 236, 255, .45));
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(92, 200, 255, .75), rgba(165, 236, 255, .75));
}
::-webkit-scrollbar-corner { background: transparent; }

/* ===== Selects: mismos en toda la app, con chevron propio y menú oscuro ===== */
select {
  appearance: none; -webkit-appearance: none;
  background-color: rgba(255, 255, 255, .05);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%239da2ae' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
  border: 1px solid var(--border); border-radius: var(--radius-s);
  color: var(--text); font-family: var(--font-ui); font-size: 13px; font-weight: 500;
  padding: 8px 30px 8px 11px; transition: border-color var(--ease);
}
select:hover { border-color: var(--border-hi); }
select:focus { outline: none; border-color: var(--accent); }
select option, select optgroup {
  background: var(--surface-2); color: var(--text); font-weight: 400; padding: 8px;
}

/* Vidrio esmerilado reutilizable */
.glass {
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  border: 1px solid var(--border);
}

/* Botón primario con gradiente de marca */
button.primary {
  background: var(--grad);
  color: #04121f; border: none; border-radius: var(--radius-s);
  font-weight: 600; padding: 9px 18px;
}
button.primary:hover { filter: brightness(1.12); box-shadow: 0 4px 18px rgba(92, 200, 255, .35); }

/* ===== Login ===== */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden; background: var(--bg);
}
.orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .32; pointer-events: none; }
.orb-a { width: 480px; height: 480px; background: #1d5fd1; top: -120px; left: 14%; }
.orb-b { width: 420px; height: 420px; background: #1aa3c9; bottom: -140px; right: 12%; }
.login-card {
  border-radius: 20px; box-shadow: var(--shadow);
  padding: 44px 40px 28px; width: 400px; display: flex; flex-direction: column; gap: 16px;
  position: relative; z-index: 1;
}
.login-sub { color: var(--muted); font-size: 14px; margin-top: -12px; }
.login-card label { display: flex; flex-direction: column; gap: 7px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.login-card input {
  background: rgba(255, 255, 255, .04); border: 1px solid var(--border); border-radius: var(--radius-s);
  padding: 12px 14px; color: var(--text); font-size: 15px; transition: border-color var(--ease);
}
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(92, 200, 255, .18); }
.login-card button.primary { padding: 13px; font-size: 15px; margin-top: 4px; }
.login-error { color: var(--bad); font-size: 13px; min-height: 17px; }
.login-foot {
  font-size: 12px; color: var(--muted); text-align: center;
  border-top: 1px solid var(--border); padding-top: 14px; margin-top: 4px;
}
.login-foot b { color: var(--text); font-weight: 600; }

/* ===== Marca ===== */
.brand {
  font-family: var(--font-brand); font-size: 19px; font-weight: 700; letter-spacing: -.02em;
  display: flex; align-items: baseline; gap: 6px; white-space: nowrap;
}
.brand.big { font-size: 30px; justify-content: center; }
.brand-mark {
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  font-style: italic; font-weight: 700; letter-spacing: -.12em; margin-right: 2px;
}
.brand-icon { height: 1.2em; width: auto; align-self: center; margin-right: 2px; }

/* ===== Layout ===== */
.app { height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 20px; padding: 11px 20px;
  background: rgba(7, 10, 16, .85); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.tabs {
  display: flex; gap: 2px; flex: 1;
  background: rgba(255, 255, 255, .04); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px; width: fit-content; flex: initial; margin: 0 auto;
}
.tab {
  background: none; border: none; color: var(--muted); padding: 7px 18px;
  border-radius: 999px; font-size: 13.5px; font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface-2); color: var(--text); box-shadow: 0 1px 6px rgba(0, 0, 0, .35); }
.badge {
  background: var(--bad); color: #fff; border-radius: 999px; font-size: 10.5px;
  padding: 1px 7px; margin-left: 4px; font-weight: 600;
}
.userbox { display: flex; align-items: center; gap: 14px; }
.clock { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.clock b { color: var(--text); font-weight: 500; }
.user-id { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; }
.role-chip {
  background: rgba(92, 200, 255, .12); border: 1px solid rgba(92, 200, 255, .3); color: var(--accent);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
}
.userbox > button {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: var(--radius-s); padding: 7px 14px; font-size: 13px;
}
.userbox > button:hover { color: var(--bad); border-color: var(--bad); }

/* Selector de empresa (solo admin) */
.org-switch select { font-size: 13.5px; padding: 8px 32px 8px 12px; max-width: 260px; min-width: 190px; }

/* ===== KPIs: tira liviana (sin cajas) y plegable ===== */
.kpi-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0; row-gap: 7px; padding: 9px 20px;
  border-bottom: 1px solid var(--border); background: var(--bg);
}
.kpi {
  display: flex; align-items: baseline; gap: 8px;
  padding: 2px 20px; border-left: 1px solid var(--border);
}
.kpi:first-child { border-left: none; padding-left: 0; }
.kpi-num { font-family: var(--font-brand); font-size: 19px; font-weight: 700; line-height: 1.1; letter-spacing: -.01em; }
.kpi-num.ok { color: var(--ok); }
.kpi-num.warn { color: var(--warn); }
.kpi-label { font-size: 11px; color: var(--muted); font-weight: 500; }
/* Plegada: solo un resumen de una línea */
.kpi-bar.collapsed { padding: 6px 20px; }
.kpi-bar.collapsed .kpi { display: none; }
.kpi-mini { display: none; font-size: 12.5px; color: var(--muted); }
.kpi-mini b { color: var(--text); font-family: var(--font-mono); font-weight: 600; }
.kpi-mini b.ok { color: var(--ok); }
.kpi-mini b.warn { color: var(--warn); }
.kpi-bar.collapsed .kpi-mini { display: block; }
.kpi-toggle {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 999px; width: 26px; height: 26px; margin-left: 12px;
  font-size: 12px; line-height: 1; display: flex; align-items: center; justify-content: center;
  transition: transform var(--ease), color var(--ease);
}
.kpi-toggle:hover { color: var(--accent); border-color: rgba(92, 200, 255, .4); }
.kpi-bar.collapsed .kpi-toggle { transform: rotate(180deg); }
.ws-pill {
  margin-left: auto; font-size: 12px; font-weight: 600; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted);
}
.ws-pill.on { color: var(--ok); border-color: rgba(61, 214, 140, .35); background: rgba(61, 214, 140, .08); }
.ws-pill.on::before { content: '● '; font-size: 9px; vertical-align: 1px; animation: blink 2.2s infinite; }
.ws-pill.off { color: var(--bad); border-color: rgba(255, 99, 105, .35); }
@keyframes blink { 50% { opacity: .3; } }

/* ===== Mapa + sidebar ===== */
.panel { flex: 1; display: flex; min-height: 0; }
.map-wrap { flex: 1; position: relative; }
#map { position: absolute; inset: 0; background: #0b0d10; }
.map-tools { position: absolute; top: 14px; right: 14px; z-index: 800; display: flex; gap: 8px; }
/* Leyenda: qué significa cada círculo/color del mapa */
.map-legend {
  position: absolute; bottom: 22px; left: 14px; z-index: 800;
  display: flex; flex-direction: column; gap: 5px;
  padding: 9px 12px; border-radius: 12px; font-size: 11px; color: var(--muted);
  background: rgba(13, 13, 16, .78); backdrop-filter: blur(10px);
  border: 1px solid var(--border);
}
.map-legend .lg { display: inline-block; width: 20px; margin-right: 7px; vertical-align: middle; }
.lg-cov { border-top: 2px dashed #8fe0ff; }
.lg-rpt { border-top: 2px dashed #2fae9e; }
.lg-zone { border-top: 2.5px solid #818cf8; }
.lg-alert {
  width: 10px !important; height: 10px; border-radius: 50%;
  background: var(--bad); border: 2px solid #fff; margin-left: 5px; margin-right: 12px;
}
.lg-beacon {
  width: 9px !important; height: 9px; transform: rotate(45deg); border-radius: 2px;
  background: var(--accent-2); border: 1.5px solid #fff; margin-left: 5px; margin-right: 13px;
}
/* Pin de beacon en el mapa: rombo violeta chico (zona techada) */
.bc-dot {
  width: 11px; height: 11px; transform: rotate(45deg); border-radius: 2.5px;
  background: var(--accent-2); border: 2px solid #fff;
  box-shadow: 0 0 8px rgba(165, 236, 255, .6), 0 1px 6px rgba(0, 0, 0, .5);
}
.bc-label {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  background: rgba(10, 14, 20, .82); backdrop-filter: blur(8px);
  color: var(--accent-2); font-size: 9.5px; font-weight: 600;
  padding: 1px 7px; border-radius: 999px; white-space: nowrap;
  border: 1px solid rgba(165, 236, 255, .3); transition: opacity var(--ease);
}
.labels-hidden .bc-label { opacity: 0; pointer-events: none; }
.labels-hidden .mk:hover .bc-label { opacity: 1; }
.map-btn {
  border-radius: var(--radius-s); padding: 8px 15px; font-size: 13px; font-weight: 500;
  color: var(--text); box-shadow: var(--shadow);
}
.map-btn:hover { border-color: var(--border-hi); }
.map-btn.armed { background: var(--grad); border-color: transparent; color: #04121f; }
.map-btn.on { border-color: rgba(92, 200, 255, .45); color: var(--accent); }
.map-readout {
  position: absolute; bottom: 38px; right: 12px; z-index: 800; /* sobre la atribución de Leaflet, sin taparla */
  border-radius: 999px; font-family: var(--font-mono); font-size: 11px; color: var(--muted);
  padding: 5px 13px; pointer-events: none;
}

.sidebar {
  width: 330px; background: var(--bg); border-right: 1px solid var(--border);
  padding: 16px; overflow-y: auto;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sidebar h2 { font-size: 15px; }
/* Qué significa cada color de estado de un equipo */
.status-legend {
  display: flex; gap: 13px; margin-bottom: 12px; font-size: 11px; color: var(--muted);
}
.status-legend span { display: flex; align-items: center; gap: 5px; }
.status-legend .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.status-legend .dot.on { background: var(--ok); }
.status-legend .dot.warn { background: var(--warn); }
.status-legend .dot.off { background: #4d515c; }
.ghost-btn {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: var(--radius-s); padding: 4px 11px; font-size: 12px; font-weight: 500;
}
.ghost-btn:hover { color: var(--accent); border-color: rgba(92, 200, 255, .4); }

.dev-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 13px 15px; margin-bottom: 10px; cursor: pointer;
  transition: border-color var(--ease), transform var(--ease);
}
.dev-card:hover { border-color: var(--border-hi); transform: translateY(-1px); }
.dev-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 6px 20px rgba(92, 200, 255, .12); }
.dev-head { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 14px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot.on { background: var(--ok); box-shadow: 0 0 10px rgba(61, 214, 140, .8); }
.status-dot.warn { background: var(--warn); }
.status-dot.off { background: #4d515c; }
.dev-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 12px; margin-top: 9px; font-size: 12px; color: var(--muted); }
.dev-meta b { color: var(--text); font-weight: 500; font-family: var(--font-mono); font-size: 11.5px; }
.batt-bar { height: 4px; border-radius: 3px; background: rgba(255, 255, 255, .07); margin-top: 10px; overflow: hidden; }
.batt-fill { height: 100%; border-radius: 3px; background: var(--ok); }
.batt-fill.warn { background: var(--warn); }
.batt-fill.bad { background: var(--bad); }

/* ===== Marcadores ===== */
.mk { position: relative; }
.mk-dot {
  width: 15px; height: 15px; border-radius: 50%; border: 2.5px solid #fff;
  box-shadow: 0 1px 10px rgba(0, 0, 0, .6);
}
.mk-dot.on { background: var(--ok); box-shadow: 0 0 12px rgba(61, 214, 140, .7), 0 1px 8px rgba(0, 0, 0, .5); }
.mk-dot.warn { background: var(--warn); }
.mk-dot.off { background: #565b66; }
.mk-pulse {
  position: absolute; inset: -8px; border-radius: 50%;
  border: 2px solid var(--ok); opacity: 0; animation: pulse 2.6s infinite;
}
@keyframes pulse { 0% { transform: scale(.5); opacity: .8; } 70% { transform: scale(1.35); opacity: 0; } 100% { opacity: 0; } }
/* Equipo fuera de su zona segura (alerta sin revisar): rojo + anillo urgente */
.mk-alert-ring {
  position: absolute; inset: -8px; border-radius: 50%;
  border: 2.5px solid var(--bad); opacity: 0; animation: pulse 1.3s infinite;
}
.mk-alert .mk-dot { background: var(--bad) !important; box-shadow: 0 0 12px rgba(255, 99, 105, .8), 0 1px 8px rgba(0, 0, 0, .5); }
.mk-alert .mk-label { color: #ff9aa1; border-color: rgba(255, 99, 105, .45); }
/* Equipo mudo: aviso explicativo en ficha y lista (que el gris no asuste) */
.off-note {
  margin: 8px 0 0; padding: 8px 11px; border-radius: 10px;
  font-size: 12px; line-height: 1.5; color: #d9dce4;
  background: rgba(139, 147, 167, .12); border: 1px solid rgba(139, 147, 167, .3);
}
.off-note b { color: #fff; }
.dev-off-hint { margin-top: 6px; font-size: 11px; color: var(--muted); font-style: italic; }
/* Historial de alertas dentro de la ficha del equipo */
.dev-events { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.dev-events li {
  display: flex; justify-content: space-between; gap: 10px; font-size: 12px;
  color: var(--muted); padding: 4px 9px; border-radius: 8px; background: rgba(255, 255, 255, .03);
}
.dev-events li.open { color: #ffb4b9; background: rgba(255, 99, 105, .08); border: 1px solid rgba(255, 99, 105, .25); }
.mk-label {
  position: absolute; top: -30px; left: 50%; transform: translateX(-50%);
  background: rgba(10, 14, 20, .82); backdrop-filter: blur(8px);
  color: var(--text); font-size: 11px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap; border: 1px solid var(--border);
  transition: opacity var(--ease);
}
/* Con zoom lejano las etiquetas se ocultan para no encimarse; la seleccionada y el hover siempre se ven */
.labels-hidden .mk-label { opacity: 0; pointer-events: none; }
.labels-hidden .mk:hover .mk-label, .labels-hidden .mk.mk-selected .mk-label { opacity: 1; }
.leaflet-popup-content-wrapper {
  background: var(--glass); backdrop-filter: blur(18px); color: var(--text);
  border-radius: 12px; border: 1px solid var(--border); box-shadow: var(--shadow);
}
.leaflet-popup-content code { font-family: var(--font-mono); font-size: 11px; color: var(--accent); }
/* Estado dentro del popup de antena */
.pop-status { font-weight: 600; font-size: 12px; }
.pop-status.ok { color: var(--ok); }
.pop-status.bad { color: var(--bad); }
.pop-hint { display: block; margin-top: 6px; font-size: 11px; color: var(--muted); line-height: 1.45; }
.leaflet-popup-tip { background: var(--surface); }
.leaflet-container { font-family: var(--font-ui); }
.leaflet-bar a { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; }

/* Antenas: torre de radio sin placa; cuando está viva, pulso expansivo.
   El halo radial oscuro la despega del satélite sin verse como "placa". */
.gw-icon {
  width: 40px; height: 40px; position: relative;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #5cc8ff 0%, #8fe0ff 100%);
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .9);
  box-shadow: 0 0 18px rgba(124, 141, 255, .75), 0 2px 10px rgba(0, 0, 0, .55);
}
.gw-icon.rpt {
  background: linear-gradient(135deg, #2fae9e 0%, #3fd9c6 100%);
  box-shadow: 0 0 18px rgba(63, 217, 198, .7), 0 2px 10px rgba(0, 0, 0, .55);
}
.gw-icon svg { display: block; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .45)); }
.gw-icon.off {
  background: linear-gradient(135deg, #4a4f5b 0%, #383c46 100%);
  border-color: rgba(255, 255, 255, .35);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .5);
}
.gw-icon::after {
  content: ''; position: absolute; bottom: 0; right: 0; width: 10px; height: 10px;
  border-radius: 50%; background: var(--ok); border: 2px solid #0d0d10;
  box-shadow: 0 0 8px rgba(61, 214, 140, 1);
}
.gw-icon.off::after { background: #8a919c; box-shadow: none; }
.gw-pulse {
  position: absolute; inset: -5px; border-radius: 50%;
  border: 2px solid rgba(122, 148, 255, .85); opacity: 0; animation: pulse 2.6s infinite .4s;
}
.gw-pulse.p2 { animation-delay: 1.7s; }
.gw-pulse.rpt { border-color: rgba(63, 217, 198, .85); }
/* Ondas de la antena "emitiendo": se encienden en secuencia interior → exterior */
.gw-icon svg .gw-w1 { animation: gwWaves 1.8s ease-out infinite; }
.gw-icon svg .gw-w2 { animation: gwWaves 1.8s ease-out infinite .35s; }
@keyframes gwWaves {
  0% { opacity: .2; }
  30% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: .2; }
}
.gw-icon.off svg .gw-w1, .gw-icon.off svg .gw-w2 { animation: none; opacity: .4; }
.gw-label.rpt { color: #3fd9c6; border-color: rgba(63, 217, 198, .35); }
.gw-label {
  position: absolute; top: 42px; left: 50%; transform: translateX(-50%);
  background: rgba(10, 14, 20, .82); backdrop-filter: blur(8px);
  color: var(--accent); font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap; border: 1px solid rgba(92, 200, 255, .3);
  transition: opacity var(--ease);
}
.labels-hidden .gw-label { opacity: 0; pointer-events: none; }
.labels-hidden .mk:hover .gw-label { opacity: 1; }

/* Agrupación de marcadores (cientos de equipos no explotan el mapa) */
.cluster { background: none; border: none; }
.cluster-inner {
  width: 100%; height: 100%; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 32% 28%, rgba(92, 200, 255, .95), rgba(165, 236, 255, .92));
  color: #fff; font-family: var(--font-brand); font-weight: 700; font-size: 13px;
  border: 2.5px solid rgba(255, 255, 255, .85);
  box-shadow: 0 0 0 5px rgba(92, 200, 255, .22), 0 4px 16px rgba(0, 0, 0, .5);
}
.cluster-inner.big { font-size: 14px; }

/* ===== Tarjeta de detalle ===== */
.detail-card {
  position: absolute; left: 14px; bottom: 14px; z-index: 800; width: 332px;
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.detail-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.detail-head b { font-size: 15px; font-family: var(--font-brand); letter-spacing: -.01em; }
.detail-close { background: none; border: none; color: var(--muted); font-size: 16px; }
.detail-close:hover { color: var(--bad); }
.detail-sub { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); }
.detail-meta { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.detail-meta b { color: var(--text); font-weight: 600; }
/* Zona indoor resuelta por beacon BLE */
.detail-meta.place { color: var(--accent-2); }
.detail-meta.place b { color: var(--accent-2); }
.dev-place {
  margin-top: 8px; font-size: 11.5px; font-weight: 600; color: var(--accent-2);
  background: rgba(165, 236, 255, .1); border: 1px solid rgba(165, 236, 255, .3);
  padding: 3px 10px; border-radius: 999px; display: inline-block;
}
/* Hora absoluta junto a la relativa en el historial de alertas de la ficha */
.ev-abs { font-style: normal; opacity: .65; font-size: 11px; }
.spark-block { margin-top: 12px; }
.spark-title { font-size: 11px; color: var(--muted); font-weight: 500; margin-bottom: 3px; display: flex; justify-content: space-between; }
.spark-title b { color: var(--text); font-family: var(--font-mono); font-weight: 500; font-size: 11px; }
.detail-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.detail-actions button {
  background: rgba(255, 255, 255, .05); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-s); padding: 6px 12px; font-size: 12.5px; font-weight: 500;
}
.detail-actions select { font-size: 12.5px; padding-top: 6px; padding-bottom: 6px; }
.detail-actions button:hover { border-color: rgba(92, 200, 255, .5); color: var(--accent); }

/* ===== Tablas ===== */
.table-wrap, .admin-grid { flex: 1; overflow-y: auto; padding: 24px; }
.table-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.table-head h2 { font-size: 17px; display: flex; align-items: center; gap: 10px; }
/* Chip que dice de qué empresa es lo que se está mirando */
.scope-chip {
  font-family: var(--font-ui); font-size: 11.5px; font-weight: 600; letter-spacing: 0;
  color: var(--accent-2); background: rgba(165, 236, 255, .1);
  border: 1px solid rgba(165, 236, 255, .3); padding: 3px 11px; border-radius: 999px;
}
.check { color: var(--muted); font-size: 13px; display: flex; gap: 7px; align-items: center; cursor: pointer; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-size: 11px; font-weight: 500; padding: 9px 12px; border-bottom: 1px solid var(--border); }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr.unack { background: rgba(255, 99, 105, .05); }
.pill { padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.pill.alert { background: rgba(255, 99, 105, .13); color: var(--bad); }
.pill.zone { background: rgba(165, 236, 255, .14); color: var(--accent-2); }
.pill.ok { background: rgba(61, 214, 140, .12); color: var(--ok); }
/* Severidad de alertas */
.pill.crit { background: rgba(255, 99, 105, .15); color: var(--bad); border: 1px solid rgba(255, 99, 105, .35); }
.pill.warn { background: rgba(255, 178, 36, .13); color: var(--warn); border: 1px solid rgba(255, 178, 36, .3); }
.pill.info { background: rgba(92, 200, 255, .12); color: var(--accent); border: 1px solid rgba(92, 200, 255, .3); }

/* Filtros de la pestaña Alertas */
.alert-filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.alert-filters input[type="search"] {
  background: rgba(255, 255, 255, .04); border: 1px solid var(--border); border-radius: var(--radius-s);
  padding: 7px 12px; color: var(--text); font-size: 13px; width: 210px;
  transition: border-color var(--ease);
}
.alert-filters input[type="search"]:focus { outline: none; border-color: var(--accent); }
.alert-filters .ghost-btn { padding: 7px 13px; }
td button, .card button:not(.primary) {
  background: rgba(255, 255, 255, .05); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-s); padding: 5px 13px; font-size: 12px; font-weight: 500;
}
td button:hover, .card button:not(.primary):hover { border-color: rgba(92, 200, 255, .5); }

/* ===== Admin ===== */
/* Administración: navegación por secciones (una entidad a la vez) */
.admin-wrap { flex: 1; overflow-y: auto; padding: 30px 24px 48px; width: 100%; }
.admin-nav { margin: 0 auto 24px; }
.admin-tab { display: flex; align-items: center; gap: 7px; }
.admin-tab .count-chip { margin-left: 0; padding: 1px 8px; }
.admin-sec { max-width: 960px; margin: 0 auto; width: 100%; padding: 26px 30px 28px; }
.admin-sec.hidden { display: none; }
.sec-head { margin-bottom: 18px; }
.sec-head h2 { font-size: 18px; margin: 0 0 5px; padding: 0; border: none; display: flex; align-items: center; gap: 10px; }
.sec-head h2 .count-chip { margin-left: 0; }
.sec-head .hint { margin: 0; }

/* Nivel 1: tarjetas de empresas */
.org-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px; margin-bottom: 6px;
}
.org-card {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-s);
  padding: 17px 19px; min-width: 0; transition: border-color var(--ease);
}
.org-card:hover { border-color: var(--accent); }
.org-card h3 { font-family: var(--font-brand); font-size: 15.5px; letter-spacing: -.01em; }
.org-card.unassigned h3 { color: var(--muted); }
.org-meta { display: flex; flex-wrap: wrap; gap: 5px 14px; margin-top: 9px; font-size: 12px; color: var(--muted); }
.org-meta b { color: var(--text); font-family: var(--font-mono); font-weight: 600; }
.org-actions { display: flex; gap: 8px; margin-top: 14px; }

/* Nivel 2: cabecera dentro de una empresa */
.org-head {
  max-width: 960px; margin: 0 auto 18px; width: 100%;
  display: flex; align-items: center; gap: 16px;
}
.org-head h2 { font-size: 20px; font-family: var(--font-brand); letter-spacing: -.01em; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; transition: border-color var(--ease); min-width: 0;
}
.card.wide { grid-column: 1 / -1; }
.card:hover { border-color: var(--border-hi); }
.card h2 {
  font-size: 15px; margin: -20px -22px 14px; padding: 14px 22px 12px;
  border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px;
}
.count-chip {
  margin-left: auto; font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  color: var(--accent); background: rgba(92, 200, 255, .1);
  border: 1px solid rgba(92, 200, 255, .25); padding: 2px 9px; border-radius: 999px;
}
.th-right { text-align: right; }
.td-right { text-align: right; white-space: nowrap; }
.td-sub { display: block; color: var(--muted); font-size: 11px; font-weight: 400; margin-top: 1px; }
.hint { color: var(--muted); font-size: 12.5px; margin-bottom: 12px; line-height: 1.5; }
.inline-form { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.inline-form input, .card input {
  background: rgba(255, 255, 255, .04); border: 1px solid var(--border); border-radius: var(--radius-s);
  padding: 8px 11px; color: var(--text); font-size: 13px; font-family: var(--font-ui);
  transition: border-color var(--ease); min-width: 0;
}
.inline-form input:focus, .card input:focus { outline: none; border-color: var(--accent); }

/* Equipos: grilla de mini-tarjetas alineadas */
.admin-dev-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
#admin-gateways { display: grid; gap: 10px; }
.admin-dev {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-s);
  padding: 13px 15px; min-width: 0;
}
.admin-dev-head { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; margin-bottom: 10px; }
.admin-dev-head b { font-size: 13.5px; }
.admin-dev .eui { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); }
.admin-dev .meta { font-size: 11.5px; color: var(--muted); margin-left: auto; }
.admin-dev form {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.1fr) 74px minmax(0, 1fr) auto;
  gap: 8px; align-items: center;
}
.admin-dev input[name="interval"] { font-family: var(--font-mono); }
.admin-dev form.gw-row { grid-template-columns: minmax(0, 1fr) 110px minmax(0, 1fr) auto; }
.admin-dev input, .admin-dev select { width: 100%; }
.admin-dev input[name="cov"] { font-family: var(--font-mono); }
@media (max-width: 1250px) {
  .admin-grid { grid-template-columns: 1fr; }
  .admin-dev-grid { grid-template-columns: 1fr; }
}

/* ===== Toast ===== */
.toast {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 900; border-radius: var(--radius-s); border-color: rgba(92, 200, 255, .4);
  color: var(--text); padding: 10px 20px; font-size: 13.5px;
  font-weight: 500; box-shadow: var(--shadow); max-width: 70%;
}
.toast.warn { border-color: rgba(255, 178, 36, .5); }

/* ===== Recorrido / playback ===== */
.trail-point { background: var(--accent); border: 1.5px solid #fff; border-radius: 50%; }
.play-marker {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--warn); border: 3px solid #fff; box-shadow: 0 0 12px rgba(255, 178, 36, .8);
}
.org-chip {
  background: rgba(165, 236, 255, .12); border: 1px solid rgba(165, 236, 255, .35); color: var(--accent-2);
  font-size: 10px; font-weight: 600; padding: 1px 8px; border-radius: 999px; margin-left: 6px;
  white-space: nowrap; display: inline-block;
}
td .org-chip { margin-left: 0; }

/* Pantallas medianas: el reloj es lo primero que sobra (evita scroll horizontal) */
@media (max-width: 1180px) {
  .clock { display: none; }
  .topbar { gap: 12px; }
}
@media (max-width: 900px) {
  .panel { flex-direction: column; }
  .sidebar { width: 100%; max-height: 38%; }
  .kpi-bar { flex-wrap: wrap; }
  .detail-card { width: calc(100% - 28px); }
  .tabs { margin: 0; }
  .org-switch select { max-width: 160px; }
}
