/* ═══════════════════════════════════════════════════════════════════
   CARMESÍ PRIME — sistema de diseño web
   Puerto del kit del cliente (client/Scripts/UI/Prime) a la wiki.
   Referencia canónica: docs/ui-prime/SISTEMA.md + referencia/*.html
   Cero literales de color fuera de :root.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  /* ── Superficies ────────────────────────────────────────── */
  --fondo:          #0A0607;
  --fondo-alt:      #0C0809;
  --panel:          #161011;
  --elevado:        #1F1618;
  --elevado-claro:  #241719;
  --hundido:        #0A0607;
  --vidrio:         rgba(18, 12, 13, .94);

  /* ── Líneas ─────────────────────────────────────────────── */
  --linea:          #332528;
  --linea-viva:     #4C3639;
  --fantasma:       #4D3F42;

  /* ── Texto ──────────────────────────────────────────────── */
  --texto:          #F1E8E9;
  --tenue:          #9C8388;
  --apagado:        #6E5B5F;

  /* ── Acento carmesí ─────────────────────────────────────── */
  --acento:         #D9534F;
  --acento-claro:   #E8615C;
  --acento-oscuro:  #B83E3B;
  --acento-tinte:   rgba(217, 83, 79, .10);
  --acento-velo:    rgba(217, 83, 79, .22);
  --sobre-acento:   #0C0809;

  /* ── Semánticos (no se tocan: significan) ───────────────── */
  --ok:             #6FD08C;
  --peligro:        #E5484D;
  --oro:            #D9B85C;
  --hp:             #C4443F;
  --mp:             #3F7BD8;
  --ene:            #C8A02C;

  /* ── Tipografía ─────────────────────────────────────────── */
  --cond:  "Barlow Condensed", "Arial Narrow", sans-serif;
  --cuerpo:"Barlow", system-ui, -apple-system, sans-serif;
  --mono:  "IBM Plex Mono", ui-monospace, "SF Mono", monospace;

  /* ── Motion ─────────────────────────────────────────────── */
  --t-rapido:  90ms;
  --t-base:   160ms;
  --t-panel:  240ms;
  --t-medidor:420ms;
  --e-salida:  cubic-bezier(.16, 1, .3, 1);
  --e-entrada: cubic-bezier(.55, 0, .85, .36);
  --e-medidor: cubic-bezier(.22, 1, .36, 1);

  /* ── Métrica ────────────────────────────────────────────── */
  --nav-w:    286px;
  --toc-w:    228px;
  --barra-h:  56px;
  --chaflan:  12px;
  --lectura:  74ch;
}

/* ═══ Reset ══════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--barra-h) + 24px); }
body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font-family: var(--cuerpo);
  font-weight: 300;
  font-size: 15.5px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* ═══ Formas: chaflán en DOS esquinas, nunca cuatro ══════════ */
.chaflan {
  clip-path: polygon(var(--chaflan) 0, 100% 0, 100% calc(100% - var(--chaflan)),
                     calc(100% - var(--chaflan)) 100%, 0 100%, 0 var(--chaflan));
}
.chaflan-s { --chaflan: 5px; clip-path: polygon(5px 0, 100% 0, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0 100%, 0 5px); }
.paralelo  { clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%); }

/* Marca biselada: la barrita de acento que abre cada cabecera */
.marca {
  width: 4px; flex: 0 0 4px; background: var(--acento);
  clip-path: polygon(0 0, 100% 4px, 100% 100%, 0 calc(100% - 4px));
}

/* Escuadras de encuadre (esquinas de la tarjeta de login) */
.escuadras { position: relative; }
.escuadras::before, .escuadras::after {
  content: ""; position: absolute; width: 22px; height: 22px; pointer-events: none;
}
.escuadras::before { left: -9px;  top: -9px;    border-left: 2px solid var(--acento); border-top: 2px solid var(--acento); }
.escuadras::after  { right: -9px; bottom: -9px; border-right: 2px solid var(--acento); border-bottom: 2px solid var(--acento); }

/* ═══ Atmósfera de fondo: respira ════════════════════════════ */
.atmosfera { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.atmosfera .base {
  position: absolute; inset: 0;
  background: linear-gradient(165deg, #120B0D 0%, var(--fondo-alt) 48%, var(--fondo) 100%);
}
.atmosfera .aura {
  position: absolute; left: 42%; top: -14%; width: 1100px; height: 820px;
  background: radial-gradient(ellipse 50% 50% at 50% 50%,
    rgba(217,83,79,.085) 0%, rgba(217,83,79,.02) 45%, transparent 68%);
  animation: respira 9s ease-in-out infinite;
}
.atmosfera .slash {
  position: absolute; top: -140px; height: 1500px; transform: rotate(16deg);
}
.atmosfera .slash.viva  { left: 68%; width: 2px; background: linear-gradient(180deg, transparent 0%, var(--acento) 26%, var(--acento) 74%, transparent 100%); box-shadow: 0 0 22px rgba(217,83,79,.4); opacity: .5; }
.atmosfera .slash.tenue { left: calc(68% + 34px); width: 1px; background: var(--linea-viva); opacity: .55; }
.atmosfera .slash.eco   { left: calc(68% - 38px); width: 1px; background: var(--linea-viva); opacity: .3; }
.atmosfera .vineta { position: absolute; inset: 0; box-shadow: inset 0 0 260px rgba(0,0,0,.62); }
.atmosfera .grano {
  position: absolute; inset: -200%; opacity: .022;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: deriva 26s steps(9) infinite;
}
@keyframes respira { 0%, 100% { opacity: 1; } 50% { opacity: .78; } }
@keyframes deriva  { 0% { transform: translate(0,0); } 100% { transform: translate(6%, 4%); } }

/* ═══ Tipografía ═════════════════════════════════════════════ */
.rotulo {
  font-family: var(--cond); font-weight: 600; font-size: 11.5px;
  letter-spacing: .26em; text-transform: uppercase; color: var(--tenue);
}
.mono { font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; color: var(--apagado); }
.cifra { font-family: var(--cond); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ═══ Barra superior ═════════════════════════════════════════ */
.barra {
  position: sticky; top: 0; z-index: 60; height: var(--barra-h);
  display: flex; align-items: center; gap: 20px; padding: 0 22px;
  background: var(--vidrio); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--linea);
}
.marca-sitio { display: flex; align-items: center; gap: 11px; text-decoration: none; flex: 0 0 auto; }
.marca-sitio .rombo { width: 24px; height: 24px; flex: 0 0 24px; }
.marca-sitio .nombre {
  font-family: var(--cond); font-weight: 600; font-size: 16px;
  letter-spacing: .2em; color: var(--texto); white-space: nowrap;
}
.marca-sitio .nombre em { font-style: normal; color: var(--acento); }
.barra .sello {
  font-family: var(--cond); font-weight: 600; font-size: 10px; letter-spacing: .22em;
  color: var(--sobre-acento); background: var(--acento); padding: 4px 13px 3px 15px;
  clip-path: polygon(7px 0, 100% 0, calc(100% - 7px) 100%, 0 100%);
}
.barra .empuje { margin-left: auto; }

/* Botón de menú (móvil) */
.btn-menu { display: none; width: 34px; height: 34px; align-items: center; justify-content: center; border: 1px solid var(--linea-viva); }
.btn-menu span { display: block; width: 16px; height: 1.5px; background: var(--texto); box-shadow: 0 -5px 0 var(--texto), 0 5px 0 var(--texto); }

/* ═══ Buscador ═══════════════════════════════════════════════ */
.buscador { position: relative; flex: 1 1 460px; max-width: 460px; }
.buscador input {
  width: 100%; height: 34px; padding: 0 34px 0 13px;
  background: rgba(10,6,7,.85); color: var(--texto);
  border: 1px solid var(--linea); border-left: 3px solid var(--linea-viva);
  font-family: var(--cuerpo); font-size: 13.5px; outline: none;
  transition: border-color var(--t-base), background var(--t-base);
}
.buscador input::placeholder { color: var(--apagado); }
.buscador input:focus { border-color: var(--linea-viva); border-left-color: var(--acento); background: rgba(10,6,7,.98); }
.buscador .atajo {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: 9.5px; color: var(--apagado);
  border: 1px solid var(--linea); padding: 1px 5px; pointer-events: none;
}
.buscador input:focus ~ .atajo { opacity: 0; }

.resultados {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 70;
  max-height: 62vh; overflow-y: auto;
  background: var(--vidrio); backdrop-filter: blur(14px);
  border: 1px solid var(--linea-viva);
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
  opacity: 0; transform: translateY(-6px); pointer-events: none;
  transition: opacity var(--t-base), transform var(--t-base) var(--e-salida);
}
.resultados.abierto { opacity: 1; transform: none; pointer-events: auto; }
.resultados .grupo { padding: 9px 14px 4px; }
.resultados .hit {
  display: block; padding: 9px 14px; text-decoration: none; color: var(--texto);
  border-left: 2px solid transparent; transition: background var(--t-rapido), border-color var(--t-rapido);
}
.resultados .hit:hover, .resultados .hit.activo { background: var(--acento-tinte); border-left-color: var(--acento); }
.resultados .hit .t { font-family: var(--cond); font-weight: 500; font-size: 15px; letter-spacing: .04em; }
.resultados .hit .d { font-size: 12.5px; color: var(--tenue); margin-top: 1px; }
.resultados .hit mark { background: var(--acento-velo); color: var(--texto); padding: 0 1px; }
.resultados .vacio { padding: 22px 14px; text-align: center; color: var(--apagado); font-size: 13.5px; }

/* ═══ Estructura ═════════════════════════════════════════════ */
.marco { position: relative; z-index: 1; display: flex; align-items: flex-start; }

/* ── Navegación lateral ─────────────────────────────────── */
.nav {
  position: sticky; top: var(--barra-h); flex: 0 0 var(--nav-w); width: var(--nav-w);
  height: calc(100vh - var(--barra-h)); overflow-y: auto;
  border-right: 1px solid var(--linea); padding: 24px 0 60px;
  scrollbar-width: thin;
}
.nav .seccion { padding: 18px 22px 6px; display: flex; align-items: center; gap: 9px; }
.nav .seccion .rombo-mini { width: 5px; height: 5px; background: var(--acento); transform: rotate(45deg); flex: 0 0 5px; }
.nav .seccion span {
  font-family: var(--cond); font-weight: 600; font-size: 10.5px;
  letter-spacing: .26em; color: var(--acento); text-transform: uppercase;
}
.nav .seccion .hairline { flex: 1; height: 1px; background: var(--linea); }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 22px 7px 20px;
  text-decoration: none; color: var(--tenue); font-size: 14px;
  border-left: 2px solid transparent;
  transition: color var(--t-base), border-color var(--t-base), background var(--t-base);
}
.nav a .num { font-family: var(--mono); font-size: 9.5px; color: var(--apagado); flex: 0 0 auto; transition: color var(--t-base); }
.nav a:hover { color: var(--texto); background: rgba(217,83,79,.05); }
.nav a.activo { color: var(--texto); border-left-color: var(--acento); background: var(--acento-tinte); }
.nav a.activo .num { color: var(--acento); }

/* ── Columna de contenido ───────────────────────────────── */
.lienzo { flex: 1 1 auto; min-width: 0; padding: 0 40px 120px; }
.pagina { max-width: var(--lectura); margin: 0 auto; }

/* ── Tabla de contenidos ────────────────────────────────── */
.toc {
  position: sticky; top: calc(var(--barra-h) + 34px); flex: 0 0 var(--toc-w); width: var(--toc-w);
  max-height: calc(100vh - var(--barra-h) - 70px); overflow-y: auto;
  padding: 34px 22px 40px 0; align-self: flex-start;
}
.toc .titulo { font-family: var(--cond); font-weight: 600; font-size: 10.5px; letter-spacing: .26em; color: var(--apagado); margin-bottom: 12px; }
.toc a {
  display: block; padding: 4.5px 0 4.5px 13px; text-decoration: none;
  color: var(--apagado); font-size: 12.8px; line-height: 1.4;
  border-left: 1px solid var(--linea);
  transition: color var(--t-base), border-color var(--t-base);
}
.toc a.h3 { padding-left: 25px; font-size: 12px; }
.toc a:hover { color: var(--tenue); }
.toc a.activo { color: var(--acento); border-left-color: var(--acento); }

/* ═══ Encabezado de página ═══════════════════════════════════ */
.encabezado { padding: 52px 0 32px; border-bottom: 1px solid var(--linea); margin-bottom: 38px; }
.encabezado .kicker { display: flex; align-items: center; gap: 11px; margin-bottom: 17px; }
.encabezado .kicker .raya { width: 24px; height: 2px; background: var(--acento); }
.encabezado .kicker span { font-family: var(--mono); font-size: 11px; letter-spacing: .3em; color: var(--acento); text-transform: uppercase; }
.encabezado h1 {
  font-family: var(--cond); font-weight: 600; font-size: clamp(38px, 5.4vw, 62px);
  line-height: .96; letter-spacing: -.005em; margin: 0; color: var(--texto);
}
.encabezado .bajada { margin-top: 15px; font-size: 17px; font-weight: 300; color: var(--tenue); max-width: 62ch; }

/* ═══ Contenido ══════════════════════════════════════════════ */
.pagina h2 {
  font-family: var(--cond); font-weight: 600; font-size: 27px; letter-spacing: .04em;
  margin: 52px 0 4px; padding-top: 4px; color: var(--texto);
  display: flex; align-items: center; gap: 12px; scroll-margin-top: 84px;
}
.pagina h2::before { content: ""; width: 5px; height: 5px; background: var(--acento); transform: rotate(45deg); flex: 0 0 5px; }
.pagina h2 + .hairline { height: 1px; background: var(--linea); margin-bottom: 22px; }
.pagina h3 {
  font-family: var(--cond); font-weight: 600; font-size: 19px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--tenue); margin: 34px 0 12px; scroll-margin-top: 84px;
}
.pagina h4 { font-family: var(--cond); font-weight: 600; font-size: 15.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--apagado); margin: 24px 0 8px; }
.pagina p { margin: 0 0 15px; }
.pagina a { color: var(--acento); text-decoration: none; border-bottom: 1px solid var(--acento-velo); transition: color var(--t-base), border-color var(--t-base); }
.pagina a:hover { color: var(--acento-claro); border-bottom-color: var(--acento-claro); }
.pagina strong { font-weight: 500; color: var(--texto); }
.pagina em { font-style: normal; color: var(--acento); }
.pagina ul, .pagina ol { margin: 0 0 16px; padding-left: 20px; }
.pagina li { margin-bottom: 6px; }
.pagina li::marker { color: var(--acento); }
.pagina hr { border: 0; height: 1px; background: var(--linea); margin: 40px 0; }

code {
  font-family: var(--mono); font-size: .87em; color: var(--acento-claro);
  background: rgba(217,83,79,.07); border: 1px solid rgba(217,83,79,.15);
  padding: .1em .38em; border-radius: 1px;
}
pre {
  background: var(--hundido); border: 1px solid var(--linea); border-left: 3px solid var(--acento);
  padding: 15px 17px; overflow-x: auto; margin: 0 0 20px; font-size: 12.8px; line-height: 1.65;
}
pre code { background: none; border: 0; color: var(--tenue); padding: 0; font-size: inherit; }

/* ═══ Tablas ═════════════════════════════════════════════════ */
.tabla-marco { overflow-x: auto; margin: 0 0 24px; border: 1px solid var(--linea); }
table { width: 100%; border-collapse: collapse; font-size: 13.6px; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--elevado); color: var(--tenue);
  font-family: var(--cond); font-weight: 600; font-size: 11px; letter-spacing: .18em; text-transform: uppercase;
  text-align: left; padding: 10px 13px; border-bottom: 1px solid var(--linea-viva); white-space: nowrap;
}
tbody td { padding: 8.5px 13px; border-bottom: 1px solid var(--linea); color: var(--tenue); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--t-rapido); }
tbody tr:hover { background: var(--acento-tinte); }
tbody tr:hover td { color: var(--texto); }
tbody td:first-child { color: var(--texto); font-weight: 400; }
td.num, th.num { text-align: right; font-family: var(--mono); font-size: 12.4px; font-variant-numeric: tabular-nums; }

/* ═══ Llamadas ═══════════════════════════════════════════════ */
.nota, .aviso, .dato {
  display: flex; gap: 13px; padding: 14px 17px; margin: 0 0 22px;
  background: var(--panel); border: 1px solid var(--linea); border-left: 3px solid var(--acento);
}
.nota .glifo, .aviso .glifo, .dato .glifo { flex: 0 0 auto; width: 15px; height: 15px; margin-top: 3px; }
.nota .cuerpo, .aviso .cuerpo, .dato .cuerpo { flex: 1; min-width: 0; font-size: 14px; }
.nota .cuerpo > :last-child, .aviso .cuerpo > :last-child, .dato .cuerpo > :last-child { margin-bottom: 0; }
.nota .rot, .aviso .rot, .dato .rot {
  display: block; font-family: var(--cond); font-weight: 600; font-size: 10.5px;
  letter-spacing: .24em; text-transform: uppercase; color: var(--acento); margin-bottom: 4px;
}
.aviso { border-left-color: var(--peligro); }
.aviso .rot { color: var(--peligro); }
.dato { border-left-color: var(--oro); }
.dato .rot { color: var(--oro); }

/* ═══ Tarjetas ═══════════════════════════════════════════════ */
.rejilla { display: grid; gap: 14px; margin: 0 0 26px; }
.rejilla.c2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.rejilla.c3 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.tarjeta {
  position: relative; display: block; padding: 18px 19px; text-decoration: none;
  background: var(--panel); border: 1px solid var(--linea);
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  transition: background var(--t-base), border-color var(--t-base), transform var(--t-base) var(--e-salida);
}
a.tarjeta:hover { background: var(--elevado); border-color: var(--linea-viva); transform: translateY(-2px); }
.tarjeta .cab { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.tarjeta .cab .marca { height: 18px; }
.tarjeta h3, .tarjeta .t {
  font-family: var(--cond); font-weight: 600; font-size: 17.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--texto); margin: 0;
}
.tarjeta p { font-size: 13.4px; color: var(--tenue); margin: 0; }
.tarjeta .flecha {
  position: absolute; right: 15px; bottom: 14px; color: var(--acento); opacity: 0;
  transform: translateX(-5px); transition: opacity var(--t-base), transform var(--t-base) var(--e-salida);
}
a.tarjeta:hover .flecha { opacity: 1; transform: none; }

/* Ficha de estadística */
.ficha {
  background: var(--panel); border: 1px solid var(--linea); padding: 14px 16px;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}
.ficha .et { font-family: var(--cond); font-weight: 600; font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--apagado); }
.ficha .val { font-family: var(--cond); font-weight: 600; font-size: 30px; line-height: 1.1; color: var(--texto); font-variant-numeric: tabular-nums; margin-top: 2px; }
.ficha .val.acento { color: var(--acento); }
.ficha .sub { font-size: 12px; color: var(--tenue); margin-top: 2px; }

/* ═══ Medidor (barra de recurso con memoria) ═════════════════ */
.medidor { height: 6px; background: var(--hundido); border: 1px solid var(--linea); position: relative; overflow: hidden; margin-top: 7px; }
.medidor .relleno { position: absolute; inset: 0 auto 0 0; transition: width var(--t-medidor) var(--e-medidor); }
.medidor .relleno.hp  { background: linear-gradient(90deg, var(--hp), #E06561); }
.medidor .relleno.mp  { background: linear-gradient(90deg, var(--mp), #6B9FE8); }
.medidor .relleno.ene { background: linear-gradient(90deg, var(--ene), #E0BE55); }
.medidor .relleno.acento { background: linear-gradient(90deg, var(--acento-oscuro), var(--acento-claro)); }

/* ═══ Píldoras ═══════════════════════════════════════════════ */
.pildora {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--cond); font-weight: 600; font-size: 10.5px; letter-spacing: .16em;
  text-transform: uppercase; padding: 3px 10px 2px;
  border: 1px solid var(--linea-viva); color: var(--tenue); white-space: nowrap;
}
.pildora.acento  { border-color: var(--acento); color: var(--acento); }
.pildora.ok      { border-color: var(--ok); color: var(--ok); }
.pildora.peligro { border-color: var(--peligro); color: var(--peligro); }
.pildora.oro     { border-color: var(--oro); color: var(--oro); }
.pildora.mp      { border-color: var(--mp); color: var(--mp); }
.pildora.llena   { background: var(--acento); color: var(--sobre-acento); border-color: var(--acento); }

/* ═══ Botones ════════════════════════════════════════════════ */
.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 42px; padding: 0 22px; text-decoration: none;
  font-family: var(--cond); font-weight: 600; font-size: 14px; letter-spacing: .2em; text-indent: .2em;
  text-transform: uppercase;
  clip-path: polygon(9px 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%, 0 9px);
  transition: filter var(--t-base) var(--e-salida), transform var(--t-rapido) ease-out, background var(--t-base), color var(--t-base);
}
.boton.primario {
  background: linear-gradient(180deg, var(--acento-claro) 0%, var(--acento) 55%, var(--acento-oscuro) 100%);
  color: var(--sobre-acento); box-shadow: 0 6px 26px rgba(217,83,79,.26); border: 0;
}
.boton.primario:hover { filter: brightness(1.08); }
.boton.normal { border: 1px solid var(--linea-viva); background: rgba(31,22,24,.4); color: var(--texto); }
.boton.normal:hover { background: var(--elevado); border-color: var(--acento); }
.boton:active { transform: translateY(1px); }

/* ═══ Pie de página ══════════════════════════════════════════ */
.pie {
  border-top: 1px solid var(--linea); margin-top: 68px; padding: 26px 0 0;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--apagado);
}
.pie .fuente { font-family: var(--mono); font-size: 10.5px; }
.pie .empuje { margin-left: auto; }

/* Paginación anterior/siguiente */
.saltos { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 46px; }
.saltos a {
  display: flex; flex-direction: column; gap: 3px; padding: 15px 17px; text-decoration: none;
  border: 1px solid var(--linea); background: var(--panel);
  transition: border-color var(--t-base), background var(--t-base);
}
.saltos a:hover { border-color: var(--acento); background: var(--elevado); }
.saltos a .dir { font-family: var(--mono); font-size: 9.5px; letter-spacing: .2em; color: var(--apagado); text-transform: uppercase; }
.saltos a .t { font-family: var(--cond); font-weight: 600; font-size: 16px; letter-spacing: .08em; color: var(--texto); }
.saltos a.der { text-align: right; }
.saltos .hueco { border: 1px dashed var(--linea); opacity: .3; }

/* ═══ Motion: entradas escalonadas ═══════════════════════════ */
@keyframes sube { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }
.stag { opacity: 0; animation: sube .42s var(--e-salida) forwards; }
.stag:nth-child(1) { animation-delay: .02s; }
.stag:nth-child(2) { animation-delay: .07s; }
.stag:nth-child(3) { animation-delay: .12s; }
.stag:nth-child(4) { animation-delay: .17s; }
.stag:nth-child(5) { animation-delay: .22s; }
.stag:nth-child(6) { animation-delay: .27s; }

.pagina > * { animation: sube .38s var(--e-salida) both; }
.revelar { opacity: 0; transform: translateY(12px); transition: opacity .5s var(--e-salida), transform .5s var(--e-salida); }
.revelar.visible { opacity: 1; transform: none; }

/* Barra de progreso de lectura */
.progreso { position: fixed; top: var(--barra-h); left: 0; height: 2px; z-index: 59; background: var(--acento); width: 0; box-shadow: 0 0 10px rgba(217,83,79,.6); transition: width 90ms linear; }

/* ═══ Portada ════════════════════════════════════════════════ */
.portada { padding: 74px 0 22px; }
.portada .titular {
  font-family: var(--cond); font-weight: 600; font-size: clamp(56px, 11vw, 124px);
  line-height: .87; letter-spacing: -.01em; margin: 18px 0 0; color: var(--texto);
}
.portada .titular em { font-style: normal; color: var(--acento); }
.portada .sub { display: flex; align-items: center; gap: 15px; margin-top: 15px; }
.portada .sub .hueca {
  font-family: var(--cond); font-weight: 500; font-size: 22px; letter-spacing: .56em;
  color: transparent; -webkit-text-stroke: 1px var(--tenue);
}
.portada .sub .raya { width: 54px; height: 1px; background: var(--linea-viva); }
.portada .lede { margin-top: 26px; font-size: 18px; font-weight: 300; color: var(--tenue); max-width: 56ch; }

/* ═══ Scrollbars ═════════════════════════════════════════════ */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: var(--fondo-alt); }
::-webkit-scrollbar-thumb { background: var(--linea-viva); }
::-webkit-scrollbar-thumb:hover { background: var(--acento-oscuro); }

/* ═══ Responsive ═════════════════════════════════════════════ */
@media (max-width: 1280px) { .toc { display: none; } }
@media (max-width: 900px) {
  .btn-menu { display: flex; }
  .nav {
    position: fixed; top: var(--barra-h); left: 0; z-index: 55;
    background: var(--vidrio); backdrop-filter: blur(16px);
    transform: translateX(-102%); transition: transform var(--t-panel) var(--e-salida);
  }
  .nav.abierta { transform: none; }
  .lienzo { padding: 0 20px 90px; }
  .barra .sello { display: none; }
  .encabezado { padding-top: 34px; }
  .saltos { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .buscador { flex: 1 1 auto; }
  .buscador .atajo { display: none; }
  .marca-sitio .nombre { display: none; }
}

/* ═══ Accesibilidad ══════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}
:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }
.salto-contenido {
  position: absolute; left: -9999px; top: 8px; z-index: 100;
  background: var(--acento); color: var(--sobre-acento); padding: 9px 16px;
  font-family: var(--cond); font-weight: 600; letter-spacing: .18em;
}
.salto-contenido:focus { left: 12px; }

/* ═══════════════════════════════════════════════════════════════════
   PIEZAS INTERACTIVAS
   ═══════════════════════════════════════════════════════════════════ */

/* ── Tabla con buscador y orden ──────────────────────────────── */
.tabla { margin: 0 0 26px; }
.tabla .controles {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; background: var(--panel);
  border: 1px solid var(--linea); border-bottom: 0;
}
.tabla .campo { position: relative; flex: 1 1 220px; max-width: 320px; }
.tabla .campo input {
  width: 100%; height: 30px; padding: 0 11px; background: var(--hundido); color: var(--texto);
  border: 1px solid var(--linea); border-left: 2px solid var(--acento);
  font-family: var(--cuerpo); font-size: 13px; outline: none;
  transition: border-color var(--t-base);
}
.tabla .campo input::placeholder { color: var(--apagado); }
.tabla .campo input:focus { border-color: var(--linea-viva); border-left-color: var(--acento-claro); }
.tabla .conteo { font-family: var(--mono); font-size: 10.5px; color: var(--apagado); letter-spacing: .06em; }
.tabla .conteo b { color: var(--acento); font-weight: 500; }
.tabla .chips { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.tabla .chip {
  font-family: var(--cond); font-weight: 600; font-size: 10.5px; letter-spacing: .14em;
  text-transform: uppercase; padding: 4px 11px 3px;
  border: 1px solid var(--linea-viva); color: var(--tenue);
  transition: background var(--t-rapido), color var(--t-rapido), border-color var(--t-rapido);
}
.tabla .chip:hover { border-color: var(--acento); color: var(--texto); }
.tabla .chip.on { background: var(--acento); border-color: var(--acento); color: var(--sobre-acento); }
.tabla .marco { max-height: 560px; overflow: auto; border: 1px solid var(--linea); }
.tabla thead th.ord { cursor: pointer; user-select: none; padding-right: 22px; position: relative; }
.tabla thead th.ord::after {
  content: "⇅"; position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 10px; color: var(--apagado); transition: color var(--t-rapido);
}
.tabla thead th.ord:hover { color: var(--texto); }
.tabla thead th.ord:hover::after { color: var(--acento); }
.tabla thead th.asc::after  { content: "↑"; color: var(--acento); }
.tabla thead th.desc::after { content: "↓"; color: var(--acento); }
.tabla tr.oculta { display: none; }
.tabla .sin-resultados { padding: 26px 14px; text-align: center; color: var(--apagado); font-size: 13.5px; }

/* ── Selector de fichas (clases, oficios, barcos…) ───────────── */
.selector { display: flex; gap: 7px; flex-wrap: wrap; margin: 0 0 16px; }
.selector .opcion {
  display: flex; align-items: center; gap: 8px; padding: 9px 15px;
  background: var(--panel); border: 1px solid var(--linea); color: var(--tenue);
  font-family: var(--cond); font-weight: 600; font-size: 13.5px; letter-spacing: .12em;
  text-transform: uppercase;
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
  transition: background var(--t-base), color var(--t-base), border-color var(--t-base), transform var(--t-rapido);
}
.selector .opcion:hover { color: var(--texto); border-color: var(--linea-viva); background: var(--elevado); }
.selector .opcion.on {
  background: linear-gradient(180deg, var(--acento-claro), var(--acento-oscuro));
  border-color: var(--acento); color: var(--sobre-acento);
  box-shadow: 0 5px 22px rgba(217,83,79,.26);
}
.selector .opcion .glifo { width: 15px; height: 15px; flex: 0 0 15px; opacity: .85; }

.hojas { position: relative; }
.hoja { display: none; }
.hoja.on { display: block; animation: sube .34s var(--e-salida) both; }

/* ── Panel real con puntos explicativos ─────────────────────── */
.panel-real {
  margin: 0 0 26px; padding: 0;
  border: 1px solid var(--linea-viva); background: var(--fondo-alt);
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
}
.panel-real .cabecera {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px;
  background: var(--elevado); border-bottom: 1px solid var(--linea);
}
.panel-real .cabecera .marca { height: 15px; }
.panel-real .cabecera .t {
  font-family: var(--cond); font-weight: 600; font-size: 13px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--texto);
}
.panel-real .cabecera .tecla {
  margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--apagado);
  border: 1px solid var(--linea-viva); padding: 2px 7px;
}
.panel-real .lienzo-img { position: relative; line-height: 0; background: var(--hundido); }
.panel-real img { width: 100%; height: auto; }

.panel-real .punto {
  position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%);
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--acento); color: var(--sobre-acento);
  font-family: var(--cond); font-weight: 600; font-size: 12.5px; line-height: 1;
  border: 2px solid rgba(12,8,9,.85);
  box-shadow: 0 0 0 0 var(--acento-velo);
  cursor: pointer; z-index: 2;
  transition: transform var(--t-base) var(--e-salida), box-shadow var(--t-base);
  animation: latido 2.6s ease-out infinite;
}
@keyframes latido {
  0%   { box-shadow: 0 0 0 0 rgba(217,83,79,.5); }
  70%  { box-shadow: 0 0 0 11px rgba(217,83,79,0); }
  100% { box-shadow: 0 0 0 0 rgba(217,83,79,0); }
}
.panel-real .punto:hover, .panel-real .punto.on {
  transform: translate(-50%, -50%) scale(1.22); animation: none;
  box-shadow: 0 0 0 5px var(--acento-velo);
}
.panel-real .leyenda { border-top: 1px solid var(--linea); }
.panel-real .leyenda .fila {
  display: flex; gap: 12px; padding: 11px 15px; border-bottom: 1px solid var(--linea);
  transition: background var(--t-rapido);
}
.panel-real .leyenda .fila:last-child { border-bottom: 0; }
.panel-real .leyenda .fila.on { background: var(--acento-tinte); }
.panel-real .leyenda .n {
  flex: 0 0 21px; height: 21px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--elevado-claro); color: var(--tenue); border: 1px solid var(--linea-viva);
  font-family: var(--cond); font-weight: 600; font-size: 11.5px;
  transition: background var(--t-rapido), color var(--t-rapido);
}
.panel-real .leyenda .fila.on .n { background: var(--acento); color: var(--sobre-acento); border-color: var(--acento); }
.panel-real .leyenda .txt { font-size: 13.6px; color: var(--tenue); }
.panel-real .leyenda .txt b { color: var(--texto); font-weight: 500; display: block; font-family: var(--cond); font-size: 14.5px; letter-spacing: .06em; }

/* ── Detalle técnico plegable ────────────────────────────────── */
details.tecnico {
  margin: 0 0 22px; background: var(--panel);
  border: 1px solid var(--linea); border-left: 3px solid var(--linea-viva);
  transition: border-color var(--t-base);
}
details.tecnico[open] { border-left-color: var(--acento); }
details.tecnico summary {
  cursor: pointer; list-style: none; padding: 11px 15px;
  display: flex; align-items: center; gap: 10px;
  font-family: var(--cond); font-weight: 600; font-size: 12px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--tenue);
  transition: color var(--t-base);
}
details.tecnico summary::-webkit-details-marker { display: none; }
details.tecnico summary:hover { color: var(--texto); }
details.tecnico summary::before {
  content: "+"; font-size: 15px; color: var(--acento); line-height: 1;
  transition: transform var(--t-base) var(--e-salida);
}
details.tecnico[open] summary::before { content: "−"; }
details.tecnico .adentro { padding: 4px 15px 15px; font-size: 14px; }
details.tecnico .adentro > :last-child { margin-bottom: 0; }

/* ── Cartel de sección (épico) ───────────────────────────────── */
.cartel {
  position: relative; margin: 0 0 30px; padding: 26px 28px;
  background: linear-gradient(120deg, var(--elevado) 0%, var(--panel) 60%);
  border: 1px solid var(--linea-viva); overflow: hidden;
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
}
.cartel::before {
  content: ""; position: absolute; right: -60px; top: -80px; width: 260px; height: 400px;
  background: radial-gradient(ellipse at center, var(--acento-velo) 0%, transparent 66%);
  transform: rotate(16deg); pointer-events: none;
}
.cartel .frase {
  font-family: var(--cond); font-weight: 600; font-size: clamp(21px, 3vw, 30px);
  line-height: 1.14; letter-spacing: .02em; color: var(--texto); margin: 0; position: relative;
}
.cartel .frase em { font-style: normal; color: var(--acento); }
.cartel .pie { margin: 9px 0 0; font-size: 14px; color: var(--tenue); position: relative; }

/* ── Barra comparativa dentro de tabla ──────────────────────── */
.barra-comp { display: flex; align-items: center; gap: 8px; min-width: 108px; }
.barra-comp .riel { flex: 1; height: 5px; background: var(--hundido); border: 1px solid var(--linea); position: relative; }
.barra-comp .relleno { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--acento-oscuro), var(--acento-claro)); width: 0; transition: width .7s var(--e-medidor); }
.barra-comp .cifra { font-family: var(--mono); font-size: 11.5px; color: var(--texto); min-width: 30px; text-align: right; }

/* ── Pasos numerados ────────────────────────────────────────── */
.pasos { counter-reset: paso; list-style: none; padding: 0; margin: 0 0 26px; }
.pasos li {
  counter-increment: paso; position: relative; padding: 0 0 20px 46px; margin: 0;
  border-left: 1px solid var(--linea);
}
.pasos li:last-child { border-left-color: transparent; padding-bottom: 0; }
.pasos li::before {
  content: counter(paso, decimal-leading-zero);
  position: absolute; left: -14px; top: -2px; width: 27px; height: 27px;
  display: flex; align-items: center; justify-content: center;
  background: var(--fondo); border: 1px solid var(--acento); color: var(--acento);
  font-family: var(--cond); font-weight: 600; font-size: 11.5px;
}
.pasos li b { display: block; font-family: var(--cond); font-weight: 600; font-size: 16.5px; letter-spacing: .08em; color: var(--texto); margin-bottom: 3px; text-transform: uppercase; }

@media (max-width: 700px) {
  .panel-real .punto { width: 20px; height: 20px; font-size: 11px; }
  .tabla .chips { margin-left: 0; }
}

/* Barra comparativa con etiqueta adelante: "Vida por nivel — la más alta" + riel */
.barra-comp { flex-wrap: wrap; row-gap: 5px; }
.barra-comp > .cifra:first-child {
  font-family: var(--cuerpo); font-weight: 400; font-size: 12.8px;
  color: var(--tenue); text-align: left; min-width: 0; flex: 1 1 100%;
}
.barra-comp > .cifra:first-child + .riel { flex: 1 1 100%; }

/* ═══════════════════════════════════════════════════════════════════
   GRÁFICOS Y ESQUEMAS
   ═══════════════════════════════════════════════════════════════════ */

.grafico {
  margin: 0 0 26px; padding: 18px 20px 16px;
  background: var(--panel); border: 1px solid var(--linea);
  clip-path: polygon(11px 0, 100% 0, 100% calc(100% - 11px), calc(100% - 11px) 100%, 0 100%, 0 11px);
}
.grafico .titulo {
  display: flex; align-items: center; gap: 9px; margin-bottom: 4px;
  font-family: var(--cond); font-weight: 600; font-size: 13px;
  letter-spacing: .2em; text-transform: uppercase; color: var(--texto);
}
.grafico .titulo::before { content: ""; width: 5px; height: 5px; background: var(--acento); transform: rotate(45deg); flex: 0 0 5px; }
.grafico .sub { font-size: 12.5px; color: var(--apagado); margin: 0 0 16px; }
.grafico .nota-pie { margin: 12px 0 0; font-size: 12px; color: var(--apagado); }

/* ── Barras horizontales ─────────────────────────────────────── */
.gbarras { display: flex; flex-direction: column; gap: 9px; }
.gbarras .fila { display: grid; grid-template-columns: minmax(72px, 128px) 1fr auto; align-items: center; gap: 12px; }
.gbarras .etq {
  font-family: var(--cond); font-weight: 500; font-size: 13.5px; letter-spacing: .06em;
  color: var(--tenue); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gbarras .riel { position: relative; height: 17px; background: var(--hundido); border: 1px solid var(--linea); }
.gbarras .relleno {
  position: absolute; inset: 0 auto 0 0; width: 0;
  background: linear-gradient(90deg, var(--acento-oscuro), var(--acento));
  transition: width .82s var(--e-medidor);
}
.gbarras .fila.destacada .etq { color: var(--texto); }
.gbarras .fila.destacada .relleno { background: linear-gradient(90deg, var(--acento), var(--acento-claro)); box-shadow: 0 0 16px rgba(217,83,79,.34); }
.gbarras .fila.apagada .relleno { background: linear-gradient(90deg, #3A2C2E, var(--fantasma)); }
.gbarras .val {
  font-family: var(--mono); font-size: 12.5px; color: var(--texto);
  font-variant-numeric: tabular-nums; min-width: 44px; text-align: right;
}

/* ── Radar / telaraña ────────────────────────────────────────── */
.gradar { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; justify-content: center; }
.gradar svg { flex: 0 0 auto; max-width: 100%; height: auto; }
.gradar .leyenda-r { display: flex; flex-direction: column; gap: 8px; }
.gradar .leyenda-r .it { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--tenue); }
.gradar .leyenda-r .muestra { width: 13px; height: 13px; flex: 0 0 13px; border: 1px solid; }

/* ── Curva ───────────────────────────────────────────────────── */
.gcurva svg { width: 100%; height: auto; display: block; }
.gcurva .punto-c { transition: r var(--t-rapido); }

/* ── Esquema de flujo ────────────────────────────────────────── */
.esquema { display: flex; align-items: stretch; gap: 0; flex-wrap: wrap; margin: 0 0 26px; }
.esquema .nodo {
  position: relative; flex: 1 1 150px; min-width: 132px; padding: 14px 15px;
  background: var(--panel); border: 1px solid var(--linea); border-left: 3px solid var(--acento);
}
.esquema .nodo b {
  display: block; font-family: var(--cond); font-weight: 600; font-size: 14.5px;
  letter-spacing: .08em; text-transform: uppercase; color: var(--texto); margin-bottom: 4px;
}
.esquema .nodo span { display: block; font-size: 12.8px; color: var(--tenue); line-height: 1.42; }
.esquema .nodo.ok      { border-left-color: var(--ok); }
.esquema .nodo.malo    { border-left-color: var(--peligro); }
.esquema .nodo.neutro  { border-left-color: var(--linea-viva); }
.esquema .flecha {
  flex: 0 0 30px; display: flex; align-items: center; justify-content: center;
  color: var(--acento); font-size: 17px; line-height: 1;
}
.esquema .flecha::before { content: "→"; }
.esquema.vertical { flex-direction: column; }
/* En columna el flex-basis pasa a ser la ALTURA: sin esto cada nodo se estira a 150px. */
.esquema.vertical .nodo { flex: 0 0 auto; width: 100%; }
.esquema.vertical .flecha { flex: 0 0 26px; }
.esquema.vertical .flecha::before { content: "↓"; }

/* Bifurcación: dos salidas de un mismo nodo */
.bifurca { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 0 26px; }
.bifurca .rama {
  padding: 14px 16px; background: var(--panel); border: 1px solid var(--linea);
  border-top: 2px solid var(--linea-viva);
}
.bifurca .rama.si   { border-top-color: var(--ok); }
.bifurca .rama.no   { border-top-color: var(--peligro); }
.bifurca .rama .cab {
  font-family: var(--cond); font-weight: 600; font-size: 11.5px; letter-spacing: .22em;
  text-transform: uppercase; margin-bottom: 6px; color: var(--tenue);
}
.bifurca .rama.si .cab { color: var(--ok); }
.bifurca .rama.no .cab { color: var(--peligro); }
.bifurca .rama p { margin: 0; font-size: 13.4px; color: var(--tenue); }

/* ── Línea de hitos por nivel ────────────────────────────────── */
.hitos { position: relative; margin: 6px 0 30px; padding: 26px 0 0; }
.hitos .riel-h { position: relative; height: 3px; background: linear-gradient(90deg, var(--linea-viva), var(--acento)); }
.hitos .hito { position: absolute; top: 0; transform: translateX(-50%); text-align: center; width: 96px; }
.hitos .hito .marca-h { width: 11px; height: 11px; margin: -4px auto 0; background: var(--fondo); border: 2px solid var(--acento); transform: rotate(45deg); }
.hitos .hito .niv {
  font-family: var(--cond); font-weight: 600; font-size: 15px; color: var(--acento);
  margin-top: 8px; letter-spacing: .06em;
}
.hitos .hito .que { font-size: 11.5px; color: var(--tenue); line-height: 1.32; margin-top: 1px; }
.hitos .hito:nth-child(even) { top: -2px; }
@media (max-width: 700px) {
  .hitos { padding-top: 0; }
  .hitos .riel-h { display: none; }
  .hitos .hito { position: static; transform: none; width: auto; text-align: left; display: flex; gap: 11px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--linea); }
  .hitos .hito .marca-h { display: none; }
  .hitos .hito .niv { margin: 0; flex: 0 0 46px; }
  .hitos .hito .que { margin: 0; }
  .esquema .flecha::before { content: "↓"; }
  .esquema { flex-direction: column; }
  .bifurca { grid-template-columns: 1fr; }
}
