/* Sistema de diseño Sakigan · componentes. SOLO tokens (--ns-*): scripts/diseno/lint_sistema.py lo comprueba.
   Uso: <body class="ns"> + <link rel="stylesheet" href="/sistema/tokens.css"> + este archivo. Documentación viva: /guia-estilos.html */

/* ================= Base ================= */
.ns { margin: 0; background: var(--ns-fondo); color: var(--ns-texto); font: var(--ns-peso-normal) var(--ns-tam-base) / var(--ns-lh-normal) var(--ns-fuente-ui); -webkit-text-size-adjust: 100%; }
.ns *, .ns *::before, .ns *::after { box-sizing: border-box; }
:where(.ns) :focus-visible { outline: 2px solid var(--ns-foco); outline-offset: 2px; }
:where(.ns) a { color: var(--ns-acento-texto); text-underline-offset: 3px; }
:where(.ns) a:hover { text-decoration-thickness: 2px; }
.ns hr, .ns-divisor { border: 0; border-top: 1px solid var(--ns-borde); margin: var(--ns-s-4) 0; }
.ns-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.ns-saltar { position: absolute; left: var(--ns-s-3); top: -100px; z-index: var(--ns-z-tip); background: var(--ns-acento); color: var(--ns-sobre-acento); padding: var(--ns-s-2) var(--ns-s-4); border-radius: var(--ns-r-control); font-weight: var(--ns-peso-seminegrita); }
.ns-saltar:focus { top: var(--ns-s-3); }

/* ================= Tipografía ================= */
.ns-t-hero, .ns-t-1, .ns-t-2, .ns-t-3 { font-family: var(--ns-fuente-titulo); font-weight: var(--ns-peso-titulo); line-height: var(--ns-lh-titulo); letter-spacing: -.005em; margin: 0; color: var(--ns-texto); }
.ns-t-hero { font-size: var(--ns-tam-hero); }
.ns-t-1 { font-size: var(--ns-tam-xxl); }
.ns-t-2 { font-size: var(--ns-tam-xl); }
.ns-t-3 { font-size: var(--ns-tam-lg); }
.ns-t-4 { font-size: var(--ns-tam-md); font-weight: var(--ns-peso-seminegrita); line-height: var(--ns-lh-ajustada); margin: 0; }
.ns-texto { font-size: var(--ns-tam-base); }
.ns-texto-sm { font-size: var(--ns-tam-sm); }
.ns-etiqueta { display: block; font-size: var(--ns-tam-sm); font-weight: var(--ns-peso-medio); color: var(--ns-texto-2); margin: 0 0 var(--ns-s-1); }
.ns-ayuda { font-size: var(--ns-tam-xs); color: var(--ns-texto-3); margin: var(--ns-s-1) 0 0; }
.ns-lead { color: var(--ns-texto-2); max-width: var(--ns-ancho-lectura); margin: var(--ns-s-2) 0 0; }
.ns-datos { font-family: var(--ns-fuente-datos); font-size: var(--ns-tam-sm); }
.ns-num { font-variant-numeric: tabular-nums lining-nums; }
.ns-prop { font-variant-numeric: proportional-nums lining-nums; }
.ns-u-texto-2 { color: var(--ns-texto-2); }
.ns-u-texto-3 { color: var(--ns-texto-3); }
.ns-kbd { display: inline-block; padding: 0 var(--ns-s-1); min-width: 20px; text-align: center; font-family: var(--ns-fuente-datos); font-size: var(--ns-tam-xs); color: var(--ns-texto-2); border: 1px solid var(--ns-borde-control); border-radius: var(--ns-r-control); background: var(--ns-superficie-2); }
.ns-codigo { font-family: var(--ns-fuente-datos); font-size: var(--ns-tam-sm); background: var(--ns-superficie-2); border: 1px solid var(--ns-borde); border-radius: var(--ns-r-control); padding: 0 var(--ns-s-1); }

/* ================= Maquetación ================= */
.ns-contenedor { width: 100%; max-width: var(--ns-ancho-contenido); margin: 0 auto; padding: 0 var(--ns-s-4); }
.ns-pila { display: flex; flex-direction: column; gap: var(--ns-s-4); }
.ns-pila--sm { gap: var(--ns-s-2); }
.ns-pila--lg { gap: var(--ns-s-5); }
.ns-fila { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ns-s-3); }
.ns-fila--sm { gap: var(--ns-s-2); }
.ns-fila--entre { justify-content: space-between; }
.ns-rejilla { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: var(--ns-s-4); }
.ns-rejilla--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }

/* ================= Botón ================= */
.ns-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--ns-s-2); min-height: var(--ns-h-alto); padding: 0 var(--ns-s-4); border: 1px solid transparent; border-radius: var(--ns-r-control); background: transparent; color: var(--ns-texto); font: var(--ns-peso-seminegrita) var(--ns-tam-base) / 1 var(--ns-fuente-ui); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background var(--ns-t-normal) var(--ns-t-curva), border-color var(--ns-t-normal) var(--ns-t-curva), color var(--ns-t-normal) var(--ns-t-curva); }
.ns-btn--primario { background: var(--ns-acento); color: var(--ns-sobre-acento); }
.ns-btn--primario:hover { background: var(--ns-acento-hover); }
.ns-btn--secundario { border-color: var(--ns-borde-control); }
.ns-btn--secundario:hover { background: var(--ns-superficie-2); }
.ns-btn--fantasma { color: var(--ns-acento-texto); padding: 0 var(--ns-s-2); }
.ns-btn--fantasma:hover { background: var(--ns-acento-suave); }
.ns-btn--peligro { border-color: var(--ns-critico-texto); color: var(--ns-critico-texto); }
.ns-btn--peligro:hover { background: var(--ns-critico-suave); }
.ns-btn--sm { min-height: var(--ns-h-alto-sm); padding: 0 var(--ns-s-3); font-size: var(--ns-tam-sm); }
.ns-btn--icono { width: var(--ns-h-alto); padding: 0; }
.ns-btn--icono.ns-btn--sm { width: var(--ns-h-alto-sm); }
.ns-btn:disabled, .ns-btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.ns-btn[aria-busy="true"] { pointer-events: none; color: transparent; position: relative; }
.ns-btn[aria-busy="true"]::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid var(--ns-sobre-acento); border-top-color: transparent; border-radius: var(--ns-r-completo); animation: ns-giro calc(var(--ns-t-lento) * 3) linear infinite; }
.ns-btn--secundario[aria-busy="true"]::after, .ns-btn--fantasma[aria-busy="true"]::after { border-color: var(--ns-texto-2); border-top-color: transparent; }
.ns-ico { width: var(--ns-h-icono); height: var(--ns-h-icono); flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
@keyframes ns-giro { to { transform: rotate(360deg); } }

/* ================= Campos ================= */
.ns-campo { display: block; min-width: 0; }
.ns-input, .ns-textarea, .ns-select { display: block; width: 100%; min-height: var(--ns-h-alto); padding: var(--ns-s-2) var(--ns-s-3); background: var(--ns-superficie-2); color: var(--ns-texto); border: 1px solid var(--ns-borde-control); border-radius: var(--ns-r-control); font: var(--ns-peso-normal) var(--ns-tam-base) / var(--ns-lh-ajustada) var(--ns-fuente-ui); transition: border-color var(--ns-t-normal) var(--ns-t-curva); }
.ns-textarea { min-height: 96px; resize: vertical; }
.ns-select { appearance: none; padding-right: var(--ns-s-6); background-image: linear-gradient(45deg, transparent 50%, var(--ns-texto-2) 50%), linear-gradient(135deg, var(--ns-texto-2) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.ns-input::placeholder, .ns-textarea::placeholder { color: var(--ns-texto-3); }
.ns-input:hover, .ns-textarea:hover, .ns-select:hover { border-color: var(--ns-texto-3); }
.ns-input:disabled, .ns-textarea:disabled, .ns-select:disabled { opacity: .5; cursor: not-allowed; }
.ns-input[aria-invalid="true"], .ns-textarea[aria-invalid="true"], .ns-select[aria-invalid="true"] { border-color: var(--ns-critico-texto); }
.ns-campo__error { display: flex; gap: var(--ns-s-2); margin: var(--ns-s-1) 0 0; font-size: var(--ns-tam-sm); color: var(--ns-critico-texto); }
.ns-campo__error::before { content: ""; flex: none; width: 14px; height: 14px; margin-top: 2px; background-color: currentColor; -webkit-mask: var(--ns-g-serio) center / contain no-repeat; mask: var(--ns-g-serio) center / contain no-repeat; }
.ns-check { display: flex; align-items: center; gap: var(--ns-s-3); min-height: var(--ns-h-alto); cursor: pointer; font-size: var(--ns-tam-base); }
.ns-check input { width: var(--ns-h-check); height: var(--ns-h-check); margin: 0; accent-color: var(--ns-acento); flex: none; }
.ns-interruptor { display: flex; align-items: center; justify-content: space-between; gap: var(--ns-s-3); min-height: var(--ns-h-alto); cursor: pointer; }
.ns-interruptor input { appearance: none; position: relative; flex: none; width: 44px; height: 26px; margin: 0; border-radius: var(--ns-r-completo); background: var(--ns-superficie-3); border: 1px solid var(--ns-borde-control); cursor: pointer; transition: background var(--ns-t-normal) var(--ns-t-curva); }
.ns-interruptor input::before { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: var(--ns-r-completo); background: var(--ns-texto-2); transition: transform var(--ns-t-normal) var(--ns-t-curva), background var(--ns-t-normal) var(--ns-t-curva); }
.ns-interruptor input:checked { background: var(--ns-acento); border-color: var(--ns-acento); }
.ns-interruptor input:checked::before { transform: translateX(18px); background: var(--ns-sobre-acento); }

/* ================= Selección: chip, segmentado, pestañas ================= */
.ns-chips { display: flex; flex-wrap: wrap; gap: var(--ns-s-2); }
.ns-chip { min-height: var(--ns-h-alto); padding: 0 var(--ns-s-3); border: 1px solid var(--ns-borde-control); border-radius: var(--ns-r-chip); background: transparent; color: var(--ns-texto); font: var(--ns-peso-medio) var(--ns-tam-sm) / 1 var(--ns-fuente-ui); cursor: pointer; transition: background var(--ns-t-normal) var(--ns-t-curva), border-color var(--ns-t-normal) var(--ns-t-curva); }
.ns-chip:hover { background: var(--ns-superficie-2); }
.ns-chip[aria-pressed="true"] { background: var(--ns-acento-suave); border-color: var(--ns-acento); color: var(--ns-acento-texto); }
.ns-seg { display: inline-flex; width: fit-content; max-width: 100%; border: 1px solid var(--ns-borde-control); border-radius: var(--ns-r-control); overflow: hidden; }
.ns-seg button { min-width: 56px; min-height: var(--ns-h-alto); padding: 0 var(--ns-s-3); border: 0; border-left: 1px solid var(--ns-borde); background: transparent; color: var(--ns-texto-2); font: var(--ns-peso-medio) var(--ns-tam-sm) / 1 var(--ns-fuente-ui); cursor: pointer; }
.ns-seg button:first-child { border-left: 0; }
.ns-seg button:hover { background: var(--ns-superficie-2); }
.ns-seg button:focus-visible { outline-offset: -3px; }
.ns-seg button[aria-checked="true"], .ns-seg button[aria-pressed="true"] { background: var(--ns-acento-suave); color: var(--ns-acento-texto); font-weight: var(--ns-peso-seminegrita); }
.ns-seg--sm button { min-height: var(--ns-h-alto-sm); }
.ns-pestanas { display: flex; gap: var(--ns-s-1); border-bottom: 1px solid var(--ns-borde); overflow-x: auto; scrollbar-width: thin; }
.ns-pestana { flex: none; min-height: var(--ns-h-alto); padding: 0 var(--ns-s-3); display: inline-flex; align-items: center; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: transparent; color: var(--ns-texto-2); font: var(--ns-peso-medio) var(--ns-tam-sm) / 1 var(--ns-fuente-ui); cursor: pointer; text-decoration: none; white-space: nowrap; }
.ns-pestana:hover { color: var(--ns-texto); }
.ns-pestana[aria-selected="true"], .ns-pestana[aria-current="page"] { color: var(--ns-texto); border-bottom-color: var(--ns-acento); }

/* ================= Tarjeta ================= */
.ns-tarjeta { background: var(--ns-superficie); border: 1px solid var(--ns-borde); border-radius: var(--ns-r-tarjeta); padding: var(--ns-s-4); min-width: 0; }
.ns-tarjeta--realce { background: var(--ns-acento-suave); border-color: var(--ns-acento); }
.ns-tarjeta--plana { background: var(--ns-superficie-2); border-color: transparent; }
.ns-tarjeta--interactiva { cursor: pointer; transition: border-color var(--ns-t-normal) var(--ns-t-curva), background var(--ns-t-normal) var(--ns-t-curva); }
.ns-tarjeta--interactiva:hover { border-color: var(--ns-borde-control); background: var(--ns-superficie-2); }
.ns-tarjeta__cab { display: flex; align-items: center; justify-content: space-between; gap: var(--ns-s-3); margin-bottom: var(--ns-s-3); flex-wrap: wrap; }
.ns-tarjeta__pie { display: flex; gap: var(--ns-s-2); flex-wrap: wrap; margin-top: var(--ns-s-4); }

/* ================= Glifos e insignias ================= */
:root {
  --ns-g-validado: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Ccircle cx='6' cy='6' r='5' fill='none' stroke='black' stroke-width='1.4'/%3E%3Cpath d='M3.6 6.2l1.7 1.7 3.2-3.6' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --ns-g-parcial: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Ccircle cx='6' cy='6' r='5' fill='none' stroke='black' stroke-width='1.4'/%3E%3Cpath d='M6 1v10a5 5 0 0 1 0-10z' fill='black'/%3E%3C/svg%3E");
  --ns-g-hipotesis: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Ccircle cx='6' cy='6' r='5' fill='none' stroke='black' stroke-width='1.4'/%3E%3C/svg%3E");
  --ns-g-sin-calibrar: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Ccircle cx='6' cy='6' r='5' fill='none' stroke='black' stroke-width='1.4' stroke-dasharray='2 2'/%3E%3C/svg%3E");
  --ns-g-ok: var(--ns-g-validado);
  --ns-g-aviso: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M6 1.3L11 10.5H1z' fill='none' stroke='black' stroke-width='1.3' stroke-linejoin='round'/%3E%3Cpath d='M6 4.7v2.7M6 8.9v.1' stroke='black' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
  --ns-g-serio: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Ccircle cx='6' cy='6' r='5' fill='none' stroke='black' stroke-width='1.4'/%3E%3Cpath d='M6 3.4v3.2M6 8.2v.1' stroke='black' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
  --ns-g-critico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Ccircle cx='6' cy='6' r='5' fill='none' stroke='black' stroke-width='1.4'/%3E%3Cpath d='M4.1 4.1l3.8 3.8M7.9 4.1L4.1 7.9' stroke='black' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
  --ns-g-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Ccircle cx='6' cy='6' r='5' fill='none' stroke='black' stroke-width='1.4'/%3E%3Cpath d='M6 5.4v3.2M6 3.6v.1' stroke='black' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
  --ns-g-sube: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M6 10V2M2.8 5.2L6 2l3.2 3.2' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --ns-g-baja: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M6 2v8M2.8 6.8L6 10l3.2-3.2' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --ns-g-cerrar: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 2.5l7 7M9.5 2.5l-7 7' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  --ns-g-marca: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.4 6.3l2.4 2.4 4.8-5.4' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.ns-glifo, .ns-evidencia::before, .ns-estado::before, .ns-delta::before, .ns-alerta::before, .ns-aviso::before { content: ""; display: inline-block; flex: none; width: 12px; height: 12px; background-color: currentColor; -webkit-mask: var(--g) center / contain no-repeat; mask: var(--g) center / contain no-repeat; }
.ns-evidencia { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 0 var(--ns-s-3) 0 var(--ns-s-2); border: 1px solid var(--ns-borde-control); border-radius: var(--ns-r-chip); background: var(--ns-superficie-2); color: var(--ns-texto-2); font: var(--ns-peso-medio) var(--ns-tam-xs) / 1 var(--ns-fuente-ui); white-space: nowrap; }
.ns-evidencia--validado { --g: var(--ns-g-validado); color: var(--ns-ok-texto); border-color: var(--ns-ok-texto); }
.ns-evidencia--parcial { --g: var(--ns-g-parcial); }
.ns-evidencia--hipotesis { --g: var(--ns-g-hipotesis); }
.ns-evidencia--sin-calibrar { --g: var(--ns-g-sin-calibrar); border-style: dashed; }
.ns-estado { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 0 var(--ns-s-3) 0 var(--ns-s-2); border-radius: var(--ns-r-chip); font: var(--ns-peso-medio) var(--ns-tam-xs) / 1 var(--ns-fuente-ui); white-space: nowrap; }
.ns-estado--ok { --g: var(--ns-g-ok); background: var(--ns-ok-suave); color: var(--ns-ok-texto); }
.ns-estado--aviso { --g: var(--ns-g-aviso); background: var(--ns-aviso-suave); color: var(--ns-aviso-texto); }
.ns-estado--serio { --g: var(--ns-g-serio); background: var(--ns-serio-suave); color: var(--ns-serio-texto); }
.ns-estado--critico { --g: var(--ns-g-critico); background: var(--ns-critico-suave); color: var(--ns-critico-texto); }
.ns-estado--info { --g: var(--ns-g-info); background: var(--ns-acento-suave); color: var(--ns-acento-texto); }

/* ================= Cifras: KPI, delta, intervalo, medidor ================= */
.ns-kpi { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--ns-s-1); min-width: 0; }
.ns-kpi__etiqueta { font-size: var(--ns-tam-sm); font-weight: var(--ns-peso-medio); color: var(--ns-texto-2); }
.ns-kpi__valor { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--ns-s-2); }
.ns-kpi__cifra { font-size: var(--ns-tam-xxl); font-weight: var(--ns-peso-seminegrita); line-height: 1.05; letter-spacing: -.02em; font-variant-numeric: proportional-nums lining-nums; }
.ns-kpi__cifra--hero { font-size: var(--ns-tam-hero); }
.ns-kpi__unidad { font-size: var(--ns-tam-sm); color: var(--ns-texto-3); }
.ns-kpi__meta { font-size: var(--ns-tam-xs); color: var(--ns-texto-3); margin: 0; }
.ns-delta { display: inline-flex; align-items: center; gap: var(--ns-s-1); font-size: var(--ns-tam-sm); font-weight: var(--ns-peso-seminegrita); }
.ns-delta--sube::before { --g: var(--ns-g-sube); width: 14px; height: 14px; }
.ns-delta--baja::before { --g: var(--ns-g-baja); width: 14px; height: 14px; }
.ns-delta--bueno { color: var(--ns-ok-texto); }
.ns-delta--malo { color: var(--ns-critico-texto); }
.ns-delta--neutro { color: var(--ns-texto-2); }
.ns-intervalo { --v: 50; --lo: 40; --hi: 60; position: relative; height: 28px; margin: var(--ns-s-1) 0; }
.ns-intervalo::before { content: ""; position: absolute; left: 0; right: 0; top: 9px; height: 3px; border-radius: 2px; background: var(--ns-superficie-3); }
.ns-intervalo__rango { position: absolute; top: 8px; height: 5px; left: calc(var(--lo) * 1%); width: calc((var(--hi) - var(--lo)) * 1%); border-radius: 3px; background: var(--ns-texto-3); }
.ns-intervalo__punto { position: absolute; top: 3px; left: calc(var(--v) * 1%); width: 14px; height: 14px; margin-left: -7px; border-radius: var(--ns-r-completo); background: var(--ns-acento); box-shadow: 0 0 0 2px var(--ns-superficie); }
.ns-intervalo__marca { position: absolute; top: 16px; font-size: var(--ns-tam-xs); color: var(--ns-texto-3); font-variant-numeric: tabular-nums; }
.ns-intervalo__marca--fin { right: 0; }
.ns-medidor { --v: 50; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--ns-s-1); }
.ns-medidor__pista { height: 8px; border-radius: var(--ns-r-completo); background: var(--ns-superficie-3); overflow: hidden; }
.ns-medidor__relleno { display: block; height: 100%; width: calc(var(--v) * 1%); border-radius: var(--ns-r-completo); background: var(--ns-acento); }
.ns-medidor[data-nivel="aviso"] .ns-medidor__relleno { background: var(--ns-aviso); }
.ns-medidor[data-nivel="critico"] .ns-medidor__relleno { background: var(--ns-critico); }
.ns-medidor__texto { display: flex; justify-content: space-between; font-size: var(--ns-tam-xs); color: var(--ns-texto-2); }

/* ================= Gráficos: barras con intervalo, leyenda, tooltip ================= */
.ns-grafico { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--ns-s-3); }
.ns-grafico__cab { display: flex; align-items: center; justify-content: space-between; gap: var(--ns-s-3); flex-wrap: wrap; }
.ns-leyenda { display: flex; flex-wrap: wrap; gap: var(--ns-s-4); margin: 0; padding: 0; list-style: none; font-size: var(--ns-tam-sm); color: var(--ns-texto); }
.ns-leyenda li { display: inline-flex; align-items: center; gap: var(--ns-s-2); }
.ns-leyenda li::before { content: ""; width: 10px; height: 10px; border-radius: 2px; background: var(--c, var(--ns-serie-1)); }
[data-serie="1"] { --c: var(--ns-serie-1); } [data-serie="2"] { --c: var(--ns-serie-2); } [data-serie="3"] { --c: var(--ns-serie-3); } [data-serie="4"] { --c: var(--ns-serie-4); }
[data-serie="5"] { --c: var(--ns-serie-5); } [data-serie="6"] { --c: var(--ns-serie-6); } [data-serie="7"] { --c: var(--ns-serie-7); } [data-serie="8"] { --c: var(--ns-serie-8); }
.ns-barras { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--ns-s-3); margin: 0; padding: 0; list-style: none; }
.ns-barra { --v: 50; --lo: 0; --hi: 0; display: grid; grid-template-columns: minmax(72px, 120px) minmax(0, 1fr); align-items: center; gap: var(--ns-s-3); min-height: 32px; border-radius: var(--ns-r-control); }
.ns-barra__nombre { font-size: var(--ns-tam-sm); font-weight: var(--ns-peso-medio); color: var(--ns-texto-2); overflow-wrap: anywhere; }
.ns-barra__pista { position: relative; height: 20px; border-left: 1px solid var(--ns-borde-control); background: linear-gradient(90deg, var(--ns-borde) 1px, transparent 1px) 0 0 / 25% 100%; }
.ns-barra__relleno { position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--v) * 1%); background: var(--c, var(--ns-serie-1)); border-radius: 0 4px 4px 0; transition: width var(--ns-t-lento) var(--ns-t-curva); }
.ns-barra__ic { position: absolute; top: 9px; height: 2px; left: calc(var(--lo) * 1%); width: calc((var(--hi) - var(--lo)) * 1%); background: var(--ns-texto); box-shadow: 0 0 0 2px var(--ns-superficie); }
.ns-barra__ic::before, .ns-barra__ic::after { content: ""; position: absolute; top: -5px; width: 2px; height: 12px; background: var(--ns-texto); box-shadow: 0 0 0 1px var(--ns-superficie); }
.ns-barra__ic::before { left: 0; } .ns-barra__ic::after { right: 0; }
.ns-barra__valor { position: absolute; top: 0; left: min(calc(max(var(--v), var(--hi)) * 1% + var(--ns-s-3)), calc(100% - 3ch)); line-height: 20px; font-size: var(--ns-tam-sm); font-weight: var(--ns-peso-seminegrita); font-variant-numeric: tabular-nums lining-nums; }
.ns-barra:focus-visible { outline-offset: 4px; }
.ns-tip { position: fixed; z-index: var(--ns-z-tip); max-width: 260px; padding: var(--ns-s-2) var(--ns-s-3); background: var(--ns-superficie-3); color: var(--ns-texto); border: 1px solid var(--ns-borde-control); border-radius: var(--ns-r-control); box-shadow: var(--ns-sombra-flotante); font-size: var(--ns-tam-xs); line-height: var(--ns-lh-ajustada); pointer-events: none; opacity: 0; transition: opacity var(--ns-t-rapido) var(--ns-t-curva); white-space: pre-line; }
.ns-tip[data-visible="true"] { opacity: 1; }

/* ================= Tabla ================= */
.ns-tabla-envoltorio { overflow-x: auto; border: 1px solid var(--ns-borde); border-radius: var(--ns-r-tarjeta); background: var(--ns-superficie); }
.ns-tabla { width: 100%; border-collapse: collapse; font-size: var(--ns-tam-sm); }
.ns-tabla caption { text-align: left; padding: var(--ns-s-3) var(--ns-s-4); color: var(--ns-texto-2); font-size: var(--ns-tam-sm); }
.ns-tabla th { position: sticky; top: 0; background: var(--ns-superficie); padding: var(--ns-s-3) var(--ns-s-4); text-align: left; font-weight: var(--ns-peso-seminegrita); color: var(--ns-texto-2); border-bottom: 1px solid var(--ns-borde-control); white-space: nowrap; }
.ns-tabla td { padding: var(--ns-s-3) var(--ns-s-4); border-bottom: 1px solid var(--ns-borde); vertical-align: middle; }
.ns-tabla tbody tr:last-child td { border-bottom: 0; }
.ns-tabla tbody tr:hover td { background: var(--ns-superficie-2); }
.ns-tabla .ns-num, .ns-tabla th.ns-num { text-align: right; font-family: var(--ns-fuente-datos); }
.ns-tabla--compacta td, .ns-tabla--compacta th { padding: var(--ns-s-2) var(--ns-s-3); }
.ns-tabla th[aria-sort] { cursor: pointer; }
.ns-tabla th[aria-sort="ascending"]::after, .ns-tabla th[aria-sort="descending"]::after { content: ""; display: inline-block; width: 10px; height: 10px; margin-left: var(--ns-s-1); background-color: currentColor; -webkit-mask: var(--ns-g-sube) center / contain no-repeat; mask: var(--ns-g-sube) center / contain no-repeat; }
.ns-tabla th[aria-sort="descending"]::after { -webkit-mask-image: var(--ns-g-baja); mask-image: var(--ns-g-baja); }

/* ================= Estados: vacío, cargando, alerta, error ================= */
.ns-vacio { display: grid; justify-items: center; gap: var(--ns-s-3); padding: var(--ns-s-7) var(--ns-s-4); text-align: center; border: 1px dashed var(--ns-borde-control); border-radius: var(--ns-r-tarjeta); }
.ns-vacio__ico { display: grid; place-items: center; width: 48px; height: 48px; border-radius: var(--ns-r-completo); background: var(--ns-superficie-2); color: var(--ns-acento-texto); }
.ns-vacio__texto { margin: 0; max-width: 46ch; color: var(--ns-texto-2); }
.ns-esqueleto { display: block; min-height: 14px; border-radius: var(--ns-r-control); background: linear-gradient(90deg, var(--ns-superficie-2), var(--ns-superficie-3), var(--ns-superficie-2)) 0 0 / 200% 100%; animation: ns-brillo calc(var(--ns-t-lento) * 5) linear infinite; }
.ns-esqueleto--titulo { min-height: 24px; width: 50%; }
.ns-esqueleto--bloque { min-height: 96px; }
@keyframes ns-brillo { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.ns-spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--ns-borde-control); border-top-color: var(--ns-acento); border-radius: var(--ns-r-completo); animation: ns-giro calc(var(--ns-t-lento) * 3) linear infinite; }
@media (prefers-reduced-motion: reduce) { .ns-spinner, .ns-esqueleto, .ns-btn[aria-busy="true"]::after { animation: none; } }
.ns-alerta { display: grid; grid-template-columns: auto 1fr auto; gap: var(--ns-s-3); align-items: start; padding: var(--ns-s-3) var(--ns-s-4); border: 1px solid var(--ns-borde); border-left: 4px solid var(--ns-acento); border-radius: var(--ns-r-control); background: var(--ns-superficie-2); font-size: var(--ns-tam-sm); }
.ns-alerta::before { margin-top: 3px; width: 14px; height: 14px; --g: var(--ns-g-info); color: var(--ns-acento-texto); }
.ns-alerta__titulo { display: block; font-weight: var(--ns-peso-seminegrita); color: var(--ns-texto); }
.ns-alerta__texto { color: var(--ns-texto-2); margin: 0; }
.ns-alerta__acciones { display: flex; gap: var(--ns-s-2); margin-top: var(--ns-s-2); flex-wrap: wrap; }
.ns-alerta--ok { border-left-color: var(--ns-ok); background: var(--ns-ok-suave); } .ns-alerta--ok::before { --g: var(--ns-g-ok); color: var(--ns-ok-texto); }
.ns-alerta--aviso { border-left-color: var(--ns-aviso); background: var(--ns-aviso-suave); } .ns-alerta--aviso::before { --g: var(--ns-g-aviso); color: var(--ns-aviso-texto); }
.ns-alerta--critico { border-left-color: var(--ns-critico); background: var(--ns-critico-suave); } .ns-alerta--critico::before { --g: var(--ns-g-critico); color: var(--ns-critico-texto); }

/* ================= Superposiciones: modal, aviso, flotante, paleta ================= */
.ns-modal { padding: 0; border: 1px solid var(--ns-borde-control); border-radius: var(--ns-r-tarjeta); background: var(--ns-superficie); color: var(--ns-texto); width: min(520px, calc(100% - var(--ns-s-5))); max-height: calc(100dvh - var(--ns-s-6)); box-shadow: var(--ns-sombra-modal); }
.ns-modal::backdrop { background: var(--ns-velo); }
.ns-modal[open] { animation: ns-entrada var(--ns-t-normal) var(--ns-t-curva); }
.ns-modal__cuerpo { padding: var(--ns-s-5); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--ns-s-3); }
.ns-modal__cab { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--ns-s-3); }
.ns-modal__pie { display: flex; justify-content: flex-end; gap: var(--ns-s-2); flex-wrap: wrap; margin-top: var(--ns-s-3); }
@keyframes ns-entrada { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.ns-avisos { position: fixed; right: var(--ns-s-4); bottom: var(--ns-s-4); z-index: var(--ns-z-aviso); display: grid; gap: var(--ns-s-2); width: min(380px, calc(100% - var(--ns-s-5))); }
.ns-aviso { display: grid; grid-template-columns: auto 1fr auto; gap: var(--ns-s-3); align-items: center; padding: var(--ns-s-3) var(--ns-s-4); border: 1px solid var(--ns-borde-control); border-radius: var(--ns-r-control); background: var(--ns-superficie-3); color: var(--ns-texto); box-shadow: var(--ns-sombra-flotante); font-size: var(--ns-tam-sm); animation: ns-entrada var(--ns-t-normal) var(--ns-t-curva); }
.ns-aviso::before { --g: var(--ns-g-info); color: var(--ns-acento-texto); }
.ns-aviso[data-tipo="ok"]::before { --g: var(--ns-g-ok); color: var(--ns-ok-texto); }
.ns-aviso[data-tipo="aviso"]::before { --g: var(--ns-g-aviso); color: var(--ns-aviso-texto); }
.ns-aviso[data-tipo="critico"]::before { --g: var(--ns-g-critico); color: var(--ns-critico-texto); }
.ns-cerrar { display: inline-grid; place-items: center; width: var(--ns-h-alto-sm); height: var(--ns-h-alto-sm); border: 0; border-radius: var(--ns-r-control); background: transparent; color: var(--ns-texto-2); cursor: pointer; }
.ns-cerrar::before { content: ""; width: 12px; height: 12px; background-color: currentColor; -webkit-mask: var(--ns-g-cerrar) center / contain no-repeat; mask: var(--ns-g-cerrar) center / contain no-repeat; }
.ns-cerrar:hover { background: var(--ns-superficie-2); color: var(--ns-texto); }
.ns-flotante { position: absolute; z-index: var(--ns-z-flotante); min-width: 220px; padding: var(--ns-s-1); background: var(--ns-superficie); border: 1px solid var(--ns-borde-control); border-radius: var(--ns-r-tarjeta); box-shadow: var(--ns-sombra-flotante); }
.ns-flotante[hidden] { display: none; }
.ns-flotante__item { display: flex; align-items: center; gap: var(--ns-s-3); width: 100%; min-height: var(--ns-h-alto); padding: 0 var(--ns-s-3); border: 0; border-radius: var(--ns-r-control); background: transparent; color: var(--ns-texto); font: var(--ns-peso-medio) var(--ns-tam-sm) / 1 var(--ns-fuente-ui); text-align: left; cursor: pointer; }
.ns-flotante__item:hover, .ns-flotante__item:focus-visible { background: var(--ns-superficie-2); }
.ns-flotante__item[aria-checked="true"]::after { content: ""; margin-left: auto; width: 12px; height: 12px; background-color: var(--ns-acento-texto); -webkit-mask: var(--ns-g-marca) center / contain no-repeat; mask: var(--ns-g-marca) center / contain no-repeat; }
.ns-flotante__sep { height: 1px; margin: var(--ns-s-1) 0; background: var(--ns-borde); border: 0; }
.ns-paleta { padding: 0; border: 1px solid var(--ns-borde-control); border-radius: var(--ns-r-tarjeta); background: var(--ns-superficie); color: var(--ns-texto); width: min(600px, calc(100% - var(--ns-s-5))); margin-top: 12vh; box-shadow: var(--ns-sombra-modal); overflow: hidden; }
.ns-paleta::backdrop { background: var(--ns-velo); }
.ns-paleta__buscar { display: block; width: 100%; min-height: 56px; padding: 0 var(--ns-s-4); border: 0; border-bottom: 1px solid var(--ns-borde); background: transparent; color: var(--ns-texto); font: var(--ns-peso-normal) var(--ns-tam-md) / 1 var(--ns-fuente-ui); }
.ns-paleta__buscar:focus-visible { outline-offset: -3px; }
.ns-paleta__lista { max-height: 340px; overflow-y: auto; margin: 0; padding: var(--ns-s-2); list-style: none; }
.ns-paleta__grupo { padding: var(--ns-s-2) var(--ns-s-3) var(--ns-s-1); font-size: var(--ns-tam-xs); font-weight: var(--ns-peso-seminegrita); color: var(--ns-texto-3); }
.ns-paleta__item { display: flex; align-items: center; justify-content: space-between; gap: var(--ns-s-3); min-height: var(--ns-h-alto); padding: 0 var(--ns-s-3); border-radius: var(--ns-r-control); cursor: pointer; font-size: var(--ns-tam-sm); }
.ns-paleta__item[aria-selected="true"] { background: var(--ns-acento-suave); color: var(--ns-acento-texto); }

/* ================= Navegación y armazón ================= */
.ns-app { display: grid; grid-template-columns: var(--ns-ancho-menu) minmax(0, 1fr); grid-template-rows: var(--ns-ancho-cabecera) minmax(0, 1fr); min-height: 100dvh; background: var(--ns-fondo); }
.ns-cabecera { grid-column: 1 / -1; position: sticky; top: 0; z-index: var(--ns-z-pegajoso); display: flex; align-items: center; gap: var(--ns-s-3); padding: 0 var(--ns-s-4); background: var(--ns-superficie); border-bottom: 1px solid var(--ns-borde); min-width: 0; }
.ns-marca { display: inline-flex; align-items: center; gap: var(--ns-s-2); color: var(--ns-texto); text-decoration: none; font-family: var(--ns-fuente-titulo); font-size: var(--ns-tam-md); font-weight: var(--ns-peso-seminegrita); flex: none; }
.ns-marca svg { width: 26px; height: 26px; color: var(--ns-acento); }
.ns-espacio { display: inline-flex; align-items: center; gap: var(--ns-s-2); min-height: var(--ns-h-alto-sm); max-width: 240px; padding: 0 var(--ns-s-3); border: 1px solid var(--ns-borde-control); border-radius: var(--ns-r-control); background: transparent; color: var(--ns-texto); font: var(--ns-peso-medio) var(--ns-tam-sm) / 1 var(--ns-fuente-ui); cursor: pointer; overflow: hidden; white-space: nowrap; }
.ns-espacio:hover { background: var(--ns-superficie-2); }
.ns-busca { display: inline-flex; align-items: center; gap: var(--ns-s-2); min-height: var(--ns-h-alto-sm); flex: 1; max-width: 300px; padding: 0 var(--ns-s-3); border: 1px solid var(--ns-borde); border-radius: var(--ns-r-control); background: transparent; color: var(--ns-texto-3); font: var(--ns-peso-normal) var(--ns-tam-sm) / 1 var(--ns-fuente-ui); cursor: pointer; }
.ns-busca:hover { border-color: var(--ns-borde-control); }
.ns-busca .ns-kbd { margin-left: auto; }
.ns-conexion { display: inline-flex; align-items: center; gap: var(--ns-s-2); margin-left: auto; font-size: var(--ns-tam-xs); color: var(--ns-texto-3); white-space: nowrap; }
.ns-conexion::before { content: ""; width: 8px; height: 8px; border-radius: var(--ns-r-completo); background: var(--ns-ok); box-shadow: 0 0 0 2px var(--ns-superficie); }
.ns-conexion[data-estado="sin"]::before { background: var(--ns-texto-3); }
.ns-avatar { display: inline-grid; place-items: center; width: var(--ns-h-alto-sm); height: var(--ns-h-alto-sm); flex: none; border-radius: var(--ns-r-completo); background: var(--ns-superficie-3); color: var(--ns-texto); font-size: var(--ns-tam-xs); font-weight: var(--ns-peso-seminegrita); border: 0; cursor: pointer; }
.ns-menu { position: sticky; top: var(--ns-ancho-cabecera); align-self: start; height: calc(100dvh - var(--ns-ancho-cabecera)); overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding: var(--ns-s-3) var(--ns-s-2); border-right: 1px solid var(--ns-borde); background: var(--ns-fondo); min-width: 0; }
.ns-menu__enlace { position: relative; display: flex; align-items: center; gap: var(--ns-s-3); min-height: var(--ns-h-alto); padding: 0 var(--ns-s-3); border-radius: var(--ns-r-control); color: var(--ns-texto-2); text-decoration: none; font: var(--ns-peso-medio) var(--ns-tam-sm) / 1 var(--ns-fuente-ui); }
.ns-menu__enlace:hover { background: var(--ns-superficie-2); color: var(--ns-texto); }
.ns-menu__enlace[aria-current="page"] { background: var(--ns-superficie-2); color: var(--ns-texto); }
.ns-menu__enlace[aria-current="page"]::before { content: ""; position: absolute; left: calc(var(--ns-s-2) * -1); top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--ns-acento); }
.ns-menu__relleno { flex: 1; }
.ns-contenido { min-width: 0; padding: var(--ns-s-5) var(--ns-s-5) var(--ns-s-7); }
.ns-pagina { width: 100%; max-width: var(--ns-ancho-contenido); margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--ns-s-5); }
.ns-pagina__cab { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--ns-s-3); }
.ns-pagina__acciones { display: flex; gap: var(--ns-s-2); flex-wrap: wrap; }
.ns-tabbar { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--ns-z-pegajoso); padding: 0 var(--ns-s-1) env(safe-area-inset-bottom); background: var(--ns-superficie); border-top: 1px solid var(--ns-borde); }
.ns-tabbar a { flex: 1; display: grid; justify-items: center; align-content: center; gap: 2px; min-height: 56px; color: var(--ns-texto-2); text-decoration: none; font-size: var(--ns-tam-xs); font-weight: var(--ns-peso-medio); border-radius: var(--ns-r-control); }
.ns-tabbar a[aria-current="page"] { color: var(--ns-acento-texto); }
@media (max-width: 1100px) {
  .ns-app { grid-template-columns: var(--ns-ancho-menu-riel) minmax(0, 1fr); }
  .ns-menu__enlace { justify-content: center; padding: 0; }
  .ns-menu__texto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .ns-contenido { padding: var(--ns-s-4) var(--ns-s-4) var(--ns-s-7); }
}
@media (max-width: 768px) {
  .ns-app { grid-template-columns: minmax(0, 1fr); }
  .ns-menu { display: none; }
  .ns-tabbar { display: flex; }
  .ns-contenido { padding-bottom: calc(56px + var(--ns-s-6)); }
  .ns-conexion span, .ns-busca span, .ns-busca .ns-kbd, .ns-marca span { display: none; }
  .ns-busca { flex: none; width: var(--ns-h-alto-sm); justify-content: center; padding: 0; }
  .ns-avisos { bottom: calc(56px + var(--ns-s-4)); }
}

/* ================= Pasos (recorridos largos, p. ej. campañas) ================= */
.ns-pasos { display: flex; gap: var(--ns-s-2); margin: 0; padding: 0; list-style: none; overflow-x: auto; counter-reset: ns-paso; }
.ns-paso { flex: 1 0 auto; display: flex; align-items: center; gap: var(--ns-s-2); min-height: var(--ns-h-alto); padding: 0 var(--ns-s-3); border: 1px solid var(--ns-borde); border-radius: var(--ns-r-control); color: var(--ns-texto-2); font-size: var(--ns-tam-sm); font-weight: var(--ns-peso-medio); counter-increment: ns-paso; white-space: nowrap; }
.ns-paso::before { content: counter(ns-paso); display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: var(--ns-r-completo); border: 1px solid var(--ns-borde-control); font-size: var(--ns-tam-xs); font-variant-numeric: tabular-nums; }
.ns-paso[data-estado="hecho"] { color: var(--ns-texto); }
.ns-paso[data-estado="hecho"]::before { content: "\2713"; background-color: var(--ns-ok-texto); border-color: var(--ns-ok-texto); color: var(--ns-sobre-acento); font-weight: var(--ns-peso-negrita); }
.ns-paso[aria-current="step"] { border-color: var(--ns-acento); background: var(--ns-acento-suave); color: var(--ns-acento-texto); }
.ns-paso[aria-current="step"]::before { background: var(--ns-acento); border-color: var(--ns-acento); color: var(--ns-sobre-acento); }
