/* Central de Monitoreo: acento rojo WITI, tema claro y oscuro, el color nunca es la única señal. */
:root {
  --fondo: #f4f5f7; --panel: #fff; --texto: #1b2430; --sub: #5d6b7a; --borde: #dfe3e8; --borde-fuerte: #c5ccd5;
  --acento: #c8302b; --acento-hover: #a82722; --acento-suave: #fbeceb; --acento-texto: #fff;
  --ok: #1e7b34; --av: #b26a00; --mal: #b3261e; --gris: #7a828f;
  --ok-f: #e7f5ea; --av-f: #fff4e0; --mal-f: #fdecea; --gris-f: #eef0f3;
  --sombra: 0 1px 2px rgb(16 24 40 / .06), 0 1px 3px rgb(16 24 40 / .08);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #0f1318; --panel: #171c23; --texto: #e4e9ef; --sub: #98a4b2; --borde: #2a323d; --borde-fuerte: #3a4452;
    --acento: #ef5350; --acento-hover: #f26d6a; --acento-suave: #3a1d1d; --acento-texto: #160707;
    --ok: #7fd18f; --av: #f0a640; --mal: #f28b82; --gris: #8d95a3;
    --ok-f: #18301e; --av-f: #33270f; --mal-f: #3a1f1d; --gris-f: #1d242d;
    --sombra: 0 1px 2px rgb(0 0 0 / .4);
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--fondo); color: var(--texto); }
a { color: var(--acento); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }
.ic { width: 16px; height: 16px; vertical-align: -3px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ok { color: var(--ok); } .av { color: var(--av); } .mal { color: var(--mal); } .gris { color: var(--gris); }
.sub { color: var(--sub); font-size: 12px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }

.barra { display: flex; align-items: center; gap: 16px; padding: 8px 20px; background: var(--panel); border-bottom: 3px solid var(--acento); flex-wrap: wrap; }
.marca { font-weight: 700; color: var(--texto); display: flex; gap: 8px; align-items: center; }
/* Logo WITI (negro y rojo sobre transparente): en tema oscuro va sobre una placa blanca para que se vea. */
.logo { width: 36px; height: 36px; border-radius: 6px; }
.logo-svg { height: 22px; width: auto; display: block; }
.logo-grande { width: 96px; height: 96px; align-self: center; }
@media (prefers-color-scheme: dark) { .logo { background: #fff; padding: 2px; } }
.barra nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.barra nav a { color: var(--texto); padding: 6px 10px; border-radius: 6px; display: flex; gap: 6px; align-items: center; }
.barra nav a.activo, .barra nav a:hover { background: var(--gris-f); text-decoration: none; }
.insignia { background: var(--mal); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; }
.instancia { color: var(--sub); font-size: 12px; display: flex; gap: 4px; align-items: center; }
.salir button { background: none; border: 1px solid var(--borde); color: var(--texto); }

main { padding: 16px 20px 40px; max-width: 1500px; margin: 0 auto; }
h1 { font-size: 20px; margin: 6px 0 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
h1 .ic { width: 22px; height: 22px; vertical-align: -4px; }
h2 { font-size: 15px; margin: 22px 0 8px; display: flex; gap: 6px; align-items: center; }
.cabecera { margin-bottom: 8px; }
.resumen { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin: 4px 0; }
.migas { color: var(--sub); font-size: 12px; margin: 0; }

.aviso { padding: 8px 12px; border-radius: 6px; margin: 8px 0; border: 1px solid var(--borde); }
.aviso.ok { background: var(--ok-f); } .aviso.av { background: var(--av-f); } .aviso.mal { background: var(--mal-f); }
.vacio { color: var(--sub); padding: 10px 0; }

button, .boton { font: inherit; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--borde); background: var(--panel); color: var(--texto);
  cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
button:hover, .boton:hover { border-color: var(--acento); text-decoration: none; }
button.primario { background: var(--acento); color: var(--acento-texto); border-color: var(--acento); }
button.peligro, .boton.peligro { color: var(--mal); border-color: var(--mal); }
button.chico { padding: 2px 8px; font-size: 12px; }
button.icono { padding: 2px 5px; margin-left: 4px; }
td form.en-linea { margin-left: 0; }
input, select { font: inherit; padding: 5px 8px; border: 1px solid var(--borde); border-radius: 6px; background: var(--panel); color: var(--texto); }
label { display: inline-flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--sub); }

.filtros { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--borde); border-radius: 8px; padding: 10px 12px; margin: 10px 0 14px; }
form.en-linea { display: inline; margin-left: auto; }

/* Árbol Contrato → Establecimiento, al estilo de Advanced IP Scanner */
details.grupo { background: var(--panel); border: 1px solid var(--borde); border-radius: 8px; margin: 8px 0; }
details.grupo > summary { padding: 8px 12px; cursor: pointer; display: flex; gap: 8px; align-items: center; list-style: none; }
details.grupo > summary::-webkit-details-marker { display: none; }
details.grupo > summary::before { content: "▸"; color: var(--sub); transition: transform .15s; }
details.grupo[open] > summary::before { transform: rotate(90deg); }
details.contrato > summary { font-size: 15px; }
details.local { margin: 0 10px 10px 22px; background: var(--fondo); }
.conteo { font-size: 12px; padding: 1px 8px; border-radius: 10px; border: 1px solid currentColor; }
details.sin-enrutador { margin: 6px 12px 10px; color: var(--sub); }
details.sin-enrutador summary { cursor: pointer; }

.tabla { width: 100%; border-collapse: collapse; background: var(--panel); }
details.local .tabla { border-top: 1px solid var(--borde); }
.tabla th, .tabla td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--borde); vertical-align: top; }
.tabla th { font-size: 12px; color: var(--sub); font-weight: 600; white-space: nowrap; }
.tabla tbody tr:hover { background: var(--gris-f); }
.tabla.compacta td, .tabla.compacta th { padding: 3px 8px; }
tr.fila-caido td:first-child { box-shadow: inset 3px 0 var(--mal); }
tr.fila-degradado td:first-child { box-shadow: inset 3px 0 var(--av); }
tr.fila-en_linea td:first-child { box-shadow: inset 3px 0 var(--ok); }
tr.fila-cortado td:first-child, tr.fila-sin_tunel td:first-child { box-shadow: inset 3px 0 var(--gris); }
.est { display: inline-flex; gap: 4px; align-items: center; white-space: nowrap; font-weight: 600; }
.est.ok { color: var(--ok); } .est.av { color: var(--av); } .est.mal { color: var(--mal); } .est.gris { color: var(--gris); }
pre.resultado { white-space: pre-wrap; max-height: 260px; overflow: auto; margin: 0; font-size: 12px; }

.tarjetas { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.tarjeta { background: var(--panel); border: 1px solid var(--borde); border-radius: 8px; padding: 10px 14px; margin: 0; }
.tarjeta dt { font-size: 12px; color: var(--sub); margin-top: 6px; display: flex; gap: 4px; align-items: center; }
.tarjeta dd { margin: 0; font-weight: 600; }
.grafica { width: 100%; max-width: 900px; height: auto; background: var(--panel); border: 1px solid var(--borde); border-radius: 8px; }
.grafica .eje { font-size: 10px; fill: var(--sub); }
.leyenda { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin: 8px 0; }
.acciones form { display: inline-flex; gap: 6px; align-items: flex-end; }
details.confirmar { display: inline-block; }
details.confirmar > summary { list-style: none; }
details.confirmar > summary::-webkit-details-marker { display: none; }
details.confirmar[open] { background: var(--panel); border: 1px solid var(--borde); border-radius: 8px; padding: 8px; }
details.confirmar form { flex-direction: column; align-items: flex-start; }

/* Barra: Mi cuenta */
.cuenta-enlace { color: var(--texto); display: flex; gap: 6px; align-items: center; padding: 6px 10px; border-radius: 6px; }
.cuenta-enlace.activo, .cuenta-enlace:hover { background: var(--gris-f); text-decoration: none; }

/* Formularios de cuentas */
.formulario { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.formulario label { font-size: 13px; min-width: min(320px, 100%); }
.formulario input:not([type=checkbox]), .formulario select { width: 100%; }
.usuario-form { align-items: stretch; max-width: 980px; }
.usuario-form .tarjeta { display: flex; flex-direction: column; gap: 10px; }
.usuario-form > button { align-self: flex-start; }
label.casilla { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--texto); }
.etiqueta { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 9px; background: var(--gris-f); border: 1px solid var(--borde); margin: 1px 0; }
.secreto { background: var(--gris-f); border: 1px dashed var(--borde); border-radius: 6px; padding: 8px 10px; word-break: break-all; letter-spacing: .04em; }
.enlace-clave p { margin: 4px 0; }
.boton.primario { background: var(--acento); color: var(--acento-texto); border-color: var(--acento); }
.tarjeta h2 { margin-top: 4px; }

/* ── Portada (entrar, segundo factor, definir contraseña): misma familia visual que WitiAdmin y WitiNotificaciones ── */
body.cuerpo-portada main { max-width: none; padding: 0; }
body.cuerpo-portada main > .aviso { position: fixed; top: 12px; right: 12px; z-index: 5; max-width: 380px; }
.pagina-portada { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(380px, 1fr); position: relative;
  background: radial-gradient(1200px 600px at 50% -10%, var(--acento-suave), transparent 60%), var(--fondo); }
.portada { position: relative; padding: 40px 56px; display: flex; flex-direction: column; gap: 14px; justify-content: center; }
.portada-marca { display: flex; align-items: center; gap: 12px; font-weight: 600; letter-spacing: .1em; font-size: 12px; color: var(--sub); }
.portada h1 { font-size: clamp(30px, 3.4vw, 46px); line-height: 1.06; margin: 4px 0 0; font-weight: 800; letter-spacing: -.02em; display: block; }
.portada h1 em { font-style: normal; color: var(--acento); }
.portada-lema { margin: 0; color: var(--sub); font-size: 16px; max-width: 36ch; }
.portada-puntos { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 12px; max-width: 520px; }
.portada-puntos li { display: flex; gap: 12px; align-items: flex-start; }
/* El mismo cuadro de icono que las tarjetas del tablero de WitiAdmin (.icono-kpi) */
.portada-puntos li > .ic { width: 34px; height: 34px; padding: 8px; border-radius: 9px; background: var(--acento-suave); color: var(--acento); flex: none; }
.portada-puntos strong { display: block; font-size: 14px; }
.portada-puntos span { font-size: 13px; color: var(--sub); }

/* Ilustración: la central y los enrutadores unidos por el túnel (colores del tema) */
.red { width: 100%; max-width: 470px; height: auto; margin: 0; }
.red .halo-centro { stop-color: var(--acento); stop-opacity: .16; }
.red .halo-borde { stop-color: var(--acento); stop-opacity: 0; }
.red .orbita { fill: none; stroke: var(--borde-fuerte); stroke-dasharray: 2 6; opacity: .7; }
.red .enlaces line { stroke: var(--borde-fuerte); stroke-width: 1.2; }
.red .pulsos line { stroke: var(--acento); stroke-width: 2.4; stroke-linecap: round; stroke-dasharray: 10 240; stroke-dashoffset: 250;
  animation: red-viaje 3.2s linear infinite; }
.red .pulsos .p2 { animation-delay: -.4s; } .red .pulsos .p3 { animation-delay: -1.6s; } .red .pulsos .p4 { animation-delay: -.9s; }
.red .pulsos .p5 { animation-delay: -2.3s; } .red .pulsos .p6 { animation-delay: -1.2s; } .red .pulsos .p7 { animation-delay: -2.8s; }
.red .pulsos .p8 { animation-delay: -2s; }
.red .enrutadores rect { fill: var(--panel); stroke: var(--borde-fuerte); stroke-width: 1.4; }
.red .enrutadores line { stroke: var(--borde-fuerte); stroke-width: 1.4; stroke-linecap: round; }
.red .luz { animation: red-luz 2.4s ease-in-out infinite; }
.red .luz.ok { fill: var(--ok); } .red .luz.av { fill: var(--av); }
.red .l2 { animation-delay: -.3s; } .red .l3 { animation-delay: -1.1s; } .red .l4 { animation-delay: -.7s; } .red .l5 { animation-delay: -1.8s; }
.red .l6 { animation-delay: -.5s; } .red .l7 { animation-delay: -1.4s; } .red .l8 { animation-delay: -2s; }
.red .central .caja { fill: #ff3131; }
.red .central .disco { fill: #fff; opacity: .95; }
.red .central .led { fill: #1e7b34; }
.red .onda { fill: none; stroke: var(--acento); stroke-width: 1.5; opacity: .6; transform-box: fill-box; transform-origin: center; animation: red-onda 3s ease-out infinite; }
.red .onda-2 { animation-delay: -1.5s; }
@keyframes red-viaje { to { stroke-dashoffset: 0; } }
@keyframes red-luz { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes red-onda { from { transform: scale(1); opacity: .7; } to { transform: scale(3.4); opacity: 0; } }

/* Lado del ingreso: la tarjeta de WitiAdmin/WitiNotificaciones */
.ingreso { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 14px; padding: 32px 24px; }
.estado-central { display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--panel); border: 1px solid var(--borde); }
.estado-central .punto { width: 9px; height: 9px; border-radius: 50%; background: var(--gris); }
.estado-central.activa { color: var(--ok); }
.estado-central.activa .punto { background: var(--ok); animation: latido 2s infinite; }
.estado-central.inactiva { color: var(--mal); }
.estado-central.inactiva .punto { background: var(--mal); }
.estado-central .sub { font-weight: 400; }
@keyframes latido { 0% { box-shadow: 0 0 0 0 rgba(30, 123, 52, .5); } 70% { box-shadow: 0 0 0 8px rgba(30, 123, 52, 0); } 100% { box-shadow: 0 0 0 0 rgba(30, 123, 52, 0); } }
form.entrar { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--borde); border-radius: 12px; padding: 2rem;
  display: grid; gap: .9rem; box-shadow: var(--sombra); }
.marca-login { display: flex; justify-content: center; padding: .25rem 0; }
form.entrar h2 { margin: 0; font-size: 1.4rem; justify-content: center; text-align: center; }
form.entrar .sub { margin: 0; }
form.entrar .sub.centro { text-align: center; margin: -.4rem 0 .4rem; }
form.entrar label { font-size: 13px; color: var(--texto); font-weight: 600; }
form.entrar input { padding: 9px 11px; font-weight: 400; }
form.entrar button.primario { justify-content: center; padding: 10px; font-weight: 600; background: var(--acento); border-color: var(--acento); color: var(--acento-texto); }
form.entrar button.primario:hover { background: var(--acento-hover); border-color: var(--acento-hover); }
.otra-accion button { background: none; border: none; color: var(--sub); }
.pie-portada { color: var(--sub); font-size: 11px; margin: 0; }

@media (max-width: 860px) {
  .pagina-portada { grid-template-columns: 1fr; }
  .portada { padding: 24px 22px 8px; }
  .portada-puntos { display: none; }
  .red { max-width: 340px; align-self: center; }
}
@media (prefers-reduced-motion: reduce) {
  .red .pulsos line, .red .luz, .red .onda, .estado-central .punto { animation: none !important; }
  .red .pulsos { display: none; }
}
