:root {
  --bg: #0b101b;
  --bg-card: #121a2b;
  --bg-elev: #182338;
  --borde: #253451;
  --texto: #f1f5f9;
  --subtexto: #94a3b8;
  --acento: #38bdf8;
  --acento-fuerte: #0284c7;
  --verde: #22c55e;
  --verde-bg: rgba(34, 197, 94, 0.14);
  --amarillo: #f59e0b;
  --amarillo-bg: rgba(245, 158, 11, 0.15);
  --rojo: #ef4444;
  --rojo-bg: rgba(239, 68, 68, 0.15);
  --radio: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: radial-gradient(circle at top right, #13203a 0%, var(--bg) 55%);
  color: var(--texto);
  min-height: 100vh;
  line-height: 1.45;
}

.oculto {
  display: none !important;
}

h1, h2, h3 {
  margin: 0 0 0.35rem 0;
  letter-spacing: -0.02em;
}

.subtexto {
  margin: 0 0 1.1rem 0;
  color: var(--subtexto);
  font-size: 0.92rem;
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--borde);
  border-radius: 18px;
  padding: 2rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.brand-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--acento);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.28);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  margin-bottom: 0.85rem;
}

.brand-badge.alerta {
  color: var(--amarillo);
  background: var(--amarillo-bg);
  border-color: rgba(245, 158, 11, 0.35);
}

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #cbd5e1;
  margin: 0.75rem 0 0.3rem;
}

input, select, textarea {
  width: 100%;
  background: #0d1424;
  color: var(--texto);
  border: 1px solid var(--borde);
  border-radius: 10px;
  padding: 0.62rem 0.78rem;
  font-size: 0.93rem;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--acento);
}

.btn-primario, .btn-secundario, .btn-texto {
  cursor: pointer;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.62rem 1rem;
  border: none;
  transition: transform 0.08s ease, opacity 0.15s ease;
}

.btn-primario {
  background: linear-gradient(135deg, var(--acento), var(--acento-fuerte));
  color: #04101d;
  margin-top: 1rem;
}

.btn-primario:hover {
  opacity: 0.94;
}

.btn-secundario {
  background: var(--bg-elev);
  color: var(--texto);
  border: 1px solid var(--borde);
}

.btn-texto {
  background: transparent;
  color: var(--subtexto);
}

.btn-full {
  width: 100%;
}

.btn-chico {
  padding: 0.36rem 0.68rem;
  font-size: 0.8rem;
  margin-top: 0;
}

.alerta-error {
  background: var(--rojo-bg);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  font-size: 0.86rem;
  margin-top: 0.8rem;
}

.separador-o {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--subtexto);
  font-size: 0.78rem;
  margin: 1rem 0 0.35rem;
}

.separador-o::before,
.separador-o::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--borde);
}

.separador-o span {
  padding: 0 0.65rem;
}

/* App Shell */
.app-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 1px solid var(--borde);
  gap: 1rem;
  flex-wrap: wrap;
}

.topbar-izq, .topbar-der {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.punto-vivo {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--verde);
  box-shadow: 0 0 10px var(--verde);
}

.topbar-sep {
  color: var(--subtexto);
  margin: 0 0.3rem;
}

.topbar-titulo {
  color: var(--subtexto);
}

.chip-rol {
  font-size: 0.8rem;
  background: var(--bg-elev);
  border: 1px solid var(--borde);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  color: #e2e8f0;
}

/* KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.9rem;
  margin: 1.25rem 0;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.kpi-card.alerta-roja {
  border-color: rgba(239, 68, 68, 0.65);
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.12), var(--bg-card));
}

.kpi-label {
  font-size: 0.78rem;
  color: var(--subtexto);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-valor {
  font-size: 1.65rem;
  font-weight: 700;
}

.kpi-pie {
  font-size: 0.8rem;
  color: var(--subtexto);
}

/* Tabs */
.tabs-bar {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--borde);
  margin-bottom: 1.35rem;
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  color: var(--subtexto);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.75rem 1rem;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn.activo {
  color: var(--acento);
  border-bottom-color: var(--acento);
}

/* Layout columnas */
.dos-columnas {
  display: grid;
  grid-template-columns: minmax(340px, 460px) 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 960px) {
  .dos-columnas {
    grid-template-columns: 1fr;
  }
}

.card-form {
  background: var(--bg-card);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 1.25rem;
}

.fila-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.fila-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
}

@media (max-width: 560px) {
  .fila-2, .fila-3 {
    grid-template-columns: 1fr;
  }
}

.checks-linea {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.35rem;
}

.check-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  font-weight: 500;
}

.check-item input {
  width: auto;
}

/* Tarjetas de nodos, prospectos y clientes */
.nodos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1rem;
}

.pila-tarjetas {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.tarjeta {
  background: var(--bg-card);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 1.1rem 1.2rem;
}

.tarjeta-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.semaforo-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.24rem 0.62rem;
  border-radius: 999px;
  text-transform: uppercase;
}

.semaforo-pill.verde, .semaforo-pill.ok {
  color: #86efac;
  background: var(--verde-bg);
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.semaforo-pill.amarillo, .semaforo-pill.atencion {
  color: #fcd34d;
  background: var(--amarillo-bg);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.semaforo-pill.rojo, .semaforo-pill.critico {
  color: #fca5a5;
  background: var(--rojo-bg);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.metricas-mini {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0.75rem 0;
  padding: 0.65rem;
  background: #0d1424;
  border-radius: 10px;
  font-size: 0.82rem;
}

.metricas-mini strong {
  display: block;
  font-size: 1rem;
  color: var(--texto);
}

.lista-motivos {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.84rem;
  color: #cbd5e1;
}

.radar-box {
  margin-top: 0.75rem;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.07);
  border: 1px solid rgba(56, 189, 248, 0.22);
  font-size: 0.82rem;
}

.acciones-fila {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 0.85rem;
}

.acciones-fila select {
  width: auto;
  padding: 0.35rem 0.6rem;
  font-size: 0.82rem;
}

.bloque-secundario {
  margin-top: 2rem;
}

.tabla-wrap {
  margin-top: 0.65rem;
  background: var(--bg-card);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

th, td {
  text-align: left;
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--borde);
}

th {
  color: var(--subtexto);
  font-weight: 600;
}

.vacio {
  padding: 1.5rem;
  text-align: center;
  color: var(--subtexto);
  background: var(--bg-card);
  border: 1px dashed var(--borde);
  border-radius: var(--radio);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 580px;
  background: var(--bg-card);
  border: 1px solid var(--borde);
  border-radius: 18px;
  padding: 1.6rem;
}

.codigo-box {
  background: #070b14;
  border: 1px solid var(--borde);
  border-radius: 10px;
  padding: 0.75rem;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.83rem;
  color: #e2e8f0;
  margin: 0.25rem 0 0.75rem;
}

.codigo-box.resaltado {
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.45);
}

.modal-acciones {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  margin-top: 1rem;
}
