/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --bg2:       #181c27;
  --bg3:       #1e2334;
  --border:    rgba(255,255,255,0.07);
  --text:      #e8eaf0;
  --muted:     #7a7f94;
  --activo:    #22c55e;
  --inactivo:  #f59e0b;
  --offline:   #ef4444;
  --alta:      #38bdf8;   /* precisión alta  — azul cielo  */
  --media:     #a78bfa;   /* precisión media — violeta     */
  --baja:      #fb923c;   /* precisión baja  — naranja     */
  --accent:    #3b82f6;
  --header-h:  52px;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* ── Header ───────────────────────────────────────────────── */
header {
  height: var(--header-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-dot {
  width: 10px; height: 10px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .6; transform: scale(1.3); }
}

h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--text);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 18px;
}

.stat {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.stat-num {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

#stat-activos   .stat-num { color: var(--activo);   }
#stat-inactivos .stat-num { color: var(--inactivo); }
#stat-offline   .stat-num { color: var(--offline);  }

.stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.separador {
  width: 1px; height: 24px;
  background: var(--border);
}

#ultima-actualizacion {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Layout ───────────────────────────────────────────────── */
#contenedor {
  display: flex;
  height: calc(100vh - var(--header-h));
}

/* ── Mapa ─────────────────────────────────────────────────── */
#mapa-wrap {
  position: relative;
  flex: 1;
  min-width: 320px;
}

#mapa {
  width: 100%;
  height: 100%;
  background: #111;
}

/* Filtro oscuro sobre las tiles para que los pines resalten */
.leaflet-tile { filter: brightness(0.85) saturate(0.7); }

/* ── Leyenda de precisión ─────────────────────────────────── */
#leyenda-precision {
  position: absolute;
  bottom: 28px;
  left: 12px;
  z-index: 1000;
  background: rgba(15,17,23,0.92);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 12px;
  backdrop-filter: blur(6px);
  min-width: 210px;
}

.ley-titulo {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 7px;
}

.ley-sep { height: 1px; background: var(--border); margin: 8px 0; }

.ley-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  color: #c0c4d4;
}

/* Ícono de pin de precisión en la leyenda */
.ley-icon {
  display: inline-block;
  width: 14px; height: 18px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  flex-shrink: 0;
}

.pin-alta  { background: var(--alta);   box-shadow: 0 0 6px var(--alta);   }
.pin-media { background: var(--media);  box-shadow: 0 0 6px var(--media);  }
.pin-baja  { background: var(--baja);   box-shadow: 0 0 6px var(--baja);   }

.ley-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-activo  { background: var(--activo);  }
.dot-inactivo{ background: var(--inactivo);}
.dot-offline { background: var(--offline); }

/* ── Panel derecho ────────────────────────────────────────── */
#panel {
  width: 52%;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--bg);
  overflow: hidden;
}

#panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-shrink: 0;
}

#panel-header h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  display: flex;
  align-items: center;
  gap: 8px;
}

#total-badge {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1px 8px;
  font-size: 11px;
  color: var(--text);
  font-weight: 500;
}

#buscador {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  padding: 5px 10px;
  outline: none;
  width: 180px;
  transition: border-color .2s;
}

#buscador:focus { border-color: var(--accent); }
#buscador::placeholder { color: var(--muted); }

/* ── Tabla ────────────────────────────────────────────────── */
#tabla-wrap {
  overflow-y: auto;
  flex: 1;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

thead th {
  background: var(--bg2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 8px 10px;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
}

tbody tr:hover { background: var(--bg3); }
tbody tr.seleccionada { background: rgba(59,130,246,.12); }

td {
  padding: 9px 10px;
  vertical-align: middle;
  white-space: nowrap;
}

/* ── Chips de estado ──────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.chip-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
}

.chip.activo   { background: rgba(34,197,94,.15);  color: var(--activo);  }
.chip.inactivo { background: rgba(245,158,11,.15); color: var(--inactivo);}
.chip.sin_conexion { background: rgba(239,68,68,.15);  color: var(--offline); }

.chip.activo    .chip-dot { background: var(--activo);   animation: blink 1.5s ease-in-out infinite; }
.chip.inactivo  .chip-dot { background: var(--inactivo); }
.chip.sin_conexion .chip-dot { background: var(--offline);  }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: .3; }
}

/* ── Badge de precisión en la tabla ──────────────────────── */
.prec-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.prec-alta  { background: rgba(56,189,248,.15);  color: var(--alta);  }
.prec-media { background: rgba(167,139,250,.15); color: var(--media); }
.prec-baja  { background: rgba(251,146,60,.15);  color: var(--baja);  }
.prec-na    { background: rgba(122,127,148,.1);  color: var(--muted); }

.prec-icono {
  font-size: 10px;
}

/* ── Actividad teclado/mouse ──────────────────────────────── */
.act-si  { color: var(--activo);  font-weight: 600; }
.act-no  { color: var(--offline); font-weight: 600; }

/* ── Detalle de empleado ──────────────────────────────────── */
#detalle {
  border-top: 1px solid var(--border);
  background: var(--bg2);
  padding: 14px 16px;
  flex-shrink: 0;
  transition: max-height .3s ease;
  max-height: 280px;
  overflow-y: auto;
}

#detalle.oculto { display: none; }

#detalle-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

#detalle-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
}

#detalle-nombre {
  font-size: 14px;
  font-weight: 600;
}

#detalle-cerrar {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  line-height: 1;
}

#detalle-cerrar:hover { color: var(--text); }

#detalle-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.det-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

.det-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  display: block;
  margin-bottom: 3px;
}

.det-item span:last-child {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

#det-apps {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.app-chip {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--muted);
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── Pines del mapa custom ────────────────────────────────── */
.pin-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pin-body {
  width: 28px; height: 28px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255,255,255,0.3);
}

.pin-inner {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.8);
  transform: rotate(45deg);
}

.pin-sombra {
  width: 8px; height: 4px;
  background: rgba(0,0,0,0.3);
  border-radius: 50%;
  margin-top: 1px;
}