/* Consola del laboratorio · estilos.
 * Design system de Pablo (Navy/Blue/Gold, Plus Jakarta Sans + DM Sans + JetBrains Mono) en CSS puro.
 * CSP: sin estilos en línea en el HTML; anchos y colores dinámicos se fijan desde consola.js por CSSOM.
 */
:root {
  color-scheme: light dark;
  --navy: #0F2B5B; --blue: #2563EB; --gold: #D4A843; --gold-h: #c49a3a;
  --success: #059669; --warning: #D97706; --danger: #DC2626;
  --base: #FAFAF9; --surface: #ffffff; --surface-2: #f1f5f9; --surface-3: #e2e8f0;
  --text: #0f172a; --text-2: #475569; --muted: #64748b;
  --border: rgba(15, 23, 42, 0.1); --border-strong: rgba(15, 23, 42, 0.2);
  --glass: rgba(255, 255, 255, 0.78);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08); --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.12);
  --shadow-lg: 0 8px 32px rgba(15, 23, 42, 0.16);
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-2xl: 28px;
  --f-display: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-sans: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --t-fast: 150ms; --t-normal: 250ms; --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --seg-sistema: #94a3b8; --seg-intocable: var(--gold); --seg-libre: var(--surface-2);
  --ok-bg: rgba(5, 150, 105, 0.1); --ok-fg: #047857;
  --warn-bg: rgba(217, 119, 6, 0.1); --warn-fg: #b45309;
  --err-bg: rgba(220, 38, 38, 0.08); --err-fg: #b91c1c;
  --info-bg: rgba(37, 99, 235, 0.08); --info-fg: #1d4ed8;
}
@media (prefers-color-scheme: dark) {
  :root {
    --base: #0F172A; --surface: #1e293b; --surface-2: #0f1f35; --surface-3: #334155;
    --text: #f1f5f9; --text-2: #cbd5e1; --muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.08); --border-strong: rgba(255, 255, 255, 0.16);
    --glass: rgba(30, 41, 59, 0.78);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4); --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.55);
    --seg-sistema: #64748b; --seg-libre: #0b1627;
    --ok-bg: rgba(16, 185, 129, 0.14); --ok-fg: #6ee7b7;
    --warn-bg: rgba(245, 158, 11, 0.14); --warn-fg: #fcd34d;
    --err-bg: rgba(248, 113, 113, 0.14); --err-fg: #fca5a5;
    --info-bg: rgba(96, 165, 250, 0.14); --info-fg: #93c5fd;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.csp {
  margin: 0; min-height: 100vh; background: var(--base); color: var(--text);
  font: 400 14px/1.55 var(--f-sans); -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
.csp [hidden] { display: none !important; }
.csp h1, .csp h2, .csp h3, .csp h4 { font-family: var(--f-display); margin: 0; letter-spacing: -0.01em; }
:where(.csp) :where(button, input, select) { font: inherit; color: inherit; }
.csp :focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
.csp code, .csp .csp-mono { font-family: var(--f-mono); font-size: 12px; }
.csp-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.csp ::-webkit-scrollbar { width: 6px; height: 6px; }
.csp ::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
.csp svg { width: 1em; height: 1em; flex: none; }

/* ---------- encabezado ---------- */
.csp-cabecera {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px;
  padding: 12px clamp(16px, 4vw, 40px); background: var(--glass); backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
}
.csp-marca { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.csp-logo {
  width: 40px; height: 40px; border-radius: var(--r-lg); display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--navy), #1e40af); color: var(--gold); font-size: 22px;
  box-shadow: 0 2px 12px -2px rgba(15, 43, 91, 0.45);
}
.csp-titulo { font: 800 17px/1.2 var(--f-display); letter-spacing: -0.02em; white-space: nowrap; }
.csp-titulo em { font-style: normal; color: var(--blue); }
.csp-resumen-frase { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); min-width: 0; }
.csp-resumen-frase span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.csp-cab-derecha { display: flex; align-items: center; gap: 10px; flex: none; }
.csp-reloj { font: 500 12px var(--f-mono); color: var(--muted); }
.csp-usuario {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 4px 4px 4px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
}
.csp-iniciales {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--navy); color: #fff; font: 700 12px var(--f-display); text-transform: uppercase;
}
.csp-usuario-nombre { font-size: 13px; font-weight: 500; }
.csp-salir { margin: 0; }

/* ---------- botones ---------- */
.csp-boton {
  position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--r-md); border: 1px solid transparent; cursor: pointer;
  font-weight: 600; font-size: 13px; white-space: nowrap; text-decoration: none;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.csp-boton:hover:not(:disabled) { transform: scale(1.01); }
.csp-boton:active:not(:disabled) { transform: scale(0.99); }
.csp-boton:disabled { opacity: 0.45; cursor: not-allowed; }
.csp-boton-primario { background: var(--blue); color: #fff; box-shadow: 0 2px 10px -3px rgba(37, 99, 235, 0.6); }
.csp-boton-primario:hover:not(:disabled) { background: #1d4ed8; }
.csp-boton-navy { background: var(--navy); color: #fff; box-shadow: 0 2px 16px -2px rgba(15, 43, 91, 0.35); }
.csp-boton-navy::after, .csp-boton-primario::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-200%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.14), transparent); transition: transform 700ms;
}
.csp-boton-navy:hover::after, .csp-boton-primario:hover::after { transform: translateX(200%); }
.csp-boton-peligro { background: var(--err-bg); color: var(--err-fg); border-color: rgba(220, 38, 38, 0.25); }
.csp-boton-peligro:hover:not(:disabled) { background: var(--danger); color: #fff; }
.csp-boton-peligro-lleno { background: var(--danger); color: #fff; }
.csp-boton-outline { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.csp-boton-outline:hover:not(:disabled) { background: var(--surface-2); }
.csp-boton-ghost { background: transparent; color: var(--text-2); }
.csp-boton-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.csp-boton-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.csp-boton-icono { width: 36px; padding: 0; }
.csp-boton svg { font-size: 16px; }

/* ---------- píldoras y puntos de estado ---------- */
.csp-pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px; border-radius: 999px; font-size: 12px;
  font-weight: 600; border: 1px solid transparent; white-space: nowrap; background: var(--surface-2); color: var(--text-2);
}
.csp-pill[data-tono="ok"] { background: var(--ok-bg); color: var(--ok-fg); border-color: rgba(5, 150, 105, 0.25); }
.csp-pill[data-tono="info"] { background: var(--info-bg); color: var(--info-fg); border-color: rgba(37, 99, 235, 0.25); }
.csp-pill[data-tono="aviso"] { background: var(--warn-bg); color: var(--warn-fg); border-color: rgba(217, 119, 6, 0.28); }
.csp-pill[data-tono="error"] { background: var(--err-bg); color: var(--err-fg); border-color: rgba(220, 38, 38, 0.25); }
.csp-pill[data-tono="gold"] { background: rgba(212, 168, 67, 0.16); color: #8a6a1f; border-color: rgba(212, 168, 67, 0.35); }
@media (prefers-color-scheme: dark) { .csp-pill[data-tono="gold"] { color: #f3d58a; } }
.csp-punto { position: relative; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.csp-punto[data-vivo="true"]::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; background: currentColor;
  animation: csp-ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}
@keyframes csp-ping { 75%, 100% { transform: scale(2.4); opacity: 0; } }

/* ---------- estructura ---------- */
.csp-main { max-width: 1320px; margin: 0 auto; padding: 24px clamp(16px, 4vw, 40px) 48px; display: grid; gap: 28px; }
.csp-seccion { display: grid; gap: 14px; min-width: 0; }
.csp-seccion-cab { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.csp-seccion-cab h2 { font-size: 18px; font-weight: 700; }
.csp-seccion-nota { font-size: 13px; color: var(--muted); }
.csp-eyebrow { font: 600 10px/1 var(--f-sans); text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); }
.csp-tarjeta-base {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t-normal) var(--ease), border-color var(--t-normal), transform var(--t-normal) var(--ease);
}
.csp-vacio { padding: 18px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- resumen ---------- */
.csp-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.csp-kpi { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--r-lg); }
.csp-kpi-icono {
  width: 38px; height: 38px; border-radius: var(--r-md); display: grid; place-items: center; font-size: 19px; flex: none;
  background: var(--info-bg); color: var(--blue);
}
.csp-kpi[data-tono="ok"] .csp-kpi-icono { background: var(--ok-bg); color: var(--success); }
.csp-kpi[data-tono="aviso"] .csp-kpi-icono { background: var(--warn-bg); color: var(--warning); }
.csp-kpi[data-tono="error"] .csp-kpi-icono { background: var(--err-bg); color: var(--danger); }
.csp-kpi[data-tono="gold"] .csp-kpi-icono { background: rgba(212, 168, 67, 0.16); color: var(--gold-h); }
.csp-kpi-label { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }
.csp-kpi-valor { display: block; font: 700 19px/1.2 var(--f-display); }
.csp-kpi-valor small { font: 500 12px var(--f-sans); color: var(--muted); margin-left: 4px; }

/* ---------- alertas ---------- */
.csp-alertas { display: grid; gap: 8px; }
.csp-alerta {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--r-lg);
  background: var(--warn-bg); color: var(--text); border: 1px solid rgba(217, 119, 6, 0.3);
}
.csp-alerta svg { font-size: 18px; color: var(--warning); margin-top: 1px; }
.csp-alerta strong { display: block; font-weight: 600; }
.csp-alerta span { color: var(--text-2); font-size: 13px; }

/* ---------- operación en curso ---------- */
.csp-operacion {
  padding: 18px 20px; border-radius: var(--r-xl); color: #fff; overflow: hidden; position: relative;
  background: linear-gradient(120deg, var(--navy) 0%, #1e40af 60%, #2563eb 100%); box-shadow: var(--shadow-md);
}
.csp-operacion::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 85% 20%, rgba(212, 168, 67, 0.28), transparent 45%);
}
.csp-op-cab { position: relative; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.csp-op-icono {
  width: 42px; height: 42px; border-radius: var(--r-lg); display: grid; place-items: center; font-size: 22px;
  background: rgba(255, 255, 255, 0.14); color: var(--gold);
}
.csp-op-icono svg { animation: csp-giro 2.4s linear infinite; }
@keyframes csp-giro { to { transform: rotate(360deg); } }
.csp-op-texto { flex: 1; min-width: 200px; }
.csp-op-texto strong { display: block; font: 700 16px var(--f-display); }
.csp-op-texto span { color: rgba(255, 255, 255, 0.78); font-size: 13px; }
.csp-op-tiempo { font: 700 18px var(--f-mono); color: var(--gold); }
.csp-pasos { position: relative; list-style: none; margin: 16px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.csp-paso { display: grid; gap: 8px; font-size: 12px; color: rgba(255, 255, 255, 0.6); }
.csp-paso i { display: block; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.18); overflow: hidden; position: relative; }
.csp-paso[data-estado="hecho"] { color: rgba(255, 255, 255, 0.9); }
.csp-paso[data-estado="hecho"] i { background: var(--gold); }
.csp-paso[data-estado="actual"] { color: #fff; font-weight: 600; }
.csp-paso[data-estado="actual"] i::after {
  content: ""; position: absolute; inset: 0; width: 40%; border-radius: 4px; background: var(--gold);
  animation: csp-avance 1.4s var(--ease) infinite;
}
@keyframes csp-avance { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* ---------- equipos ---------- */
.csp-equipos { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.csp-equipo { padding: 18px; display: grid; gap: 14px; align-content: start; min-width: 0; }
.csp-equipo:hover { box-shadow: var(--shadow-md); border-color: rgba(37, 99, 235, 0.3); }
.csp-equipo[data-conexion="sin_conexion"], .csp-equipo[data-conexion="wsl_caido"] { border-color: rgba(220, 38, 38, 0.35); }
.csp-equipo-cab { display: flex; align-items: flex-start; gap: 12px; }
.csp-equipo-icono {
  width: 40px; height: 40px; border-radius: var(--r-lg); display: grid; place-items: center; font-size: 20px; flex: none;
  background: var(--info-bg); color: var(--blue);
}
.csp-equipo-titulos { flex: 1; min-width: 0; }
.csp-equipo-titulos h3 { font-size: 16px; font-weight: 700; }
.csp-equipo-titulos p { margin: 2px 0 0; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.csp-libre { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.csp-libre-valor { font: 700 28px/1 var(--f-display); letter-spacing: -0.02em; }
.csp-libre-valor small { font: 500 13px var(--f-sans); color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.csp-libre-nota { font-size: 12px; color: var(--muted); text-align: right; }
.csp-medidor { display: grid; gap: 6px; }
.csp-barra {
  position: relative; height: 14px; border-radius: 999px; background: var(--seg-libre); display: flex; overflow: visible;
  box-shadow: inset 0 0 0 1px var(--border);
}
.csp-barra-seg { height: 100%; min-width: 2px; transition: width var(--t-normal) var(--ease); }
.csp-barra-seg:first-child { border-radius: 999px 0 0 999px; }
.csp-barra-seg + .csp-barra-seg { box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.55); }
.csp-barra-seg[data-tipo="sistema"] { background: var(--seg-sistema); }
.csp-barra-seg[data-tipo="intocable"] { background: var(--seg-intocable); }
.csp-barra-seg[data-prudencia="true"] {
  background-image: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.45) 0 4px, transparent 4px 8px);
}
.csp-barra-exceso { position: absolute; right: -2px; top: -3px; bottom: -3px; width: 6px; border-radius: 4px; background: var(--danger); }
.csp-limite { position: absolute; top: -6px; bottom: -6px; width: 2px; background: var(--text); border-radius: 2px; }
.csp-limite::after {
  content: ""; position: absolute; top: -3px; left: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--text);
}
.csp-real { height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.csp-real i { display: block; height: 100%; border-radius: 4px; background: var(--blue); opacity: 0.7; transition: width var(--t-normal) var(--ease); }
.csp-escala { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); }
.csp-escala b { font: 600 11px var(--f-mono); color: var(--text-2); }
.csp-leyenda { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--text-2); }
.csp-leyenda span { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.csp-leyenda i { width: 10px; height: 10px; border-radius: 3px; flex: none; background: var(--seg-sistema); }
.csp-leyenda i[data-tipo="intocable"] { background: var(--seg-intocable); }
.csp-leyenda i[data-tipo="libre"] { background: var(--seg-libre); box-shadow: inset 0 0 0 1px var(--border-strong); }
.csp-leyenda i[data-tipo="real"] { background: var(--blue); opacity: 0.7; }
.csp-leyenda b { font: 600 11px var(--f-mono); }
.csp-datos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.csp-dato { padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); min-width: 0; }
.csp-dato span { display: block; font-size: 11px; color: var(--muted); }
.csp-dato strong { display: block; font: 700 14px var(--f-mono); overflow-wrap: anywhere; }
.csp-dato[data-tono="error"] { background: var(--err-bg); }
.csp-dato[data-tono="error"] strong { color: var(--err-fg); }
.csp-nota { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-md); font-size: 13px; }
.csp-nota svg { font-size: 16px; margin-top: 2px; }
.csp-nota[data-tono="error"] { background: var(--err-bg); color: var(--err-fg); }
.csp-nota[data-tono="aviso"] { background: var(--warn-bg); color: var(--warn-fg); }
.csp-nota[data-tono="info"] { background: var(--info-bg); color: var(--info-fg); }
.csp-nota[data-tono="ok"] { background: var(--ok-bg); color: var(--ok-fg); }
.csp-nota p { margin: 0; }
.csp-nota code { display: block; margin-top: 6px; padding: 8px; border-radius: 8px; background: var(--surface); color: var(--text); overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- proyectos ---------- */
.csp-filtros { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); flex-wrap: wrap; }
.csp-filtro {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; border: 0;
  background: transparent; color: var(--text-2); cursor: pointer; font-size: 13px; font-weight: 500; transition: background var(--t-fast), color var(--t-fast);
}
.csp-filtro:hover { color: var(--text); }
.csp-filtro[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }
.csp-filtro small { font: 600 11px var(--f-mono); color: var(--muted); }
.csp-grupo { display: grid; gap: 12px; }
.csp-grupo-cab { display: flex; align-items: center; gap: 10px; }
.csp-grupo-cab h3 { font-size: 14px; font-weight: 700; }
.csp-grupo-cab::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.csp-proyectos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.csp-proyecto { padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; border-top: 3px solid var(--c, var(--blue)); }
.csp-proyecto:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.csp-proyecto[data-estado="activo"] { background: linear-gradient(180deg, color-mix(in srgb, var(--success) 5%, var(--surface)), var(--surface) 40%); }
.csp-proyecto[data-estado="error"] { border-color: rgba(220, 38, 38, 0.35); border-top-color: var(--danger); }
.csp-proy-cab { display: flex; align-items: flex-start; gap: 12px; }
.csp-avatar {
  width: 42px; height: 42px; border-radius: var(--r-lg); display: grid; place-items: center; flex: none; font-size: 21px;
  color: var(--c, var(--blue)); background: color-mix(in srgb, var(--c, var(--blue)) 16%, transparent);
}
.csp-proy-titulos { flex: 1; min-width: 0; }
.csp-proy-nombre { font: 700 15px/1.3 var(--f-display); overflow-wrap: anywhere; }
.csp-proy-donde { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); margin-top: 2px; }
.csp-proy-desc { margin: 0; font-size: 13px; color: var(--text-2); }
.csp-proy-mem { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.csp-proy-mem em { display: block; font-style: normal; font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.csp-proy-extra { display: grid; gap: 8px; }
.csp-proy-pie { margin-top: auto; display: grid; gap: 8px; }
.csp-proy-acciones { display: flex; gap: 8px; }
.csp-proy-acciones .csp-boton { flex: 1; }
.csp-motivo { display: flex; gap: 6px; align-items: flex-start; font-size: 12px; color: var(--muted); }
.csp-motivo svg { font-size: 14px; margin-top: 2px; }
.csp-cuenta { font-family: var(--f-mono); font-weight: 700; }
.csp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.csp-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 3px 9px; border-radius: 999px; font-size: 11px;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); overflow-wrap: anywhere;
}
.csp-chip i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); flex: none; }
.csp-chip[data-estado="running"] i { background: var(--success); }
.csp-chip[data-estado="omitido"] i { background: var(--warning); }
.csp-plegable { border-radius: var(--r-md); }
.csp-plegable > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--blue);
  padding: 4px 0; user-select: none;
}
.csp-plegable > summary::-webkit-details-marker { display: none; }
.csp-plegable > summary::before {
  content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform var(--t-fast); margin-right: 2px;
}
.csp-plegable[open] > summary::before { transform: rotate(45deg); }
.csp-plegable-cuerpo { display: grid; gap: 10px; padding-top: 8px; }
.csp-lista { display: grid; gap: 4px; }
.csp-lista ul { margin: 0; padding-left: 18px; font-size: 12px; color: var(--text-2); display: grid; gap: 3px; }
.csp-lista li { overflow-wrap: anywhere; }

/* ---------- paneles inferiores ---------- */
.csp-dos { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.csp-panel { padding: 16px 18px; min-width: 0; }
.csp-panel > summary { font: 700 15px var(--f-display); color: var(--text); padding: 2px 0; }
.csp-panel > summary::before { border-color: var(--muted); }
.csp-contador { font: 600 11px var(--f-mono); padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.csp-rev { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--r-lg); background: var(--surface-2); flex-wrap: wrap; }
.csp-rev-reloj {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: conic-gradient(var(--blue) var(--p, 0%), var(--surface-3) 0); position: relative;
}
.csp-rev-reloj::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--surface); }
.csp-rev-reloj span { position: relative; font: 700 11px var(--f-mono); }
.csp-rev-texto { flex: 1; min-width: 160px; display: grid; gap: 2px; }
.csp-rev-texto strong { font-weight: 600; }
.csp-rev-texto span { font-size: 12px; color: var(--muted); }
.csp-ctl { padding: 12px 0; border-top: 1px solid var(--border); display: grid; gap: 6px; }
.csp-ctl:first-child { border-top: 0; }
.csp-ctl-cab { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.csp-ctl-cab strong { font-weight: 600; overflow-wrap: anywhere; }
.csp-ctl p { margin: 0; font-size: 12px; color: var(--text-2); }
.csp-ctl small { font-size: 12px; color: var(--muted); }
.csp-linea { list-style: none; margin: 0; padding: 0; display: grid; }
.csp-evento { position: relative; display: grid; grid-template-columns: 58px 16px minmax(0, 1fr); gap: 8px; padding: 6px 0; font-size: 12px; }
.csp-evento time { font-family: var(--f-mono); color: var(--muted); font-size: 11px; padding-top: 1px; }
.csp-evento-punto { position: relative; display: flex; justify-content: center; }
.csp-evento-punto::before { content: ""; position: absolute; top: 14px; bottom: -8px; width: 1px; background: var(--border); }
.csp-evento:last-child .csp-evento-punto::before { display: none; }
.csp-evento-punto i { width: 9px; height: 9px; margin-top: 4px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px var(--surface); position: relative; }
.csp-evento[data-tono="ok"] .csp-evento-punto i { background: var(--success); }
.csp-evento[data-tono="error"] .csp-evento-punto i { background: var(--danger); }
.csp-evento[data-tono="aviso"] .csp-evento-punto i { background: var(--warning); }
.csp-evento-texto { color: var(--text-2); overflow-wrap: anywhere; }
.csp-evento-texto b { color: var(--text); font-weight: 600; }
.csp-evento-texto small { color: var(--muted); }
.csp-mas { justify-self: start; margin-top: 6px; }

/* ---------- avisos flotantes ---------- */
.csp-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.csp-toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-lg); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 13px; animation: csp-subir var(--t-normal) var(--ease);
}
.csp-toast svg { font-size: 18px; margin-top: 1px; }
.csp-toast[data-tono="error"] svg { color: var(--danger); }
.csp-toast[data-tono="ok"] svg { color: var(--success); }
.csp-toast[data-tono="info"] svg { color: var(--blue); }
.csp-toast p { margin: 0; flex: 1; overflow-wrap: anywhere; }
.csp-toast button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 0 2px; }
@keyframes csp-subir { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- modales ---------- */
.csp-modal-fondo {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(2, 6, 23, 0.45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: csp-aparecer var(--t-normal);
}
.csp-modal {
  width: min(760px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--surface);
  border-radius: var(--r-2xl); box-shadow: var(--shadow-lg); border: 1px solid var(--border); animation: csp-escala var(--t-normal) var(--ease);
}
.csp-modal-chico { width: min(480px, 100%); }
@keyframes csp-aparecer { from { opacity: 0; } }
@keyframes csp-escala { from { opacity: 0; transform: scale(0.96) translateY(8px); } }
.csp-modal-cab { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px 14px; border-bottom: 1px solid var(--border); }
.csp-modal-cab h3 { font-size: 18px; font-weight: 700; }
.csp-modal-cab p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.csp-modal-cab > div { flex: 1; min-width: 0; }
.csp-modal-cuerpo { padding: 18px 22px; overflow-y: auto; display: grid; gap: 18px; }
.csp-modal-pie { display: flex; align-items: center; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.csp-modal-pie .csp-resultado { flex: 1; min-width: 180px; }
.csp-bloque { display: grid; gap: 10px; }
.csp-bloque-cab { display: flex; align-items: center; gap: 10px; }
.csp-bloque-num {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--navy); color: #fff; font: 700 12px var(--f-display);
}
.csp-bloque-cab h4 { font-size: 15px; font-weight: 700; }
.csp-bloque-cab p { margin: 0; font-size: 12px; color: var(--muted); }
.csp-plan-equipo { display: grid; gap: 8px; padding: 12px; border-radius: var(--r-lg); background: var(--surface-2); }
.csp-plan-equipo-cab { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-weight: 600; }
.csp-plan-equipo-cab small { font-weight: 400; color: var(--muted); font-size: 12px; }
.csp-reglas { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.csp-regla { display: grid; gap: 4px; padding: 10px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border); align-content: start; }
.csp-regla-cab { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; }
.csp-regla-icono { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; flex: none; background: var(--surface-2); color: var(--muted); }
.csp-regla[data-cumple="true"] .csp-regla-icono { background: var(--success); color: #fff; }
.csp-regla[data-cumple="false"] { border-color: rgba(220, 38, 38, 0.35); background: var(--err-bg); }
.csp-regla[data-cumple="false"] .csp-regla-icono { background: var(--danger); color: #fff; }
.csp-regla p { margin: 0; font-size: 12px; color: var(--text-2); }
.csp-regla small { font: 400 10.5px/1.4 var(--f-mono); color: var(--muted); overflow-wrap: anywhere; }
.csp-apagar-lista { display: grid; gap: 8px; }
.csp-apagar-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; transition: border-color var(--t-fast), background var(--t-fast);
}
.csp-apagar-item:hover { border-color: rgba(37, 99, 235, 0.35); }
.csp-apagar-item[data-marcado="true"] { border-color: rgba(217, 119, 6, 0.45); background: var(--warn-bg); }
.csp-apagar-item input { width: 18px; height: 18px; accent-color: var(--warning); }
.csp-apagar-item strong { display: block; font-weight: 600; }
.csp-apagar-item small { display: block; font-size: 12px; color: var(--muted); }
.csp-apagar-item b { font: 600 12px var(--f-mono); color: var(--text-2); text-align: right; }
.csp-opciones { display: flex; flex-wrap: wrap; gap: 8px; border: 0; margin: 0; padding: 0; }
.csp-opcion { position: relative; }
.csp-opcion input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.csp-opcion span {
  display: inline-flex; align-items: center; height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); font-size: 13px; font-weight: 500; transition: all var(--t-fast);
}
.csp-opcion input:checked + span { background: var(--navy); color: #fff; border-color: var(--navy); }
.csp-opcion input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }
.csp-resultado { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.csp-resultado[data-tono="si"] { color: var(--ok-fg); }
.csp-resultado[data-tono="no"] { color: var(--err-fg); }
.csp-resultado svg { font-size: 18px; }

/* ---------- esqueletos ---------- */
.csp-skeleton {
  border-radius: var(--r-xl); min-height: 220px; border: 1px solid var(--border);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%;
  animation: csp-brillo 1.5s infinite;
}
.csp-skeleton-linea { height: 12px; border-radius: 6px; min-height: 0; border: 0; }
@keyframes csp-brillo { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------- pie ---------- */
.csp-pie {
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 16px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--muted); text-align: center;
}
.csp-pie svg { color: var(--gold); font-size: 14px; }

/* ---------- auxiliares ---------- */
.csp-boton-ancho { width: 100%; height: 46px; border-radius: var(--r-xl); font-size: 15px; }
.csp-marca-textos { display: grid; gap: 3px; min-width: 0; }
.csp-kpi-esqueleto { min-height: 68px; border-radius: var(--r-lg); }
.csp-lista-rev { display: grid; gap: 8px; }
.csp-panel .csp-seccion-cab { margin-bottom: 10px; }
.csp-panel .csp-seccion-cab h2 { display: flex; align-items: center; gap: 8px; font-size: 15px; }
/* Columnas internas que nunca crecen más que su contenedor (evita que las tarjetas se monten entre sí). */
.csp-main, .csp-seccion, .csp-equipo, .csp-grupo, .csp-medidor, .csp-proy-extra, .csp-proy-pie, .csp-plegable-cuerpo,
.csp-lista, .csp-modal-cuerpo, .csp-bloque, .csp-plan-equipo, .csp-alertas, .csp-lista-rev, .csp-ctl, .csp-apagar-lista {
  grid-template-columns: minmax(0, 1fr);
}
.csp-campo-caja input:focus-visible { outline: none; }

/* ---------- inicio de sesión ---------- */
body.csp-login-cuerpo { background: #fff; color: #0f172a; }
.csp-login { min-height: 100vh; display: flex; }
.csp-login-hero {
  position: relative; flex: 0 0 52%; overflow: hidden; display: flex; align-items: center; padding: 48px clamp(32px, 6vw, 80px);
  background: #0a1a3a; color: #fff;
}
.csp-login-capas { position: absolute; inset: 0; pointer-events: none; }
.csp-login-capas::before {
  content: ""; position: absolute; inset: -20%;
  background: radial-gradient(circle at 30% 20%, rgba(37, 99, 235, 0.45), transparent 40%),
              radial-gradient(circle at 70% 80%, rgba(212, 168, 67, 0.28), transparent 38%);
  animation: csp-respirar 9s ease-in-out infinite alternate;
}
.csp-login-capas::after {
  content: ""; position: absolute; inset: 0; opacity: 0.05;
  background-image: linear-gradient(#fff 1px, transparent 1px), linear-gradient(90deg, #fff 1px, transparent 1px);
  background-size: 80px 80px;
}
@keyframes csp-respirar { from { transform: translate3d(-2%, -1%, 0) scale(1); opacity: 0.8; } to { transform: translate3d(2%, 2%, 0) scale(1.08); opacity: 1; } }
.csp-login-hero-texto { position: relative; display: grid; gap: 18px; max-width: 520px; }
.csp-login-hero .csp-logo { width: 56px; height: 56px; font-size: 28px; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.15); }
.csp-login-marca { margin: 0; font: 800 clamp(34px, 4.2vw, 50px)/1.05 var(--f-display); letter-spacing: -0.03em; }
.csp-login-marca span { color: #60a5fa; }
.csp-login-separador { display: block; width: 64px; height: 1px; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent); }
.csp-login-lema { margin: 0; font-size: 16px; color: rgba(255, 255, 255, 0.6); max-width: 440px; }
.csp-login-puntos { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 10px; font-size: 14px; color: rgba(255, 255, 255, 0.75); }
.csp-login-puntos li { display: flex; align-items: center; gap: 10px; }
.csp-login-puntos li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 4px rgba(212, 168, 67, 0.18); flex: none; }
.csp-login-panel { flex: 1; display: grid; place-items: center; padding: 40px 24px; background: #fff; }
.csp-login-form { width: min(380px, 100%); display: grid; gap: 16px; }
.csp-login-logo { width: 64px; height: 64px; font-size: 30px; margin: 0 auto 4px; border-radius: var(--r-xl); }
.csp-login-form h1 { text-align: center; font-size: 26px; font-weight: 700; color: #0f172a; }
.csp-login-nota { margin: -8px 0 4px; text-align: center; font-size: 14px; color: #94a3b8; }
.csp-login-error {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-lg); font-size: 14px;
  background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca;
}
.csp-login-error::before {
  content: ""; width: 18px; height: 18px; flex: none; margin-top: 1px; background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 8v4M12 16h.01'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 8v4M12 16h.01'/%3E%3C/svg%3E") center / contain no-repeat;
}
.csp-campo { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: #334155; }
.csp-campo-caja {
  display: flex; align-items: center; gap: 12px; padding: 0 16px; height: 50px; border-radius: var(--r-xl); border: 1px solid #e2e8f0;
  background: rgba(248, 250, 252, 0.6); color: #94a3b8; transition: all var(--t-normal);
}
.csp-campo-caja svg { font-size: 18px; }
.csp-campo-caja:focus-within { border-color: var(--blue); background: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); color: var(--blue); }
.csp-campo-caja input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-size: 15px; font-weight: 400; color: #0f172a; }
.csp-campo-caja input::placeholder { color: #cbd5e1; }
.csp-login-pie { margin: 4px 0 0; text-align: center; font-size: 12px; color: #94a3b8; }

/* ---------- adaptación ---------- */
@media (max-width: 1080px) {
  .csp-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .csp-dos { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .csp-solo-ancho { display: none !important; }
  .csp-cabecera { padding: 10px 16px; gap: 10px; }
  .csp-titulo { font-size: 15px; }
  .csp-logo { width: 34px; height: 34px; font-size: 18px; }
  .csp-main { padding: 16px 16px 40px; gap: 22px; }
  .csp-equipos, .csp-proyectos-grid { grid-template-columns: minmax(0, 1fr); }
  .csp-reglas { grid-template-columns: minmax(0, 1fr); }
  .csp-pasos { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .csp-modal-fondo { padding: 0; place-items: end stretch; }
  .csp-modal { width: 100%; max-height: 92vh; border-radius: var(--r-2xl) var(--r-2xl) 0 0; }
  .csp-modal-cab, .csp-modal-cuerpo, .csp-modal-pie { padding-left: 16px; padding-right: 16px; }
  .csp-modal-pie .csp-boton { flex: 1; }
  .csp-login { flex-direction: column; }
  .csp-login-hero { flex: none; padding: 28px 20px; }
  .csp-login-hero .csp-login-puntos, .csp-login-hero .csp-logo, .csp-login-separador { display: none; }
  .csp-login-marca { font-size: 28px; }
  .csp-login-lema { font-size: 14px; }
  .csp-login-panel { padding: 28px 20px 40px; align-items: start; }
  .csp-login-logo { display: none; }
}
@media (max-width: 440px) {
  .csp-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .csp-kpi { padding: 10px 12px; gap: 8px; }
  .csp-kpi-icono { display: none; }
  .csp-kpi-valor { font-size: 16px; }
  .csp-kpi-valor small { display: block; margin-left: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .csp-datos, .csp-proy-mem { grid-template-columns: minmax(0, 1fr); }
  .csp-evento { grid-template-columns: 48px 14px minmax(0, 1fr); }
  .csp-apagar-item { grid-template-columns: auto minmax(0, 1fr); }
  .csp-apagar-item b { grid-column: 2; text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .csp-punto[data-vivo="true"]::after { display: none; }
}

/* ---------- ajustes tras la revisión visual ---------- */
.csp-modal:focus { outline: none; }
.csp-escala { flex-wrap: wrap; }
.csp-escala b { white-space: nowrap; }
.csp-dato strong { font-size: 13px; }
.csp-nota p, .csp-alerta span, .csp-regla small { overflow-wrap: anywhere; }
.csp-nota > div { min-width: 0; }
@media (max-width: 760px) {
  .csp-modal-pie .csp-resultado { flex: 1 1 100%; min-width: 0; }
  .csp-modal-pie .csp-boton { flex: 1 1 0; min-width: 0; }
}
