// BANCA · Video demostrativo 90s · Fraude transaccional con señales distribuidas
// [ESCENARIO DEMOSTRATIVO] · [DATOS SINTÉTICOS]

const BancaDemo = () => {
  const [scene, setScene] = React.useState(0);
  const [playing, setPlaying] = React.useState(true);
  const scenes = [
    { d: 9,  label: 'Una transacción parece legítima',                    cap: 'Una operación inicia desde un nuevo dispositivo y atraviesa los controles habituales. Reglas base no señalan alerta crítica.' },
    { d: 11, label: 'Varias señales cambian al mismo tiempo',              cap: 'Nuevo beneficiario · cambios recientes de credenciales · monto atípico · velocidad inusual · el evento se enriquece.' },
    { d: 13, label: 'Una alerta no cuenta toda la historia',                cap: 'El SDM de Fraude conecta transacción, identidad, dispositivo, comportamiento histórico y contexto del CRM. La señal se vuelve interpretable.' },
    { d: 13, label: 'OMNIX explica el riesgo',                              cap: 'La plataforma muestra qué señales aumentan el riesgo, cuáles lo reducen y qué información todavía falta para una decisión definitiva.' },
    { d: 14, label: 'Cinco alternativas evaluadas por política',            cap: 'Aprobar · verificación reforzada · retener temporalmente · escalar a analista · abrir investigación. Cada una con impacto proyectado.' },
    { d: 13, label: 'Autenticación reforzada · aprobación humana',           cap: 'Se aplica MFA dentro del umbral autorizado. Cuando el riesgo supera el umbral, se escala al analista con evidencia consolidada.' },
    { d: 12, label: 'La decisión se ejecuta y comunica',                     cap: 'Se actualizan core, procesador, case management y CRM con una misma versión del contexto. El cliente recibe notificación por canal autorizado.' },
    { d: 5,  label: 'Cada señal, aprobación y acción queda registrada',     cap: 'Log firmado con señales usadas, modelo, versión, recomendación, aprobación, acción y resultado. Auditoría regulator-ready.' },
  ];
  const totalMs = scenes.reduce((s, x) => s + x.d * 1000, 0);
  const [elapsed, setElapsed] = React.useState(0);
  React.useEffect(() => {
    if (!playing) return;
    const step = 100;
    const id = setInterval(() => {
      setElapsed((e) => {
        const next = e + step;
        let acc = 0, s = 0;
        for (let i = 0; i < scenes.length; i++) {
          acc += scenes[i].d * 1000;
          if (next < acc) { s = i; break; }
          s = i;
        }
        if (next >= totalMs) { setScene(0); return 0; }
        setScene(s);
        return next;
      });
    }, step);
    return () => clearInterval(id);
  }, [playing, totalMs]);
  const progress = Math.min(100, (elapsed / totalMs) * 100);
  const fmt = (ms) => { const s = Math.floor(ms / 1000); return `${Math.floor(s/60)}:${String(s%60).padStart(2, '0')}`; };

  return (
    <section id="demo" style={{ background: '#FFFFFF', paddingTop: 128, paddingBottom: 128 }}>
      <Container>
        <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 64, marginBottom: 56, alignItems: 'end' }}>
          <div>
            <Reveal><SectionMeta n="02" label="Demo · 90 segundos"/></Reveal>
            <Reveal delay={80}>
              <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 52, lineHeight: 1.03, letterSpacing: '-0.025em', margin: 0, color: '#000' }}>
                Fraude transaccional con señales distribuidas entre canales.
              </h2>
            </Reveal>
          </div>
          <Reveal delay={140}>
            <p style={{ fontFamily: 'var(--font-body)', fontSize: 18, lineHeight: 1.55, color: '#52557A', margin: 0 }}>
              Escenario demostrativo con datos sintéticos. OMNIX correlaciona señales fragmentadas entre canales, evalúa alternativas y coordina una respuesta proporcional dentro de política.
            </p>
          </Reveal>
        </div>

        <div style={{ display: 'grid', gridTemplateColumns: '1.55fr 1fr', gap: 24 }}>
          <Reveal y={0}>
            <div style={{ border: '1.5px solid #1E1F26', background: '#000', color: '#FFF', overflow: 'hidden' }}>
              <div style={{
                display: 'flex', justifyContent: 'space-between', alignItems: 'center',
                padding: '12px 20px', borderBottom: '1.5px solid #2E3140',
                fontFamily: 'var(--font-mono)', fontSize: 10, letterSpacing: '0.18em', textTransform: 'uppercase', color: '#96A3B5',
              }}>
                <span>OMNIX · BANKING DEMO · SCENE 0{scene+1}/08</span>
                <span style={{ color: '#F4024C', display: 'inline-flex', alignItems: 'center', gap: 6 }}>
                  <span style={{ width: 6, height: 6, borderRadius: 999, background: '#F4024C' }} className={playing ? 'omnix-blink' : ''}/>
                  {playing ? 'PLAYING' : 'PAUSED'}
                </span>
              </div>
              <div style={{ position: 'relative', aspectRatio: '16 / 10', background: '#0A0B10' }}>
                <BancaSceneStage scene={scene}/>
                <div style={{
                  position: 'absolute', top: 20, left: 20, padding: '8px 14px',
                  background: 'rgba(0,0,0,0.6)', backdropFilter: 'blur(8px)',
                  fontFamily: 'var(--font-mono)', fontSize: 10, letterSpacing: '0.18em', color: '#B8860B', textTransform: 'uppercase',
                }}>SIMULATED · [DATOS SINTÉTICOS]</div>
                <div style={{
                  position: 'absolute', bottom: 0, left: 0, right: 0,
                  padding: '20px 32px 24px',
                  background: 'linear-gradient(180deg, transparent, rgba(0,0,0,0.85) 40%)',
                }}>
                  <div style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 22, letterSpacing: '-0.015em', color: '#FFF', marginBottom: 8, lineHeight: 1.15 }}>{scenes[scene].label}</div>
                  <div style={{ fontFamily: 'var(--font-body)', fontSize: 13, color: '#96A3B5', lineHeight: 1.4, maxWidth: 640 }}>{scenes[scene].cap}</div>
                </div>
              </div>
              <div style={{ borderTop: '1.5px solid #2E3140', padding: '14px 20px', display: 'flex', alignItems: 'center', gap: 16 }}>
                <button onClick={() => setPlaying(!playing)} style={bkCtrl}>
                  <i data-lucide={playing ? 'pause' : 'play'} width="14" height="14"></i>
                </button>
                <button onClick={() => { setElapsed(0); setScene(0); }} style={bkCtrl}>
                  <i data-lucide="rotate-ccw" width="14" height="14"></i>
                </button>
                <div style={{ flex: 1, height: 4, background: '#2E3140', position: 'relative' }}>
                  <div style={{ position: 'absolute', inset: 0, right: 'auto', width: `${progress}%`, background: '#F4024C', transition: 'width 100ms linear' }}/>
                </div>
                <span style={{ fontFamily: 'var(--font-mono)', fontSize: 11, color: '#96A3B5', minWidth: 68, textAlign: 'right' }}>
                  {fmt(elapsed)} / {fmt(totalMs)}
                </span>
                <button style={bkCtrl}><i data-lucide="volume-x" width="14" height="14"></i></button>
                <button style={bkCtrl}><i data-lucide="captions" width="14" height="14"></i></button>
              </div>
              <div style={{ borderTop: '1.5px solid #2E3140', display: 'grid', gridTemplateColumns: `repeat(${scenes.length}, 1fr)` }}>
                {scenes.map((s, i) => (
                  <button key={i} onClick={() => {
                    const before = scenes.slice(0, i).reduce((a, x) => a + x.d * 1000, 0);
                    setElapsed(before); setScene(i);
                  }} style={{
                    padding: '10px 8px', border: 'none',
                    background: scene === i ? '#F4024C' : '#0A0B10',
                    color: scene === i ? '#FFF' : '#52557A',
                    borderRight: (i < scenes.length - 1) ? '1px solid #2E3140' : 'none',
                    fontFamily: 'var(--font-mono)', fontSize: 9, letterSpacing: '0.14em', textTransform: 'uppercase',
                    cursor: 'pointer',
                  }}>{i+1}</button>
                ))}
              </div>
            </div>
          </Reveal>

          {/* Panel explicación */}
          <Reveal delay={100} y={0}>
            <div style={{ border: '1.5px solid #1E1F26', background: '#FAFBFD', padding: 32, height: '100%', display: 'flex', flexDirection: 'column' }}>
              <div style={{ fontFamily: 'var(--font-mono)', fontSize: 11, letterSpacing: '0.18em', color: '#F4024C', textTransform: 'uppercase', marginBottom: 12 }}>
                Qué está haciendo OMNIX
              </div>
              <p style={{ fontFamily: 'var(--font-body)', fontSize: 14, lineHeight: 1.55, color: '#1E1F26', margin: '0 0 20px' }}>
                Convierte una alerta fragmentada en una decisión bancaria proporcional al riesgo, con evidencia trazable · aprobación humana en umbrales · rollback armado.
              </p>
              <div style={{ display: 'flex', flexDirection: 'column', gap: 8, flex: 1 }}>
                {[
                  { t: 'Detección multi-señal',       d: 'Correlaciona velocidad, dispositivo, beneficiario, comportamiento.',  sys: 'INGEST · SDM', auto: 'N1' },
                  { t: 'Contexto operacional',         d: 'Historial cliente · CRM · device intelligence · reglas política.',     sys: 'CRM · KYC',    auto: 'N2' },
                  { t: 'Explicabilidad de riesgo',    d: 'Muestra las 3-5 señales que más pesan · con confianza asociada.',      sys: 'CORTEX',        auto: 'N3' },
                  { t: 'Alternativas por política',    d: 'Aprobar · MFA · retener · escalar · investigar · según umbral.',        sys: 'SDM · policy', auto: 'N3' },
                  { t: 'Ejecución coordinada',         d: 'Core · pagos · case mgmt · CRM · comunicación cliente en atomic tx.',   sys: 'RUNTIME',        auto: 'N3-N4' },
                  { t: 'Log firmado · aprendizaje',      d: 'Signed WORM · reversible · reproducible · learning al SDM.',           sys: 'GOV · BI',     auto: '—' },
                ].map((c, i) => (
                  <div key={c.t} style={{
                    padding: '12px 14px', background: '#FFF',
                    border: '1px solid',
                    borderColor: scene >= i ? '#F4024C' : '#E4EBF3',
                    transition: 'border-color 320ms',
                    display: 'grid', gridTemplateColumns: '22px 1fr 60px', gap: 10, alignItems: 'start',
                  }}>
                    <span style={{ fontFamily: 'var(--font-mono)', fontSize: 10, color: scene >= i ? '#F4024C' : '#96A3B5' }}>0{i+1}</span>
                    <div>
                      <div style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 13, letterSpacing: '-0.005em', color: '#000', marginBottom: 3 }}>{c.t}</div>
                      <div style={{ fontFamily: 'var(--font-body)', fontSize: 12, color: '#52557A', lineHeight: 1.4 }}>{c.d}</div>
                      <div style={{ marginTop: 3, fontFamily: 'var(--font-mono)', fontSize: 9, letterSpacing: '0.14em', color: '#0050BD' }}>SYS · {c.sys}</div>
                    </div>
                    <div style={{ fontFamily: 'var(--font-mono)', fontSize: 9, letterSpacing: '0.14em', color: '#1E1F26', textAlign: 'right', paddingTop: 4 }}>{c.auto}</div>
                  </div>
                ))}
              </div>
              <div style={{ marginTop: 14, padding: '10px 12px', background: '#FBF3D9', border: '1px solid #B8860B', fontFamily: 'var(--font-mono)', fontSize: 10, letterSpacing: '0.06em', color: '#1E1F26', lineHeight: 1.55 }}>
                Escenario demostrativo. Señales, umbrales, políticas y acciones se configuran según la arquitectura y regulación de cada institución.
              </div>
            </div>
          </Reveal>
        </div>

        {/* Transcripción accesible */}
        <Reveal delay={200}>
          <details style={{ marginTop: 32, padding: '20px 24px', border: '1px solid #E4EBF3', background: '#FAFBFD' }}>
            <summary style={{ fontFamily: 'var(--font-mono)', fontSize: 11, letterSpacing: '0.18em', color: '#F4024C', textTransform: 'uppercase', cursor: 'pointer' }}>
              Transcripción del video
            </summary>
            <div style={{ marginTop: 16, fontFamily: 'var(--font-body)', fontSize: 14, lineHeight: 1.7, color: '#1E1F26' }}>
              {scenes.map((s, i) => (
                <p key={i} style={{ margin: '0 0 10px' }}>
                  <strong>Escena {i+1} · {fmt(scenes.slice(0, i).reduce((a, x) => a + x.d * 1000, 0))} — {s.label}.</strong> {s.cap}
                </p>
              ))}
              <p style={{ margin: '16px 0 0', fontStyle: 'italic', color: '#52557A' }}>
                [ESCENARIO DEMOSTRATIVO] · [DATOS SINTÉTICOS]. Sin uso de datos reales de clientes. Umbrales, políticas y niveles de autonomía se configuran según la arquitectura, regulación y gobierno de cada institución financiera.
              </p>
            </div>
          </details>
        </Reveal>
      </Container>
    </section>
  );
};

const bkCtrl = {
  width: 32, height: 32, border: '1px solid #2E3140', background: '#0A0B10',
  color: '#FFF', cursor: 'pointer', display: 'flex', alignItems: 'center', justifyContent: 'center',
};

const BancaSceneStage = ({ scene }) => (
  <div style={{ position: 'absolute', inset: 0 }}>
    {scene === 0 && <BkScene0/>}
    {scene === 1 && <BkScene1/>}
    {scene === 2 && <BkScene2/>}
    {scene === 3 && <BkScene3/>}
    {scene === 4 && <BkScene4/>}
    {scene === 5 && <BkScene5/>}
    {scene === 6 && <BkScene6/>}
    {scene === 7 && <BkScene7/>}
  </div>
);

const BkGrid = () => (
  <g stroke="#2E3140" strokeWidth="0.5" opacity="0.4">
    {Array.from({length: 17}).map((_, i) => <line key={`v${i}`} x1={i*50} y1="0" x2={i*50} y2="500"/>)}
    {Array.from({length: 11}).map((_, i) => <line key={`h${i}`} x1="0" y1={i*50} x2="800" y2={i*50}/>)}
  </g>
);

const BkScene0 = () => (
  <svg viewBox="0 0 800 500" style={{ width: '100%', height: '100%' }}>
    <BkGrid/>
    <text x="80" y="60" fontFamily="var(--font-mono)" fontSize="11" letterSpacing="0.18em" fill="#96A3B5">TRANSACCIÓN INICIADA · CANAL MÓVIL</text>
    <g transform="translate(400, 220)">
      <rect x="-140" y="-56" width="280" height="112" fill="#0A0B10" stroke="#0F5132" strokeWidth="1.5"/>
      <text x="-124" y="-28" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#96A3B5">TX #4c8f2a</text>
      <text x="-124" y="0" fontFamily="var(--font-display)" fontWeight="800" fontSize="32" fill="#FFF" letterSpacing="-0.02em">USD 8,420</text>
      <text x="-124" y="24" fontFamily="var(--font-mono)" fontSize="11" fill="#0F5132">✓ balance ok</text>
      <text x="-124" y="42" fontFamily="var(--font-mono)" fontSize="11" fill="#0F5132">✓ límite diario</text>
    </g>
    <text x="80" y="440" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#0F5132">CONTROLES BASE · SIN ALERTA CRÍTICA</text>
  </svg>
);

const BkScene1 = () => (
  <svg viewBox="0 0 800 500" style={{ width: '100%', height: '100%' }}>
    <BkGrid/>
    <text x="80" y="60" fontFamily="var(--font-mono)" fontSize="11" letterSpacing="0.18em" fill="#B8860B">SEÑALES CAMBIAN SIMULTÁNEAMENTE</text>
    {[
      { i: 'smartphone',   k: 'Nuevo dispositivo', v: 'Primer uso',  c: '#B8860B', x: 80,  y: 110 },
      { i: 'key',           k: 'Credenciales',      v: 'Cambio 2h',   c: '#EA384C', x: 280, y: 110 },
      { i: 'user-plus',     k: 'Beneficiario',      v: 'Nuevo · 3d',  c: '#B8860B', x: 480, y: 110 },
      { i: 'zap',            k: 'Velocidad',        v: '+240% vs base', c: '#EA384C', x: 80,  y: 260 },
      { i: 'dollar-sign',   k: 'Monto',             v: '3.4× media',  c: '#B8860B', x: 280, y: 260 },
      { i: 'map-pin',       k: 'Geo',               v: 'País no habitual', c: '#EA384C', x: 480, y: 260 },
    ].map((f) => (
      <g key={f.k} transform={`translate(${f.x}, ${f.y})`}>
        <rect x="0" y="0" width="180" height="110" fill="#0A0B10" stroke={f.c} strokeWidth="1.5"/>
        <text x="14" y="24" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill={f.c}>{f.k}</text>
        <text x="14" y="58" fontFamily="var(--font-display)" fontWeight="800" fontSize="18" fill="#FFF">{f.v}</text>
        <text x="14" y="88" fontFamily="var(--font-mono)" fontSize="9" fill="#96A3B5">registrado</text>
      </g>
    ))}
    <text x="80" y="440" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#EA384C">6 FACTORES CONVERGEN · IMPACTO DE RIESGO EN EVALUACIÓN</text>
  </svg>
);

const BkScene2 = () => (
  <svg viewBox="0 0 800 500" style={{ width: '100%', height: '100%' }}>
    <BkGrid/>
    <text x="80" y="60" fontFamily="var(--font-mono)" fontSize="11" letterSpacing="0.18em" fill="#96A3B5">SDM FRAUDE · MULTI-SIGNAL CORRELATION</text>
    {['Transacción', 'Identidad', 'Dispositivo', 'Comportamiento', 'CRM · contexto', 'Historial'].map((s, i) => (
      <g key={s} transform={`translate(60, ${100 + i * 46})`}>
        <rect x="0" y="-14" width="220" height="28" fill="#0A0B10" stroke="#0050BD" strokeWidth="1"/>
        <text x="12" y="4" fontFamily="var(--font-mono)" fontSize="11" fill="#FFF">{s}</text>
        <FlowPath d={`M 220 0 L 380 0 L 440 130`} stroke="#96A3B5" strokeWidth={0.5} particleColor="#F4024C" particleSize={2} duration={2.2 + i * 0.15}/>
      </g>
    ))}
    <g transform="translate(560, 250)">
      <circle r="70" fill="none" stroke="#F4024C" strokeWidth="1" opacity="0.3">
        <animate attributeName="r" values="60;76;60" dur="2.4s" repeatCount="indefinite"/>
      </circle>
      <rect x="-64" y="-44" width="128" height="88" fill="#000" stroke="#F4024C" strokeWidth="2"/>
      <text y="-12" textAnchor="middle" fontFamily="var(--font-display)" fontWeight="800" fontSize="14" fill="#FFF">SDM</text>
      <text y="8" textAnchor="middle" fontFamily="var(--font-display)" fontWeight="700" fontSize="12" fill="#F4024C">FRAUDE</text>
      <text y="30" textAnchor="middle" fontFamily="var(--font-mono)" fontSize="9" letterSpacing="0.14em" fill="#96A3B5">v0.4-demo</text>
    </g>
  </svg>
);

const BkScene3 = () => (
  <svg viewBox="0 0 800 500" style={{ width: '100%', height: '100%' }}>
    <BkGrid/>
    <text x="80" y="60" fontFamily="var(--font-mono)" fontSize="11" letterSpacing="0.18em" fill="#96A3B5">EXPLAINABILITY · TOP DRIVERS</text>
    <text x="80" y="90" fontFamily="var(--font-display)" fontWeight="700" fontSize="22" fill="#FFF">Risk score · 0.78 · confidence 0.88</text>
    {[
      { k: 'Beneficiario nuevo + monto atípico',       w: 32, c: '#EA384C' },
      { k: 'Cambio de credenciales < 3h',              w: 24, c: '#EA384C' },
      { k: 'Velocidad transaccional +240%',             w: 18, c: '#B8860B' },
      { k: 'Dispositivo sin historial',                  w: 12, c: '#B8860B' },
      { k: 'Cliente enterprise · contract SLA',        w: -8, c: '#0F5132' },
    ].map((r, i) => (
      <g key={r.k} transform={`translate(80, ${130 + i * 56})`}>
        <text x="0" y="0" fontFamily="var(--font-body)" fontSize="14" fill="#FFF">{r.k}</text>
        <rect x="0" y="12" width="480" height="8" fill="#2E3140"/>
        <rect x={r.w < 0 ? 240 + r.w * 5 : 240} y="12" width={Math.abs(r.w) * 5} height="8" fill={r.c}>
          <animate attributeName="width" from="0" to={Math.abs(r.w) * 5} dur="0.9s" begin={`${i * 0.15}s`} fill="freeze"/>
        </rect>
        <text x="500" y="20" fontFamily="var(--font-mono)" fontSize="12" fill={r.c}>{r.w > 0 ? '+' : ''}{r.w}</text>
      </g>
    ))}
    <text x="80" y="460" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#B8860B">[VALIDAR MÉTRICA] · escenario demostrativo con datos sintéticos</text>
  </svg>
);

const BkScene4 = () => {
  const options = [
    { k: 'APPROVE',    t: 'Aprobar sin fricción',                fric: 0,  risk: 78, cust: 100, sel: false },
    { k: 'MFA',         t: 'Autenticación reforzada · SMS+bio',  fric: 12, risk: 22, cust: 84,  sel: true },
    { k: 'HOLD',        t: 'Retener temporalmente · 30min',       fric: 34, risk: 12, cust: 62,  sel: false },
    { k: 'ESCALATE',    t: 'Escalar al analista con contexto',    fric: 45, risk: 8,  cust: 55,  sel: false },
    { k: 'INVESTIGATE', t: 'Abrir caso · retener + KYC review',  fric: 78, risk: 4,  cust: 32,  sel: false },
  ];
  return (
    <svg viewBox="0 0 800 500" style={{ width: '100%', height: '100%' }}>
      <BkGrid/>
      <text x="80" y="60" fontFamily="var(--font-mono)" fontSize="11" letterSpacing="0.18em" fill="#96A3B5">DEEP THINK · POLICY-DRIVEN ALTERNATIVES</text>
      <g transform="translate(80, 100)">
        <text x="0" y="0" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#96A3B5">ACCIÓN</text>
        <text x="370" y="0" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#B8860B">FRICCIÓN</text>
        <text x="490" y="0" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#EA384C">RIESGO RESIDUAL</text>
        <text x="620" y="0" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#0F5132">CX SCORE</text>
      </g>
      {options.map((o, i) => (
        <g key={o.k} transform={`translate(80, ${140 + i * 62})`}>
          {o.sel && <rect x="-8" y="-16" width="656" height="52" fill="#F4024C" opacity="0.08"/>}
          {o.sel && <rect x="-8" y="-16" width="4" height="52" fill="#F4024C"/>}
          <text x="0" y="0" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill={o.sel ? '#F4024C' : '#96A3B5'}>0{i+1} · {o.k}</text>
          <text x="0" y="20" fontFamily="var(--font-display)" fontWeight="700" fontSize="14" fill="#FFF">{o.t}</text>
          {[
            { x: 360, v: o.fric, c: '#B8860B' },
            { x: 480, v: o.risk, c: '#EA384C' },
            { x: 610, v: o.cust, c: '#0F5132' },
          ].map((b, j) => (
            <g key={j}>
              <rect x={b.x} y="8" width="80" height="6" fill="#2E3140"/>
              <rect x={b.x} y="8" width={b.v * 0.8} height="6" fill={b.c}>
                <animate attributeName="width" from="0" to={b.v * 0.8} dur="0.9s" begin={`${i * 0.12}s`} fill="freeze"/>
              </rect>
              <text x={b.x} y="30" fontFamily="var(--font-mono)" fontSize="10" fill={b.c}>{b.v}</text>
            </g>
          ))}
          {o.sel && <text x="660" y="0" textAnchor="end" fontFamily="var(--font-mono)" fontSize="10" fill="#F4024C">SELECTED</text>}
        </g>
      ))}
      <text x="80" y="470" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#B8860B">
        DENTRO DE UMBRAL · N3 EJECUCIÓN ASISTIDA · APRUEBA ANALISTA SI risk_confidence &lt; 0.85
      </text>
    </svg>
  );
};

const BkScene5 = () => (
  <svg viewBox="0 0 800 500" style={{ width: '100%', height: '100%' }}>
    <BkGrid/>
    <text x="80" y="60" fontFamily="var(--font-mono)" fontSize="11" letterSpacing="0.18em" fill="#96A3B5">MFA APLICADA · CLIENTE RESPONDE EN 42 SEG</text>
    <g transform="translate(160, 200)">
      <rect x="0" y="0" width="220" height="120" fill="#0A0B10" stroke="#0050BD" strokeWidth="1.5"/>
      <text x="14" y="24" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#0050BD">STEP-UP AUTHENTICATION</text>
      <text x="14" y="52" fontFamily="var(--font-body)" fontSize="14" fill="#FFF">✓ SMS OTP · 12s</text>
      <text x="14" y="74" fontFamily="var(--font-body)" fontSize="14" fill="#FFF">✓ Biometría dispositivo · 8s</text>
      <text x="14" y="96" fontFamily="var(--font-body)" fontSize="14" fill="#FFF">✓ Confirmación en app · 22s</text>
    </g>
    <g transform="translate(440, 200)">
      <rect x="0" y="0" width="220" height="120" fill="#0A0B10" stroke="#0F5132" strokeWidth="2"/>
      <text x="14" y="24" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#0F5132">RESULTADO</text>
      <text x="14" y="60" fontFamily="var(--font-display)" fontWeight="800" fontSize="22" fill="#0F5132">Aprobado</text>
      <text x="14" y="84" fontFamily="var(--font-body)" fontSize="12" fill="#FFF">Cliente verificado · risk resuelto</text>
      <text x="14" y="104" fontFamily="var(--font-mono)" fontSize="10" fill="#96A3B5">tiempo total · 42s</text>
    </g>
    <text x="80" y="420" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#F4024C">SIN INTERVENCIÓN DEL ANALISTA · DENTRO DE POLÍTICA · REVERSIBLE 24h</text>
  </svg>
);

const BkScene6 = () => (
  <svg viewBox="0 0 800 500" style={{ width: '100%', height: '100%' }}>
    <BkGrid/>
    <text x="80" y="60" fontFamily="var(--font-mono)" fontSize="11" letterSpacing="0.18em" fill="#96A3B5">EJECUCIÓN COORDINADA · CROSS-SYSTEM</text>
    <g transform="translate(400, 250)">
      <circle r="52" fill="none" stroke="#F4024C" strokeWidth="1" opacity="0.4">
        <animate attributeName="r" values="44;58;44" dur="1.6s" repeatCount="indefinite"/>
      </circle>
      <rect x="-44" y="-44" width="88" height="88" fill="#F4024C" stroke="#F4024C" strokeWidth="2"/>
      <text y="-6" textAnchor="middle" fontFamily="var(--font-display)" fontWeight="800" fontSize="14" fill="#FFF">OMNIX</text>
      <text y="16" textAnchor="middle" fontFamily="var(--font-mono)" fontSize="10" fill="#FFF">RUNTIME</text>
    </g>
    {[
      { s: 'CORE',     a: 'confirma transacción',            x: 130, y: 130 },
      { s: 'FRAUDE',    a: 'cierra caso · pattern learn',    x: 670, y: 130 },
      { s: 'CRM',      a: 'log de MFA aplicado',              x: 130, y: 380 },
      { s: 'CX',       a: 'notifica cliente · SMS+app',       x: 670, y: 380 },
    ].map((s) => (
      <g key={s.s}>
        <FlowPath d={`M 400 250 L ${s.x} ${s.y}`} stroke="#F4024C" strokeWidth={1.5} particleColor="#F4024C" particleSize={4} duration={1.4} pulseWidth/>
        <g transform={`translate(${s.x}, ${s.y})`}>
          <rect x="-88" y="-24" width="176" height="48" fill="#0A0B10" stroke="#0F5132" strokeWidth="1.5"/>
          <text x="-74" y="-4" fontFamily="var(--font-display)" fontWeight="800" fontSize="14" fill="#FFF">{s.s}</text>
          <text x="-74" y="14" fontFamily="var(--font-mono)" fontSize="9" fill="#0F5132">✓ {s.a}</text>
        </g>
      </g>
    ))}
    <text x="80" y="480" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.14em" fill="#0F5132">
      ✓ TX #BK-4c8f2a · 4 sistemas · 180ms · signed WORM · reversible 24h
    </text>
  </svg>
);

const BkScene7 = () => (
  <svg viewBox="0 0 800 500" style={{ width: '100%', height: '100%' }}>
    <BkGrid/>
    <text x="80" y="60" fontFamily="var(--font-mono)" fontSize="11" letterSpacing="0.18em" fill="#96A3B5">DECISION TRACE · AUDITORÍA REGULATOR-READY</text>
    <g transform="translate(80, 100)">
      <rect x="0" y="0" width="680" height="360" fill="#0A0B10" stroke="#F4024C" strokeWidth="1.5"/>
      <text x="20" y="30" fontFamily="var(--font-mono)" fontSize="10" letterSpacing="0.18em" fill="#F4024C">TRACE · #BK-4c8f2a · signed WORM · 7y retention</text>
      {[
        'timestamp:  2026-11-14 14:28:41.412 UTC',
        'client:      customer-hash-e4c2 (anonimizado)',
        'sdm:         sdm.fraud-banking-v0.4 (demo)',
        'signals:     6 (beneficiary, credentials, velocity, device, geo, amount)',
        'risk_score:  0.78 · confidence 0.88',
        'options:     5 evaluated · policy-scored',
        'recommendation: option 02 · MFA · fric 12 · risk 22 · cx 84',
        'approval:    auto-N3 · dentro de umbral · policy pol.fraud-2.1',
        'systems:     core, fraud, crm, cx',
        'result:      client verified · tx approved · 42s total',
        'reversible:  yes · 24h window',
        'evidence:    signed WORM · [VALIDAR RETENCIÓN JURISDICCIÓN]',
      ].map((line, i) => (
        <text key={i} x="20" y={60 + i * 24} fontFamily="var(--font-mono)" fontSize="11" fill="#FFF">
          <tspan fill="#52557A">{`0${i+1}  `}</tspan>{line}
        </text>
      ))}
    </g>
  </svg>
);

Object.assign(window, { BancaDemo });
