/* App.jsx — main landing page composition */

const { useState, useEffect, useRef } = React;

// Copy variants — misterioso vs direto
const COPY = {
  misterioso: {
    eyebrow: "ACESSO POR CONVITE / V1.0",
    title: ["Onde o tráfego ", <em key="i">se revela.</em>],
    sub: "Rastreamento, atribuição e orquestração — em silêncio, em escala, em uma única infraestrutura. Para quem move volume e prefere que ninguém saiba como.",
    primaryCTA: "Solicitar convite",
    secondaryCTA: "Ver demonstração",
    metaA: "Todas as contas da BM",
    metaB: "TikTok Ads · sandbox sob NDA",
    metaC: "BR · região protegida",
    sectionFeatures: ["O sistema", <em key="i"> em quatro órgãos.</em>],
    sectionFeaturesSub: "Cada módulo é independente. Juntos, eles capturam, atribuem, orquestram e reconciliam — sem interferência humana.",
    sectionFlow: ["Do clique ao", <em key="i"> ROAS reconciliado.</em>],
    sectionFlowSub: "Cinco passos. Sem dependências externas. Tudo persiste no seu Postgres.",
    sectionCompare: ["O que mais ninguém", <em key="i"> entrega.</em>],
    sectionCompareSub: "Por que você não consegue dormir tranquilo com Utmify ou planilha — e como o Corvex resolve.",
    sectionDash: ["O cockpit é seu.", <em key="i"> O dado também.</em>],
    sectionDashSub: "Toda métrica que você usa para decidir vive no seu próprio banco. Sem black-box, sem licença de dados.",
    sectionTesti: ["Quem voa com", <em key="i"> a gente.</em>],
    finalTitle: ["O céu", <em key="i"> é uma rota.</em>],
    finalSub: "Acesso restrito. Onboarding manual. Solicite o convite e nós entramos em contato em até 48h.",
  },
  direto: {
    eyebrow: "PLATAFORMA DE ATRIBUIÇÃO PARA TIKTOK ADS",
    title: ["Atribuição de verdade ", <em key="i">para quem escala.</em>],
    sub: "Substitui Utmify. Centraliza rastreamento, atribuição, criação de campanhas e custos do TikTok Ads em um único banco — todo o dado é seu, todas as decisões são suas.",
    primaryCTA: "Solicitar convite",
    secondaryCTA: "Ver demonstração",
    metaA: "Todas as contas da BM",
    metaB: "TikTok Marketing API · Events API",
    metaC: "Self-hosted · Postgres",
    sectionFeatures: ["Quatro módulos.", <em key="i"> Uma única infraestrutura.</em>],
    sectionFeaturesSub: "Rastreamento, atribuição, criação em lote e custo ao vivo — tudo em um só lugar, sem precisar abrir três ferramentas.",
    sectionFlow: ["Como funciona, ", <em key="i">passo a passo.</em>],
    sectionFlowSub: "Cinco etapas, totalmente automatizadas. O dado entra pelo clique e sai como ROAS reconciliado.",
    sectionCompare: ["Corvex vs ", <em key="i">o resto.</em>],
    sectionCompareSub: "Comparativo direto com as ferramentas de mercado mais usadas no nicho.",
    sectionDash: ["Dashboard ", <em key="i">de controle total.</em>],
    sectionDashSub: "Veja ROAS, CPA, leads e atribuição por conta, campanha e anúncio — em tempo real, agregado em uma view materializada.",
    sectionTesti: ["O que dizem ", <em key="i">os operadores.</em>],
    finalTitle: ["Pronto para ", <em key="i">tomar o controle?</em>],
    finalSub: "Solicite seu convite. Onboarding em 48h. Setup técnico assistido.",
  },
};

const FEATURES = [
  {
    num: "01 / RASTREAMENTO",
    title: "Não perde nenhum clique.",
    desc: "Cada clique no anúncio é registrado antes do usuário chegar ao Telegram. Nada se perde — nem o que o TikTok não te entrega.",
    tags: ["TTCLID", "SHORT-REF", "302 REDIRECT", "POSTGRES"],
    icon: (
      <svg width="22" height="22" viewBox="0 0 24 24" fill="none">
        <path d="M3 12 L21 12 M14 5 L21 12 L14 19" stroke="currentColor" strokeWidth="1.2"/>
        <circle cx="6" cy="12" r="2" fill="currentColor"/>
      </svg>
    ),
  },
  {
    num: "02 / ATRIBUIÇÃO + UTM",
    title: "Sabe de onde veio cada venda.",
    desc: "Liga a venda ao anúncio que gerou o clique e devolve a conversão para o TikTok com UTMs corretas. O algoritmo aprende com dado real.",
    tags: ["UTM", "EVENTS API", "ATRIBUIÇÃO", "VENDA → ANÚNCIO"],
    icon: (
      <svg width="22" height="22" viewBox="0 0 24 24" fill="none">
        <rect x="3" y="6" width="18" height="12" stroke="currentColor" strokeWidth="1.2"/>
        <path d="M3 10 L12 14 L21 10" stroke="currentColor" strokeWidth="1.2"/>
      </svg>
    ),
  },
  {
    num: "03 / CRIAÇÃO EM LOTE",
    title: "Todas as contas. Um clique.",
    desc: "Cria a mesma campanha em todas as contas da sua Business Manager de uma vez só. Link de rastreamento já vai pronto com UTMs.",
    tags: ["TEMPLATES", "P-LIMIT", "MARKETING API", "PARALELO"],
    icon: (
      <svg width="22" height="22" viewBox="0 0 24 24" fill="none">
        <circle cx="12" cy="6"  r="2.4" stroke="currentColor" strokeWidth="1.2"/>
        <circle cx="6"  cy="18" r="2.4" stroke="currentColor" strokeWidth="1.2"/>
        <circle cx="18" cy="18" r="2.4" stroke="currentColor" strokeWidth="1.2"/>
        <path d="M12 8.4 L7.2 15.6 M12 8.4 L16.8 15.6" stroke="currentColor" strokeWidth="1.2"/>
      </svg>
    ),
  },
  {
    num: "04 / CUSTO AO VIVO",
    title: "ROAS atualizado em tempo real.",
    desc: "Spend, CPA e ROAS por anúncio sempre atuais. Você decide pausar ou escalar olhando o número certo, não o de duas horas atrás.",
    tags: ["AO VIVO", "ROAS", "CPA", "SPEND"],
    icon: (
      <svg width="22" height="22" viewBox="0 0 24 24" fill="none">
        <circle cx="12" cy="12" r="8" stroke="currentColor" strokeWidth="1.2"/>
        <path d="M12 7 L12 12 L15.5 14" stroke="currentColor" strokeWidth="1.2"/>
      </svg>
    ),
  },
];

const FLOW_STEPS = [
  { n: "01", t: "Clique", d: "Usuário clica no anúncio. O Corvex registra antes do redirect." },
  { n: "02", t: "Redirect", d: "Cai no bot do Telegram com um link único de rastreio." },
  { n: "03", t: "Atribuição", d: "Quando o usuário interage, ligamos a ação ao clique original." },
  { n: "04", t: "Venda", d: "Pagamento dispara o evento de conversão para o TikTok." },
  { n: "05", t: "ROAS ao vivo", d: "Custo e receita reconciliados no painel — em tempo real." },
];

const COMPARE_ROWS = [
  { name: "Atribuição via TikTok Events API", utmify: "partial", planilha: "x", corvex: "check" },
  { name: "Banco de dados próprio (sem black-box)", utmify: "x", planilha: "check", corvex: "check" },
  { name: "Criação de campanhas em lote (BM inteira)", utmify: "x", planilha: "x", corvex: "check" },
  { name: "Sincronização de custo automática", utmify: "check", planilha: "x", corvex: "check" },
  { name: "Webhook idempotente com HMAC", utmify: "partial", planilha: "x", corvex: "check" },
  { name: "View materializada de ROAS / CPA / LTV", utmify: "x", planilha: "x", corvex: "check" },
  { name: "Self-hosted · sem licença de dados", utmify: "x", planilha: "check", corvex: "check" },
];

const TESTIMONIALS = [
  {
    q: "Saímos da Utmify e nunca mais olhamos pra trás. O dado é nosso, o ROAS bate com o do TikTok, e o disparo em lote economizou semanas.",
    n: "R. Almeida",
    r: "Head de Mídia · Operação 7-fig",
    a: "RA",
  },
  {
    q: "A view materializada do Corvex virou a base do meu BI. Hoje eu sei o LTV por anúncio, não por campanha. Mudou o jogo.",
    n: "F. Tavares",
    r: "Mídia paga · Produto digital",
    a: "FT",
  },
  {
    q: "Toda a BM em paralelo, criação de campanha em um clique, custo ao vivo. É a infra que eu sempre quis ter, mas não tinha tempo de construir.",
    n: "C. Nakamura",
    r: "Founder · Agência performance",
    a: "CN",
  },
];

// ---------------------------------------------------------------------------

const App = () => {
  const [tweaks, setTweak] = window.useTweaks(window.TWEAK_DEFAULTS);

  const variant = tweaks.copy === "direto" ? "direto" : "misterioso";
  const C = COPY[variant];

  // Apply CSS vars from tweaks
  useEffect(() => {
    const r = document.documentElement.style;
    r.setProperty("--silver", tweaks.silverHex);
    r.setProperty("--silver-glow", tweaks.silverGlow);
    r.setProperty("--grid-opacity", String(tweaks.gridOpacity));
    r.setProperty("--grain-opacity", String(tweaks.grainOpacity));
    r.setProperty("--particle-opacity", String(tweaks.particleOpacity));
  }, [tweaks]);

  return (
    <>
      {/* Background layers */}
      <div className="bg-layer bg-vignette"></div>
      {tweaks.density !== "limpo" && tweaks.density !== "particles" && (
        <div className="bg-layer bg-grid"></div>
      )}
      {tweaks.density === "particles" && <ParticlesCanvas />}
      <div className="bg-layer bg-grain"></div>

      <Nav C={C} />
      <Hero C={C} variant={tweaks.heroVariant} />
      <MetricsStrip />
      <Features C={C} />
      <Flow C={C} />
      {tweaks.showDashboard !== false && <DashboardSection C={C} />}
      <Compare C={C} />
      <Testimonials C={C} />
      <FinalCTA C={C} />
      <Footer />
      <ScrollStamp />

      <window.TweaksPanel title="Tweaks">
        <window.TweakSection title="Hero">
          <window.TweakRadio
            label="Estilo do hero"
            value={tweaks.heroVariant}
            options={[
              { value: "centered", label: "Centrado" },
              { value: "blueprint", label: "Blueprint" },
              { value: "cinema", label: "Cinema" },
              { value: "asymmetric", label: "Off-axis" },
            ]}
            onChange={(v) => setTweak("heroVariant", v)}
          />
        </window.TweakSection>

        <window.TweakSection title="Acento prata">
          <window.TweakRadio
            label="Tom"
            value={tweaks.silverTone}
            options={[
              { value: "neutro",   label: "Neutro" },
              { value: "azulado",  label: "Azulado" },
              { value: "quente",   label: "Quente" },
            ]}
            onChange={(v) => {
              const map = {
                neutro:  { silverHex: "#c8c8cc", silverGlow: "rgba(200,200,204,0.18)" },
                azulado: { silverHex: "#b8c4d6", silverGlow: "rgba(184,196,214,0.22)" },
                quente:  { silverHex: "#d4c8b8", silverGlow: "rgba(212,200,184,0.22)" },
              };
              setTweak({ silverTone: v, ...map[v] });
            }}
          />
        </window.TweakSection>

        <window.TweakSection title="Atmosfera">
          <window.TweakRadio
            label="Densidade do fundo"
            value={tweaks.density}
            options={[
              { value: "limpo",     label: "Limpo" },
              { value: "grid",      label: "Grid" },
              { value: "particles", label: "Partículas" },
            ]}
            onChange={(v) => {
              const map = {
                limpo:     { gridOpacity: 0, particleOpacity: 0 },
                grid:      { gridOpacity: 0.10, particleOpacity: 0 },
                particles: { gridOpacity: 0.04, particleOpacity: 0.55 },
              };
              setTweak({ density: v, ...map[v] });
            }}
          />
          <window.TweakSlider
            label="Intensidade do grão"
            min={0} max={0.18} step={0.01}
            value={tweaks.grainOpacity}
            onChange={(v) => setTweak("grainOpacity", v)}
          />
        </window.TweakSection>

        <window.TweakSection title="Conteúdo">
          <window.TweakRadio
            label="Tom de copy"
            value={tweaks.copy}
            options={[
              { value: "misterioso", label: "Misterioso" },
              { value: "direto",     label: "Direto" },
            ]}
            onChange={(v) => setTweak("copy", v)}
          />
          <window.TweakToggle
            label="Mostrar dashboard"
            value={tweaks.showDashboard}
            onChange={(v) => setTweak("showDashboard", v)}
          />
        </window.TweakSection>
      </window.TweaksPanel>
    </>
  );
};

// ---------------------------------------------------------------------------
// NAV
// ---------------------------------------------------------------------------
const Nav = ({ C }) => (
  <nav className="nav">
    <a href="#" className="nav-brand">
      <img src="/landing/assets/logo.png" alt="" />
      <img src="https://i.postimg.cc/VNR74y5S/wordmark.png" alt="Corvex" style={{ height: "40px", width: "auto", filter: "brightness(0) invert(1)", opacity: 0.92 }} />
    </a>
    <div className="nav-links">
      <a href="#sistema">Sistema</a>
      <a href="#fluxo">Fluxo</a>
      <a href="#dashboard">Dashboard</a>
      <a href="#comparativo">Comparativo</a>
      <a href="/terms">Termos</a>
      <a href="/privacy">Privacidade</a>
    </div>
    <a href="#convite" className="nav-cta">Solicitar convite →</a>
  </nav>
);

// ---------------------------------------------------------------------------
// HERO — 4 variants
// ---------------------------------------------------------------------------
const Hero = ({ C, variant }) => {
  if (variant === "blueprint")  return <HeroBlueprint C={C} />;
  if (variant === "cinema")     return <HeroCinema C={C} />;
  if (variant === "asymmetric") return <HeroAsymmetric C={C} />;
  return <HeroCentered C={C} />;
};

const HeroCentered = ({ C }) => (
  <section className="hero">
    <div className="hero-bracket tl"></div>
    <div className="hero-bracket tr"></div>
    <div className="hero-bracket bl"></div>
    <div className="hero-bracket br"></div>
    <div className="container">
      <div className="hero-tag eyebrow">{C.eyebrow}</div>
      <h1 className="display hero-title">{C.title}</h1>
      <p className="hero-sub">{C.sub}</p>
      <div className="hero-actions">
        <a href="#convite" className="btn btn-primary">
          {C.primaryCTA}
          <Arrow />
        </a>
        <a href="#dashboard" className="btn btn-ghost">
          {C.secondaryCTA}
        </a>
      </div>
      <div className="hero-meta">
        <div><span>◇</span> {C.metaA}</div>
        <div><span>◇</span> {C.metaB}</div>
        <div><span>◇</span> {C.metaC}</div>
      </div>
    </div>
  </section>
);

const HeroBlueprint = ({ C }) => (
  <section className="hero" style={{ paddingTop: 200 }}>
    <BlueprintGrid />
    <div className="container">
      <div className="hero-tag eyebrow">{C.eyebrow}</div>
      <h1 className="display hero-title">{C.title}</h1>
      <p className="hero-sub">{C.sub}</p>
      <div className="hero-actions">
        <a href="#convite" className="btn btn-primary">{C.primaryCTA}<Arrow /></a>
        <a href="#dashboard" className="btn btn-ghost">{C.secondaryCTA}</a>
      </div>
      <div className="hero-meta">
        <div><span>◇</span> {C.metaA}</div>
        <div><span>◇</span> {C.metaB}</div>
        <div><span>◇</span> {C.metaC}</div>
      </div>
    </div>
  </section>
);

const HeroCinema = ({ C }) => (
  <section className="hero" style={{ paddingTop: 220, paddingBottom: 140 }}>
    <img src="/landing/assets/logo.png" className="hero-crow" alt="" />
    <div className="container" style={{ position: "relative", zIndex: 2 }}>
      <div className="hero-tag eyebrow">{C.eyebrow}</div>
      <h1 className="display hero-title" style={{ maxWidth: 880 }}>{C.title}</h1>
      <p className="hero-sub">{C.sub}</p>
      <div className="hero-actions">
        <a href="#convite" className="btn btn-primary">{C.primaryCTA}<Arrow /></a>
        <a href="#dashboard" className="btn btn-ghost">{C.secondaryCTA}</a>
      </div>
      <div className="hero-meta">
        <div><span>◇</span> {C.metaA}</div>
        <div><span>◇</span> {C.metaB}</div>
        <div><span>◇</span> {C.metaC}</div>
      </div>
    </div>
  </section>
);

const HeroAsymmetric = ({ C }) => (
  <section className="hero" style={{ textAlign: "left", paddingTop: 200 }}>
    <div className="container" style={{ display: "grid", gridTemplateColumns: "1.4fr 1fr", gap: 60, alignItems: "center" }}>
      <div>
        <div className="hero-tag eyebrow">{C.eyebrow}</div>
        <h1 className="display hero-title" style={{ textAlign: "left", margin: "20px 0 24px" }}>{C.title}</h1>
        <p className="hero-sub" style={{ margin: "0 0 32px" }}>{C.sub}</p>
        <div className="hero-actions" style={{ justifyContent: "flex-start", marginBottom: 40 }}>
          <a href="#convite" className="btn btn-primary">{C.primaryCTA}<Arrow /></a>
          <a href="#dashboard" className="btn btn-ghost">{C.secondaryCTA}</a>
        </div>
        <div className="hero-meta" style={{ justifyContent: "flex-start" }}>
          <div><span>◇</span> {C.metaA}</div>
          <div><span>◇</span> {C.metaB}</div>
        </div>
      </div>
      <div style={{ position: "relative", aspectRatio: "1 / 1", maxWidth: 380, marginLeft: "auto" }}>
        <div style={{
          position: "absolute", inset: 0,
          border: "1px solid var(--line-strong)",
          background: "radial-gradient(ellipse at 50% 30%, rgba(200,200,204,0.08), transparent 70%), var(--bg-1)",
        }}>
          <img src="/landing/assets/logo.png" alt="" style={{ width: "70%", position: "absolute", top: "50%", left: "50%", transform: "translate(-50%, -50%)", filter: "drop-shadow(0 0 40px var(--silver-glow))" }} />
          <div style={{ position: "absolute", top: 12, left: 12, fontFamily: "var(--font-mono)", fontSize: 10, color: "var(--text-3)", letterSpacing: "0.14em" }}>CRX-MK01</div>
          <div style={{ position: "absolute", bottom: 12, right: 12, fontFamily: "var(--font-mono)", fontSize: 10, color: "var(--silver-2)", letterSpacing: "0.14em" }}>◇ ATIVO</div>
        </div>
      </div>
    </div>
  </section>
);

const Arrow = () => (
  <svg className="arrow" viewBox="0 0 24 24" fill="none">
    <path d="M5 12 H19 M13 6 L19 12 L13 18" stroke="currentColor" strokeWidth="1.6"/>
  </svg>
);

// ---------------------------------------------------------------------------
const BlueprintGrid = () => (
  <svg style={{ position: "absolute", inset: 0, width: "100%", height: "100%", pointerEvents: "none", opacity: 0.18, zIndex: 0 }}
       preserveAspectRatio="none" viewBox="0 0 100 100">
    <defs>
      <pattern id="bp" width="5" height="5" patternUnits="userSpaceOnUse">
        <path d="M 5 0 L 0 0 0 5" fill="none" stroke="rgba(200,200,204,0.2)" strokeWidth="0.1"/>
      </pattern>
    </defs>
    <rect width="100" height="100" fill="url(#bp)"/>
  </svg>
);

// ---------------------------------------------------------------------------
const ParticlesCanvas = () => {
  const ref = useRef(null);
  useEffect(() => {
    const c = ref.current; if (!c) return;
    const ctx = c.getContext("2d");
    const resize = () => { c.width = window.innerWidth; c.height = window.innerHeight; };
    resize(); window.addEventListener("resize", resize);
    const N = 60;
    const ps = Array.from({ length: N }, () => ({
      x: Math.random() * c.width, y: Math.random() * c.height,
      vx: (Math.random() - 0.5) * 0.15, vy: (Math.random() - 0.5) * 0.15,
      r: Math.random() * 1.2 + 0.3,
    }));
    let raf;
    const tick = () => {
      ctx.clearRect(0, 0, c.width, c.height);
      ctx.fillStyle = "rgba(200,200,204,0.5)";
      ps.forEach(p => {
        p.x += p.vx; p.y += p.vy;
        if (p.x < 0 || p.x > c.width)  p.vx *= -1;
        if (p.y < 0 || p.y > c.height) p.vy *= -1;
        ctx.beginPath();
        ctx.arc(p.x, p.y, p.r, 0, Math.PI * 2);
        ctx.fill();
      });
      raf = requestAnimationFrame(tick);
    };
    tick();
    return () => { cancelAnimationFrame(raf); window.removeEventListener("resize", resize); };
  }, []);
  return <canvas ref={ref} id="particles-canvas" />;
};

// ---------------------------------------------------------------------------
const MetricsStrip = () => (
  <section className="metrics">
    <div className="container">
      <div className="metrics-grid">
        <div className="metric">
          <div className="metric-value">BM <span className="unit">inteira</span></div>
          <div className="metric-label">Disparo em paralelo</div>
        </div>
        <div className="metric">
          <div className="metric-value">live <span className="unit">sync</span></div>
          <div className="metric-label">Custo atualizado ao vivo</div>
        </div>
        <div className="metric">
          <div className="metric-value">100<span className="unit">%</span></div>
          <div className="metric-label">Sem clique perdido</div>
        </div>
        <div className="metric">
          <div className="metric-value">∞ <span className="unit">eventos</span></div>
          <div className="metric-label">Dado é seu, sem teto</div>
        </div>
      </div>
    </div>
  </section>
);

// ---------------------------------------------------------------------------
const Features = ({ C }) => (
  <section id="sistema">
    <div className="container">
      <div className="section-head">
        <div className="eyebrow">/ O SISTEMA</div>
        <h2>{C.sectionFeatures}</h2>
        <p>{C.sectionFeaturesSub}</p>
      </div>
      <div className="features-grid">
        {FEATURES.map((f, i) => (
          <div key={i} className="feature">
            <div className="feature-icon">{f.icon}</div>
            <div className="feature-num">{f.num}</div>
            <h3 className="feature-title">{f.title}</h3>
            <p className="feature-desc">{f.desc}</p>
            <div className="feature-tags">
              {f.tags.map((t, j) => <span key={j}>{t}</span>)}
            </div>
          </div>
        ))}
      </div>
    </div>
  </section>
);

// ---------------------------------------------------------------------------
const Flow = ({ C }) => (
  <section id="fluxo" className="flow">
    <div className="container">
      <div className="section-head">
        <div className="eyebrow">/ FLUXO COMPLETO</div>
        <h2>{C.sectionFlow}</h2>
        <p>{C.sectionFlowSub}</p>
      </div>
      <div className="flow-track">
        {FLOW_STEPS.map((s, i) => (
          <div key={i} className="flow-step">
            <div className="flow-dot">{s.n}</div>
            <div>
              <h4 className="flow-title">{s.t}</h4>
              <p className="flow-desc">{s.d}</p>
            </div>
          </div>
        ))}
      </div>
    </div>
  </section>
);

// ---------------------------------------------------------------------------
const DashboardSection = ({ C }) => (
  <section id="dashboard">
    <div className="container">
      <div className="section-head">
        <div className="eyebrow">/ COCKPIT</div>
        <h2>{C.sectionDash}</h2>
        <p>{C.sectionDashSub}</p>
      </div>
      <div className="dashboard-frame">
        <window.Dashboard />
      </div>
    </div>
  </section>
);

// ---------------------------------------------------------------------------
const Compare = ({ C }) => {
  const Cell = ({ v }) => {
    if (v === "check") return <span className="check">●</span>;
    if (v === "x") return <span className="x">—</span>;
    return <span className="partial">PARCIAL</span>;
  };
  return (
    <section id="comparativo">
      <div className="container">
        <div className="section-head">
          <div className="eyebrow">/ COMPARATIVO</div>
          <h2>{C.sectionCompare}</h2>
          <p>{C.sectionCompareSub}</p>
        </div>
        <div className="compare-wrap">
          <table className="compare">
            <thead>
              <tr>
                <th>Capacidade</th>
                <th>Utmify</th>
                <th>Planilha / 3rd-party</th>
                <th className="col-corvex">Corvex</th>
              </tr>
            </thead>
            <tbody>
              {COMPARE_ROWS.map((r, i) => (
                <tr key={i}>
                  <td className="feature-name">{r.name}</td>
                  <td><Cell v={r.utmify} /></td>
                  <td><Cell v={r.planilha} /></td>
                  <td className="col-corvex"><Cell v={r.corvex} /></td>
                </tr>
              ))}
            </tbody>
          </table>
        </div>
      </div>
    </section>
  );
};

// ---------------------------------------------------------------------------
const Testimonials = ({ C }) => (
  <section>
    <div className="container">
      <div className="section-head">
        <div className="eyebrow">/ OPERADORES</div>
        <h2>{C.sectionTesti}</h2>
      </div>
      <div className="testimonials">
        {TESTIMONIALS.map((t, i) => (
          <div key={i} className="tcard">
            <p className="tquote">"{t.q}"</p>
            <div className="tperson">
              <div className="tavatar">{t.a}</div>
              <div>
                <div className="tname">{t.n}</div>
                <div className="trole">{t.r}</div>
              </div>
            </div>
          </div>
        ))}
      </div>
    </div>
  </section>
);

// ---------------------------------------------------------------------------
const FinalCTA = ({ C }) => (
  <section id="convite" className="final">
    <div className="container">
      <div className="final-frame">
        <span className="corner-tl"></span>
        <span className="corner-tr"></span>
        <span className="corner-bl"></span>
        <span className="corner-br"></span>
        <div className="eyebrow">/ ACESSO RESTRITO</div>
        <h2>{C.finalTitle}</h2>
        <p>{C.finalSub}</p>
        <div className="hero-actions" style={{ marginBottom: 0 }}>
          <a href="#" className="btn btn-primary">Solicitar convite<Arrow /></a>
          <a href="#dashboard" className="btn btn-ghost">Agendar demonstração</a>
        </div>
      </div>
    </div>
  </section>
);

// ---------------------------------------------------------------------------
const Footer = () => (
  <footer className="footer">
    <div className="container">
      <div className="footer-grid">
        <div className="footer-brand">
          <img src="/landing/assets/logo.png" alt="" />
          <p>Infraestrutura de tráfego pago. Self-hosted, idempotente, em silêncio.</p>
        </div>
        <div className="footer-col">
          <h4>Sistema</h4>
          <a href="#sistema">Tracker</a>
          <a href="#sistema">Webhook</a>
          <a href="#sistema">Orquestrador</a>
          <a href="#sistema">Cost Sync</a>
        </div>
        <div className="footer-col">
          <h4>Recursos</h4>
          <a href="#fluxo">Fluxo</a>
          <a href="#dashboard">Dashboard</a>
          <a href="#comparativo">Comparativo</a>
        </div>
        <div className="footer-col">
          <h4>Acesso</h4>
          <a href="#convite">Solicitar convite</a>
          <a href="#convite">Demonstração</a>
          <a href="/terms">Termos de Uso</a>
          <a href="/privacy">Privacidade</a>
        </div>
      </div>
      <div className="footer-bottom">
        <span>◇ CORVEX · 2026 · BR</span>
        <div style={{ display: "flex", gap: 24 }}>
          <a href="/terms" style={{ color: "var(--text-3)", textDecoration: "none", fontSize: 11, fontFamily: "var(--font-mono)", letterSpacing: "0.1em", textTransform: "uppercase" }}>Termos de Uso</a>
          <a href="/privacy" style={{ color: "var(--text-3)", textDecoration: "none", fontSize: 11, fontFamily: "var(--font-mono)", letterSpacing: "0.1em", textTransform: "uppercase" }}>Privacidade</a>
        </div>
      </div>
    </div>
  </footer>
);

const ScrollStamp = () => {
  const [t, setT] = useState("");
  useEffect(() => {
    const tick = () => {
      const d = new Date();
      const pad = (n) => String(n).padStart(2, "0");
      setT(`${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`);
    };
    tick();
    const id = setInterval(tick, 1000);
    return () => clearInterval(id);
  }, []);
  return <div className="scrolling-stamp">◇ {t} BRT · SESSÃO ANÔNIMA</div>;
};

// ---------------------------------------------------------------------------
window.App = App;
