/* cctv.ae — part 2: threats (live-scan sim), facial, industries, partners,
   ANPR parking sim, CCC callback, page. */
(function () {
  const data = window.cctv;
  const wrap = window.cctvWrap;
  const Icon = window.CCTVIcon;
  const sevColor = (s) => (s === "Critical" ? "#ff6168" : s === "High" ? "#ffb020" : "var(--af-light-blue)");
  const feedBg = "radial-gradient(120% 90% at 28% 18%, rgba(0,174,239,0.22), transparent 55%), repeating-linear-gradient(0deg, rgba(255,255,255,0.05) 0 1px, transparent 1px 5px), linear-gradient(135deg, #082a55, #041a3a)";

  /* ── Threats Uncovered — live camera-network simulation ─── */
  function Threats() {
    const t = data.threats;
    const IconChip = window.CCTVIconChip;
    const col = (s) => (s === "Critical" ? "#ff6168" : s === "High" ? "#ffb020" : "var(--af-light-blue)");
    const counts = t.items.reduce((m, it) => (m[it.severity] = (m[it.severity] || 0) + 1, m), {});
    return (
      <section style={{ position: "relative", overflow: "hidden", background: "var(--af-midnight)", color: "#fff", paddingBlock: "5.5rem" }}>
        <img src="assets/plexus-bg.jpg" alt="" aria-hidden style={{ position: "absolute", inset: 0, width: "100%", height: "100%", objectFit: "cover", opacity: 0.32 }} />
        <div aria-hidden style={{ position: "absolute", inset: 0, background: "linear-gradient(180deg, rgba(4,30,66,0.86), rgba(4,26,58,0.94))" }} />
        <div style={{ ...wrap, position: "relative" }}>
          <div style={{ textAlign: "center" }}>
            <p style={{ fontSize: "var(--text-sm)", fontWeight: "var(--weight-semibold)", letterSpacing: "0.16em", textTransform: "uppercase", color: "var(--af-light-blue)" }}>{t.title}</p>
            <p style={{ margin: "1.25rem auto 0", maxWidth: "46rem", fontSize: "var(--text-base)", lineHeight: 1.7, color: "rgba(255,255,255,0.78)" }}>{t.intro}</p>
          </div>
          <div style={{ marginTop: "3rem", borderRadius: "var(--radius-lg)", border: "1px solid rgba(255,255,255,0.14)", background: "rgba(4,18,40,0.55)", backdropFilter: "blur(4px)", overflow: "hidden", boxShadow: "0 30px 60px rgba(0,0,0,0.35)" }}>
            <div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", gap: "1rem", padding: "0.85rem 1.25rem", borderBottom: "1px solid rgba(255,255,255,0.1)", background: "rgba(0,0,0,0.25)" }}>
              <span style={{ display: "inline-flex", alignItems: "center", gap: 8, fontFamily: "ui-monospace, monospace", fontSize: "var(--text-xs)", fontWeight: 600, letterSpacing: "0.06em", textTransform: "uppercase", color: "#fff" }}>
                <img src="assets/AFT-arrowhead.png" alt="Al-Futtaim" className="aft-float" style={{ height: 22, width: "auto", filter: "drop-shadow(0 5px 12px rgba(0,174,239,0.55))" }} />{t.scanLabel}
              </span>
              <span style={{ display: "inline-flex", alignItems: "center", gap: 6, fontFamily: "ui-monospace, monospace", fontSize: 11, color: "var(--af-light-blue)" }}>
                <span className="ai-blink" style={{ width: 7, height: 7, borderRadius: "50%", background: "var(--af-light-blue)" }} />ANALYSING
              </span>
            </div>
            <div className="threat-console" style={{ display: "grid", gridTemplateColumns: "1.15fr 1fr", gap: "1.25rem", padding: "1.25rem" }}>
              <div style={{ position: "relative", borderRadius: "var(--radius-md)", border: "1px solid rgba(255,255,255,0.1)", background: "radial-gradient(120% 100% at 30% 0%, rgba(0,174,239,0.10), transparent 55%), linear-gradient(160deg, #07244a, #04112a)", padding: "0.9rem 1rem", display: "flex", flexDirection: "column", minHeight: "19rem" }}>
                <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", fontFamily: "ui-monospace, monospace", fontSize: 10, letterSpacing: "0.05em", color: "rgba(255,255,255,0.6)" }}>
                  <span>LIVE TOPOLOGY · 248 NODES</span><span style={{ color: "#37d39b" }}>● ONLINE</span>
                </div>
                <div style={{ flex: 1, marginBlock: "0.5rem", minHeight: 0 }}>{React.createElement(window.CCTVCameraNetwork, { items: t.items })}</div>
                <div style={{ display: "flex", gap: "1.1rem", flexWrap: "wrap", fontSize: 10, fontFamily: "ui-monospace, monospace" }}>
                  {[["Critical", counts.Critical || 0], ["High", counts.High || 0], ["Medium", counts.Medium || 0]].map(([s, n]) => (
                    <span key={s} style={{ display: "inline-flex", alignItems: "center", gap: 5, color: "rgba(255,255,255,0.72)" }}><span style={{ width: 7, height: 7, borderRadius: "50%", background: col(s) }} />{s} · {n}</span>
                  ))}
                </div>
              </div>
              <div style={{ display: "flex", flexDirection: "column", gap: "0.7rem" }}>
                {t.items.map((it) => {
                  const c = col(it.severity);
                  return (
                    <div key={it.title} style={{ display: "flex", gap: "0.85rem", alignItems: "flex-start", padding: "0.85rem 1rem", borderRadius: "var(--radius-md)", background: "rgba(255,255,255,0.04)", border: "1px solid rgba(255,255,255,0.08)", borderLeft: "3px solid " + c }}>
                      <IconChip name={it.icon} chip={42} size={20} onDark />
                      <div style={{ flex: 1, minWidth: 0 }}>
                        <div style={{ display: "flex", alignItems: "center", gap: 8, justifyContent: "space-between" }}>
                          <h4 style={{ fontSize: "var(--text-sm)", fontWeight: "var(--weight-semibold)", color: "#fff" }}>{it.title}</h4>
                          <span style={{ flexShrink: 0, padding: "1px 7px", borderRadius: "var(--radius-pill)", background: c + "22", color: c, fontSize: 9, fontWeight: 700, letterSpacing: "0.05em", textTransform: "uppercase" }}>{it.severity}</span>
                        </div>
                        <p style={{ marginTop: "0.3rem", fontSize: "var(--text-xs)", lineHeight: 1.5, color: "rgba(255,255,255,0.62)" }}>{it.body}</p>
                      </div>
                    </div>
                  );
                })}
              </div>
            </div>
          </div>
        </div>
      </section>
    );
  }

  /* ── Facial recognition band ────────────────────────────── */
  function Facial() {
    const f = data.facial;
    return (
      <section style={{ background: "var(--af-mist)", paddingBottom: "5.5rem" }}>
        <div style={{ position: "relative", overflow: "hidden", color: "#fff", minHeight: "26rem" }}>
          <img src="assets/facial-band.jpg" alt="" aria-hidden style={{ position: "absolute", inset: 0, width: "100%", height: "100%", objectFit: "cover" }} />
          <div aria-hidden style={{ position: "absolute", inset: 0, background: "linear-gradient(180deg, rgba(4,30,66,0.80), rgba(4,30,66,0.88))" }} />
          {window.AIFaceBand && React.createElement(window.AIFaceBand)}
          <div style={{ ...wrap, position: "relative", zIndex: 3, textAlign: "center", paddingBlock: "5rem" }}>
            <p style={{ fontSize: "var(--text-sm)", fontWeight: "var(--weight-semibold)", letterSpacing: "0.16em", textTransform: "uppercase", color: "var(--af-light-blue)" }}>{f.eyebrow}</p>
            <h2 style={{ marginTop: "1rem", fontSize: "var(--text-h2)", fontWeight: "var(--weight-semibold)", lineHeight: 1.12, letterSpacing: "-0.02em" }}>
              {f.titleLead}<br /><span>{f.titleHighlight}</span>
            </h2>
            <p style={{ margin: "1.25rem auto 0", maxWidth: "40rem", fontSize: "var(--text-base)", lineHeight: 1.7, color: "rgba(255,255,255,0.8)" }}>{f.intro}</p>
          </div>
        </div>
        <div style={{ ...wrap, marginTop: "-3.5rem", position: "relative" }}>
          <div className="grid-3" style={{ display: "grid", gridTemplateColumns: "repeat(3,1fr)", gap: "1.5rem" }}>
            {f.items.map((it) => (
              <div key={it.no} style={{ background: "#fff", borderTop: "3px solid var(--af-dark-blue)", borderRadius: "var(--radius-md)", boxShadow: "var(--shadow-md)", padding: "2rem 1.75rem" }}>
                <div style={{ fontSize: "2.5rem", fontWeight: "var(--weight-semibold)", lineHeight: 1, color: "var(--text-strong)" }}>{it.no}</div>
                <h3 style={{ marginTop: "1rem", fontSize: "var(--text-lg)", fontWeight: "var(--weight-semibold)", color: "var(--text-strong)" }}>{it.title}</h3>
                <p style={{ marginTop: "0.6rem", fontSize: "var(--text-sm)", lineHeight: 1.6, color: "var(--text-body)" }}>{it.body}</p>
              </div>
            ))}
          </div>
        </div>
      </section>
    );
  }

  /* ── Industries — branded live-FR feed tiles ────────────── */
  function Industries() {
    const ind = data.industries;
    return (
      <section style={{ background: "#fff", paddingBlock: "5.5rem" }}>
        <div style={{ ...wrap, display: "grid", gridTemplateColumns: "1.5fr 1fr", gap: "3rem", alignItems: "start" }} className="grid-2">
          <div>
            <p style={{ fontSize: "var(--text-sm)", fontWeight: "var(--weight-semibold)", letterSpacing: "0.05em", color: "var(--text-strong)" }}>{ind.eyebrow}</p>
            <h2 style={{ marginTop: "0.6rem", paddingLeft: "1rem", borderLeft: "4px solid var(--af-dark-blue)", fontSize: "var(--text-h2)", fontWeight: "var(--weight-semibold)", lineHeight: 1.1, letterSpacing: "-0.02em", color: "var(--text-strong)" }}>
              {ind.titleLead}<br />{ind.titleTail}
            </h2>
            <p style={{ marginTop: "1.1rem", maxWidth: "32rem", fontSize: "var(--text-base)", lineHeight: 1.7, color: "var(--text-body)" }}>{ind.intro}</p>
            <div className="grid-2" style={{ marginTop: "2rem", display: "grid", gridTemplateColumns: "1fr 1fr", gap: "1rem" }}>
              {ind.tiles.map((tile, i) => (
                <a key={tile.title} href="#contact" className="ind-tile" style={{ position: "relative", overflow: "hidden", borderRadius: "var(--radius-md)", aspectRatio: "16/10", display: "block", textDecoration: "none", boxShadow: "var(--shadow-sm)", background: "#04102a" }}>
                  <div className="ind-illo" style={{ position: "absolute", inset: 0 }}>{window.CCTVIllos[tile.illo] && React.createElement(window.CCTVIllos[tile.illo])}</div>
                  <span aria-hidden style={{ position: "absolute", inset: 0, background: "linear-gradient(180deg, transparent 42%, rgba(4,19,44,0.88) 100%)" }} />
                  <span style={{ position: "absolute", top: 9, left: 11, display: "inline-flex", alignItems: "center", gap: 4, fontFamily: "ui-monospace, monospace", fontSize: 9, color: "rgba(255,255,255,0.82)" }}>
                    <span className="ai-blink" style={{ width: 5, height: 5, borderRadius: "50%", background: "var(--af-light-blue)" }} />FR ACTIVE
                  </span>
                  <span style={{ position: "absolute", left: "0.9rem", bottom: "0.8rem", color: "#fff", fontSize: "var(--text-sm)", fontWeight: "var(--weight-semibold)", whiteSpace: "nowrap" }}>{tile.title}</span>
                </a>
              ))}
            </div>
          </div>
          <div style={{ borderLeft: "3px solid var(--af-dark-blue)", background: "#fff", boxShadow: "var(--shadow-lg)", borderRadius: "0 var(--radius-md) var(--radius-md) 0", padding: "2rem 1.75rem" }}>
            <ul style={{ listStyle: "none", margin: 0, padding: 0, display: "flex", flexDirection: "column", gap: "1.25rem" }}>
              {ind.capabilities.map((c) => (
                <li key={c.label} style={{ display: "flex", alignItems: "center", gap: "0.85rem", paddingBottom: "1.25rem", borderBottom: "1px solid var(--border-subtle)", fontSize: "var(--text-sm)", fontWeight: "var(--weight-medium)", color: "var(--text-strong)" }}>
                  {React.createElement(window.CCTVIconChip, { name: c.icon, chip: 40, size: 19 })} {c.label}
                </li>
              ))}
            </ul>
            <div style={{ marginTop: "1.75rem", textAlign: "center" }}>
              <span style={{ display: "inline-grid", placeItems: "center", width: "3rem", height: "3rem", borderRadius: "50%", background: "var(--af-pale)" }}>
                <Icon name="mail" size={22} color="var(--af-dark-blue)" />
              </span>
              <h4 style={{ marginTop: "0.85rem", fontSize: "var(--text-lg)", fontWeight: "var(--weight-semibold)", color: "var(--text-strong)" }}>{ind.demo.title}</h4>
              <p style={{ marginTop: "0.3rem", fontSize: "var(--text-sm)", color: "var(--text-muted)" }}>{ind.demo.sub}</p>
              <form onSubmit={(e) => e.preventDefault()} style={{ marginTop: "1rem", display: "flex", gap: "0.5rem" }}>
                <input type="email" placeholder={ind.demo.placeholder} style={{ flex: 1, padding: "0.6rem 0.85rem", fontSize: "var(--text-sm)", border: "1px solid #c2cedd", borderRadius: "var(--radius-pill)", outline: "none", fontFamily: "inherit" }} />
                <button type="submit" style={{ padding: "0.6rem 1.25rem", fontSize: "var(--text-sm)", fontWeight: "var(--weight-semibold)", color: "#fff", background: "var(--af-dark-blue)", border: "none", borderRadius: "var(--radius-pill)", cursor: "pointer" }}>{ind.demo.cta}</button>
              </form>
            </div>
          </div>
        </div>
      </section>
    );
  }

  /* ── Strategic partners — frosted cards ─────────────────── */
  function Partners() {
    const p = data.partners;
    return (
      <section style={{ position: "relative", overflow: "hidden", background: "var(--af-midnight)", paddingBlock: "4.5rem" }}>
        <img src="assets/plexus-bg.jpg" alt="" aria-hidden style={{ position: "absolute", inset: 0, width: "100%", height: "100%", objectFit: "cover", opacity: 0.55 }} />
        <div aria-hidden style={{ position: "absolute", inset: 0, background: "linear-gradient(180deg, rgba(4,30,66,0.82), rgba(4,30,66,0.9))" }} />
        <div style={{ ...wrap, position: "relative", textAlign: "center" }}>
          <h2 style={{ fontSize: "var(--text-h4)", fontWeight: "var(--weight-semibold)", letterSpacing: "0.08em", textTransform: "uppercase", color: "#fff" }}>{p.title}</h2>
          <div style={{ width: "3rem", height: "3px", background: "var(--af-light-blue)", margin: "0.9rem auto 0", borderRadius: "2px" }} />
          <div className="partner-row" style={{ marginTop: "2.5rem", display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: "1.25rem", alignItems: "stretch", maxWidth: "60rem", marginInline: "auto" }}>
            {p.logos.map((logo) => (
              <div key={logo.name} title={logo.name} style={{ display: "grid", placeItems: "center", padding: "1.5rem 1rem", minHeight: "6.5rem", background: "rgba(255,255,255,0.06)", border: "1px solid rgba(255,255,255,0.12)", borderRadius: "var(--radius-md)", backdropFilter: "blur(4px)" }}>
                <img src={logo.src} alt={logo.name} style={{ maxHeight: "2.8rem", maxWidth: "100%", width: "auto", objectFit: "contain" }} />
              </div>
            ))}
          </div>
        </div>
      </section>
    );
  }

  /* ── ANPR smart-parking simulation (innovative footer band) */
  function ANPRParking() {
    const a = data.anpr;
    return (
      <section style={{ position: "relative", overflow: "hidden", background: "#03132c", color: "#fff" }}>
        <img src="assets/plexus-bg.jpg" alt="" aria-hidden style={{ position: "absolute", inset: 0, width: "100%", height: "100%", objectFit: "cover", opacity: 0.28 }} />
        <div aria-hidden style={{ position: "absolute", inset: 0, background: "linear-gradient(180deg, rgba(3,19,44,0.92), rgba(3,19,44,0.96))" }} />
        <div style={{ ...wrap, position: "relative", display: "grid", gridTemplateColumns: "1.25fr 1fr", gap: "2.5rem", alignItems: "center", paddingBlock: "4.5rem" }} className="grid-2">
          {/* scene */}
          <div style={{ position: "relative", height: "17rem", borderRadius: "var(--radius-lg)", border: "1px solid rgba(255,255,255,0.12)", background: "radial-gradient(120% 100% at 30% 0%, rgba(0,174,239,0.16), transparent 55%), linear-gradient(180deg, #04183a, #061026)", overflow: "hidden" }}>
            {/* parking bays */}
            <div style={{ position: "absolute", left: "5%", top: "12%", display: "flex", gap: 8 }}>
              {a.bays.map((b) => {
                const on = b === a.assignedBay;
                return (
                  <span key={b} className={on ? "ai-blink" : undefined} style={{ width: 34, height: 56, transform: "skewX(-18deg)", borderRadius: 3, border: "1.5px solid " + (on ? "var(--af-light-blue)" : "rgba(255,255,255,0.22)"), background: on ? "rgba(0,174,239,0.18)" : "transparent", display: "grid", placeItems: "center", fontFamily: "ui-monospace, monospace", fontSize: 8, color: on ? "var(--af-light-blue)" : "rgba(255,255,255,0.5)" }}>{b}</span>
                );
              })}
            </div>
            {/* ground line */}
            <div aria-hidden style={{ position: "absolute", left: 0, right: 0, bottom: "3.2rem", height: 2, background: "rgba(255,255,255,0.14)" }} />
            {/* ANPR camera pole */}
            <div style={{ position: "absolute", right: "30%", bottom: "3.2rem" }}>
              <div style={{ width: 4, height: 92, background: "rgba(255,255,255,0.3)", marginInline: "auto" }} />
              <div style={{ position: "absolute", top: -6, left: -16, width: 34, height: 16, borderRadius: 3, background: "#cfd6e0" }} />
              <div style={{ position: "absolute", top: -3, left: -22, width: 8, height: 9, borderRadius: 2, background: "#04122a" }} />
              <span aria-hidden className="anpr-beam" style={{ position: "absolute", top: 2, left: -22, width: 120, height: 1, transformOrigin: "left center", transform: "rotate(28deg)", background: "linear-gradient(90deg, var(--af-light-blue), transparent)" }} />
            </div>
            {/* barrier */}
            <div style={{ position: "absolute", right: "20%", bottom: "3.2rem" }}>
              <div style={{ width: 7, height: 70, background: "linear-gradient(#e9edf3,#aab3c2)", borderRadius: 2 }} />
              <div className="anpr-arm" style={{ position: "absolute", left: 3, top: 2, width: 120, height: 8, transformOrigin: "left center", borderRadius: 4, background: "repeating-linear-gradient(90deg, #ff6168 0 14px, #fff 14px 28px)" }} />
            </div>
            {/* car */}
            <svg viewBox="0 0 230 96" width="190" style={{ position: "absolute", left: "8%", bottom: "2.1rem" }} aria-hidden>
              <g fill="none">
                <path d="M6 64 Q8 44 34 42 L74 26 Q86 19 120 20 L156 22 Q184 25 196 44 L214 50 Q224 54 224 66 L224 70 Q224 76 216 76 L24 76 Q8 76 6 66 Z" fill="#1f4e8a" />
                <path d="M80 30 Q88 24 116 25 L150 27 Q172 29 184 44 L120 44 L84 44 Z" fill="#7fc7f0" opacity="0.85" />
                <rect x="116" y="44" width="2.5" height="0" />
              </g>
              <circle cx="62" cy="76" r="17" fill="#0c1830" stroke="#5b6b86" strokeWidth="3" />
              <circle cx="62" cy="76" r="6" fill="#5b6b86" />
              <circle cx="176" cy="76" r="17" fill="#0c1830" stroke="#5b6b86" strokeWidth="3" />
              <circle cx="176" cy="76" r="6" fill="#5b6b86" />
              <rect x="206" y="58" width="14" height="9" rx="2" fill="#ffe08a" />
              <rect x="196" y="64" width="26" height="10" rx="2" fill="#fff" />
            </svg>
            {/* plate ANPR HUD */}
            <div style={{ position: "absolute", left: "30%", bottom: "4.4rem", border: "1.5px solid var(--af-light-blue)", borderRadius: 3, padding: "2px 6px", background: "rgba(4,18,40,0.6)", boxShadow: "0 0 12px rgba(0,174,239,0.5)", fontFamily: "ui-monospace, monospace", fontWeight: 700, fontSize: 12, letterSpacing: "0.06em", color: "#fff" }}>
              <span style={{ fontSize: 8, color: "var(--af-light-blue)", display: "block", lineHeight: 1 }}>{a.region}</span>{a.plate}
            </div>
            {/* status chip */}
            <div style={{ position: "absolute", top: 12, right: 14, fontFamily: "ui-monospace, monospace", fontSize: 11, fontWeight: 700 }}>
              <span className="anpr-scan-txt" style={{ color: "var(--af-light-blue)" }}>{a.statusScanning}</span>
              <span className="anpr-grant-txt" style={{ position: "absolute", top: 0, right: 0, whiteSpace: "nowrap", color: "#37d39b" }}>✓ {a.statusGranted}</span>
            </div>
          </div>
          {/* copy + meta */}
          <div>
            <p style={{ fontSize: "var(--text-sm)", fontWeight: "var(--weight-semibold)", letterSpacing: "0.16em", textTransform: "uppercase", color: "var(--af-light-blue)" }}>{a.eyebrow}</p>
            <h2 style={{ marginTop: "0.8rem", fontSize: "var(--text-h3)", fontWeight: "var(--weight-semibold)", lineHeight: 1.15, letterSpacing: "-0.02em", color: "#fff" }}>{a.title}</h2>
            <p style={{ marginTop: "1rem", fontSize: "var(--text-base)", lineHeight: 1.7, color: "rgba(255,255,255,0.75)" }}>{a.intro}</p>
            <div style={{ marginTop: "1.75rem", display: "flex", gap: "2.5rem", flexWrap: "wrap" }}>
              {a.meta.map((m) => (
                <div key={m.k}>
                  <div style={{ fontSize: "1.6rem", fontWeight: "var(--weight-semibold)", color: "var(--af-light-blue)", lineHeight: 1 }}>{m.v}</div>
                  <div style={{ marginTop: "0.35rem", fontSize: "var(--text-xs)", letterSpacing: "0.04em", textTransform: "uppercase", color: "rgba(255,255,255,0.6)" }}>{m.k}</div>
                </div>
              ))}
            </div>
          </div>
        </div>
      </section>
    );
  }

  /* ── Request a Call Back — CCC console ───────────────────── */
  function Callback() {
    const c = data.callback;
    const [done, setDone] = React.useState(false);
    const [submitting, setSubmitting] = React.useState(false);
    const [err, setErr] = React.useState("");
    const ref = React.useMemo(() => "CCC-" + Math.floor(100000 + Math.random() * 899999), []);
    const submit = async (e) => {
      e.preventDefault();
      setSubmitting(true); setErr("");
      const payload = Object.fromEntries(new FormData(e.target).entries());
      payload.ref = ref;
      try {
        const res = await fetch("/api/callback", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload) });
        const out = await res.json().catch(() => ({}));
        if (!res.ok || !out.ok) throw new Error([out.error, out.detail].filter(Boolean).join(" — ") || ("HTTP " + res.status));
        setDone(true);
      } catch (e2) {
        setErr("Couldn't submit: " + ((e2 && e2.message) ? e2.message : "unknown error") + ". You can also email support@alfuttaim.technology.");
      } finally {
        setSubmitting(false);
      }
    };
    const field = (fld) => {
      const base = { width: "100%", padding: "0.7rem 0.9rem", fontSize: "var(--text-sm)", border: "1.5px solid #c2cedd", borderRadius: "var(--radius-sm)", outline: "none", fontFamily: "inherit", background: "#fff", color: "var(--text-strong)", boxSizing: "border-box" };
      if (fld.type === "select") return <select name={fld.name} required={fld.required} defaultValue="" style={base}><option value="" disabled>Select…</option>{fld.options.map((o) => <option key={o}>{o}</option>)}</select>;
      if (fld.type === "textarea") return <textarea name={fld.name} rows={3} required={fld.required} style={{ ...base, resize: "vertical" }} />;
      return <input name={fld.name} type={fld.type} required={fld.required} style={base} />;
    };
    return (
      <section id="contact" style={{ position: "relative", overflow: "hidden", background: "var(--af-mist)", paddingBlock: "5.5rem" }}>
        <div style={{ ...wrap, display: "grid", gridTemplateColumns: "0.9fr 1.1fr", gap: "2.5rem", alignItems: "stretch" }} className="grid-2">
          {/* CCC live console + AI visual */}
          <div style={{ display: "flex", flexDirection: "column", gap: "1.25rem" }}>
          <div style={{ position: "relative", overflow: "hidden", borderRadius: "var(--radius-lg)", background: "linear-gradient(160deg, #07254d, #041124)", color: "#fff", padding: "2.25rem 2rem", boxShadow: "var(--shadow-lg)" }}>
            <div aria-hidden style={{ position: "absolute", inset: 0, opacity: 0.5, background: "radial-gradient(80% 60% at 90% 0%, rgba(0,174,239,0.25), transparent 60%)" }} />
            <div style={{ position: "relative" }}>
              <span style={{ display: "inline-flex", alignItems: "center", gap: 7, padding: "5px 11px", borderRadius: "var(--radius-pill)", border: "1px solid rgba(0,174,239,0.5)", fontFamily: "ui-monospace, monospace", fontSize: 11, fontWeight: 700, letterSpacing: "0.08em", textTransform: "uppercase", whiteSpace: "nowrap" }}>
                <span className="ai-blink" style={{ width: 7, height: 7, borderRadius: "50%", background: "var(--af-light-blue)" }} />{c.ccc.label}
              </span>
              <h3 style={{ marginTop: "1.25rem", fontSize: "var(--text-h4)", fontWeight: "var(--weight-semibold)", lineHeight: 1.2, color: "#fff" }}>Command &amp; Control Centre</h3>
              {/* live waveform */}
              <div aria-hidden style={{ marginTop: "1rem", display: "flex", alignItems: "flex-end", gap: 4, height: 28 }}>
                {[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map((i) => <span key={i} className="ccc-bar" style={{ width: 5, background: "var(--af-light-blue)", borderRadius: 2, animationDelay: (i * 0.12) + "s" }} />)}
              </div>
              <div style={{ marginTop: "1.75rem", display: "grid", gridTemplateColumns: "1fr 1fr", gap: "1.1rem" }}>
                {c.ccc.stat.map((s) => (
                  <div key={s.k} style={{ display: "flex", gap: "0.7rem", alignItems: "center" }}>
                    <span style={{ display: "grid", placeItems: "center", width: "2.3rem", height: "2.3rem", borderRadius: "var(--radius-sm)", background: "rgba(255,255,255,0.08)", flexShrink: 0 }}><Icon name={s.icon} size={18} color="var(--af-light-blue)" /></span>
                    <div><div style={{ fontSize: "1.25rem", fontWeight: "var(--weight-semibold)", lineHeight: 1 }}>{s.v}</div><div style={{ marginTop: 3, fontSize: "var(--text-xs)", color: "rgba(255,255,255,0.6)" }}>{s.k}</div></div>
                  </div>
                ))}
              </div>
              <div style={{ marginTop: "1.75rem", display: "flex", flexWrap: "wrap", gap: "0.5rem" }}>
                {c.ccc.channels.map((ch) => <span key={ch} style={{ padding: "5px 11px", borderRadius: "var(--radius-pill)", background: "rgba(255,255,255,0.08)", border: "1px solid rgba(255,255,255,0.14)", fontSize: "var(--text-xs)", fontWeight: 600 }}>{ch}</span>)}
              </div>
              <p style={{ marginTop: "1.5rem", fontSize: "var(--text-sm)", lineHeight: 1.6, color: "rgba(255,255,255,0.7)" }}>{c.ccc.reassurance}</p>
            </div>
          </div>
          {/* AI control-room visual below the CCC */}
          <figure style={{ margin: 0, position: "relative", borderRadius: "var(--radius-lg)", overflow: "hidden", border: "1px solid rgba(0,174,239,0.25)", boxShadow: "var(--shadow-md)", aspectRatio: "640/300" }}>
            {window.CCTVAIControlRoom && React.createElement(window.CCTVAIControlRoom)}
            <figcaption style={{ position: "absolute", left: 0, right: 0, bottom: 0, padding: "0.6rem 1rem", background: "linear-gradient(transparent, rgba(4,18,40,0.85))", color: "#fff", fontSize: "var(--text-xs)", fontWeight: "var(--weight-medium)", display: "flex", alignItems: "center", gap: 7 }}>
              <Icon name="sparkles" size={14} color="var(--af-light-blue)" /> AI-assisted monitoring across your CCTV estate
            </figcaption>
          </figure>
          </div>
          {/* form */}
          <div style={{ background: "#fff", borderRadius: "var(--radius-lg)", boxShadow: "var(--shadow-lg)", padding: "2.25rem 2rem" }}>
            <p style={{ fontSize: "var(--text-sm)", fontWeight: "var(--weight-semibold)", letterSpacing: "0.14em", textTransform: "uppercase", color: "var(--af-dark-blue)" }}>{c.eyebrow}</p>
            <h2 style={{ marginTop: "0.5rem", fontSize: "var(--text-h3)", fontWeight: "var(--weight-semibold)", color: "var(--text-strong)" }}>{c.title}</h2>
            {done ? (
              <div style={{ marginTop: "2rem", padding: "1.5rem", borderRadius: "var(--radius-md)", background: "var(--af-pale)", border: "1px solid var(--border-subtle)" }}>
                <div style={{ display: "flex", alignItems: "center", gap: "0.6rem", color: "var(--af-dark-blue)", fontWeight: "var(--weight-semibold)" }}><Icon name="check-circle-2" size={22} color="var(--af-dark-blue)" /> Request received</div>
                <p style={{ marginTop: "0.75rem", fontSize: "var(--text-sm)", lineHeight: 1.6, color: "var(--text-body)" }}>Your reference is <b style={{ fontFamily: "ui-monospace, monospace", color: "var(--text-strong)" }}>{ref}</b>. A CCC operator will call you back <b>soon</b>.</p>
              </div>
            ) : (
              <>
                <p style={{ marginTop: "0.75rem", fontSize: "var(--text-sm)", lineHeight: 1.6, color: "var(--text-body)" }}>{c.intro}</p>
                <form onSubmit={submit} style={{ marginTop: "1.5rem", display: "grid", gridTemplateColumns: "1fr 1fr", gap: "1rem 1.25rem" }} className="grid-2">
                  {c.fields.map((fld) => (
                    <label key={fld.name} style={{ gridColumn: fld.full ? "1 / -1" : "auto", display: "flex", flexDirection: "column", gap: "0.35rem" }}>
                      <span style={{ fontSize: "var(--text-xs)", fontWeight: "var(--weight-semibold)", letterSpacing: "0.04em", textTransform: "uppercase", color: "var(--text-muted)" }}>{fld.label}{fld.required ? " *" : ""}</span>
                      {field(fld)}
                    </label>
                  ))}
                  <label style={{ gridColumn: "1 / -1", display: "flex", alignItems: "flex-start", gap: "0.5rem", fontSize: "var(--text-xs)", color: "var(--text-muted)", lineHeight: 1.5 }}>
                    <input type="checkbox" name="consent" required style={{ marginTop: 2 }} /> I agree to be contacted by the CCTV.ae Command &amp; Control Centre about my enquiry.
                  </label>
                  <div style={{ gridColumn: "1 / -1" }}>
                    {err ? <p style={{ marginBottom: "0.75rem", fontSize: "var(--text-sm)", color: "var(--status-error)" }}>{err}</p> : null}
                    <button type="submit" disabled={submitting} style={{ display: "inline-flex", alignItems: "center", gap: "0.5rem", padding: "0.85rem 2rem", fontSize: "var(--text-sm)", fontWeight: "var(--weight-semibold)", letterSpacing: "0.03em", color: "#fff", background: "var(--af-dark-blue)", border: "none", borderRadius: "var(--radius-sm)", cursor: submitting ? "default" : "pointer", opacity: submitting ? 0.7 : 1 }}><Icon name="phone-call" size={16} color="#fff" /> {submitting ? "Sending…" : c.cta}</button>
                  </div>
                </form>
              </>
            )}
          </div>
        </div>
      </section>
    );
  }

  function CCTVPage() {
    React.useEffect(() => { if (window.lucide) window.lucide.createIcons(); });
    return (
      <div data-screen-label="cctv.ae home">
        {React.createElement(window.CCTVHeader)}
        {React.createElement(window.CCTVHero)}
        {React.createElement(window.CCTVSolutions)}
        {React.createElement(window.CCTVTrust)}
        {React.createElement(window.CCTVStats)}
        <Threats />
        <Facial />
        <Industries />
        <Partners />
        <Callback />
        <ANPRParking />
        {React.createElement(window.CCTVFooter)}
      </div>
    );
  }

  window.CCTVPage = CCTVPage;
})();
