/* Unidos MIA · identidad de MIA AC (Movimiento Integral de Apoyo): oro del logotipo, negro, blanco y plata.
   Escala oro tomada de integracentro-ui (globals.css). oro-600 es el tono de botones y enlaces sobre blanco;
   oro-300 a oro-500 son acentos sobre negro. El logotipo es un JPG sobre negro: solo va sobre superficies negras.
   Sin frameworks ni fuentes externas (residencia: nada de CDN, ADR-C2-08). Animaciones solo con CSS. */
:root {
  --oro-50: #FCF9F1; --oro-100: #F7EED6; --oro-200: #EEDCA8; --oro-300: #E3C574; --oro-400: #D8AE47;
  --oro-500: #C9962A; --oro-600: #8C6914; --oro-700: #765811; --oro-800: #5F470F; --oro-900: #4A380E; --oro-950: #2E2109;
  --negro: #000000;         /* fondo del logotipo y de las superficies de marca */
  --plata: #C9C5BC;         /* texto secundario sobre negro */
  --titulo: var(--oro-700); /* títulos y cifras sobre claro (6.6:1 en blanco) */
  --acento: var(--oro-600); /* enlaces, pasos y bordes activos sobre claro (5.1:1 en blanco) */
  --acento-osc: var(--oro-300); /* acentos sobre superficies negras */
  --foco: var(--oro-600);   /* anillo de foco: 5.1:1 sobre blanco y 4.2:1 sobre negro */
  --hielo: var(--oro-100);  /* superficie tenue (métricas, botón secundario) */
  --sobre-hielo: var(--oro-800);
  --grad: linear-gradient(140deg, #000 0%, #0d0b06 48%, var(--oro-950) 100%);
  --grad-boton: linear-gradient(135deg, var(--oro-700) 0%, var(--oro-600) 100%);
  --sobre-boton: #ffffff;
  --grad-oro: linear-gradient(135deg, var(--oro-300) 0%, var(--oro-500) 100%); /* botón principal sobre negro */
  --brillo-oro: rgba(201, 150, 42, .38);
  --texto: #17150F;
  --texto-2: #5C574D;
  --fondo: #F6F5F1;
  --tarjeta: #ffffff;
  --borde: #E6E0D2;
  --ok: #0f7a3f;   --ok-f: #e3f6ec;   /* verde y ámbar oscurecidos para AA (≥ 4.5:1 sobre su fondo) */
  --aviso: #8a5300; --aviso-f: #fff3dc;
  --error: #c0261b; --error-f: #fdecea;
  --radio: 20px;
  --sombra: 0 10px 30px -12px rgba(23, 21, 15, .22), 0 2px 6px rgba(23, 21, 15, .06);
  --sombra-oro: 0 14px 34px -14px rgba(140, 105, 20, .65);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --texto: #F2F0EA; --texto-2: #A8A39A; --fondo: #0B0B0B; --tarjeta: #161616; --borde: #2C2A25;
    --hielo: #221D12; --sobre-hielo: var(--oro-200); --titulo: var(--oro-300); --acento: var(--oro-300); --foco: var(--oro-400);
    --grad-boton: linear-gradient(135deg, var(--oro-400) 0%, var(--oro-500) 100%); --sobre-boton: #000000;
    --ok-f: #0d2c1c; --aviso-f: #33250a; --error-f: #3a1411;
    --ok: #4ade80; --aviso: #f5b84a; --error: #f87171;
    --sombra: 0 10px 30px -12px rgba(0, 0, 0, .6);
    --sombra-oro: 0 14px 34px -16px rgba(201, 150, 42, .45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; background: var(--fondo); color: var(--texto);
  font: 16px/1.5 system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh; display: flex; flex-direction: column;
}

/* ---------- Encabezado: negro con el logotipo de MIA AC ---------- */
.barra {
  background: var(--negro); color: #fff; padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right));
  display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 20;
  border-bottom: 1px solid var(--oro-900); box-shadow: 0 6px 24px -12px rgba(0, 0, 0, .8);
}
.barra img { height: 40px; width: auto; display: block; }
.barra h1 { font-size: 1.1rem; margin: 0; font-weight: 800; letter-spacing: .4px; line-height: 1.1; color: var(--oro-300); }
.barra .sub { font-size: .72rem; color: var(--plata); letter-spacing: 1.5px; text-transform: uppercase; }
.barra button {
  margin-left: auto; background: transparent; color: var(--oro-200); border: 1px solid var(--oro-700);
  padding: 6px 14px; min-height: 44px; font-size: .85rem;
}
.aviso-beta { background: #111; color: var(--plata); font-size: .7rem; text-align: center; padding: 4px 16px; }

main { width: 100%; max-width: 680px; margin: 0 auto; padding: 16px 16px 24px; flex: 1; outline: none; }

/* ---------- Tarjetas y héroe ---------- */
.tarjeta {
  background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 18px; margin-bottom: 16px; box-shadow: var(--sombra);
}
.heroe {
  position: relative; overflow: hidden; background: var(--grad); color: #fff; border: 0;
  box-shadow: var(--sombra-oro);
}
.heroe::before, .heroe::after {
  content: ""; position: absolute; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, var(--brillo-oro), transparent 70%);
}
.heroe::before { width: 280px; height: 280px; right: -90px; top: -110px; }
.heroe::after { width: 200px; height: 200px; left: -80px; bottom: -120px; opacity: .6; }
.heroe > * { position: relative; }
.heroe h2, .heroe .tenue { color: #fff; }
.heroe .tenue { color: var(--plata); }
.heroe .metrica { background: rgba(255, 255, 255, .07); border: 1px solid rgba(227, 197, 116, .22); }
.heroe .metrica b { color: var(--oro-300); }
.heroe .metrica > span { color: var(--plata); }

h2 { font-size: 1.3rem; margin: 0 0 8px; color: var(--titulo); letter-spacing: -.2px; line-height: 1.25; }
h3 { font-size: 1rem; margin: 16px 0 6px; }
p { margin: 0 0 10px; }
.tenue { color: var(--texto-2); font-size: .9rem; }
.centro { text-align: center; }
.saludo { font-size: 1.6rem; font-weight: 800; letter-spacing: -.5px; margin: 0 0 2px; }
.cabeza { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.cabeza h2 { margin: 0; }

/* ---------- Botones ---------- */
button, .boton {
  font: inherit; font-weight: 700; border: 0; border-radius: 14px; cursor: pointer;
  padding: 13px 18px; min-height: 50px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; transition: transform .12s ease, box-shadow .2s ease, background .2s;
}
button:active, .boton:active { transform: scale(.97); }
.primario { background: var(--grad-boton); color: var(--sobre-boton); width: 100%; box-shadow: var(--sombra-oro); }
.primario:hover:not(:disabled) { filter: brightness(1.08); }
.secundario { background: var(--hielo); color: var(--sobre-hielo); width: 100%; }
.secundario:hover:not(:disabled) { filter: brightness(.97); }
/* Botón principal sobre superficies negras (héroe, onboarding): oro con texto negro (≥ 7.9:1) */
.blanco { background: var(--grad-oro); color: #000; width: 100%; box-shadow: 0 10px 24px -12px rgba(201, 150, 42, .6); }
.blanco:hover:not(:disabled) { filter: brightness(1.06); }
.fantasma { background: transparent; color: var(--oro-200); border: 1px solid var(--oro-700); width: 100%; }
.enlace { background: none; color: var(--acento); min-height: 44px; padding: 6px; font-weight: 600; }
.enlace:hover { text-decoration: underline; }
.heroe .enlace, .portada .enlace { color: var(--acento-osc); }
.chico { min-height: 36px; padding: 6px 12px; font-size: .85rem; border-radius: 10px; width: auto; }
button:disabled { opacity: .5; cursor: default; box-shadow: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--foco); outline-offset: 2px; }
.barra button:focus-visible, .heroe :focus-visible, .portada :focus-visible, .lamina :focus-visible, .camara :focus-visible { outline-color: var(--oro-300); }
.fila { display: flex; gap: 10px; align-items: center; }
.fila > * { flex: 1; }
.pila > * + * { margin-top: 10px; }

/* ---------- Formularios ---------- */
label { display: block; font-weight: 600; font-size: .9rem; margin: 12px 0 4px; }
input[type=text], input[type=tel], input[type=date], input[type=search], select {
  width: 100%; font: inherit; padding: 12px 14px; border: 1.5px solid var(--borde); border-radius: 12px;
  background: var(--tarjeta); color: var(--texto); transition: border-color .2s, box-shadow .2s;
}
input:focus { border-color: var(--acento); box-shadow: 0 0 0 4px rgba(201, 150, 42, .22); outline: none; }
.codigo { text-align: center; font-size: 1.6rem !important; letter-spacing: 6px; font-weight: 800; text-transform: uppercase;
  font-family: ui-monospace, "SF Mono", Menlo, monospace !important; }
.casilla { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 10px 0; }
.casilla input { width: 22px; height: 22px; margin-top: 1px; accent-color: var(--oro-600); flex: none; }

/* ---------- Pantalla de bienvenida ---------- */
.portada {
  margin: -16px -16px 16px; padding: 36px 24px 44px; text-align: center; color: #fff; background: var(--grad);
  position: relative; overflow: hidden; border-radius: 0 0 32px 32px;
}
.portada::before {
  content: ""; position: absolute; inset: -40%; pointer-events: none;
  background: radial-gradient(circle at 70% 20%, rgba(201, 150, 42, .32), transparent 40%),
              radial-gradient(circle at 20% 90%, rgba(201, 150, 42, .18), transparent 35%);
}
.portada > * { position: relative; }
/* El JPG del logotipo tiene fondo negro: «lighten» lo funde con el degradado oscuro */
.portada img, .onb .grande { mix-blend-mode: lighten; height: auto; display: block; margin: 0 auto; }
.portada img { width: 200px; max-width: 70%; }
.portada h2 { color: #fff; font-size: 1.9rem; margin: 18px 0 6px; font-weight: 800; letter-spacing: -.6px; }
.portada p { color: var(--plata); max-width: 420px; margin: 0 auto 6px; }
.chips { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.chips span { font-size: .75rem; padding: 5px 11px; border-radius: 99px; background: rgba(227, 197, 116, .1);
  border: 1px solid rgba(227, 197, 116, .35); color: var(--oro-100); }

/* ---------- Onboarding ---------- */
.onb { min-height: calc(100dvh - 130px); display: flex; flex-direction: column; }
.onb .lamina {
  flex: 1; display: flex; flex-direction: column; justify-content: center; text-align: center; color: #fff;
  background: var(--grad); border-radius: 28px; padding: 32px 22px; position: relative; overflow: hidden;
  box-shadow: var(--sombra-oro);
}
.onb .lamina::before {
  content: ""; position: absolute; width: 360px; height: 360px; right: -140px; top: -140px; border-radius: 50%;
  background: radial-gradient(circle, var(--brillo-oro), transparent 70%); pointer-events: none;
}
.onb .lamina > * { position: relative; }
.onb h2 { color: #fff; font-size: 1.7rem; font-weight: 800; letter-spacing: -.5px; }
.onb p { color: var(--plata); }
.onb .grande { width: 220px; max-width: 75%; margin-bottom: 10px; }
.onb input { background: #fff; color: #17150F; border: 0; text-align: center; font-weight: 700; font-size: 1.15rem; }
.onb label { color: var(--oro-200); }
.puntos { display: flex; justify-content: center; gap: 8px; margin: 16px 0 12px; }
.puntos i { width: 8px; height: 8px; border-radius: 99px; background: var(--borde); transition: all .3s; }
.puntos i.activo { width: 26px; background: var(--oro-500); }
.icono-grande { width: 84px; height: 84px; margin: 0 auto 14px; border-radius: 26px; display: grid; place-items: center;
  background: rgba(227, 197, 116, .12); border: 1px solid rgba(227, 197, 116, .35); color: var(--oro-300); }
.icono-grande svg { width: 46px; height: 46px; }
.lista-check { list-style: none; padding: 0; margin: 10px auto 0; text-align: left; max-width: 340px; }
.lista-check li { padding: 8px 0 8px 34px; position: relative; color: #F2F0EA; }
.lista-check li::before { content: "✓"; position: absolute; left: 0; top: 7px; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; background: var(--oro-500); color: #000; font-size: .8rem; font-weight: 800; }

/* ---------- Visualización de la red (órbitas) ---------- */
.orbitas { width: 100%; max-width: 360px; display: block; margin: 0 auto; overflow: visible; }
.orbitas .anillo { fill: none; stroke: rgba(255, 255, 255, .16); stroke-width: 1; stroke-dasharray: 3 5; }
.orbitas .giro { transform-origin: 0 0; animation: girar 90s linear infinite; }
.orbitas .giro.n2 { animation-duration: 140s; animation-direction: reverse; }
.orbitas .giro.n3 { animation-duration: 220s; }
.orbitas .punto { animation: aparecer .6s both; }
.orbitas .centro-red { filter: drop-shadow(0 0 12px rgba(216, 174, 71, .8)); }
.orbitas .pulso { fill: none; stroke: var(--oro-300); stroke-width: 2; animation: pulso 2.6s ease-out infinite; transform-origin: 0 0; }
.tarjeta:not(.heroe) .orbitas .anillo { stroke: var(--borde); }
@keyframes girar { to { transform: rotate(360deg); } }
@keyframes pulso { from { transform: scale(1); opacity: .9; } to { transform: scale(3.2); opacity: 0; } }
@keyframes aparecer { from { opacity: 0; transform: scale(0); } to { opacity: 1; transform: scale(1); } }
.leyenda-red { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; font-size: .8rem; margin-top: 8px; }
.leyenda-red span { display: inline-flex; align-items: center; gap: 6px; }
.leyenda-red i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ---------- Captura de imágenes ---------- */
.captura { border: 2px dashed var(--borde); border-radius: 18px; padding: 16px; text-align: center; background: var(--hielo); }
.captura img { max-width: 100%; max-height: 220px; border-radius: 12px; display: block; margin: 0 auto 10px; }
.guia { aspect-ratio: 85.6 / 54; border: 3px solid var(--acento); border-radius: 14px; margin: 0 auto 10px; max-width: 280px;
  display: flex; align-items: center; justify-content: center; color: var(--acento); font-weight: 700; font-size: .9rem;
  background: repeating-linear-gradient(135deg, transparent 0 10px, rgba(201, 150, 42, .08) 10px 20px); }
.guia.rostro { aspect-ratio: 3 / 4; max-width: 160px; border-radius: 50%; }

.pasos { display: flex; gap: 6px; margin-bottom: 16px; }
.pasos span { flex: 1; height: 6px; border-radius: 3px; background: var(--borde); }
.pasos span.hecho { background: var(--grad-boton); }
.pasos:has(+ .paso-actual) { margin-bottom: 8px; }
.paso-actual { margin: 0 0 14px; font-size: .85rem; font-weight: 700; color: var(--acento); }
.lista-pasos { margin: 6px 0 0; padding: 0; list-style: none; counter-reset: paso; }
.lista-pasos li { padding: 8px 0; border-bottom: 1px solid var(--borde); }
.lista-pasos li:last-child { border-bottom: 0; }
.lista-pasos b { color: var(--acento); }

/* ---------- Estados y etiquetas ---------- */
.estado { border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; font-size: .95rem; }
.estado.ok { background: var(--ok-f); color: var(--ok); }
.estado.aviso { background: var(--aviso-f); color: var(--aviso); }
.estado.error { background: var(--error-f); color: var(--error); }
.etiqueta { display: inline-block; font-size: .68rem; font-weight: 800; padding: 2px 8px; border-radius: 99px; background: var(--hielo); color: var(--sobre-hielo); letter-spacing: .3px; }
.etiqueta.sim { background: var(--aviso-f); color: var(--aviso); }
.etiqueta.ok { background: var(--ok-f); color: var(--ok); }
.exito { width: 92px; height: 92px; border-radius: 50%; margin: 6px auto 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, #17a35a, #4ade80); color: #fff; font-size: 2.6rem; font-weight: 900;
  box-shadow: 0 14px 30px -12px rgba(23, 163, 90, .8); animation: aparecer .5s cubic-bezier(.3, 1.6, .5, 1) both; }

/* ---------- Métricas, barras y gráficas ---------- */
.metricas { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.metrica { background: var(--hielo); border-radius: 16px; padding: 12px 14px; }
.metrica b { display: block; font-size: 1.75rem; color: var(--titulo); line-height: 1.15; font-weight: 800; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.metrica > span { font-size: .78rem; color: var(--texto-2); }
.nivel { display: grid; grid-template-columns: 74px 1fr 60px; gap: 10px; align-items: center; margin: 10px 0; font-size: .9rem; }
.nivel .pista { background: var(--hielo); border-radius: 99px; height: 14px; overflow: hidden; }
.nivel .pista i { display: block; height: 100%; width: 0; background: var(--grad-boton); border-radius: 99px; min-width: 4px;
  transition: width 1s cubic-bezier(.2, .8, .2, 1); }
.nivel b { text-align: right; font-variant-numeric: tabular-nums; }
.heroe .nivel .pista { background: rgba(255, 255, 255, .12); }
.heroe .nivel .pista i { background: linear-gradient(90deg, var(--oro-500), var(--oro-200)); }
.grafica { width: 100%; height: auto; display: block; }
.grafica .area { fill: url(#gradArea); }
.grafica .linea { fill: none; stroke: var(--oro-500); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.grafica text { font-size: 10px; fill: var(--texto-2); }
.dona-fila { display: flex; align-items: center; gap: 18px; }
.dona { width: 130px; height: 130px; flex: none; }
.dona text { font-weight: 800; fill: var(--texto); }
.leyenda { list-style: none; margin: 0; padding: 0; font-size: .9rem; flex: 1; }
.leyenda li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.leyenda i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; flex: none; }
.leyenda b { margin-left: auto; font-variant-numeric: tabular-nums; }

/* ---------- Mapa de secciones ---------- */
.mapa-caja { position: relative; border-radius: 16px; overflow: hidden; background: radial-gradient(circle at 50% 40%, #1d1a14, #050505);
  touch-action: none; aspect-ratio: 1 / 1.08; user-select: none; -webkit-user-select: none; }
.mapa-caja svg { width: 100%; height: 100%; display: block; cursor: grab; }
.mapa-caja svg.arrastrando { cursor: grabbing; }
.mapa-caja .sec { stroke: rgba(0, 0, 0, .55); vector-effect: non-scaling-stroke; stroke-width: .4; transition: fill .4s; }
.mapa-caja .sec.sel { stroke: #5BD3FF; stroke-width: 3; } /* cian: se distingue de la rampa dorada */
.mapa-caja .mun { fill-opacity: 0; stroke: rgba(255, 255, 255, .55); stroke-width: 1.1; vector-effect: non-scaling-stroke;
  pointer-events: none; transition: fill-opacity .5s; }
.mapa-caja svg.lejos .mun { fill-opacity: .9; pointer-events: visiblePainted; }
.mapa-caja .etq-n { font-weight: 800; fill: var(--oro-200); }
.mapa-caja .mun.activo { stroke: #fff; stroke-width: 2.4; }
.mapa-caja .etq { fill: #fff; font-weight: 700; paint-order: stroke; stroke: rgba(0, 0, 0, .85); pointer-events: none; text-anchor: middle; }
.mapa-controles { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 6px; }
.mapa-controles button { width: 44px; min-height: 44px; height: 44px; padding: 0; border-radius: 12px; background: rgba(255, 255, 255, .92);
  color: var(--oro-700); font-size: 1.3rem; box-shadow: 0 4px 12px rgba(0, 0, 0, .3); }
.mapa-escala { position: absolute; left: 10px; bottom: 10px; right: 64px; background: rgba(0, 0, 0, .72); backdrop-filter: blur(6px);
  border-radius: 12px; padding: 8px 10px; color: #fff; font-size: .7rem; }
.mapa-escala .rampa { height: 8px; border-radius: 99px; margin: 4px 0 2px; background: linear-gradient(90deg, #3a2c0c, #765811, #c9962a, #e3c574, #fcf9f1); }
.mapa-escala .fila { justify-content: space-between; }
.mapa-escala .fila > * { flex: none; }
.mapa-info { margin-top: 12px; border-radius: 16px; padding: 14px; background: var(--hielo); min-height: 74px; }
.mapa-info b.grande { font-size: 1.8rem; color: var(--titulo); font-weight: 800; font-variant-numeric: tabular-nums; }
.chips-mun { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; margin-bottom: 6px; scrollbar-width: none; }
.chips-mun::-webkit-scrollbar { display: none; }
.chips-mun button { flex: none; min-height: 36px; padding: 4px 12px; border-radius: 99px; font-size: .8rem; font-weight: 600;
  background: var(--hielo); color: var(--sobre-hielo); width: auto; }
.chips-mun button.activo { background: var(--grad-boton); color: var(--sobre-boton); }
.ranking { counter-reset: r; }
.ranking li { counter-increment: r; }
.ranking li::before { content: counter(r); width: 26px; height: 26px; border-radius: 8px; flex: none; display: grid; place-items: center;
  background: var(--hielo); color: var(--sobre-hielo); font-weight: 800; font-size: .8rem; margin-right: 10px; }
.ranking li .mini { height: 6px; border-radius: 99px; background: var(--grad-boton); margin-top: 4px; width: 0; transition: width 1s; }

/* ---------- Listas y tablas ---------- */
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { padding: 12px 0; border-bottom: 1px solid var(--borde); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.lista li:last-child { border-bottom: 0; }
.lista a { color: var(--acento); }
.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 800; font-size: .85rem;
  color: var(--sobre-boton); background: var(--grad-boton); }
.persona { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.persona > div { min-width: 0; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--borde); }
th { color: var(--texto-2); font-weight: 600; font-size: .8rem; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- QR ---------- */
.qr { background: #fff; padding: 16px; border-radius: 26px; display: inline-block; position: relative;
  box-shadow: 0 0 0 6px rgba(227, 197, 116, .25), 0 20px 40px -14px rgba(0, 0, 0, .55); }
.qr img { width: 230px; height: 230px; display: block; }

/* ---------- Menú inferior flotante ---------- */
.menu {
  position: sticky; bottom: 0; z-index: 20; display: flex; gap: 4px; margin: 0 auto; width: 100%; max-width: 680px;
  padding: 8px max(10px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--tarjeta) 82%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--borde);
}
.menu a { flex: 1; min-width: 0; min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 6px 2px; font-size: .68rem;
  color: var(--texto-2); text-decoration: none; font-weight: 700; border-radius: 14px; transition: background .2s, color .2s; }
.menu a svg { width: 22px; height: 22px; }
.menu a.activo { color: var(--sobre-boton); background: var(--grad-boton); box-shadow: var(--sombra-oro); }

/* ---------- Movimiento ---------- */
.entra { animation: entra .5s cubic-bezier(.2, .8, .2, 1) both; }
.entra:nth-child(2) { animation-delay: .06s; } .entra:nth-child(3) { animation-delay: .12s; }
.entra:nth-child(4) { animation-delay: .18s; } .entra:nth-child(5) { animation-delay: .24s; }
.entra:nth-child(n+6) { animation-delay: .3s; }
@keyframes entra { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.girando { width: 46px; height: 46px; border: 4px solid var(--hielo); border-top-color: var(--oro-500); border-radius: 50%;
  margin: 18px auto; animation: g 1s linear infinite; }
.escaneo { width: 120px; height: 76px; margin: 10px auto 16px; border-radius: 12px; border: 3px solid var(--acento); position: relative; overflow: hidden; }
.escaneo::after { content: ""; position: absolute; left: 0; right: 0; height: 3px; background: var(--oro-400); box-shadow: 0 0 14px var(--oro-400);
  animation: barrido 1.6s ease-in-out infinite alternate; }
@keyframes barrido { from { top: 4px; } to { top: calc(100% - 7px); } }
@keyframes g { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
.oculto { display: none !important; }
.mt { margin-top: 14px; }
.fila input[type=search] { flex: 3; }

/* Prueba de vida: cámara frontal a pantalla completa */
.camara { position: fixed; inset: 0; z-index: 50; background: var(--grad); color: #fff; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); }
.camara-marco { position: relative; width: min(82vw, 360px); aspect-ratio: 3 / 4; border-radius: 28px; overflow: hidden;
  background: #000; box-shadow: 0 20px 60px rgba(0, 0, 0, .45); }
.camara video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.camara .ovalo { position: absolute; inset: 12% 16% 16%; border-radius: 50%; border: 4px solid rgba(255, 255, 255, .9);
  box-shadow: 0 0 0 999px rgba(0, 0, 0, .5); transition: border-color .3s; }
.camara .ovalo.activo { border-color: var(--oro-300); animation: latido 1s ease-in-out infinite alternate; }
.camara .flecha { position: absolute; top: 50%; font-size: 64px; font-weight: 800; color: var(--oro-300);
  text-shadow: 0 4px 18px rgba(0, 0, 0, .5); transform: translateY(-50%); }
.camara .flecha.izquierda { left: 4%; animation: empuja-izq .8s ease-in-out infinite alternate; }
.camara .flecha.derecha { right: 4%; animation: empuja-der .8s ease-in-out infinite alternate; }
.camara-texto { font-size: 1.15rem; font-weight: 700; text-align: center; max-width: 360px; min-height: 2.8em; margin: 0; }
.camara-avance { width: min(82vw, 360px); height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .2); overflow: hidden; }
.camara-avance i { display: block; height: 100%; width: 0; background: var(--oro-400); border-radius: 99px; transition: width .3s; }
.camara > button { width: min(82vw, 360px); background: rgba(255, 255, 255, .1); color: #fff; border: 1px solid rgba(255, 255, 255, .35); }
.camara.revisando video { filter: blur(6px) brightness(.7); }
@keyframes latido { from { transform: scale(1); } to { transform: scale(1.03); } }
@keyframes empuja-izq { from { transform: translate(0, -50%); } to { transform: translate(-10px, -50%); } }
@keyframes empuja-der { from { transform: translate(0, -50%); } to { transform: translate(10px, -50%); } }
@media (prefers-reduced-motion: reduce) { .camara .ovalo.activo, .camara .flecha { animation: none; } }

/* Captura automática de la INE (HU-038): cámara trasera sin espejo y marco de credencial */
.camara video.trasera { transform: none; }
.camara .marco-ine { position: absolute; left: 6%; right: 6%; top: 50%; transform: translateY(-50%); aspect-ratio: 85.6 / 54;
  border: 4px solid rgba(255, 255, 255, .9); border-radius: 14px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .5);
  transition: border-color .2s; }
.camara .marco-ine.ok { border-color: #7cf29a; }
.camara .marco-ine.tomada { border-color: #fff; background: rgba(255, 255, 255, .35); }
.camara > button.primario { background: var(--grad-oro); color: #000; border-color: var(--oro-400); }
.captura .alterna { display: block; margin: 8px auto 0; font-size: .9rem; cursor: pointer; }

/* Pantalla «antes de empezar» */
.preparar { list-style: none; margin: 12px 0 18px; padding: 0; }
.preparar li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--borde); }
.preparar li:last-child { border-bottom: 0; }
.preparar li > span { font-size: 1.6rem; line-height: 1.2; }

/* Selector de dos o tres opciones (mapa: presencia o meta; embudo: periodo) */
.segmentos { display: inline-flex; gap: 2px; padding: 3px; border-radius: 99px; background: var(--hielo); margin: 2px 0 10px; }
.segmentos button { min-height: 36px; padding: 4px 14px; border-radius: 99px; font-size: .82rem; font-weight: 700;
  background: transparent; color: var(--texto-2); border: 0; }
.segmentos button.activo { background: var(--grad-boton); color: var(--sobre-boton); }

/* Mapa: avance contra meta */
.mapa-escala.meta ul { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.mapa-escala.meta li { display: flex; align-items: center; gap: 4px; }
.mapa-escala.meta i { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(255, 255, 255, .35); }
#mapa .sec.atenuada { opacity: .22; }
.ranking .mini.meta { background: #3fb88f; }

/* Embudo de registro por paso */
.embudo { list-style: none; margin: 8px 0 10px; padding: 0; }
.embudo .paso { display: grid; grid-template-columns: minmax(120px, 38%) 1fr 54px 44px; gap: 10px; align-items: center;
  padding: 6px 0; font-size: .88rem; }
.embudo .paso .pista { background: var(--hielo); border-radius: 4px; height: 18px; overflow: hidden; }
.embudo .paso .pista i { display: block; height: 100%; width: 0; background: var(--grad-boton); border-radius: 0 4px 4px 0;
  transition: width .6s ease; }
.embudo .paso b { text-align: right; font-variant-numeric: tabular-nums; }
.embudo .paso small { text-align: right; color: var(--texto-2); font-variant-numeric: tabular-nums; }
.embudo .caida { font-size: .78rem; color: var(--texto-2); padding: 0 0 0 calc(38% + 10px); }
.embudo .caida.peor { color: var(--aviso); }
.embudo .caida.peor::before { content: "▼ "; }
@media (max-width: 480px) {
  .embudo .paso { grid-template-columns: 1fr 50px 40px; }
  .embudo .paso .pista { grid-column: 1 / -1; grid-row: 2; }
  .embudo .caida { padding-left: 0; }
}

/* ---------- Tablero de estructura ---------- */
.filtros-est .segmentos { margin-right: 8px; }
.filtros { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 4px; }
.filtros label { display: flex; flex-direction: column; gap: 4px; font-size: .78rem; font-weight: 700; color: var(--texto-2); }
.filtros select { min-height: 38px; border-radius: 10px; border: 1px solid var(--borde); background: var(--tarjeta); color: var(--texto);
  padding: 4px 8px; font: inherit; font-size: .88rem; }
.metrica b small { font-size: .9rem; font-weight: 700; margin-left: 2px; }

/* Barras de avance con la meta marcada */
.av-fila { display: grid; grid-template-columns: minmax(110px, 36%) 1fr 64px; gap: 10px; align-items: center; padding: 5px 0; font-size: .86rem; }
.av-fila > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.av-fila > b { text-align: right; font-variant-numeric: tabular-nums; }
.av-pista { position: relative; height: 16px; border-radius: 4px; background: var(--hielo); }
.av-pista i { display: block; height: 100%; width: 0; border-radius: 0 4px 4px 0; background: var(--grad-boton); transition: width .6s ease; }
.av-pista i.ok { background: #3fb88f; }
.av-pista em { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--texto); opacity: .7; z-index: 1; }

/* Semana por semana */
.sem-graf { position: relative; display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; align-items: end; height: 176px;
  margin-top: 8px; }
.sem-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; font-size: .72rem; }
.sem-col b { font-size: .74rem; font-variant-numeric: tabular-nums; }
.sem-col i { display: block; width: 100%; max-width: 44px; height: 0; border-radius: 4px 4px 0 0; background: var(--grad-boton); transition: height .6s ease; }
.sem-col small { color: var(--texto-2); height: 16px; line-height: 16px; }
.sem-req { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--aviso); pointer-events: none; z-index: 1; }
.sem-req span { position: absolute; right: 0; top: -20px; font-size: .72rem; font-weight: 700; color: var(--aviso); background: var(--tarjeta); padding: 0 4px; }

/* Rankings */
.ranking-est { counter-reset: rk; }
.ranking-est li { counter-increment: rk; gap: 12px; }
.ranking-est li > div { display: flex; flex-direction: column; flex: 1; }
.ranking-est li::before { content: counter(rk); flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: .8rem; background: var(--hielo); color: var(--texto-2); }
.ranking-est li > b { text-align: right; font-size: .86rem; }

/* Tabla dinámica */
.tabla-scroll { overflow-x: auto; margin: 6px -4px 8px; }
.pivote { width: 100%; border-collapse: collapse; font-size: .84rem; min-width: 640px; }
.pivote th, .pivote td { padding: 7px 8px; border-bottom: 1px solid var(--borde); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pivote th[scope="row"] { text-align: left; font-weight: 600; white-space: normal; min-width: 190px; }
.pivote .celda-nombre { display: flex; align-items: flex-start; gap: 4px; }
.pivote th[scope="row"] small { display: block; font-weight: 400; color: var(--texto-2); font-size: .76rem; }
.pivote thead th { position: sticky; top: 0; background: var(--tarjeta); }
.pivote thead th:first-child { text-align: left; }
.pivote thead button { background: none; border: 0; min-height: 0; padding: 0; font: inherit; font-weight: 700; color: var(--texto-2); cursor: pointer; }
.pivote thead button.activo { color: var(--texto); }
.pivote .nivel-grupo { background: var(--hielo); }
.pivote .s1 th[scope="row"] { padding-left: 24px; }
.pivote .nivel-sec th[scope="row"] { padding-left: 34px; font-weight: 400; }
.pivote .nivel-sec.s2 th[scope="row"] { padding-left: 52px; }
.pliega { background: none; border: 0; min-height: 0; width: 22px; padding: 0; font-size: .9rem; color: var(--texto-2); cursor: pointer; }
.meta-ok { color: var(--ok); font-weight: 700; }

/* Grafo de la estructura (nodos por cumplimiento) */
.leyenda-estado { list-style: none; margin: 4px 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .8rem; }
.leyenda-estado li { display: flex; align-items: center; gap: 6px; }
.leyenda-estado i, .tip-estado i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 2px var(--tarjeta); }
.grafo-caja { position: relative; overflow: auto; margin: 0 -4px; border-radius: 12px; background: var(--hielo); }
.grafo { display: block; font-family: inherit; }
.grafo .arista { fill: none; stroke: var(--texto-2); stroke-opacity: .35; stroke-width: 1.5; transition: stroke-opacity .2s, stroke-width .2s; }
.grafo .arista.activa { stroke: var(--texto); stroke-opacity: .9; stroke-width: 2.5; }
.grafo .nodo { cursor: pointer; outline: none; transition: opacity .2s; }
.grafo .nodo.atenuado { opacity: .3; }
.grafo .toque { fill: transparent; }
.grafo .punto { stroke: var(--tarjeta); stroke-width: 2.5; }
.grafo .nodo:hover .punto, .grafo .nodo:focus-visible .punto { stroke: var(--texto); }
.grafo .glifo { fill: #ffffff; font-size: 11px; font-weight: 800; text-anchor: middle; pointer-events: none; }
.grafo .etq-nodo { fill: var(--texto); font-size: 12.5px; font-weight: 600; paint-order: stroke; stroke: var(--hielo); stroke-width: 4px; stroke-linejoin: round; }
.grafo .etq-nodo.fuerte { font-size: 14px; font-weight: 800; }
.grafo .etq-sub { fill: var(--texto-2); font-size: 11px; paint-order: stroke; stroke: var(--hielo); stroke-width: 4px; }
.grafo .centro { text-anchor: middle; }
.grafo .fin { text-anchor: end; }
.grafo-tip { position: absolute; z-index: 2; min-width: 210px; max-width: 260px; padding: 10px 12px; border-radius: 12px; pointer-events: none;
  background: var(--tarjeta); color: var(--texto); border: 1px solid var(--borde); box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  display: flex; flex-direction: column; gap: 3px; font-size: .8rem; }
.grafo-tip > span { color: var(--texto-2); }
.tip-estado { display: flex; align-items: center; gap: 6px; margin: 4px 0 2px; font-size: .85rem; }

/* Mi red: árbol de cargos (coordinaciones → responsables) */
.arbol-est details { width: 100%; }
.arbol-est summary { display: flex; justify-content: space-between; align-items: center; gap: 8px; cursor: pointer; list-style: none; }
.arbol-est summary::-webkit-details-marker { display: none; }
.arbol-est summary::before { content: "▸"; color: var(--texto-2); width: 12px; flex: none; }
.arbol-est details[open] > summary::before { content: "▾"; }
.arbol-est summary .persona { flex: 1; }
.arbol-est details > .lista { margin: 6px 0 0 22px; border-left: 2px solid var(--borde); padding-left: 10px; }
.arbol-est > li { display: block; }
.arbol-est > li:not(:has(details)) { display: flex; }

/* Invitación a instalar la app */
.instalar h2 { margin-bottom: 4px; }
.pasos-instalar { margin: 4px 0 6px; padding-left: 22px; }
.pasos-instalar li { padding: 4px 0; }
.icono-paso { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: var(--hielo);
  color: var(--acento); vertical-align: middle; font-weight: 800; }
.flecha-compartir { text-align: center; font-size: 2rem; color: var(--acento); animation: empuja-abajo .9s ease-in-out infinite alternate; }
@keyframes empuja-abajo { from { transform: translateY(0); } to { transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .flecha-compartir { animation: none; } }
