:root {
  --fondo: #0f141b;
  --superficie: #151b23;
  --superficie-2: #232b36;
  --superficie-3: #2c3643;
  --borde: #232b36;
  --texto: #eef2f6;
  --tenue: #93a0ae;
  --azul: #1f6feb;
  --azul-claro: #7aa7ff;
  --verde: #3fb950;
  --verde-texto: #56d364;
  --naranja: #e3b341;
  --rojo: #f85149;
  --rojo-texto: #ff7b72;
  --violeta: #a78bfa;
  --radio: 16px;
  --sombra: 0 10px 34px rgba(0, 0, 0, .35);
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --fondo: #f3f5f8;
    --superficie: #ffffff;
    --superficie-2: #e9edf2;
    --superficie-3: #dde3ea;
    --borde: #e1e6ec;
    --texto: #16202b;
    --tenue: #566270;
    --azul-claro: #1a5fd0;
    --verde-texto: #1a7f37;
    --naranja: #9a6700;
    --rojo-texto: #c62828;
    --sombra: 0 10px 30px rgba(20, 30, 50, .12);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--fondo);
  color: var(--texto);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--azul-claro); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
h1, h2, h3 { margin: 0; font-weight: 650; }
h2 { font-size: 20px; }
h3 { font-size: 15px; margin-bottom: 12px; }
.tenue { color: var(--tenue); }
.pequeno { font-size: 13px; }
.sin-margen { margin: 0; }
.crece { flex: 1; min-width: 220px; }
.texto-aviso { color: var(--naranja); }
.texto-rojo { color: var(--rojo-texto) !important; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ login */
.pantalla-login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login {
  width: min(380px, 100%); background: var(--superficie); border-radius: 20px; padding: 36px 28px;
  box-shadow: var(--sombra); display: grid; gap: 16px; text-align: center;
}
.login label { text-align: left; }
.login .logo { display: grid; place-items: center; }
.login h1 { font-size: 22px; }
.login > .tenue { margin: -10px 0 4px; }
.login .codigo { font-family: var(--mono); font-size: 28px; letter-spacing: 10px; text-align: center; min-height: 58px; }
.error-login { color: var(--rojo-texto); min-height: 1.5em; margin: 0; }

/* ------------------------------------------------------------ marco */
.marco { display: flex; min-height: 100vh; }
.lateral {
  width: 232px; flex-shrink: 0; background: var(--superficie); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 20px 12px;
}
.marca { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; font-size: 17px; }
.menu { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; flex: 1; }
.menu a {
  display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 14px; border-radius: 12px;
  color: var(--texto); opacity: .85; font-weight: 500;
}
.menu a:hover { background: var(--superficie-2); text-decoration: none; opacity: 1; }
.menu a.activo { background: var(--azul); color: #fff; opacity: 1; font-weight: 600; }
.pie-lateral { padding-top: 12px; }
.ancho-total { width: 100%; justify-content: flex-start; }
.principal { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.barra-superior {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px 36px 6px;
  max-width: 1180px; width: 100%;
}
.barra-superior h1 { font-size: 26px; font-weight: 700; }
.contenido { padding: 14px 36px 64px; display: grid; gap: 20px; align-content: start; max-width: 1180px; width: 100%; }
.contenido-anidado { display: grid; gap: 18px; }
.barra-movil { display: none; }

/* ------------------------------------------------------- tarjetas */
.tarjeta { background: var(--superficie); border-radius: var(--radio); padding: 22px; min-width: 0; }
.rejilla { display: grid; gap: 16px; }
.rejilla.dos { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.rejilla.tres { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.rejilla.cuatro { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.columna { display: flex; flex-direction: column; gap: 12px; }
.empuja-abajo { margin-top: auto; }
.subtitulo { font-size: 18px; }
.saludo { font-size: 22px; }
.cifra { font-size: 30px; font-weight: 700; margin: 0 0 6px; }
.cifra small { font-size: 14px; font-weight: 400; color: var(--tenue); }
.datos { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.datos dt { color: var(--tenue); }
.datos dd { margin: 0; overflow-wrap: anywhere; }
.consejos { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.lista-simple { margin: 0 0 10px; padding-left: 0; list-style: none; display: grid; gap: 6px; }
.enlace { font-size: 13px; }

/* ----------------------------------------------- inicio y estados */
.estado-general, .aviso-actualizar { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.estado-general { padding: 28px; }
.estado-general h2 { font-size: 24px; }
.estado-general p { margin: 4px 0 0; }
.con-error { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--rojo) 55%, transparent); }
.aviso-actualizar { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--naranja) 55%, transparent); }
.aviso-actualizar h2 { font-size: 18px; color: var(--naranja); }
.aviso-actualizar p { margin: 4px 0 0; }
.lista-problemas { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 4px; }
.lista-problemas a { color: var(--texto); }
.circulo { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.circulo.ok { background: color-mix(in srgb, var(--verde) 16%, transparent); color: var(--verde-texto); }
.circulo.error { background: color-mix(in srgb, var(--rojo) 16%, transparent); color: var(--rojo-texto); }
.circulo.aviso { background: color-mix(in srgb, var(--naranja) 16%, transparent); color: var(--naranja); width: 48px; height: 48px; }
.circulo.grande { margin: 0 auto 6px; }
.medidor-simple .valor-grande { font-size: 32px; font-weight: 700; margin: 2px 0 10px; }
.medidor-simple p { margin: 10px 0 0; }
.rejilla-acciones { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 14px; }
.fila-icono { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.fila-entre { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.centrado { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.grande-relleno { padding: 32px; display: flex; flex-direction: column; gap: 12px; }
.grande-relleno.centrado { padding: 44px 24px; }
.valor-enorme { font-size: 56px; font-weight: 800; line-height: 1; }
.grande-texto { font-size: 18px; margin: 0 0 10px; }
.lista-paquetes { margin: 14px 0 0; padding-left: 20px; display: grid; gap: 4px; }
details.tarjeta summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.lista-filas { display: grid; }
.fila-lista { padding: 12px 0; border-top: 1px solid var(--borde); }

/* ----------------------------------------------- servicios y sitios */
.cabeza-seccion { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  min-height: 40px; padding: 0 18px; border-radius: 99px; border: 0; background: var(--superficie-2); color: var(--texto);
  font: inherit; font-weight: 500; cursor: pointer;
}
.chip.activo { background: var(--texto); color: var(--fondo); }
.rejilla-servicios { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.servicio { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px; }
.servicio.error { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--rojo) 55%, transparent); }
.servicio-cabeza { display: flex; align-items: center; gap: 10px; }
.servicio-cabeza strong { flex: 1; font-size: 16px; overflow-wrap: anywhere; }
.servicio-pie { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: auto; }
.punto { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: var(--tenue); }
.punto.ok { background: var(--verde); }
.punto.error { background: var(--rojo); }
.punto.aviso { background: var(--naranja); }
.estado-texto { font-size: 13px; font-weight: 600; }
.estado-texto.ok { color: var(--verde-texto); }
.estado-texto.error { color: var(--rojo-texto); }
.estado-texto.aviso { color: var(--naranja); }
.estado-texto.neutro { color: var(--tenue); }
.webs { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; font-size: 14px; overflow-wrap: anywhere; }

/* ----------------------------------------------------- herramientas */
.rejilla-herramientas { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.herramienta { display: flex; flex-direction: column; gap: 8px; color: var(--texto); min-height: 150px; }
.herramienta:hover { background: var(--superficie-2); text-decoration: none; }
.icono-caja { width: 44px; height: 44px; border-radius: 12px; background: var(--superficie-2); display: grid; place-items: center; color: var(--azul-claro); }
.herramienta:hover .icono-caja { background: var(--superficie-3); }
.migas-herramienta { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

/* -------------------------------------------------------- alertas */
.lista-alertas { display: grid; gap: 8px; }
.alerta { display: block; border-radius: 12px; padding: 12px 16px; color: var(--texto); }
a.alerta:hover { text-decoration: none; filter: brightness(1.15); }
.alerta p { margin: 4px 0 0; color: var(--tenue); }
.alerta.ok { background: color-mix(in srgb, var(--verde) 12%, transparent); }
.alerta.aviso { background: color-mix(in srgb, var(--naranja) 12%, transparent); }
.alerta.error { background: color-mix(in srgb, var(--rojo) 12%, transparent); }
.alerta.info { background: color-mix(in srgb, var(--azul) 12%, transparent); }

.insignia { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; white-space: nowrap; vertical-align: middle; }
.insignia.ok { background: color-mix(in srgb, var(--verde) 16%, transparent); color: var(--verde-texto); }
.insignia.aviso { background: color-mix(in srgb, var(--naranja) 16%, transparent); color: var(--naranja); }
.insignia.error { background: color-mix(in srgb, var(--rojo) 16%, transparent); color: var(--rojo-texto); }
.insignia.info { background: color-mix(in srgb, var(--azul) 18%, transparent); color: var(--azul-claro); }
.insignia.neutro { background: var(--superficie-2); color: var(--tenue); }

.medidor-cabeza { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.medidor-cabeza span { color: var(--tenue); }
.medidor-cabeza strong { font-size: 24px; }
.barra { height: 8px; background: var(--superficie-2); border-radius: 99px; overflow: hidden; margin-bottom: 8px; }
.barra.gruesa { height: 12px; margin: 4px 0; }
.barra-relleno { height: 100%; border-radius: 99px; transition: width .5s; }
.barra-relleno.ok { background: var(--verde); }
.barra-relleno.aviso { background: var(--naranja); }
.barra-relleno.error { background: var(--rojo); }
.barra-relleno.azul { background: var(--azul); }

/* --------------------------------------------------------- tablas */
.tabla-envoltura { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--tenue); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--borde); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
td > code { white-space: nowrap; }
.recortado { display: inline-block; max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.mensaje-log { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.clicable { cursor: pointer; }
.clicable:hover { color: var(--azul-claro); }

/* -------------------------------------------------------- botones */
.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 10px; cursor: pointer; background: var(--superficie-2); color: var(--texto); border: 0;
  font: inherit; font-weight: 600; white-space: nowrap; text-decoration: none;
}
.boton:hover { background: var(--superficie-3); text-decoration: none; }
.boton:disabled { opacity: .55; cursor: progress; }
.boton.primario { background: var(--azul); color: #fff; }
.boton.primario:hover { background: #3b82f6; }
.boton.peligro { background: #da3633; color: #fff; }
.boton.peligro-suave { color: var(--rojo-texto); }
.boton.fantasma { background: transparent; }
.boton.fantasma:hover { background: var(--superficie-2); }
.boton.chico { min-height: 34px; padding: 0 12px; font-size: 13px; }
.boton.grande { min-height: 54px; padding: 0 22px; font-size: 16px; }
.boton.enorme { min-height: 62px; padding: 0 36px; font-size: 18px; margin: 6px 0; }
.botonera { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.barra-acciones { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.barra-acciones input[type="search"], .barra-acciones input[type="text"] { width: auto; flex: 1; min-width: 180px; }

.pestanas { display: flex; gap: 4px; border-bottom: 1px solid var(--borde); overflow-x: auto; }
.pestanas button {
  background: none; border: 0; color: var(--tenue); padding: 10px 14px; min-height: 44px; cursor: pointer; font: inherit;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.pestanas button.activa { color: var(--texto); border-bottom-color: var(--azul); font-weight: 600; }

/* ---------------------------------------------------- formularios */
label { display: grid; gap: 6px; font-weight: 500; }
label small { font-weight: 400; color: var(--tenue); }
label.casilla { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 32px; }
label.casilla small { flex-basis: 100%; }
label.en-linea { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
input, select, textarea {
  width: 100%; background: var(--fondo); color: var(--texto); border: 1px solid var(--superficie-3); border-radius: 10px;
  padding: 10px 12px; font: inherit; min-height: 44px;
}
textarea { min-height: auto; }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--azul); }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--azul) 55%, transparent); border-color: var(--azul); }
:focus-visible { outline: 2px solid var(--azul-claro); outline-offset: 2px; }
.invalido { border-color: var(--rojo) !important; }
.formulario { display: grid; gap: 14px; }
.acciones { display: flex; justify-content: flex-end; gap: 8px; align-items: center; }
.acciones small { margin-right: auto; }
.filtros { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 12px; }
.filtros label { min-width: 140px; }

/* ------------------------------------------------- consola y logs */
pre.consola {
  background: #0a0d12; color: #d6dee8; border-radius: 10px; padding: 14px;
  font: 12.5px/1.45 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 360px; overflow: auto; margin: 0;
}
pre.consola.alta { max-height: 62vh; min-height: 200px; }
.terminal { background: #0a0d12; color: #d6dee8; border-radius: 10px 10px 0 0; padding: 14px; height: 55vh; overflow: auto; }
.terminal pre { margin: 0 0 6px; font: 12.5px/1.45 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.terminal pre.comando { color: var(--verde-texto); }
.terminal pre.error { color: #ff8a8a; }
.entrada-terminal { border-radius: 0 0 10px 10px; background: #0a0d12; color: #e6edf3; border: 0; border-top: 1px solid #232b36; }
.editor {
  width: 100%; min-height: 60vh; font: 13px/1.5 var(--mono); tab-size: 4; resize: vertical; white-space: pre;
  background: #0a0d12; color: #d6dee8; margin-bottom: 12px;
}
.migas { margin-bottom: 10px; overflow-wrap: anywhere; }
.carpeta { font-weight: 600; }
.cabeza-sitio { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.cabeza-sitio h3 { margin: 0; }

/* -------------------------------------------------------- gráficas */
.grafica { width: 100%; height: auto; display: block; }
.grafica .eje { stroke: var(--superficie-3); stroke-dasharray: 3 4; }
.grafica .etiqueta-eje { fill: var(--tenue); font-size: 11px; }
.leyenda { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--tenue); margin-top: 6px; }
.leyenda i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------------------------------------------------------- modales */
.modal-fondo { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal {
  width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column;
  background: var(--superficie); border-radius: 18px; box-shadow: var(--sombra);
}
.modal.ancho { width: min(1100px, 100%); }
.modal header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--borde); }
.modal header h2 { font-size: 17px; overflow-wrap: anywhere; }
.modal .cerrar { background: none; border: 0; color: var(--tenue); font-size: 26px; cursor: pointer; line-height: 1; min-width: 44px; min-height: 44px; }
.modal-cuerpo { padding: 20px; overflow: auto; display: grid; gap: 14px; }
.mensaje-confirmar { margin: 0; white-space: pre-line; }
.estado-tarea { display: flex; align-items: center; gap: 8px; }

#avisos { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; max-width: min(420px, calc(100vw - 32px)); }
.aviso-flotante {
  padding: 13px 18px; border-radius: 12px; background: var(--superficie); box-shadow: var(--sombra);
  border-left: 4px solid var(--verde); white-space: pre-line; overflow-wrap: anywhere;
}
.aviso-flotante.error { border-left-color: var(--rojo); }
.aviso-flotante.aviso { border-left-color: var(--naranja); }

.cargando { display: flex; align-items: center; gap: 10px; color: var(--tenue); padding: 24px; }
.giro { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--superficie-3); border-top-color: var(--azul); animation: girar .8s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ móvil */
@media (max-width: 760px) {
  .lateral {
    position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s;
    box-shadow: var(--sombra); height: 100%; padding-bottom: 90px;
  }
  .lateral.abierto { transform: none; }
  .barra-superior { padding: 16px 16px 4px; }
  .barra-superior h1 { font-size: 22px; }
  .barra-superior .boton span { display: none; }
  .contenido { padding: 10px 16px 100px; }
  .rejilla-servicios, .rejilla-herramientas { grid-template-columns: minmax(0, 1fr); }
  .recortado { max-width: 180px; }
  .estado-general { padding: 20px; }
  .barra-movil {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    background: var(--superficie); border-top: 1px solid var(--borde); padding: 6px 4px calc(10px + env(safe-area-inset-bottom));
  }
  .barra-movil a, .barra-movil button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 54px;
    color: var(--tenue); font: inherit; font-size: 12px; background: none; border: 0; cursor: pointer;
  }
  .barra-movil a:hover { text-decoration: none; }
  .barra-movil .activo { color: var(--azul-claro); font-weight: 600; }
  #avisos { bottom: 86px; }
}
