// agent-detail.jsx — Shared agent page template (consumes window.ECHO_AGENTS[window.AGENT_ID])
const { useState, useEffect, useRef } = React;

// ── Logo ─────────────────────────────────────────────────────────
function LogoMark({ size = 26 }) {
  // Brand mark — uses the canonical Echo logo image asset.
  return (
    <img
      src="../img/echo-logo.jpeg"
      alt="Echo"
      width={size}
      height={size}
      style={{ display: 'block', borderRadius: 4, objectFit: 'contain' }}
    />
  );
}

// ── Agent glyph icons (mirror app.jsx so the Agents dropdown matches) ─
function AgentGlyph({ name }) {
  const glyphs = {
    'Triage':  <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" style={{display:'block'}}><path d="M3 8h18M5 12h14M8 16h8"/><circle cx="20" cy="6" r="1.5" fill="currentColor" stroke="none"/></svg>,
    'Docs':    <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" style={{display:'block'}}><path d="M6 3h9l4 4v13a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1z"/><path d="M15 3v4h4"/><path d="M9 14l2.5 2.5L16 12"/></svg>,
    'Cal':     <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" style={{display:'block'}}><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3.5 2"/><path d="M21 12h-2"/></svg>,
    'Ledger':  <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" style={{display:'block'}}><circle cx="12" cy="13" r="8"/><path d="M9 2h6M12 8v5l3 2"/><path d="M19 5l1.5 1.5"/></svg>,
  };
  return glyphs[name] || <span>{name[0]}</span>;
}

// ── Solutions dropdown ────────────────────────────────────────────
function SolutionsDropdownDetail() {
  const [open, setOpen] = useState(false);
  const ref = useRef(null);
  const closeTimer = useRef(null);
  const hoverOpen = () => { clearTimeout(closeTimer.current); setOpen(true); };
  const hoverClose = () => { closeTimer.current = setTimeout(() => setOpen(false), 120); };
  useEffect(() => {
    const close = e => { if (ref.current && !ref.current.contains(e.target)) setOpen(false); };
    document.addEventListener('mousedown', close);
    return () => document.removeEventListener('mousedown', close);
  }, []);
  // Carriers is the current vertical for /agents/* pages — flag it so it
  // renders muted (still clickable but visually de-emphasized).
  const items = [
    { label: 'Carriers',            sub: 'Asset-based · LTL · TL',          href: '/',        current: true  },
    { label: 'Oracle ERP',          sub: 'Fusion · NetSuite · JD Edwards',  href: '/erp',     current: false },
    { label: 'Freight & Logistics', sub: 'Brokers · Freight forwarders',    href: '/freight', current: false },
    { label: 'Regenerative Health', sub: 'Clinics · Wellness · Aesthetics', href: '/health',  current: false },
  ];
  return (
    <div ref={ref} style={{ position: 'relative' }} onMouseEnter={hoverOpen} onMouseLeave={hoverClose}>
      <button onClick={() => setOpen(o => !o)} style={{ background: 'none', border: 'none', cursor: 'pointer', padding: 0, fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.1em', color: open ? 'var(--ink)' : 'var(--muted)', textTransform: 'uppercase', transition: 'color 0.2s', fontWeight: 500, display: 'flex', alignItems: 'center', gap: 5 }}
        onMouseEnter={e => e.currentTarget.style.color = 'var(--ink)'}
        onMouseLeave={e => { if (!open) e.currentTarget.style.color = 'var(--muted)'; }}
      >
        Verticals
        <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" style={{ transform: open ? 'rotate(180deg)' : 'none', transition: 'transform 0.2s' }}><path d="M6 9l6 6 6-6"/></svg>
      </button>
      {open && (
        <div style={{ position: 'absolute', top: 'calc(100% + 14px)', left: '50%', transform: 'translateX(-50%)', background: 'var(--bg)', border: '1px solid var(--hairline)', borderRadius: 12, padding: '8px', minWidth: 240, boxShadow: '0 20px 60px rgba(0,0,0,0.22)', zIndex: 200 }}>
          {items.map(item => (
            <a key={item.href} href={item.href} onClick={() => setOpen(false)} style={{ display: 'flex', flexDirection: 'column', gap: 2, padding: '11px 14px', borderRadius: 8, textDecoration: 'none', color: 'inherit', transition: 'background 0.15s', opacity: item.current ? 0.55 : 1 }}
              onMouseEnter={e => e.currentTarget.style.background = 'var(--surface)'}
              onMouseLeave={e => e.currentTarget.style.background = 'transparent'}
            >
              <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, fontWeight: 600, color: 'var(--ink)', letterSpacing: '0.04em' }}>
                {item.label}
                {item.current && <span style={{ marginLeft: 8, fontWeight: 500, color: 'var(--muted)' }}>· current</span>}
              </span>
              <span style={{ fontSize: 11, color: 'var(--muted)' }}>{item.sub}</span>
            </a>
          ))}
        </div>
      )}
    </div>
  );
}

// ── Agents dropdown (mirrors homepage) ────────────────────────────
function AgentsDropdownDetail({ currentId }) {
  const [open, setOpen] = useState(false);
  const ref = useRef(null);
  const closeTimer = useRef(null);
  useEffect(() => {
    const close = e => { if (ref.current && !ref.current.contains(e.target)) setOpen(false); };
    document.addEventListener('mousedown', close);
    return () => document.removeEventListener('mousedown', close);
  }, []);
  const hoverOpen = () => { clearTimeout(closeTimer.current); setOpen(true); };
  const hoverClose = () => { closeTimer.current = setTimeout(() => setOpen(false), 120); };
  const items = [
    { id: 'triage', name: 'Triage', domain: 'Email & Customer Service', color: '#5059C9', href: 'triage.html' },
    { id: 'docs',   name: 'Docs',   domain: 'Documents & AR',           color: '#5B5FC7', href: 'docs.html' },
    { id: 'cal',    name: 'Cal',    domain: 'Scheduling & Dock Ops',    color: '#30C15A', href: 'cal.html' },
    { id: 'ledger', name: 'Ledger', domain: 'Detention & Claims',       color: '#A855F7', href: 'ledger.html' },
  ];
  return (
    <div ref={ref} style={{ position: 'relative' }} onMouseEnter={hoverOpen} onMouseLeave={hoverClose}>
      <button onClick={() => setOpen(o => !o)} style={{ background: 'none', border: 'none', cursor: 'pointer', padding: 0, fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.1em', color: open ? 'var(--ink)' : 'var(--muted)', textTransform: 'uppercase', transition: 'color 0.2s', fontWeight: 500, display: 'flex', alignItems: 'center', gap: 5 }}
        onMouseEnter={e => e.currentTarget.style.color = 'var(--ink)'}
        onMouseLeave={e => { if (!open) e.currentTarget.style.color = 'var(--muted)'; }}
      >
        Agents
        <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" style={{ transform: open ? 'rotate(180deg)' : 'none', transition: 'transform 0.2s' }}><path d="M6 9l6 6 6-6"/></svg>
      </button>
      {open && (
        <div style={{ position: 'absolute', top: 'calc(100% + 14px)', left: '50%', transform: 'translateX(-50%)', background: 'var(--bg)', border: '1px solid var(--hairline)', borderRadius: 12, padding: '8px', width: 300, boxShadow: '0 20px 60px rgba(0,0,0,0.22)', zIndex: 200 }}>
          {items.map(item => {
            const isCurrent = item.id === currentId;
            return (
              <a key={item.href} href={item.href} onClick={() => setOpen(false)} style={{ display: 'flex', alignItems: 'center', gap: 12, padding: '10px 12px', borderRadius: 8, textDecoration: 'none', color: 'inherit', transition: 'background 0.15s', opacity: isCurrent ? 0.55 : 1 }}
                onMouseEnter={e => { if (!isCurrent) e.currentTarget.style.background = `${item.color}14`; }}
                onMouseLeave={e => { e.currentTarget.style.background = 'transparent'; }}
              >
                <span style={{ width: 32, height: 32, borderRadius: 8, background: `linear-gradient(180deg, ${item.color}EE 0%, ${item.color} 100%)`, display: 'inline-flex', alignItems: 'center', justifyContent: 'center', color: '#fff', boxShadow: `0 4px 12px ${item.color}33, inset 0 1px 0 rgba(255,255,255,0.22)`, flexShrink: 0, lineHeight: 1 }}>
                  <AgentGlyph name={item.name} />
                </span>
                <span style={{ display: 'flex', flexDirection: 'column', gap: 2, minWidth: 0 }}>
                  <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, fontWeight: 600, color: 'var(--ink)', letterSpacing: '0.04em' }}>
                    {item.name}{isCurrent && <span style={{ marginLeft: 8, fontWeight: 500, color: 'var(--muted)' }}>· current</span>}
                  </span>
                  <span style={{ fontSize: 11, color: 'var(--muted)' }}>{item.domain}</span>
                </span>
              </a>
            );
          })}
        </div>
      )}
    </div>
  );
}

// ── Mobile menu (full-screen overlay) ─────────────────────────────
function MobileMenuDetail({ open, onClose, currentId }) {
  const [solOpen, setSolOpen] = useState(false);
  const [agentsOpen, setAgentsOpen] = useState(false);
  useEffect(() => {
    if (open) {
      const prev = document.body.style.overflow;
      document.body.style.overflow = 'hidden';
      return () => { document.body.style.overflow = prev; };
    }
  }, [open]);
  const links = [
    { label: 'Why Echo',     href: '../index.html#why-echo' },
    { label: 'How It Works', href: '../index.html#how-it-works' },
  ];
  const solutions = [
    { label: 'Carriers',            sub: 'Asset-based · LTL · TL',          href: '/',        current: true  },
    { label: 'Oracle ERP',          sub: 'Fusion · NetSuite · JD Edwards',  href: '/erp',     current: false },
    { label: 'Freight & Logistics', sub: 'Brokers · Freight forwarders',    href: '/freight', current: false },
    { label: 'Regenerative Health', sub: 'Clinics · Wellness · Aesthetics', href: '/health',  current: false },
  ];
  const agents = [
    { id: 'triage', name: 'Triage', domain: 'Email & Customer Service', color: '#5059C9', href: 'triage.html' },
    { id: 'docs',   name: 'Docs',   domain: 'Documents & AR',           color: '#5B5FC7', href: 'docs.html' },
    { id: 'cal',    name: 'Cal',    domain: 'Scheduling & Dock Ops',    color: '#30C15A', href: 'cal.html' },
    { id: 'ledger', name: 'Ledger', domain: 'Detention & Claims',       color: '#A855F7', href: 'ledger.html' },
  ];
  return (
    <div className="mobile-menu-overlay" onClick={onClose} aria-hidden={!open} style={{ position: 'fixed', inset: 0, zIndex: 150, background: 'rgba(10,22,18,0.96)', opacity: open ? 1 : 0, pointerEvents: open ? 'auto' : 'none', visibility: open ? 'visible' : 'hidden', transition: 'opacity 0.25s cubic-bezier(0.4,0,0.2,1), visibility 0s linear ' + (open ? '0s' : '0.25s'), display: 'flex', flexDirection: 'column', padding: '88px 24px 32px', overflowY: 'auto' }}>
      <div onClick={e => e.stopPropagation()} style={{ display: 'flex', flexDirection: 'column', gap: 4, flex: 1 }}>
        <button onClick={() => setSolOpen(o => !o)} style={{ background: 'none', border: 'none', cursor: 'pointer', display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '18px 8px', width: '100%', fontFamily: 'var(--ff-mono)', fontSize: 13, letterSpacing: '0.12em', color: '#F4F0E8', textTransform: 'uppercase', fontWeight: 500, borderBottom: '1px solid rgba(244,240,232,0.10)' }}>
          Verticals
          <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" style={{ transform: solOpen ? 'rotate(180deg)' : 'none', transition: 'transform 0.2s' }}><path d="M6 9l6 6 6-6"/></svg>
        </button>
        {solOpen && (
          <div style={{ display: 'flex', flexDirection: 'column', gap: 2, padding: '8px 0 16px 16px', borderBottom: '1px solid rgba(244,240,232,0.10)' }}>
            {solutions.map(s => (
              <a key={s.href} href={s.href} onClick={onClose} style={{ display: 'flex', flexDirection: 'column', gap: 4, padding: '12px 8px', textDecoration: 'none', opacity: s.current ? 0.55 : 1 }}>
                <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 12, fontWeight: 600, color: '#F4F0E8', letterSpacing: '0.04em' }}>{s.label}{s.current && <span style={{ marginLeft: 8, color: 'rgba(244,240,232,0.55)' }}>· current</span>}</span>
                <span style={{ fontSize: 12, color: 'rgba(244,240,232,0.55)' }}>{s.sub}</span>
              </a>
            ))}
          </div>
        )}
        <button onClick={() => setAgentsOpen(o => !o)} style={{ background: 'none', border: 'none', cursor: 'pointer', display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '18px 8px', width: '100%', fontFamily: 'var(--ff-mono)', fontSize: 13, letterSpacing: '0.12em', color: '#F4F0E8', textTransform: 'uppercase', fontWeight: 500, borderBottom: '1px solid rgba(244,240,232,0.10)' }}>
          Agents
          <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" style={{ transform: agentsOpen ? 'rotate(180deg)' : 'none', transition: 'transform 0.2s' }}><path d="M6 9l6 6 6-6"/></svg>
        </button>
        {agentsOpen && (
          <div style={{ display: 'flex', flexDirection: 'column', gap: 2, padding: '8px 0 16px 16px', borderBottom: '1px solid rgba(244,240,232,0.10)' }}>
            {agents.map(a => {
              const isCurrent = a.id === currentId;
              return (
                <a key={a.href} href={a.href} onClick={onClose} style={{ display: 'flex', alignItems: 'center', gap: 14, padding: '12px 8px', textDecoration: 'none', opacity: isCurrent ? 0.55 : 1 }}>
                  <span style={{ width: 36, height: 36, borderRadius: 9, background: `linear-gradient(180deg, ${a.color}EE 0%, ${a.color} 100%)`, display: 'inline-flex', alignItems: 'center', justifyContent: 'center', color: '#fff', boxShadow: `0 4px 14px ${a.color}40, inset 0 1px 0 rgba(255,255,255,0.22)`, flexShrink: 0, lineHeight: 1 }}>
                    <AgentGlyph name={a.name} />
                  </span>
                  <span style={{ display: 'flex', flexDirection: 'column', gap: 4, minWidth: 0 }}>
                    <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 12, fontWeight: 600, color: '#F4F0E8', letterSpacing: '0.04em' }}>{a.name}{isCurrent && <span style={{ marginLeft: 8, color: 'rgba(244,240,232,0.55)' }}>· current</span>}</span>
                    <span style={{ fontSize: 12, color: 'rgba(244,240,232,0.55)' }}>{a.domain}</span>
                  </span>
                </a>
              );
            })}
          </div>
        )}
        {links.map(l => (
          <a key={l.label} href={l.href} onClick={onClose} style={{ display: 'block', padding: '18px 8px', fontFamily: 'var(--ff-mono)', fontSize: 13, letterSpacing: '0.12em', color: '#F4F0E8', textTransform: 'uppercase', fontWeight: 500, textDecoration: 'none', borderBottom: '1px solid rgba(244,240,232,0.10)' }}>{l.label}</a>
        ))}
        <div style={{ marginTop: 32 }}>
          <a href="#book" data-open-book-call onClick={onClose} className="echo-cta echo-cta--primary" style={{ width: '100%', justifyContent: 'center' }}>
            Get a demo
          </a>
        </div>
      </div>
    </div>
  );
}

// ── Nav ──────────────────────────────────────────────────────────
function Nav({ theme, setTheme, scrolled, currentId }) {
  const [mobileOpen, setMobileOpen] = useState(false);
  const links = [
    { label: 'Why Echo',     href: '../index.html#why-echo' },
    { label: 'How It Works', href: '../index.html#how-it-works' },
  ];
  return (
    <nav style={{
      position: 'fixed', top: 0, left: 0, right: 0, zIndex: 100,
      background: scrolled ? (theme === 'dark' ? '#0A1612' : '#F4F0E8') : 'transparent',
      borderBottom: scrolled ? '1px solid var(--hairline)' : '1px solid transparent',
      transition: 'all 0.4s cubic-bezier(0.16,1,0.3,1)',
    }}>
      <div className="nav-inner" style={{ maxWidth: 1280, margin: '0 auto', padding: '0 48px', height: 68, display: 'flex', alignItems: 'center', gap: 40 }}>
        <a href="/" style={{ display: 'flex', alignItems: 'center', gap: 8, flexShrink: 0 }}>
          <LogoMark size={26} />
          <span style={{ fontFamily: 'var(--ff-display)', fontSize: 19, fontWeight: 500, letterSpacing: '-0.01em', color: 'var(--ink)' }}>Echo</span>
        </a>
        <div className="nav-links" style={{ flex: 1, display: 'flex', gap: 32, alignItems: 'center' }}>
          <SolutionsDropdownDetail />
          <AgentsDropdownDetail currentId={currentId} />
          {links.map(l => (
            <a key={l.label} href={l.href} style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.1em', color: 'var(--muted)', textTransform: 'uppercase', transition: 'color 0.2s', fontWeight: 500 }}
              onMouseEnter={e => e.target.style.color = 'var(--ink)'}
              onMouseLeave={e => e.target.style.color = 'var(--muted)'}
            >{l.label}</a>
          ))}
        </div>
        <div className="nav-right" style={{ display: 'flex', alignItems: 'center', gap: 14 }}>
          <button
            className="nav-hamburger"
            aria-label={mobileOpen ? 'Close menu' : 'Open menu'}
            aria-expanded={mobileOpen}
            onClick={() => setMobileOpen(o => !o)}
            style={{ background: 'none', border: 'none', cursor: 'pointer', color: mobileOpen ? '#F4F0E8' : 'var(--ink)', padding: 8, borderRadius: 8, alignItems: 'center', justifyContent: 'center', position: 'relative', zIndex: 160 }}
          >
            {mobileOpen
              ? <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round"><path d="M18 6L6 18M6 6l12 12"/></svg>
              : <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round"><path d="M3 6h18M3 12h18M3 18h18"/></svg>
            }
          </button>
          <a href="#book" data-open-book-call className="echo-cta echo-cta--nav">
            Get a demo
          </a>
        </div>
      </div>
      <MobileMenuDetail open={mobileOpen} onClose={() => setMobileOpen(false)} currentId={currentId} />
    </nav>
  );
}

// ── Hero ─────────────────────────────────────────────────────────
function AgentHero({ agent }) {
  const accent = agent.accent || 'var(--accent)';
  return (
    <section className="plate-section agent-hero-section" style={{ paddingTop: 100, paddingBottom: 40, position: 'relative', overflow: 'hidden' }}>
      <div className="glass-plate glass-plate--rounded" style={{ maxWidth: 1240, margin: '0 auto', padding: '64px 56px', position: 'relative', overflow: 'hidden' }}>
      <div style={{ position: 'absolute', inset: 0, pointerEvents: 'none', background: `radial-gradient(ellipse 50% 50% at 30% 30%, ${accent}22 0%, transparent 70%)` }} />
      <div style={{ position: 'relative' }}>
        {/* Breadcrumb */}
        <div style={{ animation: 'heroUp 0.6s cubic-bezier(0,0,0.2,1) both', marginBottom: 40, display: 'flex', alignItems: 'center', gap: 10 }}>
          <a href="../index.html#agents" style={{ display: 'inline-flex', alignItems: 'center', gap: 8, fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.08em', color: 'var(--muted)', textTransform: 'uppercase', transition: 'color 0.2s' }}
            onMouseEnter={e => e.currentTarget.style.color = 'var(--ink)'}
            onMouseLeave={e => e.currentTarget.style.color = 'var(--muted)'}
          >
            <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round"><path d="M19 12H5M12 19l-7-7 7-7"/></svg>
            All agents
          </a>
        </div>

        <div className="agent-hero-grid" style={{ display: 'grid', gridTemplateColumns: '1.6fr 1fr', gap: 80, alignItems: 'end' }}>
          <div style={{ animation: 'heroUp 0.7s cubic-bezier(0,0,0.2,1) both', animationDelay: '0.08s' }}>
            <div style={{ display: 'inline-flex', alignItems: 'center', gap: 8, fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.14em', color: accent, textTransform: 'uppercase', marginBottom: 18 }}>
              <span style={{ width: 6, height: 6, borderRadius: '50%', background: accent, boxShadow: `0 0 8px ${accent}88` }} />
              {agent.domain}
            </div>
            <h1 style={{ fontFamily: 'var(--ff-display)', fontSize: 'clamp(64px, 9vw, 128px)', fontWeight: 400, letterSpacing: '-0.04em', lineHeight: 0.92, color: 'var(--ink)', marginBottom: 20 }}>
              {agent.name}
            </h1>
            {agent.personality && (
              <p style={{ fontFamily: 'var(--ff-display)', fontSize: 'clamp(18px, 1.8vw, 22px)', fontWeight: 300, fontStyle: 'italic', color: accent, lineHeight: 1.4, letterSpacing: '-0.01em', maxWidth: 560, marginBottom: 18, opacity: 0.9 }}>
                {agent.personality}
              </p>
            )}
          </div>

          <div style={{ animation: 'heroUp 0.7s cubic-bezier(0,0,0.2,1) both', animationDelay: '0.18s', display: 'flex', flexDirection: 'column', gap: 14, paddingBottom: 6 }}>
            <div style={{ background: 'var(--surface)', border: '1px solid var(--hairline)', borderLeft: `2px solid ${accent}`, borderRadius: 12, padding: 22 }}>
              <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.1em', color: 'var(--muted)', textTransform: 'uppercase', marginBottom: 8 }}>Channel</div>
              <div style={{ fontFamily: 'var(--ff-display)', fontSize: 22, fontWeight: 400, letterSpacing: '-0.01em', color: 'var(--ink)', marginBottom: 4 }}>{agent.channel}</div>
              <div style={{ fontSize: 12, color: 'var(--muted)', lineHeight: 1.5 }}>{agent.channelSub}</div>
            </div>
            <div style={{ background: 'var(--surface)', border: '1px solid var(--hairline)', borderLeft: `2px solid ${accent}`, borderRadius: 12, padding: 22, display: 'flex', alignItems: 'flex-start', gap: 12 }}>
              <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke={accent} strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round" style={{ flexShrink: 0, marginTop: 2 }}><polyline points="20 6 9 17 4 12"/></svg>
              <div>
                <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.1em', color: 'var(--muted)', textTransform: 'uppercase', marginBottom: 6 }}>Outcome</div>
                <div style={{ fontSize: 14, color: 'var(--ink)', fontWeight: 500, lineHeight: 1.5 }}>{agent.outcome}</div>
              </div>
            </div>
          </div>
        </div>
      </div>
      </div>
    </section>
  );
}

// ── Overview + Metrics ───────────────────────────────────────────
function AgentOverview({ agent }) {
  return (
    <section className="plate-section" style={{ padding: '40px 0' }}>
      <div className="glass-plate glass-plate--rounded" style={{ maxWidth: 1240, margin: '0 auto', padding: '72px 56px' }}>
        <div className="agent-overview-grid" style={{ display: 'grid', gridTemplateColumns: '1fr 1.3fr', gap: 80, alignItems: 'start' }}>
          <div>
            <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.12em', color: 'var(--muted)', textTransform: 'uppercase', marginBottom: 18 }}>What {agent.name} does</div>
            <h2 style={{ fontFamily: 'var(--ff-display)', fontSize: 'clamp(28px, 3vw, 40px)', fontWeight: 400, letterSpacing: '-0.025em', lineHeight: 1.1, color: 'var(--ink)' }}>
              The work, <em style={{ fontStyle: 'italic', fontWeight: 300, color: 'var(--muted)' }}>handled.</em>
            </h2>
          </div>
          <div>
            <p style={{ fontSize: 17, color: 'var(--ink)', lineHeight: 1.65, marginBottom: 36, fontWeight: 400 }}>{agent.description}</p>
            <div className="agent-metrics" style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 14 }}>
              {agent.metrics.map((m, i) => (
                <div key={i} style={{ background: 'var(--bg)', border: '1px solid var(--hairline)', borderRadius: 10, padding: '20px 18px' }}>
                  <div style={{ fontFamily: 'var(--ff-display)', fontSize: 32, fontWeight: 400, letterSpacing: '-0.025em', color: 'var(--ink)', lineHeight: 1, marginBottom: 8 }}>{m.value}</div>
                  <div style={{ fontSize: 11, color: 'var(--muted)', lineHeight: 1.45 }}>{m.label}</div>
                </div>
              ))}
            </div>
          </div>
        </div>
      </div>
    </section>
  );
}

// ── Capabilities ─────────────────────────────────────────────────
function AgentCapabilities({ agent }) {
  const accent = agent.accent || 'var(--accent)';
  return (
    <section className="plate-section" style={{ padding: '40px 0' }}>
      <div className="glass-plate glass-plate--rounded" style={{ maxWidth: 1240, margin: '0 auto', padding: '72px 56px' }}>
        <div style={{ marginBottom: 56, maxWidth: 600 }}>
          <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.12em', color: 'var(--muted)', textTransform: 'uppercase', marginBottom: 18 }}>Capabilities</div>
          <h2 style={{ fontFamily: 'var(--ff-display)', fontSize: 'clamp(32px, 3.6vw, 50px)', fontWeight: 400, letterSpacing: '-0.025em', lineHeight: 1.05, color: 'var(--ink)' }}>
            What {agent.name} ships<br /><em style={{ fontStyle: 'italic', fontWeight: 300, color: 'var(--muted)' }}>out of the box.</em>
          </h2>
        </div>
        <div className="agent-cap-grid" style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', borderTop: '1px solid var(--hairline)', borderLeft: '1px solid var(--hairline)' }}>
          {agent.capabilities.map((cap, i) => (
            <div key={i} style={{
              padding: '36px 32px', borderRight: '1px solid var(--hairline)', borderBottom: '1px solid var(--hairline)',
              transition: 'background 0.25s',
            }}
              onMouseEnter={e => e.currentTarget.style.background = 'var(--surface)'}
              onMouseLeave={e => e.currentTarget.style.background = 'transparent'}
            >
              <div style={{ display: 'flex', alignItems: 'center', gap: 12, marginBottom: 16 }}>
                <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, color: accent, letterSpacing: '0.08em', fontWeight: 600 }}>{String(i + 1).padStart(2, '0')}</span>
                <span style={{ flex: 1, height: 1, background: 'var(--hairline)' }} />
              </div>
              <h3 style={{ fontFamily: 'var(--ff-display)', fontSize: 24, fontWeight: 400, letterSpacing: '-0.015em', color: 'var(--ink)', marginBottom: 10 }}>{cap.title}</h3>
              <p style={{ fontSize: 14, color: 'var(--muted)', lineHeight: 1.65 }}>{cap.body}</p>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

// ── Workflow ─────────────────────────────────────────────────────
function AgentWorkflow({ agent }) {
  const accent = agent.accent || 'var(--accent)';
  return (
    <section className="plate-section" style={{ padding: '40px 0' }}>
      <div className="glass-plate glass-plate--rounded" style={{ maxWidth: 1240, margin: '0 auto', padding: '72px 56px' }}>
        <div style={{ marginBottom: 56, maxWidth: 600 }}>
          <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.12em', color: 'var(--muted)', textTransform: 'uppercase', marginBottom: 18 }}>Dispatch to delivery</div>
          <h2 style={{ fontFamily: 'var(--ff-display)', fontSize: 'clamp(32px, 3.6vw, 50px)', fontWeight: 400, letterSpacing: '-0.025em', lineHeight: 1.05, color: 'var(--ink)' }}>
            One workflow,<br /><em style={{ fontStyle: 'italic', fontWeight: 300, color: 'var(--muted)' }}>start to finish.</em>
          </h2>
        </div>
        <div className="agent-workflow-grid" style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 0, position: 'relative' }}>
          {agent.workflow.map((w, i) => (
            <div key={i} style={{ position: 'relative', paddingRight: i < 3 ? 24 : 0 }}>
              <div style={{ background: 'var(--bg)', border: '1px solid var(--hairline)', borderRadius: 12, padding: '28px 22px', minHeight: 168, display: 'flex', flexDirection: 'column', gap: 14 }}>
                <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
                  <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.1em', color: accent, fontWeight: 600 }}>STEP {String(i + 1).padStart(2, '0')}</span>
                  {i < 3 && (
                    <svg data-workflow-arrow width="18" height="18" viewBox="0 0 24 24" fill="none" stroke={accent} strokeWidth="1.8" strokeLinecap="round" style={{ opacity: 0.55 }}><path d="M5 12h14M12 5l7 7-7 7"/></svg>
                  )}
                </div>
                <h4 style={{ fontFamily: 'var(--ff-display)', fontSize: 20, fontWeight: 400, letterSpacing: '-0.01em', color: 'var(--ink)', lineHeight: 1.2 }}>{w.step}</h4>
                <p style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, color: 'var(--muted)', lineHeight: 1.55, letterSpacing: '0.02em', marginTop: 'auto' }}>{w.detail}</p>
              </div>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

// ── In Action ────────────────────────────────────────────────────
function AgentInAction({ agent }) {
  const accent = agent.accent || 'var(--accent)';
  const inAction = agent.inAction;
  if (!inAction) return null;

  const renderMockup = () => {
    if (inAction.type === 'teams') return <TeamsCardMockup accent={accent} payload={inAction.payload} />;
    if (inAction.type === 'pod')   return <PodCardMockup accent={accent} payload={inAction.payload} />;
    if (inAction.type === 'sms')   return <SmsThreadMockup accent={accent} payload={inAction.payload} />;
    if (inAction.type === 'detention') return <DetentionCardMockup accent={accent} payload={inAction.payload} />;
    return null;
  };

  return (
    <section className="plate-section" style={{ padding: '40px 0' }}>
      <div className="glass-plate glass-plate--rounded" style={{ maxWidth: 1240, margin: '0 auto', padding: '72px 56px' }}>
        <div className="agent-inaction-grid" style={{ display: 'grid', gridTemplateColumns: '1fr 1.2fr', gap: 64, alignItems: 'start' }}>
          <div>
            <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.12em', color: 'var(--muted)', textTransform: 'uppercase', marginBottom: 18 }}>In action</div>
            <h2 style={{ fontFamily: 'var(--ff-display)', fontSize: 'clamp(32px, 3.6vw, 50px)', fontWeight: 400, letterSpacing: '-0.025em', lineHeight: 1.05, color: 'var(--ink)', marginBottom: 22 }}>
              See {agent.name} <em style={{ fontStyle: 'italic', fontWeight: 300, color: 'var(--muted)' }}>handle a real one.</em>
            </h2>
            <p style={{ fontSize: 15, color: 'var(--muted)', lineHeight: 1.65, maxWidth: 380 }}>
              {agent.outcome} Below is a sample run on live data, with every field {agent.name} extracted and the action it took.
            </p>
          </div>
          <div>
            {renderMockup()}
          </div>
        </div>
      </div>
    </section>
  );
}

function TeamsCardMockup({ accent, payload }) {
  return (
    <div style={{ background: 'var(--bg)', border: '1px solid var(--hairline)', borderRadius: 12, overflow: 'hidden' }}>
      <div style={{ padding: '14px 18px', borderBottom: '1px solid var(--hairline)', display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
        <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
          <span style={{ width: 8, height: 8, borderRadius: '50%', background: accent, boxShadow: `0 0 8px ${accent}88` }} />
          <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.08em', color: accent, fontWeight: 600 }}>CSR · TEAMS</span>
        </div>
        <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, color: 'var(--muted)' }}>{payload.intent} · {payload.confidence}% conf</span>
      </div>
      <div style={{ padding: 20, borderBottom: '1px solid var(--hairline)' }}>
        <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, color: 'var(--muted)', textTransform: 'uppercase', letterSpacing: '0.08em', marginBottom: 6 }}>Inbound</div>
        <div style={{ fontSize: 13, color: 'var(--ink)', fontWeight: 500, marginBottom: 4 }}>{payload.subject}</div>
        <div style={{ fontSize: 12, color: 'var(--muted)', marginBottom: 10 }}>{payload.from}</div>
        <div style={{ fontSize: 13, color: 'var(--ink)', lineHeight: 1.6, fontStyle: 'italic', borderLeft: `2px solid ${accent}`, paddingLeft: 12 }}>{payload.excerpt}</div>
      </div>
      <div style={{ padding: 20, borderBottom: '1px solid var(--hairline)' }}>
        <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, color: 'var(--muted)', textTransform: 'uppercase', letterSpacing: '0.08em', marginBottom: 12 }}>Data pulled from TruckMate</div>
        <div className="agent-mockup-fields-2col" style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: 10 }}>
          {payload.pulled.map((f, i) => (
            <div key={i}>
              <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 9.5, color: 'var(--muted)', letterSpacing: '0.06em', textTransform: 'uppercase', marginBottom: 3 }}>{f.label}</div>
              <div style={{ fontSize: 12.5, color: 'var(--ink)', fontWeight: 500 }}>{f.value}</div>
            </div>
          ))}
        </div>
      </div>
      <div style={{ padding: 20 }}>
        <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, color: 'var(--muted)', textTransform: 'uppercase', letterSpacing: '0.08em', marginBottom: 10 }}>Drafted reply</div>
        <div style={{ fontSize: 13, color: 'var(--ink)', lineHeight: 1.6, marginBottom: 14 }}>{payload.draft}</div>
        <div style={{ display: 'flex', gap: 8 }}>
          <span style={{ background: accent, color: '#fff', padding: '8px 14px', borderRadius: 6, fontFamily: 'var(--ff-mono)', fontSize: 10.5, letterSpacing: '0.08em', textTransform: 'uppercase', fontWeight: 600 }}>Send from Outlook</span>
          <span style={{ border: '1px solid var(--hairline)', color: 'var(--muted)', padding: '8px 14px', borderRadius: 6, fontFamily: 'var(--ff-mono)', fontSize: 10.5, letterSpacing: '0.08em', textTransform: 'uppercase' }}>Edit</span>
        </div>
      </div>
    </div>
  );
}

function PodCardMockup({ accent, payload }) {
  return (
    <div style={{ background: 'var(--bg)', border: '1px solid var(--hairline)', borderRadius: 12, overflow: 'hidden' }}>
      <div style={{ padding: '14px 18px', borderBottom: '1px solid var(--hairline)', display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
        <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
          <span style={{ width: 8, height: 8, borderRadius: '50%', background: accent, boxShadow: `0 0 8px ${accent}88` }} />
          <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.08em', color: accent, fontWeight: 600 }}>POD · PRO# {payload.pro}</span>
        </div>
        <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, color: 'var(--muted)' }}>{payload.source}</span>
      </div>
      <div style={{ padding: 20, borderBottom: '1px solid var(--hairline)' }}>
        <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, color: 'var(--muted)', textTransform: 'uppercase', letterSpacing: '0.08em', marginBottom: 4 }}>Consignee</div>
        <div style={{ fontSize: 14, color: 'var(--ink)', fontWeight: 500 }}>{payload.consignee}</div>
      </div>
      <div style={{ padding: 20, borderBottom: '1px solid var(--hairline)' }}>
        <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, color: 'var(--muted)', textTransform: 'uppercase', letterSpacing: '0.08em', marginBottom: 12 }}>Extracted fields</div>
        {payload.fields.map((f, i) => (
          <div key={i} className="agent-mockup-pod-row" style={{ display: 'grid', gridTemplateColumns: '110px 1fr 50px', gap: 10, padding: '6px 0', borderBottom: i < payload.fields.length - 1 ? '1px dashed var(--hairline)' : 'none', alignItems: 'center' }}>
            <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, color: 'var(--muted)', letterSpacing: '0.06em', textTransform: 'uppercase' }}>{f.label}</div>
            <div style={{ fontSize: 12.5, color: 'var(--ink)', fontWeight: 500 }}>{f.value}</div>
            <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10.5, color: accent, fontWeight: 600, textAlign: 'right' }}>{f.conf}%</div>
          </div>
        ))}
      </div>
      <div style={{ padding: '16px 20px', display: 'flex', alignItems: 'center', gap: 10 }}>
        <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke={accent} strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round"><polyline points="20 6 9 17 4 12"/></svg>
        <span style={{ fontSize: 12.5, color: 'var(--ink)', fontWeight: 500 }}>{payload.action}</span>
      </div>
    </div>
  );
}

function SmsThreadMockup({ accent, payload }) {
  return (
    <div style={{ background: 'var(--bg)', border: '1px solid var(--hairline)', borderRadius: 12, overflow: 'hidden' }}>
      <div style={{ padding: '14px 18px', borderBottom: '1px solid var(--hairline)', display: 'flex', alignItems: 'center', gap: 10 }}>
        <span style={{ width: 8, height: 8, borderRadius: '50%', background: accent, boxShadow: `0 0 8px ${accent}88` }} />
        <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.08em', color: accent, fontWeight: 600 }}>SMS · DISPATCH ↔ CAL</span>
      </div>
      <div style={{ padding: 18, display: 'flex', flexDirection: 'column', gap: 10 }}>
        {payload.thread.map((m, i) => {
          const isCal = m.from === 'cal';
          return (
            <div key={i} style={{ display: 'flex', justifyContent: isCal ? 'flex-end' : 'flex-start' }}>
              <div style={{
                maxWidth: '78%',
                background: isCal ? accent : 'var(--surface)',
                color: isCal ? '#fff' : 'var(--ink)',
                padding: '10px 14px',
                borderRadius: 14,
                borderBottomRightRadius: isCal ? 4 : 14,
                borderBottomLeftRadius: isCal ? 14 : 4,
                fontSize: 13,
                lineHeight: 1.55,
              }}>
                <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 9.5, opacity: 0.75, letterSpacing: '0.06em', textTransform: 'uppercase', marginBottom: 3 }}>{isCal ? 'Cal' : 'Dispatch'}</div>
                {m.text}
              </div>
            </div>
          );
        })}
      </div>
    </div>
  );
}

function DetentionCardMockup({ accent, payload }) {
  return (
    <div style={{ background: 'var(--bg)', border: '1px solid var(--hairline)', borderRadius: 12, overflow: 'hidden' }}>
      <div style={{ padding: '14px 18px', borderBottom: '1px solid var(--hairline)', display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
        <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
          <span style={{ width: 8, height: 8, borderRadius: '50%', background: accent, boxShadow: `0 0 8px ${accent}88` }} />
          <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.08em', color: accent, fontWeight: 600 }}>DETENTION · PRO# {payload.pro}</span>
        </div>
        <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, color: 'var(--muted)' }}>{payload.consignee}</span>
      </div>
      <div className="agent-mockup-stats-3col" style={{ padding: 20, borderBottom: '1px solid var(--hairline)', display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 14 }}>
        <div>
          <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, color: 'var(--muted)', letterSpacing: '0.06em', textTransform: 'uppercase', marginBottom: 4 }}>Free time</div>
          <div style={{ fontFamily: 'var(--ff-display)', fontSize: 20, color: 'var(--ink)' }}>{payload.freeTime}</div>
        </div>
        <div>
          <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, color: 'var(--muted)', letterSpacing: '0.06em', textTransform: 'uppercase', marginBottom: 4 }}>Actual</div>
          <div style={{ fontFamily: 'var(--ff-display)', fontSize: 20, color: 'var(--ink)' }}>{payload.actual}</div>
        </div>
        <div>
          <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, color: accent, letterSpacing: '0.06em', textTransform: 'uppercase', marginBottom: 4 }}>Chargeable</div>
          <div style={{ fontFamily: 'var(--ff-display)', fontSize: 20, color: accent, fontWeight: 500 }}>{payload.chargeable}</div>
        </div>
      </div>
      <div style={{ padding: 20, borderBottom: '1px solid var(--hairline)' }}>
        <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, color: 'var(--muted)', textTransform: 'uppercase', letterSpacing: '0.08em', marginBottom: 12 }}>Evidence packaged</div>
        <div className="agent-mockup-fields-2col" style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: 10 }}>
          {payload.evidence.map((e, i) => (
            <div key={i}>
              <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 9.5, color: 'var(--muted)', letterSpacing: '0.06em', textTransform: 'uppercase', marginBottom: 3 }}>{e.label}</div>
              <div style={{ fontSize: 12.5, color: 'var(--ink)', fontWeight: 500 }}>{e.value}</div>
            </div>
          ))}
        </div>
      </div>
      <div style={{ padding: '16px 20px', display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
        <span style={{ fontSize: 12.5, color: 'var(--ink)', fontWeight: 500 }}>{payload.action}</span>
        <span style={{ fontFamily: 'var(--ff-display)', fontSize: 22, color: accent, fontWeight: 500 }}>{payload.amount}</span>
      </div>
    </div>
  );
}

// ── ROI Calculator ───────────────────────────────────────────────
function AgentROI({ agent }) {
  const accent = agent.accent || 'var(--accent)';

  // Per-agent default state + compute
  const config = roiConfig(agent.id);
  const [inputs, setInputs] = useState(config.defaults);
  const outputs = computeRoi(agent.id, inputs);

  return (
    <section className="plate-section" style={{ padding: '40px 0' }}>
      <div className="glass-plate glass-plate--rounded" style={{ maxWidth: 1240, margin: '0 auto', padding: '72px 56px' }}>
        <div style={{ marginBottom: 48, maxWidth: 640 }}>
          <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.12em', color: 'var(--muted)', textTransform: 'uppercase', marginBottom: 18 }}>ROI snapshot</div>
          <h2 style={{ fontFamily: 'var(--ff-display)', fontSize: 'clamp(32px, 3.6vw, 50px)', fontWeight: 400, letterSpacing: '-0.025em', lineHeight: 1.05, color: 'var(--ink)' }}>
            What {agent.name} <em style={{ fontStyle: 'italic', fontWeight: 300, color: 'var(--muted)' }}>could save you.</em>
          </h2>
        </div>
        <div className="agent-roi-grid" style={{ display: 'grid', gridTemplateColumns: '1fr 1.2fr', gap: 56, alignItems: 'start' }}>
          <div style={{ display: 'flex', flexDirection: 'column', gap: 22 }}>
            <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.1em', color: 'var(--muted)', textTransform: 'uppercase', marginBottom: -4 }}>Your numbers</div>
            {config.inputs.map(field => (
              <RoiInput key={field.key} field={field} value={inputs[field.key]} accent={accent}
                onChange={v => setInputs(prev => ({ ...prev, [field.key]: v }))}
              />
            ))}
          </div>
          <div className="agent-roi-outputs" style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: 14 }}>
            {outputs.map((o, i) => (
              <div key={i} style={{
                background: i === 0 ? `linear-gradient(180deg, ${accent}18 0%, var(--bg) 100%)` : 'var(--bg)',
                border: `1px solid ${i === 0 ? accent + '55' : 'var(--hairline)'}`,
                borderRadius: 12, padding: '24px 22px',
                display: 'flex', flexDirection: 'column', gap: 10,
              }}>
                <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, color: 'var(--muted)', letterSpacing: '0.08em', textTransform: 'uppercase' }}>{o.label}</div>
                <div style={{ fontFamily: 'var(--ff-display)', fontSize: 36, fontWeight: 400, letterSpacing: '-0.025em', color: i === 0 ? accent : 'var(--ink)', lineHeight: 1 }}>{o.value}</div>
                {o.caption && <div style={{ fontSize: 12, color: 'var(--muted)', lineHeight: 1.5 }}>{o.caption}</div>}
              </div>
            ))}
          </div>
        </div>
      </div>
    </section>
  );
}

function RoiInput({ field, value, onChange, accent }) {
  const [raw, setRaw] = useState(String(value));
  useEffect(() => { setRaw(String(value)); }, [value]);
  return (
    <label style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
      <span style={{ fontSize: 13, color: 'var(--ink)', fontWeight: 500 }}>{field.label}</span>
      <div style={{ display: 'flex', alignItems: 'center', gap: 10, border: '1px solid var(--hairline)', borderRadius: 10, padding: '10px 14px', background: 'var(--bg)' }}>
        <input
          type="text"
          inputMode="numeric"
          value={raw}
          onChange={e => {
            const v = e.target.value.replace(/[^0-9]/g, '');
            setRaw(v);
            onChange(v === '' ? 0 : parseInt(v, 10));
          }}
          onFocus={e => { if (raw === '0') { setRaw(''); } }}
          onBlur={e => { if (raw === '') { setRaw('0'); onChange(0); } }}
          style={{
            flex: 1, background: 'transparent', border: 'none', outline: 'none',
            fontFamily: 'var(--ff-display)', fontSize: 22, color: 'var(--ink)', fontWeight: 500,
            letterSpacing: '-0.01em', minWidth: 0,
          }}
        />
        <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, color: accent, letterSpacing: '0.06em', textTransform: 'uppercase', fontWeight: 600 }}>{field.unit}</span>
      </div>
      {field.hint && <span style={{ fontSize: 11, color: 'var(--muted)', fontFamily: 'var(--ff-mono)', letterSpacing: '0.04em' }}>{field.hint}</span>}
    </label>
  );
}

function roiConfig(id) {
  switch (id) {
    case 'triage':
      return {
        defaults: { emails: 200, minutes: 5 },
        inputs: [
          { key: 'emails',  label: 'Inbound CSR emails per day',  unit: 'emails',  hint: 'Industry avg for a mid-size carrier: 150-300' },
          { key: 'minutes', label: 'Average minutes per email',   unit: 'min',     hint: 'Read, look up, draft, send' },
        ],
      };
    case 'docs':
      return {
        defaults: { pods: 150 },
        inputs: [
          { key: 'pods', label: 'PODs processed per day', unit: 'pods', hint: 'Driver uploads + email + EDI combined' },
        ],
      };
    case 'cal':
      return {
        defaults: { bookings: 80 },
        inputs: [
          { key: 'bookings', label: 'Dock bookings per week', unit: 'bookings', hint: 'Inbound + outbound across all dock doors' },
        ],
      };
    case 'ledger':
      return {
        defaults: { events: 40 },
        inputs: [
          { key: 'events', label: 'Detention events per month', unit: 'events', hint: 'Loads that exceed free time and qualify for billing' },
        ],
      };
    default:
      return { defaults: {}, inputs: [] };
  }
}

function computeRoi(id, i) {
  const fmt = n => n.toLocaleString('en-US', { maximumFractionDigits: 0 });
  const fmtMoney = n => '$' + n.toLocaleString('en-US', { maximumFractionDigits: 0 });
  switch (id) {
    case 'triage': {
      const minsPerWeek = i.emails * i.minutes * 5;
      const hrsPerWeek = minsPerWeek / 60;
      const hrsPerYear = hrsPerWeek * 52;
      const dollars = hrsPerYear * 35;
      return [
        { label: 'Hours saved per week',   value: fmt(hrsPerWeek) + ' hrs', caption: 'Across your CSR team' },
        { label: 'Annual time recovered',  value: fmt(hrsPerYear) + ' hrs', caption: 'Per year, baseline volume' },
        { label: 'Dollars saved per year', value: fmtMoney(dollars),        caption: 'At a $35/hr loaded CSR rate' },
        { label: 'Full-time equivalents',  value: fmt(hrsPerYear / 2080) + ' FTE', caption: 'Capacity returned to your team' },
      ];
    }
    case 'docs': {
      const minsSaved = i.pods * 4;
      const hrsPerDay = minsSaved / 60;
      const hrsPerYear = hrsPerDay * 250;
      const dollars = hrsPerYear * 32;
      return [
        { label: 'Hours saved per day',   value: fmt(hrsPerDay) + ' hrs', caption: 'AR clerk time on POD posting' },
        { label: 'Backlog cleared',       value: 'Same shift',            caption: 'No documents roll to next day' },
        { label: 'Hours saved per year',  value: fmt(hrsPerYear) + ' hrs', caption: '250 working days' },
        { label: 'Dollars saved per year', value: fmtMoney(dollars),      caption: 'At a $32/hr loaded AR rate' },
      ];
    }
    case 'cal': {
      const minsSaved = i.bookings * 6;
      const hrsPerWeek = minsSaved / 60;
      const hrsPerYear = hrsPerWeek * 52;
      const dollars = hrsPerYear * 34;
      return [
        { label: 'Hours saved per week',  value: fmt(hrsPerWeek) + ' hrs', caption: 'Dispatcher time on booking' },
        { label: 'Phone tag reduced',     value: '85%',                   caption: 'Bookings handled via SMS' },
        { label: 'Hours per year',        value: fmt(hrsPerYear) + ' hrs', caption: 'Across the dispatch team' },
        { label: 'Dollars saved per year', value: fmtMoney(dollars),      caption: 'At a $34/hr dispatcher rate' },
      ];
    }
    case 'ledger': {
      const recoveredPerMonth = i.events * 285;
      const recoveredPerYear = recoveredPerMonth * 12;
      return [
        { label: 'Recovered per month',  value: fmtMoney(recoveredPerMonth), caption: 'Avg $285 per detention event billed' },
        { label: 'Recovered per year',   value: fmtMoney(recoveredPerYear),  caption: 'Detention only, before accessorials' },
        { label: 'Capture rate',         value: '100%',                      caption: 'Every qualifying event flagged' },
        { label: 'Time to billable',     value: '< 24 hrs',                  caption: 'Event to packaged claim' },
      ];
    }
    default:
      return [];
  }
}

// ── Integrations ─────────────────────────────────────────────────
function AgentIntegrations({ agent }) {
  const accent = agent.accent || 'var(--accent)';
  return (
    <section className="plate-section" style={{ padding: '40px 0' }}>
      <div className="glass-plate glass-plate--rounded" style={{ maxWidth: 1240, margin: '0 auto', padding: '72px 56px' }}>
        <div className="agent-integrations-grid" style={{ display: 'grid', gridTemplateColumns: '1fr 1.4fr', gap: 80, alignItems: 'start' }}>
          <div>
            <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.12em', color: 'var(--muted)', textTransform: 'uppercase', marginBottom: 18 }}>Integrations</div>
            <h2 style={{ fontFamily: 'var(--ff-display)', fontSize: 'clamp(32px, 3.6vw, 50px)', fontWeight: 400, letterSpacing: '-0.025em', lineHeight: 1.1, color: 'var(--ink)', marginBottom: 24 }}>
              Plugs into <em style={{ fontStyle: 'italic', fontWeight: 300, color: 'var(--muted)' }}>your stack.</em>
            </h2>
            <p style={{ fontSize: 14, color: 'var(--muted)', lineHeight: 1.7, maxWidth: 360 }}>
              Read-write access inside your tenant. No data egress. Your systems, your audit trail.
            </p>
          </div>
          <div>
            <div className="agent-integrations-list" style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: 0, border: '1px solid var(--hairline)', borderRadius: 12, overflow: 'hidden', marginBottom: 28 }}>
              {agent.integrations.map((name, i) => (
                <div key={i} style={{
                  padding: '22px 24px',
                  borderRight: i % 2 === 0 ? '1px solid var(--hairline)' : 'none',
                  borderBottom: i < agent.integrations.length - 2 ? '1px solid var(--hairline)' : 'none',
                  display: 'flex', alignItems: 'center', gap: 12,
                }}>
                  <div style={{ width: 8, height: 8, borderRadius: '50%', background: accent, flexShrink: 0, boxShadow: `0 0 8px ${accent}66` }} />
                  <span style={{ fontSize: 13, color: 'var(--ink)', fontWeight: 500 }}>{name}</span>
                </div>
              ))}
            </div>
            <div style={{ borderTop: '1px solid var(--hairline)', paddingTop: 24 }}>
              <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.1em', color: 'var(--muted)', textTransform: 'uppercase', marginBottom: 12 }}>Escalation triggers</div>
              <p style={{ fontSize: 13, color: 'var(--ink)', lineHeight: 1.7 }}>{agent.escalations}</p>
            </div>
          </div>
        </div>
      </div>
    </section>
  );
}

// ── Other agents ─────────────────────────────────────────────────
function OtherAgents({ currentId }) {
  const order = window.ECHO_AGENT_ORDER;
  const others = order.filter(id => id !== currentId).map(id => window.ECHO_AGENTS[id]);
  return (
    <section className="plate-section" style={{ padding: '40px 0' }}>
      <div className="glass-plate glass-plate--rounded" style={{ maxWidth: 1240, margin: '0 auto', padding: '72px 56px' }}>
        <div className="agent-others-header" style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-end', marginBottom: 48, gap: 24 }}>
          <div>
            <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.12em', color: 'var(--muted)', textTransform: 'uppercase', marginBottom: 18 }}>The rest of the team</div>
            <h2 style={{ fontFamily: 'var(--ff-display)', fontSize: 'clamp(30px, 3.5vw, 46px)', fontWeight: 400, letterSpacing: '-0.025em', lineHeight: 1.05, color: 'var(--ink)' }}>
              Three more agents,<br /><em style={{ fontStyle: 'italic', fontWeight: 300, color: 'var(--muted)' }}>all on the same stack.</em>
            </h2>
          </div>
          <a href="../index.html#agents" style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.08em', color: 'var(--muted)', display: 'flex', alignItems: 'center', gap: 7, borderBottom: '1px solid var(--hairline)', paddingBottom: 2, textTransform: 'uppercase', transition: 'all 0.2s' }}
            onMouseEnter={e => { e.currentTarget.style.color = 'var(--ink)'; e.currentTarget.style.borderColor = 'var(--ink)'; }}
            onMouseLeave={e => { e.currentTarget.style.color = 'var(--muted)'; e.currentTarget.style.borderColor = 'var(--hairline)'; }}
          >
            All agents
            <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
          </a>
        </div>
        <div className="agent-others-grid" style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 14 }}>
          {others.map(a => <OtherAgentCard key={a.id} agent={a} />)}
        </div>
      </div>
    </section>
  );
}

function OtherAgentCard({ agent }) {
  const [hovered, setHovered] = useState(false);
  const accent = agent.accent || 'var(--accent)';
  return (
    <a href={`${agent.id}.html`}
      onMouseEnter={() => setHovered(true)} onMouseLeave={() => setHovered(false)}
      style={{
        background: 'var(--bg)',
        border: `1px solid ${hovered ? accent : 'var(--hairline)'}`,
        borderLeft: `3px solid ${hovered ? accent : 'var(--hairline)'}`,
        borderRadius: 12, padding: '28px 24px', display: 'flex', flexDirection: 'column', gap: 16,
        cursor: 'pointer', transform: hovered ? 'translateY(-3px)' : 'none',
        boxShadow: hovered ? `0 12px 40px ${accent}33` : 'none',
        transition: 'all 0.28s cubic-bezier(0.4,0,0.2,1)', textDecoration: 'none',
      }}>
      <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start' }}>
        <span style={{ display: 'inline-flex', alignItems: 'center', gap: 7, fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.1em', color: hovered ? accent : 'var(--muted)' }}>
          <span style={{ width: 6, height: 6, borderRadius: '50%', background: accent, opacity: hovered ? 1 : 0.55, transition: 'opacity 0.25s' }} />
          {agent.domain.toUpperCase()}
        </span>
        <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke={hovered ? accent : 'var(--muted)'} strokeWidth="2" strokeLinecap="round" style={{ transition: 'all 0.28s', transform: hovered ? 'translate(2px, -2px)' : 'none' }}><path d="M7 17L17 7M7 7h10v10"/></svg>
      </div>
      <div>
        <div style={{ fontFamily: 'var(--ff-display)', fontSize: 34, fontWeight: 400, letterSpacing: '-0.02em', lineHeight: 1, marginBottom: 4 }}>{agent.name}</div>
        <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.08em', color: accent, textTransform: 'uppercase' }}>{agent.channel}</div>
      </div>
      <p style={{ fontSize: 13, color: 'var(--muted)', lineHeight: 1.6 }}>{agent.personality}</p>
    </a>
  );
}

// ── Testimonials ─────────────────────────────────────────────────
function AgentTestimonials({ agent }) {
  const accent = agent.accent || 'var(--accent)';
  const items = agent.testimonials || [];

  return (
    <section className="plate-section" style={{ padding: '40px 0' }}>
      <div className="glass-plate glass-plate--rounded" style={{ maxWidth: 1240, margin: '0 auto', padding: '72px 56px' }}>
        <div style={{ marginBottom: 48, maxWidth: 640 }}>
          <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.12em', color: 'var(--muted)', textTransform: 'uppercase', marginBottom: 18 }}>From the field</div>
          <h2 style={{ fontFamily: 'var(--ff-display)', fontSize: 'clamp(32px, 3.6vw, 50px)', fontWeight: 400, letterSpacing: '-0.025em', lineHeight: 1.05, color: 'var(--ink)' }}>
            What teams say about <em style={{ fontStyle: 'italic', fontWeight: 300, color: 'var(--muted)' }}>{agent.name}.</em>
          </h2>
        </div>
        {items.length === 0 ? (
          <p style={{ fontSize: 14, color: 'var(--muted)' }}>Customer testimonials coming soon.</p>
        ) : (
          <div className="agent-testimonials-grid" style={{ display: 'grid', gridTemplateColumns: items.length > 1 ? 'repeat(2, 1fr)' : '1fr', gap: 16 }}>
            {items.map((t, i) => (
              <figure key={i} style={{
                background: 'var(--bg)', border: '1px solid var(--hairline)', borderLeft: `2px solid ${accent}`,
                borderRadius: 12, padding: '32px 30px', margin: 0,
                display: 'flex', flexDirection: 'column', gap: 22,
              }}>
                <svg width="22" height="18" viewBox="0 0 24 24" fill={accent} style={{ opacity: 0.65 }}>
                  <path d="M9.5 4 7 8.5v6.5h6V8.5H9l2-4.5h-1.5zM18 4l-2.5 4.5v6.5h6V8.5h-4l2-4.5H18z"/>
                </svg>
                <blockquote style={{ margin: 0, fontFamily: 'var(--ff-display)', fontSize: 19, lineHeight: 1.5, color: 'var(--ink)', fontWeight: 400, letterSpacing: '-0.005em' }}>
                  {t.quote}
                </blockquote>
                <figcaption style={{ display: 'flex', alignItems: 'center', gap: 14, marginTop: 'auto' }}>
                  <div aria-hidden="true" style={{
                    width: 40, height: 40, borderRadius: '50%',
                    background: `linear-gradient(135deg, ${accent} 0%, ${accent}55 100%)`,
                    display: 'flex', alignItems: 'center', justifyContent: 'center',
                    color: '#fff', fontFamily: 'var(--ff-mono)', fontSize: 13, fontWeight: 600, letterSpacing: '0.04em',
                  }}>
                    {(t.name || '?').split(' ').map(s => s[0]).slice(0, 2).join('').toUpperCase()}
                  </div>
                  <div>
                    <div style={{ fontSize: 13, color: 'var(--ink)', fontWeight: 500 }}>{t.name}</div>
                    <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, color: 'var(--muted)', letterSpacing: '0.04em' }}>{t.title}</div>
                  </div>
                </figcaption>
              </figure>
            ))}
          </div>
        )}
      </div>
    </section>
  );
}

// ── FAQ ──────────────────────────────────────────────────────────
function AgentFaqItem({ q, a, open, onToggle, isLast, accent }) {
  return (
    <div style={{ borderBottom: isLast ? 'none' : '1px solid var(--hairline)' }}>
      <button
        onClick={onToggle}
        aria-expanded={open}
        style={{
          width: '100%',
          display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 24,
          padding: '22px 4px',
          background: 'none', border: 'none', cursor: 'pointer',
          textAlign: 'left', color: 'inherit', transition: 'color 0.2s',
        }}
      >
        <span style={{
          fontFamily: 'var(--ff-display)', fontSize: 18, fontWeight: 400,
          letterSpacing: '-0.005em', lineHeight: 1.35,
          color: open ? accent : 'var(--ink)',
          transition: 'color 0.2s',
        }}>{q}</span>
        <span style={{
          flexShrink: 0,
          width: 28, height: 28, borderRadius: '50%',
          border: `1px solid ${open ? accent : 'var(--hairline)'}`,
          display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
          color: open ? accent : 'var(--muted)',
          transition: 'border-color 0.25s, color 0.25s',
        }}>
          <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" style={{ transform: open ? 'rotate(180deg)' : 'none', transition: 'transform 0.28s cubic-bezier(0.4,0,0.2,1)' }}>
            <path d="M6 9l6 6 6-6"/>
          </svg>
        </span>
      </button>
      <div style={{
        maxHeight: open ? 320 : 0,
        opacity: open ? 1 : 0,
        overflow: 'hidden',
        transition: 'max-height 0.4s cubic-bezier(0.16,1,0.3,1), opacity 0.3s ease, padding 0.3s ease',
        paddingBottom: open ? 22 : 0,
      }}>
        <p style={{ fontSize: 14.5, color: 'var(--muted)', lineHeight: 1.7, maxWidth: 720, paddingRight: 52 }}>{a}</p>
      </div>
    </div>
  );
}

function AgentFAQ({ agent }) {
  const accent = agent.accent || 'var(--accent)';
  const [openIdx, setOpenIdx] = useState(-1);
  const items = agent.faq || [];
  if (items.length === 0) return null;

  return (
    <section className="plate-section" style={{ padding: '40px 0' }}>
      <div className="glass-plate glass-plate--rounded" style={{ maxWidth: 1240, margin: '0 auto', padding: '52px 56px' }}>
        <div className="agent-faq-grid" style={{ display: 'grid', gridTemplateColumns: '320px 1fr', gap: 64, alignItems: 'start' }}>
          <div>
            <h2 style={{ fontFamily: 'var(--ff-display)', fontSize: 'clamp(28px, 3vw, 40px)', fontWeight: 400, letterSpacing: '-0.02em', lineHeight: 1.1, color: 'var(--ink)' }}>
              What carriers ask about <em style={{ fontStyle: 'italic', fontWeight: 300, color: 'var(--muted)' }}>{agent.name}.</em>
            </h2>
          </div>
          <div>
            {items.map((it, i) => (
              <AgentFaqItem
                key={i}
                q={it.q}
                a={it.a}
                open={openIdx === i}
                onToggle={() => setOpenIdx(openIdx === i ? -1 : i)}
                isLast={i === items.length - 1}
                accent={accent}
              />
            ))}
          </div>
        </div>
      </div>
    </section>
  );
}

// ── CTA ──────────────────────────────────────────────────────────
function AgentCTA({ agent }) {
  const accent = agent.accent || 'var(--accent)';
  return (
    <section className="plate-section" style={{ padding: '40px 0' }}>
      <div className="glass-plate glass-plate--rounded" style={{ maxWidth: 880, margin: '0 auto', padding: '64px 56px', textAlign: 'center', position: 'relative', overflow: 'hidden' }}>
        <div style={{ position: 'absolute', inset: 0, pointerEvents: 'none', background: `radial-gradient(ellipse 70% 80% at 50% 100%, ${accent}1f 0%, transparent 65%)` }} />
        <div style={{ position: 'relative' }}>
          <VerticalCrossLinks accent={accent} />
          <h2 style={{ fontFamily: 'var(--ff-display)', fontSize: 'clamp(36px, 4.6vw, 60px)', fontWeight: 400, letterSpacing: '-0.03em', lineHeight: 1.0, color: 'var(--ink)', marginBottom: 20 }}>
            See {agent.name} <em style={{ fontStyle: 'italic', fontWeight: 300, color: 'var(--muted)' }}>at work.</em>
          </h2>
          <p style={{ fontSize: 16, color: 'var(--muted)', lineHeight: 1.65, marginBottom: 36, maxWidth: 480, margin: '0 auto 36px' }}>
            A 30-minute walkthrough on your live data.
          </p>
          <div className="agent-cta-buttons" style={{ display: 'flex', gap: 14, justifyContent: 'center', flexWrap: 'wrap' }}>
            <a href="#book" data-open-book-call className="echo-cta echo-cta--primary">
              Get a demo
            </a>
          </div>
        </div>
      </div>
    </section>
  );
}

// ── Vertical cross-links (above CTA headline) ────────────────────
function VerticalCrossLinks({ accent }) {
  const verticals = [
    { label: 'ERP',      href: '/erp' },
    { label: 'Freight',  href: '/freight' },
    { label: 'Health',   href: '/health' },
  ];
  return (
    <div className="agent-vertical-pills" style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 10, marginBottom: 22, flexWrap: 'wrap' }}>
      <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.12em', color: 'var(--muted)', textTransform: 'uppercase' }}>
        Echo also runs in
      </span>
      {verticals.map(v => (
        <a key={v.href} href={v.href}
          style={{
            fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.1em', textTransform: 'uppercase', fontWeight: 600,
            color: 'var(--ink)', background: 'var(--surface)',
            border: '1px solid var(--hairline)', borderRadius: 999,
            padding: '5px 12px', textDecoration: 'none',
            transition: 'all 0.2s',
          }}
          onMouseEnter={e => { e.currentTarget.style.color = accent; e.currentTarget.style.borderColor = accent; }}
          onMouseLeave={e => { e.currentTarget.style.color = 'var(--ink)'; e.currentTarget.style.borderColor = 'var(--hairline)'; }}
        >
          {v.label}
        </a>
      ))}
    </div>
  );
}

// ── Solutions row (footer vertical nav) ──────────────────────────
function SolutionsRow({ current }) {
  const items = [
    { href: '/', label: 'Carriers', key: 'carriers' },
    { href: '/erp', label: 'Oracle ERP', key: 'erp' },
    { href: '/freight', label: 'Freight & Logistics', key: 'freight' },
    { href: '/health', label: 'Regenerative Health', key: 'health' },
  ];
  return (
    <div style={{ borderTop: '1px solid var(--hairline)', padding: '16px 0 18px', display: 'flex', alignItems: 'center', gap: 16, flexWrap: 'wrap' }}>
      <style>{`.echo-solutions-link{color:var(--muted);text-decoration:none;border-bottom:1px solid transparent;transition:color 200ms ease,border-color 200ms ease}.echo-solutions-link:hover{color:var(--ink);border-bottom-color:var(--ink)}`}</style>
      <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, color: 'var(--muted)', letterSpacing: '0.14em', textTransform: 'uppercase' }}>Verticals</span>
      <div style={{ display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap' }}>
        {items.map((v, i) => (
          <span key={v.key} style={{ display: 'inline-flex', alignItems: 'center', gap: 10 }}>
            {v.key === current ? (
              <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, color: 'var(--muted-soft)', letterSpacing: '0.08em', textTransform: 'uppercase' }}>{v.label}</span>
            ) : (
              <a href={v.href} className="echo-solutions-link" style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.08em', textTransform: 'uppercase' }}>{v.label}</a>
            )}
            {i < items.length - 1 && <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, color: 'var(--hairline)' }}>·</span>}
          </span>
        ))}
      </div>
    </div>
  );
}

// ── Footer ───────────────────────────────────────────────────────
function AgentFooter() {
  return (
    <footer className="plate-section" style={{ padding: '40px 0 60px' }}>
      <div className="glass-plate glass-plate--rounded" style={{ maxWidth: 1240, margin: '0 auto', padding: '48px 56px 32px' }}>
        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-end', gap: 32, flexWrap: 'wrap', marginBottom: 32 }}>
          <div>
            <div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 14 }}>
              <LogoMark size={26} />
              <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 13, fontWeight: 500, letterSpacing: '0.05em' }}>Echo</span>
            </div>
            <p style={{ fontFamily: 'var(--ff-display)', fontSize: 16, color: 'var(--ink)', lineHeight: 1.5, maxWidth: 320, fontWeight: 400, letterSpacing: '-0.01em' }}>
              AI agents for carriers.<br/>
              <span style={{ color: 'var(--muted)', fontStyle: 'italic', fontWeight: 300 }}>Built on your stack. Owned by you.</span>
            </p>
          </div>
          <a href="#book" data-open-book-call className="echo-cta echo-cta--primary">
            Get a demo
          </a>
        </div>
        <SolutionsRow />
        <div style={{ borderTop: '1px solid var(--hairline)', paddingTop: 20, display: 'flex', justifyContent: 'space-between', alignItems: 'center', flexWrap: 'wrap', gap: 12 }}>
          <span style={{ display: 'inline-flex', alignItems: 'center', gap: 14, flexWrap: 'wrap', fontFamily: 'var(--ff-mono)', fontSize: 10, color: 'var(--muted)', letterSpacing: '0.07em' }}>
            <span>© 2026 ELITE CAPITAL INC.</span>
            <span style={{ display: 'inline-flex', alignItems: 'center', gap: 8 }}>
              <a href="/privacy.html" className="echo-solutions-link">Privacy</a>
              <span style={{ color: 'var(--hairline)' }}>·</span>
              <a href="/terms.html" className="echo-solutions-link">Terms</a>
              <span style={{ color: 'var(--hairline)' }}>·</span>
              <a href="/security.html" className="echo-solutions-link">Security</a>
              <span style={{ color: 'var(--hairline)' }}>·</span>
              <a href="mailto:jay@echoagents.io" className="echo-solutions-link">Contact</a>
            </span>
          </span>
          <div style={{ display: 'flex', alignItems: 'center', gap: 14, flexWrap: 'wrap' }}>
            <span style={{ display: 'inline-flex', alignItems: 'center', gap: 7, fontFamily: 'var(--ff-mono)', fontSize: 10, color: 'var(--muted)', letterSpacing: '0.07em' }}>
              <span style={{ width: 6, height: 6, borderRadius: '50%', background: '#7DC9A8', boxShadow: '0 0 6px rgba(125,201,168,0.6)', animation: 'pulse 2.4s ease-in-out infinite' }} />
              All systems operational
            </span>
            <span style={{ display: 'inline-flex', alignItems: 'baseline', gap: 6, fontFamily: 'var(--ff-mono)', fontSize: 10, color: 'var(--muted)', letterSpacing: '0.07em' }}>
              SOC 2
              <span style={{ fontSize: 9, opacity: 0.7 }}>(Type II in progress)</span>
            </span>
          </div>
        </div>
      </div>
    </footer>
  );
}

// ── App ──────────────────────────────────────────────────────────
function AgentApp() {
  const agent = window.ECHO_AGENTS[window.AGENT_ID];
  const [theme, setThemeState] = useState('dark');
  const [scrolled, setScrolled] = useState(false);

  const setTheme = (fn) => setThemeState(t => typeof fn === 'function' ? fn(t) : fn);

  useEffect(() => { document.documentElement.setAttribute('data-theme', theme); }, [theme]);
  useEffect(() => {
    const onScroll = () => setScrolled(window.scrollY > 20);
    window.addEventListener('scroll', onScroll, { passive: true });
    return () => window.removeEventListener('scroll', onScroll);
  }, []);
  useEffect(() => { document.title = `${agent.name} · Echo`; }, [agent.name]);

  // Plate halo + scroll-reveal observers
  useEffect(() => {
    const obs = new IntersectionObserver(entries => {
      entries.forEach(e => { if (e.isIntersecting) { e.target.classList.add('visible'); obs.unobserve(e.target); } });
    }, { threshold: 0.07 });
    document.querySelectorAll('.reveal').forEach(el => obs.observe(el));

    const plateObs = new IntersectionObserver(entries => {
      entries.forEach(e => {
        if (e.isIntersecting) { e.target.classList.add('in-view'); plateObs.unobserve(e.target); }
      });
    }, { threshold: 0.12, rootMargin: '0px 0px -8% 0px' });
    document.querySelectorAll('.glass-plate').forEach(el => plateObs.observe(el));

    return () => { obs.disconnect(); plateObs.disconnect(); };
  }, []);

  return (
    <>
      {/* Responsive overrides scoped to agent detail pages.
          Lives here because styles.css edits are gated and we want a single
          ship-anywhere file. Keep selectors specific to .agent-* classes so
          they don't bleed into the homepage. */}
      <style>{`
        @media (max-width: 1024px) {
          .agent-roi-grid,
          .agent-inaction-grid,
          .agent-faq-grid {
            grid-template-columns: 1fr !important;
            gap: 32px !important;
          }
          .agent-cta-buttons {
            flex-wrap: wrap !important;
            justify-content: center !important;
          }
        }
        @media (max-width: 640px) {
          .agent-roi-outputs { grid-template-columns: 1fr !important; }
          .agent-mockup-fields-2col { grid-template-columns: 1fr !important; }
          .agent-mockup-stats-3col { grid-template-columns: 1fr !important; gap: 10px !important; }
          .agent-mockup-pod-row { grid-template-columns: 84px 1fr 44px !important; gap: 8px !important; }
          .agent-integrations-list { grid-template-columns: 1fr !important; }
          .agent-integrations-list > div { border-right: none !important; border-bottom: 1px solid var(--hairline) !important; }
          .agent-integrations-list > div:last-child { border-bottom: none !important; }
          .agent-others-header { flex-direction: column !important; align-items: flex-start !important; gap: 16px !important; }
          .agent-testimonials-grid { grid-template-columns: 1fr !important; }
          .agent-cta-buttons { flex-direction: column !important; width: 100% !important; align-items: stretch !important; }
          .agent-cta-buttons > a { width: 100% !important; justify-content: center !important; }
          .agent-vertical-pills { gap: 8px !important; }
          .agent-workflow-grid > div > div { min-height: 0 !important; }
          .agent-faq-grid button > span:first-child { font-size: 16px !important; line-height: 1.4 !important; }
        }
      `}</style>
      <Nav theme={theme} setTheme={setTheme} scrolled={scrolled} currentId={agent.id} />
      <main>
        <AgentHero agent={agent} />
        <AgentOverview agent={agent} />
        <AgentCapabilities agent={agent} />
        <AgentWorkflow agent={agent} />
        <AgentROI agent={agent} />
        <AgentIntegrations agent={agent} />
        <OtherAgents currentId={agent.id} />
        <AgentCTA agent={agent} />
      </main>
      <AgentFooter />
      <DemoModal />
      <BookCallModal />
    </>
  );
}

ReactDOM.createRoot(document.getElementById('root')).render(<AgentApp />);
