// ═══════════════════════════════════════════════════════════════════
// ANALYTICS · INVESTOR INTELLIGENCE — the OFFERING DOSSIER.
// The analysis deck over the Raisable Investment project: extracted
// facts with provenance, verification classes, contradictions,
// evidence gaps and readiness — the institutional read an investor
// (or the issuer's counsel) needs before the round opens.
//
// Scope discipline:
//   · offerings themselves      → Operations · Projects
//   · ontology object instances → Ontology · Object Explorer
//   · financials & proceeds     → Control · Execution (Raise tab)
// This screen ANALYZES; it does not operate.
// ═══════════════════════════════════════════════════════════════════
(function () {
  const { useState } = React;
  const R = window.RAISABLE;
  const D = R.DOSSIER;
  const usd = (n) => (n === 0 ? "$0" : "$" + (n >= 1e6 ? (n / 1e6).toFixed(2).replace(/\.?0+$/, "") + "M" : Math.round(n / 1e3) + "K"));
  const mono = (s, extra) => <span style={{ fontFamily: "var(--mono)", fontSize: "8.5px", letterSpacing: "0.1em", textTransform: "uppercase", color: "var(--ink-4)", ...extra }}>{s}</span>;
  const card = (extra) => ({ border: "1px solid var(--rule-hard)", borderRadius: "var(--r-3)", background: "var(--bg)", padding: "13px 15px", ...extra });
  const SEV_TONE = { high: "err", med: "warn", low: "neutral" };
  const SEV_COLOR = { high: "var(--err)", med: "var(--warn)", low: "var(--ink-4)" };
  const PRI_TONE = { P0: "err", P1: "warn", P2: "info" };

  const ClassBadge = ({ cls, short }) => {
    const c = R.CLASS[cls] || {};
    return <window.Pill tone={c.tone || "neutral"} title={c.note}>{short ? cls : c.label}</window.Pill>;
  };

  // red–yellow–green confidence indicator — one per datapoint
  const TONE_VAR = { ok: "var(--ok)", warn: "var(--warn)", err: "var(--err)" };
  const Conf = ({ n }) => {
    const t = R.confTone(n);
    return (
      <span title={"confidence " + n + "/100 — " + (t === "ok" ? "high" : t === "warn" ? "medium" : "low")} style={{ display: "inline-flex", alignItems: "center", gap: 6 }}>
        <span style={{ width: 8, height: 8, borderRadius: 999, background: TONE_VAR[t], flex: "0 0 auto" }}></span>
        <span style={{ fontFamily: "var(--mono)", fontSize: "10px", fontWeight: 600, color: "var(--ink-2)", width: 18, textAlign: "right" }}>{n}</span>
        <span style={{ width: 34, height: 4, borderRadius: 2, background: "var(--bg-3)", overflow: "hidden", display: "inline-block" }}>
          <span style={{ display: "block", width: n + "%", height: "100%", background: TONE_VAR[t], borderRadius: 2 }}></span>
        </span>
      </span>
    );
  };

  // shared segmented sub-tab control
  function SubBar({ tabs, active, onTab }) {
    return (
      <div style={{ display: "flex", marginBottom: 14, border: "1px solid var(--rule-hard)", borderRadius: "var(--r-2)", overflow: "hidden", width: "fit-content" }}>
        {tabs.map(([id, lbl, hint], i) => (
          <button key={id} onClick={() => onTab(id)} title={hint} style={{ border: "none", borderLeft: i ? "1px solid var(--rule-hard)" : "none", background: active === id ? "var(--bg-dark)" : "var(--bg)", color: active === id ? "#fff" : "var(--ink-3)", padding: "8px 18px", cursor: "pointer", fontFamily: "var(--mono)", fontSize: "9.5px", letterSpacing: "0.08em", textTransform: "uppercase", fontWeight: 600 }}>{lbl}</button>
        ))}
      </div>
    );
  }

  // ── separation banner — Business twin vs Investment project ───────
  function SeparationBanner() {
    const S = R.SEPARATION;
    const cell = (side, active) => (
      <div style={{ flex: 1, padding: "12px 16px", background: active ? "var(--accent-bg)" : "var(--bg)", borderLeft: active ? "2px solid var(--accent)" : "2px solid transparent" }}>
        <div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 }}>
          <span style={{ fontFamily: "var(--ui-display)", fontWeight: 600, fontSize: "var(--fs-sm)", whiteSpace: "nowrap", color: active ? "var(--accent-lo)" : "var(--ink)" }}>{side.name}</span>
          {active ? <window.Pill tone="accent">this view</window.Pill> : <window.Pill tone="neutral">separate plane</window.Pill>}
        </div>
        <p style={{ margin: "5px 0 0", fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.55 }}>{side.note}</p>
      </div>
    );
    return (
      <div style={{ display: "flex", border: "1px solid var(--rule-hard)", borderRadius: "var(--r-3)", overflow: "hidden", marginBottom: "var(--s-5)" }}>
        {cell(S.business, false)}
        <div style={{ width: 1, background: "var(--rule-hard)" }}></div>
        {cell(S.investment, true)}
      </div>
    );
  }

  // ── 00 · EXECUTIVE BRIEF ───────────────────────────────────────────
  function Brief() {
    const cc = R.classCounts();
    return (
      <div>
        <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 14, marginBottom: 14 }}>
          <div style={card()}>
            {mono("investment thesis · the case for the round", { display: "block", marginBottom: 8 })}
            <p style={{ margin: "0 0 10px", fontSize: "var(--fs-md)", fontWeight: 600, color: "var(--ink)", lineHeight: 1.45 }}>{D.thesis.headline}</p>
            <div style={{ display: "flex", flexDirection: "column" }}>
              {D.thesis.pillars.map((p, i) => (
                <div key={i} style={{ display: "grid", gridTemplateColumns: "128px 1fr", gap: 10, borderTop: "1px solid var(--rule-soft)", padding: "7px 0" }}>
                  <span style={{ fontFamily: "var(--mono)", fontSize: "9px", fontWeight: 600, letterSpacing: "0.08em", textTransform: "uppercase", color: "var(--accent-lo)" }}>{p.t}</span>
                  <span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-2)", lineHeight: 1.55 }}>{p.d}</span>
                </div>
              ))}
            </div>
            <p style={{ margin: "10px 0 0", fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.55, fontStyle: "italic" }}>{D.thesis.counterweight}</p>
          </div>
          <div style={card()}>
            {mono("platform verdict · generated from " + R.KB.length + " sourced facts", { display: "block", marginBottom: 8 })}
            <p style={{ margin: "0 0 6px", fontSize: "var(--fs-md)", fontWeight: 600, color: "var(--ink)", lineHeight: 1.45 }}>{D.verdict.headline}</p>
            <p style={{ margin: "0 0 12px", fontSize: "var(--fs-sm)", color: "var(--ink-2)", lineHeight: 1.6 }}>{D.verdict.body}</p>
            <div style={{ display: "flex", alignItems: "center", gap: 14 }}>
              <div style={{ flex: 1 }}>
                <div style={{ display: "flex", justifyContent: "space-between", marginBottom: 4 }}>
                  {mono("confidence in the package as staged")}
                  <span style={{ fontFamily: "var(--mono)", fontSize: "11px", fontWeight: 700, color: "var(--accent-lo)" }}>{D.verdict.confidence} / 100</span>
                </div>
                <div style={{ height: 7, background: "var(--bg-3)", borderRadius: 4, overflow: "hidden" }}>
                  <div style={{ width: D.verdict.confidence + "%", height: "100%", background: "var(--accent)", borderRadius: 4 }}></div>
                </div>
              </div>
            </div>
            <div style={{ display: "flex", gap: 6, flexWrap: "wrap", marginTop: 12 }}>
              {D.verdict.pills.map(([k, vv]) => (
                <span key={k} style={{ display: "inline-flex", alignItems: "baseline", gap: 6, border: "1px solid var(--rule-hard)", borderRadius: "var(--r-1)", padding: "3px 9px", background: "var(--bg-2)" }}>
                  {mono(k)}<span style={{ fontFamily: "var(--mono)", fontSize: "10px", fontWeight: 600, color: "var(--ink)" }}>{vv}</span>
                </span>
              ))}
            </div>
          </div>
        </div>
        <div style={{ ...card(), marginBottom: 14 }}>
            {mono("top findings · classified", { display: "block", marginBottom: 8 })}
            <div style={{ display: "flex", flexDirection: "column" }}>
              {D.findings.map((f, i) => (
                <div key={i} style={{ display: "grid", gridTemplateColumns: "auto 1fr", gap: 9, alignItems: "baseline", borderTop: i ? "1px solid var(--rule-soft)" : "none", padding: "6px 0" }}>
                  <ClassBadge cls={f.cls} />
                  <span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-2)", lineHeight: 1.55 }}>{f.text}</span>
                </div>
              ))}
            </div>
            <div style={{ borderTop: "1px solid var(--rule-soft)", marginTop: 8, paddingTop: 8, display: "flex", gap: 6, flexWrap: "wrap", alignItems: "baseline" }}>
              {mono("fact ledger")}
              {Object.entries(cc).map(([k, n]) => n > 0 && (
                <span key={k} style={{ display: "inline-flex", alignItems: "center", gap: 4 }}>
                  <ClassBadge cls={k} short />
                  <span style={{ fontFamily: "var(--mono)", fontSize: "10px", fontWeight: 600, color: "var(--ink-2)" }}>{n}</span>
                </span>
              ))}
            </div>
        </div>
        <div style={{ display: "grid", gridTemplateColumns: "repeat(2, 1fr)", gap: 14 }}>
          {[["strengths", D.strengths, "var(--ok)"], ["asks before close", D.asks, "var(--info)"]].map(([t, list, color]) => (
            <div key={t} style={card()}>
              {mono(t, { display: "block", marginBottom: 8, color })}
              <div style={{ display: "flex", flexDirection: "column" }}>
                {list.map((s, i) => (
                  <div key={i} style={{ display: "grid", gridTemplateColumns: "10px 1fr", gap: 8, borderTop: i ? "1px solid var(--rule-soft)" : "none", padding: "6px 0" }}>
                    <span style={{ color, fontSize: 10, lineHeight: 1.8 }}>▪</span>
                    <span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-2)", lineHeight: 1.55 }}>{s}</span>
                  </div>
                ))}
              </div>
            </div>
          ))}
        </div>
        <div style={{ ...card(), marginTop: 14 }}>
          {mono("risk register · the downside, rated", { display: "block", marginBottom: 8 })}
          <div style={{ display: "grid", gridTemplateColumns: "repeat(2, 1fr)", gap: 12 }}>
            {D.risks.map((r) => (
              <div key={r.id} style={{ border: "1px solid var(--rule-soft)", borderRadius: "var(--r-2)", padding: "10px 12px", borderLeft: "3px solid " + SEV_COLOR[r.sev] }}>
                <div style={{ display: "flex", alignItems: "baseline", gap: 8, flexWrap: "wrap", marginBottom: 5 }}>
                  <span style={{ fontFamily: "var(--mono)", fontSize: "8.5px", color: "var(--ink-4)" }}>{r.id}</span>
                  <span style={{ fontFamily: "var(--ui-display)", fontWeight: 600, fontSize: "var(--fs-sm)", color: "var(--ink)" }}>{r.title}</span>
                  <span style={{ marginLeft: "auto", display: "inline-flex", gap: 6, alignItems: "center" }}>
                    <span style={{ fontFamily: "var(--mono)", fontSize: "8px", letterSpacing: "0.08em", textTransform: "uppercase", color: "var(--ink-4)", border: "1px solid var(--rule-hard)", borderRadius: "999px", padding: "1px 7px" }}>{r.cat}</span>
                    <window.Pill tone={SEV_TONE[r.sev]}>{r.sev}</window.Pill>
                  </span>
                </div>
                <p style={{ margin: "0 0 6px", fontSize: "var(--fs-xs)", color: "var(--ink-2)", lineHeight: 1.5 }}>{r.desc}</p>
                <div style={{ display: "grid", gridTemplateColumns: "auto 1fr", gap: 8, alignItems: "baseline" }}>
                  {mono("mitigation")}<span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.5 }}>{r.mitig}</span>
                </div>
              </div>
            ))}
          </div>
        </div>
      </div>
    );
  }

  // ── 02 · CAPITAL STRUCTURE — Reg D + Reg CF rails, no token layer ─
  function Capital() {
    const C = D.capital;
    const TERMS = [
      ["combined round", "$2.7M", "Reg D $2.0M + Reg CF $700K"],
      ["instrument", "YC SAFE", "post-money · one paper, both paths"],
      ["valuation cap", "$16M", "post-money"],
      ["combined dilution", "~16.9%", "at the full $2.7M"],
      ["minimum check", "$1,000", "per investor · both paths"],
      ["priced round", "Series A", "$8–12M at $25–50M pre (hypothesis)"],
    ];
    return (
      <div>
        <div style={{ display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap", marginBottom: 14, ...card({ padding: "10px 14px", borderColor: "var(--accent-bd)", background: "var(--accent-bg)" }) }}>
          <window.Pill tone="accent">classic rails</window.Pill>
          <span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-2)", lineHeight: 1.5, flex: 1, minWidth: 260 }}>{C.note}</span>
        </div>
        <div style={{ display: "grid", gridTemplateColumns: "repeat(6, 1fr)", gap: 1, background: "var(--rule)", border: "1px solid var(--rule-hard)", borderRadius: "var(--r-3)", overflow: "hidden", marginBottom: 14 }}>
          {TERMS.map(([k, vv, sub]) => (
            <div key={k} style={{ background: "var(--bg)", padding: "11px 13px" }}>
              {mono(k, { display: "block", marginBottom: 4 })}
              <div style={{ fontFamily: "var(--ui-display)", fontWeight: 700, fontSize: "18px", letterSpacing: "-0.01em", color: "var(--ink)" }}>{vv}</div>
              <div style={{ fontSize: "10px", color: "var(--ink-4)", marginTop: 3, lineHeight: 1.35 }}>{sub}</div>
            </div>
          ))}
        </div>
        <div style={{ display: "grid", gridTemplateColumns: "repeat(2, 1fr)", gap: 14, marginBottom: 14 }}>
          {C.paths.map((p) => (
            <div key={p.id} style={{ border: "1px solid var(--rule-hard)", borderRadius: "var(--r-3)", overflow: "hidden", background: "var(--bg)" }}>
              <div style={{ background: "var(--bg-dark)", color: "#fff", padding: "11px 15px", display: "flex", alignItems: "baseline", gap: 10, flexWrap: "wrap" }}>
                <span style={{ fontFamily: "var(--mono)", fontSize: "9px", letterSpacing: "0.1em", color: "var(--accent-hi)" }}>{p.id}</span>
                <span style={{ fontFamily: "var(--ui-display)", fontWeight: 600, fontSize: "var(--fs-sm)" }}>{p.name}</span>
                <span style={{ marginLeft: "auto", fontFamily: "var(--mono)", fontSize: "8.5px", letterSpacing: "0.1em", textTransform: "uppercase", color: "#aab4d4" }}>{p.role}</span>
              </div>
              <div style={{ padding: "9px 15px" }}>
                {p.points.map((pt, i) => (
                  <div key={i} style={{ display: "grid", gridTemplateColumns: "10px 1fr", gap: 8, borderTop: i ? "1px solid var(--rule-soft)" : "none", padding: "7px 0" }}>
                    <span style={{ color: "var(--accent)", fontSize: 10, lineHeight: 1.8 }}>▪</span>
                    <span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-2)", lineHeight: 1.55 }}>{pt}</span>
                  </div>
                ))}
              </div>
            </div>
          ))}
        </div>
        <div style={card({ marginBottom: 14 })}>
          {mono("issuance lifecycle · both paths on one calendar", { display: "block", marginBottom: 4 })}
          {C.steps.map((s, i) => (
            <div key={s.n} style={{ display: "grid", gridTemplateColumns: "34px 1fr", gap: 14, borderTop: i ? "1px solid var(--rule-soft)" : "none", padding: "11px 0" }}>
              <span style={{ width: 30, height: 30, borderRadius: "50%", border: "1px solid var(--accent-bd)", background: "var(--accent-bg)", color: "var(--accent-lo)", display: "grid", placeItems: "center", fontFamily: "var(--mono)", fontWeight: 700, fontSize: "10px" }}>{s.n}</span>
              <div>
                <div style={{ display: "flex", alignItems: "baseline", gap: 10, flexWrap: "wrap" }}>
                  <span style={{ fontFamily: "var(--ui-display)", fontWeight: 600, fontSize: "var(--fs-sm)", color: "var(--ink)" }}>{s.title}</span>
                  {s.pills.map((pl) => <span key={pl} style={{ fontFamily: "var(--mono)", fontSize: "8.5px", color: "var(--ink-4)", border: "1px solid var(--rule-hard)", borderRadius: "999px", padding: "1px 8px", letterSpacing: "0.04em" }}>{pl}</span>)}
                </div>
                <p style={{ margin: "3px 0 0", fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.55 }}>{s.body}</p>
              </div>
            </div>
          ))}
        </div>
      </div>
    );
  }

  // ── 02 · SOURCES — provenance registry; every fact cites exactly one
  //    source. (The Knowledge Base, Knowledge Graph and Entity Registry
  //    moved to the sidebar under Knowledge · this project.)
  function Warehouse({ go }) {
    const docCount = Object.values(R.SRC).filter((s) => s.kind === "doc").length;
    return (
      <div>
        <window.SectionHead sub="provenance — every fact cites exactly one source; the registry lives in the sidebar">Sources</window.SectionHead>
        <div style={card({ background: "var(--bg-2)" })}>
          <p style={{ margin: 0, fontSize: "var(--fs-sm)", color: "var(--ink-2)", lineHeight: 1.6 }}>
            This dossier is generated from the project Knowledge Base — {R.KB.length} classified facts across {Object.keys(R.SRC).length} sources ({docCount} data-room documents · settings · onboarding), each fact citing exactly one source. Sourced facts and the full source registry are not re-tabled here; they live in the sidebar Knowledge views so the report stays decision-focused.
          </p>
          {go && (
            <div style={{ display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap", marginTop: 12, paddingTop: 12, borderTop: "1px solid var(--rule-soft)" }}>
              {mono("open the evidence layer")}
              {[["knowledge base", "kb"], ["knowledge graph", "graph"], ["entity registry", "entity"], ["workflow", "workflow"]].map(([label, route]) => (
                <button key={route} onClick={() => go(route)} style={{ border: "1px solid var(--accent-bd)", background: "var(--accent-bg)", color: "var(--accent-lo)", borderRadius: "var(--r-1)", padding: "4px 10px", cursor: "pointer", fontFamily: "var(--mono)", fontSize: "8.5px", letterSpacing: "0.06em", textTransform: "uppercase", whiteSpace: "nowrap" }}>{label} ↗</button>
              ))}
            </div>
          )}
        </div>
        <p style={{ margin: "var(--s-4) 0 0", fontFamily: "var(--mono)", fontSize: "9px", letterSpacing: "0.06em", color: "var(--ink-4)", lineHeight: 1.7 }}>
          Classifications: V verified · P self-reported · A assumption · H hypothesis · Q questionable · U unknown.
        </p>
      </div>
    );
  }

  // ── 03 · VERIFICATION LAYER ────────────────────────────────────────
  function Verification() {
    const counts = {};
    D.verification.forEach((v) => { counts[v.cls] = (counts[v.cls] || 0) + 1; });
    return (
      <div>
        <div style={{ display: "grid", gridTemplateColumns: "repeat(5, 1fr)", gap: 1, background: "var(--rule)", border: "1px solid var(--rule-hard)", borderRadius: "var(--r-3)", overflow: "hidden", marginBottom: 14 }}>
          {Object.entries(R.CLASS).map(([k, c]) => (
            <div key={k} style={{ background: "var(--bg)", padding: "11px 14px" }}>
              <div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", gap: 6 }}>
                <ClassBadge cls={k} />
                <span style={{ fontFamily: "var(--ui-display)", fontWeight: 700, fontSize: "18px", color: "var(--ink)" }}>{counts[k] || 0}</span>
              </div>
              <div style={{ fontSize: "10px", color: "var(--ink-4)", marginTop: 5, lineHeight: 1.45 }}>{c.note}</div>
            </div>
          ))}
        </div>
        <div style={{ border: "1px solid var(--rule-hard)", borderRadius: "var(--r-3)", overflow: "hidden" }}>
          <div style={{ display: "grid", gridTemplateColumns: "minmax(200px, 0.8fr) 1.3fr 120px", gap: 1, background: "var(--rule)" }}>
            {["Material claim", "How the platform checked it", "Class"].map((h) => (
              <div key={h} style={{ background: "var(--bg-2)", padding: "8px 12px" }}><window.MonoLabel>{h}</window.MonoLabel></div>
            ))}
            {D.verification.map((v, i) => (
              <React.Fragment key={i}>
                <div style={{ background: "var(--bg)", padding: "9px 12px", fontSize: "var(--fs-sm)", fontWeight: 500, color: "var(--ink)", lineHeight: 1.45 }}>{v.claim}</div>
                <div style={{ background: "var(--bg)", padding: "9px 12px", fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.55 }}>{v.finding}</div>
                <div style={{ background: "var(--bg)", padding: "9px 12px" }}><ClassBadge cls={v.cls} /></div>
              </React.Fragment>
            ))}
          </div>
        </div>
      </div>
    );
  }

  // ── 04 · CONTRADICTION REGISTER ────────────────────────────────────
  function Contradictions() {
    return (
      <div style={{ border: "1px solid var(--rule-hard)", borderRadius: "var(--r-3)", overflow: "hidden" }}>
        <div style={{ display: "grid", gridTemplateColumns: "52px 1fr 1fr 76px 1.2fr", gap: 1, background: "var(--rule)" }}>
          {["ID", "Source A vs Source B", "Conflict", "Severity", "Resolution"].map((h) => (
            <div key={h} style={{ background: "var(--bg-2)", padding: "8px 12px" }}><window.MonoLabel>{h}</window.MonoLabel></div>
          ))}
          {D.contradictions.map((x) => (
            <React.Fragment key={x.id}>
              <div style={{ background: "var(--bg)", padding: "9px 12px", fontFamily: "var(--mono)", fontSize: "10px", color: "var(--ink-3)" }}>{x.id}</div>
              <div style={{ background: "var(--bg)", padding: "9px 12px", fontSize: "var(--fs-xs)", lineHeight: 1.55 }}>
                <div style={{ color: "var(--ink)" }}>{x.a}</div>
                <div style={{ color: "var(--ink-3)", marginTop: 2 }}>vs · {x.b}</div>
              </div>
              <div style={{ background: "var(--bg)", padding: "9px 12px", fontSize: "var(--fs-xs)", color: "var(--ink-2)", lineHeight: 1.55 }}>{x.conflict}</div>
              <div style={{ background: "var(--bg)", padding: "9px 12px" }}><window.Pill tone={SEV_TONE[x.sev]}>{x.sev}</window.Pill></div>
              <div style={{ background: "var(--bg)", padding: "9px 12px", fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.55 }}>{x.fix}</div>
            </React.Fragment>
          ))}
        </div>
      </div>
    );
  }

  // ── 05 · EVIDENCE GAPS ─────────────────────────────────────────────
  function Gaps() {
    return (
      <div>
        <p style={{ margin: "0 0 12px", fontSize: "var(--fs-sm)", color: "var(--ink-3)", maxWidth: "82ch", lineHeight: 1.55 }}>
          What is missing to upgrade each fact class — every gap names the facts it blocks and the single piece of evidence that closes it.
        </p>
        <div style={{ display: "grid", gridTemplateColumns: "repeat(2, 1fr)", gap: 14 }}>
          {D.gaps.map((g) => (
            <div key={g.id} style={card()}>
              <div style={{ display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap", marginBottom: 6 }}>
                <span style={{ fontFamily: "var(--mono)", fontSize: "9px", color: "var(--ink-4)", letterSpacing: "0.06em" }}>{g.id}</span>
                <span style={{ fontFamily: "var(--ui-display)", fontWeight: 600, fontSize: "var(--fs-sm)", color: "var(--ink)" }}>{g.gap}</span>
                <span style={{ marginLeft: "auto" }}><window.Pill tone={SEV_TONE[g.sev]}>{g.sev}</window.Pill></span>
              </div>
              <div style={{ display: "grid", gridTemplateColumns: "58px 1fr", gap: 8, fontSize: "var(--fs-xs)", lineHeight: 1.55 }}>
                {mono("blocks")}<span style={{ fontFamily: "var(--mono)", fontSize: "10px", color: "var(--accent-lo)" }}>{g.affects}</span>
                {mono("today")}<span style={{ color: "var(--ink-3)" }}>{g.today}</span>
                {mono("closes")}<span style={{ color: "var(--ink-2)" }}>{g.closes}</span>
                {mono("due")}<span style={{ fontFamily: "var(--mono)", fontSize: "10px", color: "var(--ink-3)" }}>{g.due}</span>
              </div>
            </div>
          ))}
        </div>
      </div>
    );
  }

  // ── 06 · READINESS + STRATEGIC ACTIONS ─────────────────────────────
  function Readiness() {
    return (
      <div>
        <div style={{ display: "grid", gridTemplateColumns: "repeat(2, 1fr)", gap: 14, marginBottom: 18 }}>
          {D.readiness.map((p) => {
            const done = p.items.filter((i) => i.ok).length;
            return (
              <div key={p.path} style={{ border: "1px solid var(--rule-hard)", borderRadius: "var(--r-3)", overflow: "hidden", background: "var(--bg)" }}>
                <div style={{ background: "var(--bg-dark)", color: "#fff", padding: "11px 15px", display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap" }}>
                  <span style={{ fontFamily: "var(--ui-display)", fontWeight: 600, fontSize: "var(--fs-sm)" }}>{p.path}</span>
                  <span style={{ marginLeft: "auto", display: "flex", alignItems: "center", gap: 8 }}>
                    <span style={{ fontFamily: "var(--mono)", fontSize: "10px", color: "var(--accent-hi)" }}>{done}/{p.items.length} gates</span>
                    <window.Pill tone={p.verdict === "cleared to open" ? "ok" : "warn"}>{p.verdict}</window.Pill>
                  </span>
                </div>
                <div style={{ padding: "10px 15px" }}>
                  <div style={{ display: "flex", gap: 3, marginBottom: 10 }}>
                    {p.items.map((it, i) => (
                      <div key={i} title={it.what} style={{ flex: 1, height: 6, borderRadius: 3, background: it.ok ? "var(--ok)" : "var(--bg-3)" }}></div>
                    ))}
                  </div>
                  {p.items.map((it, i) => (
                    <div key={i} style={{ display: "grid", gridTemplateColumns: "16px 1fr auto", gap: 8, alignItems: "baseline", borderTop: i ? "1px solid var(--rule-soft)" : "none", padding: "6px 0" }}>
                      <span style={{ color: it.ok ? "var(--ok)" : "var(--ink-5)", fontSize: "11px" }}>{it.ok ? "●" : "○"}</span>
                      <span style={{ fontSize: "var(--fs-xs)", color: it.ok ? "var(--ink-2)" : "var(--ink)", fontWeight: it.ok ? 400 : 500 }}>{it.what}</span>
                      <span style={{ fontFamily: "var(--mono)", fontSize: "8.5px", color: "var(--ink-4)", whiteSpace: "nowrap" }}>{it.note}</span>
                    </div>
                  ))}
                  <p style={{ margin: "8px 0 0", fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.5 }}>{p.note}</p>
                </div>
              </div>
            );
          })}
        </div>
        <window.SectionHead sub="ranked · every action gated on the evidence above">Strategic Actions</window.SectionHead>
        <div style={{ border: "1px solid var(--rule-hard)", borderRadius: "var(--r-3)", overflow: "hidden" }}>
          <div style={{ display: "grid", gridTemplateColumns: "36px 1.1fr 1.3fr 64px 80px", gap: 1, background: "var(--rule)" }}>
            {["#", "Recommended action", "Rationale (evidence)", "Priority", "Impact"].map((h) => (
              <div key={h} style={{ background: "var(--bg-2)", padding: "8px 12px" }}><window.MonoLabel>{h}</window.MonoLabel></div>
            ))}
            {D.actions.map((a) => (
              <React.Fragment key={a.n}>
                <div style={{ background: "var(--bg)", padding: "9px 12px", fontFamily: "var(--mono)", fontSize: "10px", color: "var(--ink-4)" }}>{a.n}</div>
                <div style={{ background: "var(--bg)", padding: "9px 12px", fontSize: "var(--fs-sm)", fontWeight: 500, color: "var(--ink)", lineHeight: 1.45 }}>{a.action}</div>
                <div style={{ background: "var(--bg)", padding: "9px 12px", fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.55 }}>{a.rationale}</div>
                <div style={{ background: "var(--bg)", padding: "9px 12px" }}><window.Pill tone={PRI_TONE[a.pri]}>{a.pri}</window.Pill></div>
                <div style={{ background: "var(--bg)", padding: "9px 12px", fontSize: "var(--fs-xs)", color: "var(--ink-2)" }}>{a.impact}</div>
              </React.Fragment>
            ))}
          </div>
        </div>
      </div>
    );
  }

  // ── screen ─────────────────────────────────────────────────────────
  const TABS_FROM_SCHEMA = true; // tab groups derived from REPORT_SCHEMA.groupsForClass (see InvestorIntelligence)

  // ── FINANCIAL MODEL — round · financials · unit econ · market ──────
  const HypoBanner = ({ text }) => (
    <div style={{ display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap", marginBottom: 14, ...card({ padding: "10px 14px", borderColor: "var(--rule-hard)", background: "var(--bg-2)" }) }}>
      <window.Pill tone="neutral">hypothesis · model targets</window.Pill>
      <span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-2)", lineHeight: 1.5, flex: 1, minWidth: 260 }}>{text}</span>
    </div>
  );

  // Cap Table & Proceeds — the ownership math; headline terms live under The Offering
  function FinRound() {
    const ROUND = 2700000;
    return (
      <div>
        <p style={{ margin: "0 0 12px", fontFamily: "var(--mono)", fontSize: "9px", letterSpacing: "0.06em", color: "var(--ink-4)", lineHeight: 1.7 }}>
          Headline terms live under Offering · Offering Terms.
        </p>
        <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 14 }}>
          <div style={card()}>
            {mono("pro-forma cap table · at incorporation · DOC-011", { display: "block", marginBottom: 8 })}
            {R.CAPTABLE.map((h, i) => (
              <div key={h.holder} style={{ display: "grid", gridTemplateColumns: "1fr 50px 50px", gap: 10, alignItems: "center", borderTop: i ? "1px solid var(--rule-soft)" : "none", padding: "7px 0" }}>
                <div>
                  <div style={{ fontSize: "var(--fs-xs)", color: "var(--ink)", fontWeight: 500 }}>{h.holder}</div>
                  <div style={{ fontSize: "10px", color: "var(--ink-4)" }}>{h.role}</div>
                </div>
                <span style={{ fontFamily: "var(--mono)", fontSize: "9px", color: "var(--ink-3)", textAlign: "center", border: "1px solid var(--rule-hard)", borderRadius: "var(--r-1)", padding: "1px 0" }}>Cls {h.cls}</span>
                <span style={{ fontFamily: "var(--mono)", fontSize: "11px", fontWeight: 600, color: "var(--accent-lo)", textAlign: "right" }}>{h.pct}%</span>
              </div>
            ))}
            <p style={{ margin: "8px 0 0", fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.5 }}>10M authorized — 9M Class A (10× votes) + 1M Class B, all Class A unvested per RSPA. SAFE converts on the next priced round; not on this table yet.</p>
          </div>
          <div style={card()}>
            {mono("use of proceeds · $2.7M combined · DOC-001", { display: "block", marginBottom: 8 })}
            {R.USE_OF_PROCEEDS.map((u) => (
              <div key={u.cat} style={{ borderTop: "1px solid var(--rule-soft)", padding: "7px 0" }}>
                <div style={{ display: "flex", justifyContent: "space-between", alignItems: "baseline", gap: 8 }}>
                  <span style={{ fontSize: "var(--fs-sm)", color: "var(--ink)", fontWeight: 500 }}>{u.cat}</span>
                  <span style={{ fontFamily: "var(--mono)", fontSize: "10.5px", fontWeight: 600, color: "var(--accent-lo)", whiteSpace: "nowrap" }}>{u.pct}% · {usd(ROUND * u.pct / 100)}</span>
                </div>
                <div style={{ height: 6, background: "var(--bg-3)", borderRadius: 3, overflow: "hidden", margin: "5px 0 3px" }}><div style={{ width: u.pct * 2.4 + "%", height: "100%", background: "var(--accent)", borderRadius: 3 }}></div></div>
                <div style={{ fontSize: "var(--fs-xs)", color: "var(--ink-3)" }}>{u.note}</div>
              </div>
            ))}
          </div>
        </div>
        <div style={{ ...card(), marginTop: 14 }}>
          {mono("dilution stack · the three layers, compounded · GAP-07", { display: "block", marginBottom: 8 })}
          <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 12 }}>
            {[["SAFE conversion", "~16.9%", "$2.7M YC post-money SAFE at $16M cap"], ["TX founding tier", "5–10%", "alliance equity — contingent on cap intro + BD of record"], ["Class B pool", "10%", "advisor / option pool — unissued until Board RSAs"]].map(([k, v, sub]) => (
              <div key={k} style={{ border: "1px solid var(--rule-soft)", borderRadius: "var(--r-2)", padding: "10px 12px" }}>
                <div style={{ display: "flex", justifyContent: "space-between", alignItems: "baseline", gap: 6 }}>
                  <span style={{ fontSize: "var(--fs-xs)", color: "var(--ink)", fontWeight: 500 }}>{k}</span>
                  <span style={{ fontFamily: "var(--ui-display)", fontWeight: 700, fontSize: "16px", color: "var(--accent-lo)" }}>{v}</span>
                </div>
                <div style={{ fontSize: "var(--fs-xs)", color: "var(--ink-3)", marginTop: 4, lineHeight: 1.45 }}>{sub}</div>
              </div>
            ))}
          </div>
          <p style={{ margin: "8px 0 0", fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.5 }}>Layers stated separately, never compounded. One pro-forma cap table owed before the TX session (GAP-07); compounded dilution is an open assumption (H).</p>
        </div>
      </div>
    );
  }

  // Financials — $0 baseline, burn, runway, ARR ramp
  function FinFinancials() {
    const F = R.FINANCIALS;
    const maxArr = Math.max(...F.arrRamp.map((r) => r.arr));
    return (
      <div>
        <HypoBanner text="Every figure starts from a verified $0 actual — no entity, no statements. Priced on milestones, not projections."></HypoBanner>
        <div style={{ display: "grid", gridTemplateColumns: "1fr 1.3fr", gap: 14 }}>
          <div style={card()}>
            {mono("burn & runway · " + F.asOf, { display: "block", marginBottom: 8 })}
            {F.snapshot.map(([k, vv]) => (
              <div key={k} style={{ display: "flex", justifyContent: "space-between", gap: 10, borderTop: "1px solid var(--rule-soft)", padding: "6px 0", alignItems: "baseline" }}>
                {mono(k)}<span style={{ fontFamily: "var(--mono)", fontSize: "10px", fontWeight: 600, color: "var(--ink-2)", textAlign: "right" }}>{vv}</span>
              </div>
            ))}
            <p style={{ margin: "8px 0 0", fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.5 }}>{F.revMixNote}</p>
          </div>
          <div style={{ ...card(), display: "flex", flexDirection: "column" }}>
            {mono("projected ARR ramp · starts from a $0 actual · 3-yr SOM $5–10M", { display: "block", marginBottom: 10 })}
            <div style={{ flex: 1, display: "grid", gridTemplateColumns: "repeat(5, 1fr)", gap: 12, alignItems: "end", minHeight: 140 }}>
              {F.arrRamp.map((r) => (
                <div key={r.year} style={{ display: "flex", flexDirection: "column", justifyContent: "flex-end", gap: 5, height: "100%" }}>
                  <span style={{ fontFamily: "var(--mono)", fontSize: "9.5px", fontWeight: 600, color: "var(--ink-2)", textAlign: "center" }}>{usd(r.arr)}</span>
                  <div style={{ height: Math.max(3, (r.arr / maxArr) * 110), background: r.arr === 0 ? "var(--bg-3)" : "var(--accent-bd)", borderRadius: "3px 3px 0 0" }}></div>
                  <span style={{ fontFamily: "var(--mono)", fontSize: "9px", color: "var(--ink-4)", textAlign: "center" }}>{r.year}</span>
                  <span style={{ fontFamily: "var(--mono)", fontSize: "8px", color: "var(--ink-5)", textAlign: "center" }}>{r.customers.toLocaleString()} issuers</span>
                </div>
              ))}
            </div>
            <div style={{ borderTop: "1px solid var(--rule-soft)", marginTop: 10, paddingTop: 8, display: "flex", flexDirection: "column", gap: 3 }}>
              {F.milestones.map((m) => (
                <div key={m.when} style={{ display: "grid", gridTemplateColumns: "64px 1fr", gap: 10, alignItems: "baseline" }}>
                  <span style={{ fontFamily: "var(--mono)", fontSize: "9px", fontWeight: 600, color: "var(--accent-lo)" }}>{m.when}</span>
                  <span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-3)" }}>{m.what}</span>
                </div>
              ))}
            </div>
          </div>
        </div>
        <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 14, marginTop: 14 }}>
          <div style={card()}>
            {mono("projection scenarios · ARR at Yr3 (2029) · per driver", { display: "block", marginBottom: 8 })}
            {[["Downside", "$3.0M", "slower PMF — first closes slip to M9–12; CAC runs hot", "warn"], ["Base", "$6.5M", "plan — ~700 issuers · BD + 2 CBS partnerships signed", "info"], ["Upside", "$10M", "parent pipeline + alliance convert faster than modeled", "ok"]].map(([k, v, sub, tone]) => (
              <div key={k} style={{ display: "grid", gridTemplateColumns: "82px 60px 1fr", gap: 10, alignItems: "baseline", borderTop: "1px solid var(--rule-soft)", padding: "7px 0" }}>
                <span style={{ display: "inline-flex" }}><window.Pill tone={tone}>{k}</window.Pill></span>
                <span style={{ fontFamily: "var(--mono)", fontSize: "12px", fontWeight: 700, color: "var(--accent-lo)" }}>{v}</span>
                <span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.45 }}>{sub}</span>
              </div>
            ))}
            <p style={{ margin: "8px 0 0", fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.5 }}>Band on the milestone set; all hypothesis (H). Priced on milestones, not the point estimate.</p>
          </div>
          <div style={card()}>
            {mono("revenue quality · concentration · retention · mix", { display: "block", marginBottom: 8 })}
            {[["concentration", "N/A — pre-revenue"], ["net retention", "N/A — no cohorts yet"], ["revenue mix", "subscription-only at launch (no services)"], ["first signal", "5–10 on-platform closes (M3–6) — the PMF gate"]].map(([k, v], i) => (
              <div key={k} style={{ display: "grid", gridTemplateColumns: "108px 1fr", gap: 10, borderTop: i ? "1px solid var(--rule-soft)" : "none", padding: "7px 0" }}>
                {mono(k)}<span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-2)", lineHeight: 1.45 }}>{v}</span>
              </div>
            ))}
            <p style={{ margin: "8px 0 0", fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.5 }}>No actuals — unmeasurable until first revenue. Tracked as an explicit gap.</p>
          </div>
        </div>
      </div>
    );
  }

  // Unit Economics — pricing, margins, CAC, LTV
  function FinUnit() {
    return (
      <div>
        <HypoBanner text="Pricing and unit economics are model targets (DOC-001 · DOC-010) — zero operating data; Series A gates on proving them."></HypoBanner>
        <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 14 }}>
          <div style={card()}>
            {mono("planned pricing · blended ARPA · DOC-001", { display: "block", marginBottom: 8 })}
            {[["Launch — one offering, single regime", "$3.6K / yr"], ["Growth — typical issuer, multi-regime", "$7.2K / yr"], ["Scale — multiple offerings, post-raise", "$12K / yr"], ["Enterprise — CBS white-label", "custom"]].map(([k, vv]) => (
              <div key={k} style={{ display: "flex", justifyContent: "space-between", gap: 10, borderTop: "1px solid var(--rule-soft)", padding: "6px 0", alignItems: "baseline" }}>
                <span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-2)" }}>{k}</span>
                <span style={{ fontFamily: "var(--mono)", fontSize: "10.5px", fontWeight: 600, color: "var(--accent-lo)", whiteSpace: "nowrap" }}>{vv}</span>
              </div>
            ))}
            <p style={{ margin: "8px 0 0", fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.5 }}>Base tiers $199–499/mo; typical issuer ~$5–10K blended ARPA (X-05).</p>
          </div>
          <div style={card()}>
            {mono("unit-economics targets · DOC-010", { display: "block", marginBottom: 8 })}
            {[["gross margin", "~80% · ~$100 AI COGS / client"], ["blended CAC", "$500–800 · channel-embedded"], ["LTV / CAC", "17–28×"], ["payback", "< 3 months"], ["GM-LTV", "~$14K per issuer"]].map(([k, vv]) => (
              <div key={k} style={{ display: "grid", gridTemplateColumns: "92px 1fr", gap: 10, borderTop: "1px solid var(--rule-soft)", padding: "6px 0" }}>
                {mono(k)}<span style={{ fontFamily: "var(--mono)", fontSize: "10.5px", fontWeight: 600, color: "var(--ink-2)" }}>{vv}</span>
              </div>
            ))}
            <p style={{ margin: "8px 0 0", fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.5 }}>Zero operating data; Series A gates on proving these.</p>
          </div>
        </div>
      </div>
    );
  }

  // Market — pool · TAM · SAM · SOM + verified anchors
  function FinMarket() {
    const mkt = R.KB.filter((f) => f.group === "market");
    const find = (k) => mkt.find((f) => f.key === k) || {};
    const funnel = [
      { label: "Problem pool", key: "mkt.problem_pool", v: "$3–5B / yr", note: "US legal + compliance spend on offerings", w: 100 },
      { label: "Revenue TAM", key: "mkt.revenue_tam", v: "$400–600M / yr", note: "addressable at ~$7K ACV", w: 64 },
      { label: "SAM", key: "mkt.sam", v: "$120–180M / yr", note: "reachable via CBS + broker channel", w: 40 },
      { label: "SOM (3-yr)", key: "mkt.som", v: "$5–10M ARR", note: "~700–1,400 issuers", w: 20 },
    ];
    return (
      <div>
        <HypoBanner text="Top-of-funnel volume and exit comp are public/verified; pool/TAM/SAM sizing cites no source (GAP-04) — assumption."></HypoBanner>
        <div style={{ display: "grid", gridTemplateColumns: "1.1fr 1fr", gap: 14 }}>
          <div style={card()}>
            {mono("market funnel · pool → TAM → SAM → SOM", { display: "block", marginBottom: 10 })}
            {funnel.map((t, i) => (
              <div key={t.key} style={{ borderTop: i ? "1px solid var(--rule-soft)" : "none", padding: "9px 0" }}>
                <div style={{ display: "flex", alignItems: "baseline", gap: 8, marginBottom: 5 }}>
                  <span style={{ fontFamily: "var(--ui-display)", fontWeight: 600, fontSize: "var(--fs-sm)", color: "var(--ink)" }}>{t.label}</span>
                  <ClassBadge cls={find(t.key).cls} short />
                  <span style={{ marginLeft: "auto", fontFamily: "var(--mono)", fontSize: "12px", fontWeight: 700, color: "var(--accent-lo)" }}>{t.v}</span>
                </div>
                <div style={{ height: 8, background: "var(--bg-3)", borderRadius: 4, overflow: "hidden" }}>
                  <div style={{ width: t.w + "%", height: "100%", background: "var(--accent)", opacity: 0.35 + i * 0.18, borderRadius: 4 }}></div>
                </div>
                <div style={{ fontSize: "var(--fs-xs)", color: "var(--ink-3)", marginTop: 4 }}>{t.note}</div>
              </div>
            ))}
          </div>
          <div style={card()}>
            {mono("verified anchors · public figures, cross-checked", { display: "block", marginBottom: 8 })}
            {[["mkt.formd_volume", "Form D volume"], ["mkt.median_raise", "Median raise"], ["mkt.exit_comp", "Exit comp"]].map(([k, lbl], i) => {
              const f = find(k);
              return (
                <div key={k} style={{ borderTop: i ? "1px solid var(--rule-soft)" : "none", padding: "9px 0" }}>
                  <div style={{ display: "flex", alignItems: "baseline", gap: 8, marginBottom: 4 }}>
                    <span style={{ fontFamily: "var(--ui-display)", fontWeight: 600, fontSize: "var(--fs-sm)", color: "var(--ink)" }}>{lbl}</span>
                    <span style={{ marginLeft: "auto" }}><Conf n={f.conf}></Conf></span>
                  </div>
                  <div style={{ fontSize: "var(--fs-xs)", color: "var(--ink-2)", lineHeight: 1.5 }}>{f.value}</div>
                </div>
              );
            })}
            <p style={{ margin: "9px 0 0", fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.5 }}>Checkable against SEC EDGAR/DERA and a public transaction — the verified floor under the TAM.</p>
          </div>
        </div>
      </div>
    );
  }

  function FinModel() {
    return (
      <div>
        <window.SectionHead sub="pro-forma ownership · use of proceeds">Cap Table & Proceeds</window.SectionHead>
        <FinRound></FinRound>
        <div style={{ marginTop: 24 }}>
          <window.SectionHead sub="$0 baseline · burn · runway · ARR ramp">Financials</window.SectionHead>
          <FinFinancials></FinFinancials>
        </div>
        <div style={{ marginTop: 24 }}>
          <window.SectionHead sub="pricing · margins · CAC · LTV">Unit Economics</window.SectionHead>
          <FinUnit></FinUnit>
        </div>
        <div style={{ marginTop: 24 }}>
          <window.SectionHead sub="pool · TAM · SAM · SOM · exit comp">Market</window.SectionHead>
          <FinMarket></FinMarket>
        </div>
      </div>
    );
  }

  // ── grouped wrappers — the investor reading arc ───────────────────
  // ── LEGAL FRAMEWORK — one instrument under two exemptions ─────────
  function Legal() {
    const L = D.legal;
    return (
      <div>
        <div style={{ display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap", marginBottom: 14, ...card({ padding: "10px 14px", borderColor: "var(--accent-bd)", background: "var(--accent-bg)" }) }}>
          <window.Pill tone="accent">one instrument · two exemptions</window.Pill>
          <span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-2)", lineHeight: 1.5, flex: 1, minWidth: 260 }}>{L.note}</span>
        </div>
        <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 14, marginBottom: 14 }}>
          {L.exemptions.map((e) => (
            <div key={e.id} style={{ border: "1px solid var(--rule-hard)", borderRadius: "var(--r-3)", overflow: "hidden", background: "var(--bg)" }}>
              <div style={{ background: "var(--bg-dark)", color: "#fff", padding: "11px 15px", display: "flex", alignItems: "baseline", gap: 10, flexWrap: "wrap" }}>
                <span style={{ fontFamily: "var(--mono)", fontSize: "9px", letterSpacing: "0.1em", color: "var(--accent-hi)" }}>{e.id}</span>
                <span style={{ fontFamily: "var(--ui-display)", fontWeight: 600, fontSize: "var(--fs-sm)" }}>{e.reg}</span>
                <span style={{ marginLeft: "auto", fontFamily: "var(--mono)", fontSize: "8.5px", letterSpacing: "0.1em", textTransform: "uppercase", color: "#aab4d4" }}>{e.offering}</span>
              </div>
              <div style={{ padding: "4px 15px 10px" }}>
                {[["audience", e.audience], ["solicitation", e.solicitation], ["verification", e.verification], ["filing", e.filing], ["blue sky", e.bluesky]].map(([k, v]) => (
                  <div key={k} style={{ display: "grid", gridTemplateColumns: "84px 1fr", gap: 10, borderTop: "1px solid var(--rule-soft)", padding: "7px 0" }}>
                    {mono(k)}<span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-2)", lineHeight: 1.5 }}>{v}</span>
                  </div>
                ))}
              </div>
            </div>
          ))}
        </div>
        <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 14 }}>
          <div style={card()}>
            {mono("the instrument · YC post-money SAFE · DOC-003", { display: "block", marginBottom: 6 })}
            {L.instrument.map(([k, v], i) => (
              <div key={k} style={{ display: "grid", gridTemplateColumns: "120px 1fr", gap: 10, borderTop: i ? "1px solid var(--rule-soft)" : "none", padding: "7px 0" }}>
                {mono(k)}<span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-2)", lineHeight: 1.5 }}>{v}</span>
              </div>
            ))}
          </div>
          <div style={card({ borderLeft: "3px solid var(--warn)" })}>
            {mono("concurrent-offering discipline", { display: "block", marginBottom: 5, color: "var(--warn)" })}
            <p style={{ margin: 0, fontSize: "var(--fs-xs)", color: "var(--ink-2)", lineHeight: 1.6 }}>{L.discipline}</p>
          </div>
        </div>
      </div>
    );
  }

  // ── THE BUSINESS — product & go-to-market, sourced facts only ─────
  function BizProduct() {
    const pillars = [D.thesis.pillars[0], D.thesis.pillars[1]];
    const build = R.USE_OF_PROCEEDS.filter((u) => u.cat === "AI infrastructure" || u.cat === "Product — modules 2–3");
    return (
      <div>
        <div style={{ display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap", marginBottom: 14, ...card({ padding: "10px 14px", borderColor: "var(--warn)", background: "var(--bg-2)", borderLeftWidth: 3 }) }}>
          <window.Pill tone="warn">in development · nothing shipped</window.Pill>
          <span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-2)", lineHeight: 1.5, flex: 1, minWidth: 260 }}>A product plan, not a product — no demo, shipped module or design-partner contract cited. Every claim below is classified.</span>
        </div>
        <div style={{ display: "grid", gridTemplateColumns: "1fr", gap: 14 }}>
          <div style={{ display: "flex", flexDirection: "column", gap: 14 }}>
            <div style={card()}>
              {mono("the product claim · thesis pillars", { display: "block", marginBottom: 6 })}
              {pillars.map((p, i) => (
                <div key={p.t} style={{ display: "grid", gridTemplateColumns: "128px 1fr", gap: 10, borderTop: i ? "1px solid var(--rule-soft)" : "none", padding: "7px 0" }}>
                  <span style={{ fontFamily: "var(--mono)", fontSize: "9px", fontWeight: 600, letterSpacing: "0.08em", textTransform: "uppercase", color: "var(--accent-lo)" }}>{p.t}</span>
                  <span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-2)", lineHeight: 1.55 }}>{p.d}</span>
                </div>
              ))}
            </div>
            <div style={card()}>
              {mono("build plan funded by this round · DOC-001", { display: "block", marginBottom: 6 })}
              {build.map((u, i) => (
                <div key={u.cat} style={{ borderTop: i ? "1px solid var(--rule-soft)" : "none", padding: "7px 0" }}>
                  <div style={{ display: "flex", justifyContent: "space-between", alignItems: "baseline", gap: 8 }}>
                    <span style={{ fontSize: "var(--fs-sm)", color: "var(--ink)", fontWeight: 500 }}>{u.cat}</span>
                    <span style={{ fontFamily: "var(--mono)", fontSize: "10.5px", fontWeight: 600, color: "var(--accent-lo)", whiteSpace: "nowrap" }}>{u.pct}%</span>
                  </div>
                  <div style={{ fontSize: "var(--fs-xs)", color: "var(--ink-3)", marginTop: 3, lineHeight: 1.5 }}>{u.note}</div>
                </div>
              ))}
            </div>
          </div>
        </div>
        <p style={{ margin: "10px 0 0", fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.55 }}>Module 1 (documentation engine) is the wedge; modules 2–3 funded by proceeds, gated at M12. Until a module ships, the story rests on plan docs (DOC-001 · DOC-010).</p>
      </div>
    );
  }

  function BizGTM() {
    const ch = D.thesis.pillars[2];
    const gtm = R.USE_OF_PROCEEDS.find((u) => u.cat === "GTM & partnerships");
    const proof = R.FINANCIALS.milestones.slice(0, 2);
    return (
      <div>
        <div style={{ display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap", marginBottom: 14, ...card({ padding: "10px 14px", borderColor: "var(--warn)", background: "var(--bg-2)", borderLeftWidth: 3 }) }}>
          <window.Pill tone="warn">no executed channel contract</window.Pill>
          <span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-2)", lineHeight: 1.5, flex: 1, minWidth: 260 }}>Partner-led by design, but the alliance is at signature — no portal selected, no BD executed. The channel is a thesis until the docs close.</span>
        </div>
        <div style={{ display: "grid", gridTemplateColumns: "1fr", gap: 14 }}>
          <div style={{ display: "flex", flexDirection: "column", gap: 14 }}>
            <div style={card()}>
              {mono("the channel thesis · partner-led CAC", { display: "block", marginBottom: 6 })}
              <div style={{ display: "grid", gridTemplateColumns: "128px 1fr", gap: 10, padding: "7px 0" }}>
                <span style={{ fontFamily: "var(--mono)", fontSize: "9px", fontWeight: 600, letterSpacing: "0.08em", textTransform: "uppercase", color: "var(--accent-lo)" }}>{ch.t}</span>
                <span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-2)", lineHeight: 1.55 }}>{ch.d}</span>
              </div>
              <div style={{ borderTop: "1px solid var(--rule-soft)", padding: "7px 0 0" }}>
                <div style={{ display: "flex", justifyContent: "space-between", alignItems: "baseline", gap: 8 }}>
                  <span style={{ fontSize: "var(--fs-sm)", color: "var(--ink)", fontWeight: 500 }}>{gtm.cat}</span>
                  <span style={{ fontFamily: "var(--mono)", fontSize: "10.5px", fontWeight: 600, color: "var(--accent-lo)", whiteSpace: "nowrap" }}>{gtm.pct}%</span>
                </div>
                <div style={{ fontSize: "var(--fs-xs)", color: "var(--ink-3)", marginTop: 3, lineHeight: 1.5 }}>{gtm.note}</div>
              </div>
            </div>
            <div style={card()}>
              {mono("proof milestones · what makes the channel real", { display: "block", marginBottom: 6 })}
              {proof.map((m, i) => (
                <div key={m.when} style={{ display: "grid", gridTemplateColumns: "64px 1fr", gap: 10, borderTop: i ? "1px solid var(--rule-soft)" : "none", padding: "7px 0" }}>
                  <span style={{ fontFamily: "var(--mono)", fontSize: "9px", fontWeight: 600, color: "var(--accent-lo)" }}>{m.when}</span>
                  <span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.5 }}>{m.what}</span>
                </div>
              ))}
            </div>
          </div>
        </div>
        <p style={{ margin: "10px 0 0", fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.55 }}>Raise demand is $0 — pre-launch. Once open, the broker reports demand as aggregates only; no account-level PII reaches the platform.</p>
      </div>
    );
  }

  function BusinessTab() {
    return (
      <div>
        <window.SectionHead sub="what is claimed · what exists · build plan">Product</window.SectionHead>
        <BizProduct></BizProduct>
        <div style={{ marginTop: 24 }}>
          <window.SectionHead sub="partner-led channel · alliance status · proof milestones">Go-to-Market</window.SectionHead>
          <BizGTM></BizGTM>
        </div>
      </div>
    );
  }

  function OfferingTab() {
    return (
      <div>
        <window.SectionHead sub="$2.7M · one SAFE · two paths · issuance lifecycle">Offering Terms</window.SectionHead>
        <Capital></Capital>
        <div style={{ marginTop: 24 }}>
          <window.SectionHead sub="exemptions · audience · solicitation · filings">Legal Framework</window.SectionHead>
          <Legal></Legal>
        </div>
      </div>
    );
  }

  // ── DUE DILIGENCE — compliance · entity background · cross-checks ──
  function Compliance() {
    const STAT = { due: ["warn", "due now"], pending: ["info", "queued"], future: ["neutral", "future"], filed: ["ok", "filed"] };
    return (
      <div>
        <window.SectionHead sub="what must be filed, in dependency order — nothing files before incorporation">Filing Pipeline</window.SectionHead>
        <div style={{ border: "1px solid var(--rule-hard)", borderRadius: "var(--r-3)", overflow: "hidden", marginBottom: 18 }}>
          <div style={{ display: "grid", gridTemplateColumns: "210px 84px 1fr", gap: 1, background: "var(--rule)" }}>
            {["Filing", "Status", "Detail"].map((h) => (<div key={h} style={{ background: "var(--bg-2)", padding: "8px 12px" }}><window.MonoLabel>{h}</window.MonoLabel></div>))}
            {R.FILINGS.map((f) => (
              <React.Fragment key={f.id}>
                <div style={{ background: "var(--bg)", padding: "9px 12px", fontSize: "var(--fs-sm)", fontWeight: 500, color: "var(--ink)" }}>{f.name}</div>
                <div style={{ background: "var(--bg)", padding: "9px 12px" }}><window.Pill tone={(STAT[f.status] || ["neutral", f.status])[0]}>{(STAT[f.status] || ["", f.status])[1]}</window.Pill></div>
                <div style={{ background: "var(--bg)", padding: "9px 12px", fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.55 }}>{f.detail}</div>
              </React.Fragment>
            ))}
          </div>
        </div>
        <p style={{ margin: "0 0 18px", fontFamily: "var(--mono)", fontSize: "9px", letterSpacing: "0.06em", color: "var(--ink-4)", lineHeight: 1.7 }}>
          Exemption rules — audience · solicitation · verification · filing triggers — live under The Offering · Legal Framework.
        </p>
        <window.SectionHead sub="what's still missing to clear each gate — every gap names the evidence that closes it">Open Evidence Gaps</window.SectionHead>
        <Gaps></Gaps>
      </div>
    );
  }

  function EntityBackground() {
    const { nodes } = R.graph ? R.graph() : { nodes: [] };
    const order = [];
    const byType = {};
    nodes.forEach((n) => { if (!byType[n.of]) { byType[n.of] = []; order.push(n.of); } byType[n.of].push(n); });
    return (
      <div>
        <div style={{ display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap", marginBottom: 14, ...card({ padding: "10px 14px", borderColor: "var(--warn)", background: "var(--bg-2)", borderLeftWidth: 3 }) }}>
          <window.Pill tone="warn">not yet incorporated</window.Pill>
          <span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-2)", lineHeight: 1.5, flex: 1, minWidth: 260 }}>Articles drafted to filing standard (DOC-002) but unfiled — target Jul 1, 2026. No EIN, no bank, no statements. Everything below is self-reported until the entity exists.</span>
        </div>

        {/* RS-10 · G5.a — Entity stack, resolved deal objects (filled by the entity step · WF-04b) */}
        <div style={{ ...card(), marginBottom: 14 }}>
          <div style={{ display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap", marginBottom: 10 }}>
            {mono("entity stack · what exists on paper, instance by instance")}
            <window.Pill tone="ok">entity registry</window.Pill>
            <span style={{ marginLeft: "auto", fontFamily: "var(--mono)", fontSize: "9px", color: "var(--ink-4)" }}>{nodes.length} objects · {order.length} classes</span>
          </div>
          <div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(238px, 1fr))", gap: 10 }}>
            {order.map((t) => (
              <div key={t} style={{ border: "1px solid var(--rule-soft)", borderRadius: "var(--r-2)", background: "var(--bg-2)", padding: "9px 11px" }}>
                <div style={{ display: "flex", alignItems: "baseline", gap: 6, marginBottom: 5 }}>
                  <span style={{ fontFamily: "var(--ui-display)", fontWeight: 600, fontSize: "var(--fs-sm)", color: "var(--ink)" }}>{t}</span>
                  <span style={{ fontFamily: "var(--mono)", fontSize: "8.5px", color: "var(--ink-4)" }}>{byType[t].length}</span>
                </div>
                {byType[t].map((n, i) => (
                  <div key={n.id} style={{ borderTop: i ? "1px solid var(--rule-soft)" : "none", padding: "5px 0" }}>
                    <div style={{ fontSize: "var(--fs-xs)", color: "var(--ink-2)", lineHeight: 1.4, fontWeight: 500 }}>{n.name}</div>
                    <div style={{ fontFamily: "var(--mono)", fontSize: "8px", color: "var(--ink-4)", marginTop: 1, lineHeight: 1.4 }}>{n.kicker}</div>
                  </div>
                ))}
              </div>
            ))}
          </div>
          <p style={{ margin: "9px 0 0", fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.5 }}>
            The deal objects as deduplicated, queryable records, resolved from the typed knowledge graph. Full graph and edges: sidebar · Knowledge · Entity Registry.
          </p>
        </div>

        <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 14 }}>
          <div style={card()}>
            {mono("corporate profile · synthesis", { display: "block", marginBottom: 6 })}
            <p style={{ margin: 0, fontSize: "var(--fs-xs)", color: "var(--ink-2)", lineHeight: 1.6 }}>Self-reported and pre-incorporation: a Wyoming C-corp drafted to filing standard, four founders on a Class A/B ledger, no EIN and no statements. Each line is one classified, confidence-scored datapoint — the full self-reported profile lives in the Knowledge Base (sidebar · Knowledge · this project), not re-tabled here.</p>
          </div>
          <div style={{ display: "flex", flexDirection: "column", gap: 14 }}>
            <div style={card()}>
              {mono("lineage · the Stobox parent", { display: "block", marginBottom: 5 })}
              <p style={{ margin: 0, fontSize: "var(--fs-xs)", color: "var(--ink-2)", lineHeight: 1.6 }}>Stobox group — operating since 2018, 100+ issuer engagements — is the parent. It feeds top-of-funnel issuer pipeline from day one (DOC-013) and grounds the team's regulated-offering experience.</p>
            </div>
            <div style={card()}>
              {mono("draft corporate package · what exists on paper", { display: "block", marginBottom: 6 })}
              {[["DOC-002", "WY Articles of Incorporation — drafted to filing standard, unfiled"], ["DOC-011", "Initial Stock Ledger — 4 founders · Class A/B · unvested per RSPA"], ["DOC-003", "YC post-money SAFE — unissuable until the entity exists"]].map(([id, what], i) => (
                <div key={id} style={{ display: "grid", gridTemplateColumns: "64px 1fr", gap: 10, borderTop: i ? "1px solid var(--rule-soft)" : "none", padding: "7px 0" }}>
                  <span style={{ fontFamily: "var(--mono)", fontSize: "9px", fontWeight: 600, color: "var(--accent-lo)" }}>{id}</span>
                  <span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-2)", lineHeight: 1.5 }}>{what}</span>
                </div>
              ))}
              <p style={{ margin: "8px 0 0", fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.5 }}>Effective dates on the drafts are stale (X-04). Ownership math — the pro-forma cap table — lives under Financial Model · Cap Table & Proceeds.</p>
            </div>
          </div>
        </div>
      </div>
    );
  }

  function FactChecks() {
    return (
      <div>
        <window.SectionHead sub="material claims checked against their single source">Claims Cross-Checked</window.SectionHead>
        <div style={{ marginBottom: 18 }}><Verification></Verification></div>
        <window.SectionHead sub="where two sources disagree — severity & resolution">Contradiction Register</window.SectionHead>
        <Contradictions></Contradictions>
      </div>
    );
  }


  function EvidenceTab() {
    return (
      <div>
        <FactChecks></FactChecks>
        <div style={{ marginTop: 24 }}><Compliance></Compliance></div>
        <div style={{ marginTop: 24 }}>
          <window.SectionHead sub="entity stack · corporate profile · structure · parent">Entity Background</window.SectionHead>
          <EntityBackground></EntityBackground>
        </div>
      </div>
    );
  }

  function InvestorIntelligence({ go }) {
    const SCHEMA = window.REPORT_SCHEMA;
    const classId = (window.AssetClass && window.AssetClass.of) ? window.AssetClass.of({ id: "raisable-seed", tenant: "raisable" }) : "equity";
    const schemaGroups = SCHEMA && SCHEMA.groupsForClass ? SCHEMA.groupsForClass(classId) : [];
    // one tab per Report Schema group — label & sub-caption come straight from the schema
    const TABS = schemaGroups.map((g) => ({ id: g.id, label: g.label, sub: g.subs.map((s) => s.label).join(" · "), classSpecific: g.classSpecific }));
    const [tab, setTab] = useState("G1");
    const renderGroup = (id) => {
      switch (id) {
        case "G1": return <Brief></Brief>;
        case "G2": return <BusinessTab></BusinessTab>;
        case "G3": return <OfferingTab></OfferingTab>;
        case "G4": return <FinModel></FinModel>;
        case "G5": return <EvidenceTab></EvidenceTab>;
        case "G6": return <Readiness></Readiness>;
        case "G7": return <Warehouse go={go}></Warehouse>;
        default: return null;
      }
    };
    const kpis = [
      ["combined round", usd(R.OFFERINGS.reduce((s, o) => s + o.target, 0)), "Reg D $2.0M + Reg CF $700K · one SAFE"],
      ["safe cap", "$16M", "YC post-money · ~16.9% dilution"],
      ["committed", usd(R.DEMAND.committed), "no commitments yet — pre-launch"],
      ["revenue today", "$0", "pre-revenue · product in development"],
      ["entity status", "Jul 1", "incorporation target — docs in draft · no EIN"],
      ["post-raise runway", "12–18 mo", "milestone-bound → Series A $8–12M"],
    ];
    return (
      <div>
        <window.PageHead eyebrow="Raisable Inc. · Raisable Inc. — Seed Round" title="Offering Dossier — Intelligence Report"
          sub="Every datapoint sourced and classified; claims verified, contradictions and gaps named, readiness gated. Offerings under Operations · Projects; objects under Ontology.">
        </window.PageHead>

        {/* SECTION selector — schema-group pill nav (aligned with the SAXCAP report shell) */}
        <div style={{ position: "sticky", top: 0, zIndex: 6, background: "var(--bg-2)", borderBottom: "1px solid var(--rule)", margin: "0 0 var(--s-5)", paddingBottom: 12 }}>
          <div style={{ display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap" }}>
            {mono("section", { flex: "0 0 auto" })}
            <div style={{ display: "flex", gap: 6, flexWrap: "wrap" }}>
              {TABS.map((t) => {
                const on = tab === t.id;
                return (
                  <button key={t.id} onClick={() => setTab(t.id)} title={t.sub} style={{ display: "inline-flex", alignItems: "center", gap: 7, border: "1px solid " + (on ? "var(--accent-bd)" : "var(--rule-hard)"), background: on ? "var(--accent-bg)" : "var(--bg)", color: on ? "var(--accent-lo)" : "var(--ink-3)", borderRadius: "999px", padding: "5px 13px", cursor: "pointer", fontFamily: "var(--ui)", fontSize: "12px", fontWeight: 500 }}>
                    <span style={{ width: 5, height: 5, borderRadius: 999, background: t.classSpecific ? "var(--accent)" : "var(--ink-4)", flex: "0 0 auto" }}></span>
                    {t.label}
                  </button>
                );
              })}
            </div>
          </div>
          <div style={{ display: "flex", gap: 16, flexWrap: "wrap", marginTop: 9 }}>
            {[["var(--accent)", "class-specific — relabeled per asset class"], ["var(--ink-4)", "universal — identical across classes"]].map(([c, lbl]) => (
              <span key={lbl} style={{ display: "inline-flex", alignItems: "center", gap: 6, fontFamily: "var(--mono)", fontSize: "8.5px", letterSpacing: "0.06em", textTransform: "uppercase", color: "var(--ink-4)" }}>
                <span style={{ width: 6, height: 6, borderRadius: 999, background: c }}></span>{lbl}
              </span>
            ))}
          </div>
        </div>

        <div style={{ display: "grid", gridTemplateColumns: "repeat(6, 1fr)", gap: 1, background: "var(--rule)", border: "1px solid var(--rule-hard)", borderRadius: "var(--r-3)", overflow: "hidden", marginBottom: "var(--s-5)" }}>
          {kpis.map(([k, vv, sub]) => (
            <div key={k} style={{ background: "var(--bg)", padding: "12px 14px" }}>
              {mono(k, { display: "block", marginBottom: 4 })}
              <div style={{ fontFamily: "var(--ui-display)", fontWeight: 700, fontSize: "20px", letterSpacing: "-0.01em", color: "var(--ink)" }}>{vv}</div>
              <div style={{ fontSize: "10.5px", color: "var(--ink-4)", marginTop: 3, lineHeight: 1.4 }}>{sub}</div>
            </div>
          ))}
        </div>

        {renderGroup(tab)}

        <p style={{ margin: "var(--s-6) 0 0", fontFamily: "var(--mono)", fontSize: "9px", letterSpacing: "0.06em", color: "var(--ink-4)", lineHeight: 1.7 }}>
          DEMO DATA — assembled from the offering data room (documents · settings · onboarding). Classifications: V verified · P self-reported · A assumption · H hypothesis · Q questionable. Unaudited; not an offer to sell securities.
        </p>
      </div>
    );
  }

  window.InvestorIntelligence = InvestorIntelligence;

  // ── register Raisable's payload with the universal shell (IntelligenceReport) ──
  // Universal sections (thesis · diligence · readiness · sources) are rendered
  // by the shell from this data; the rich equity class-sections stay here.
  (function registerRaisableReport() {
    const D = R.DOSSIER;
    const STAT = { due: ["warn", "due now"], pending: ["info", "queued"], future: ["neutral", "future"], filed: ["ok", "filed"] };
    const filings = (R.FILINGS || []).map((f) => ({ name: f.name, statusTone: (STAT[f.status] || ["neutral"])[0], statusLabel: (STAT[f.status] || ["", f.status])[1], detail: f.detail }));
    const vc = {}; D.verification.forEach((v) => { vc[v.cls] = (vc[v.cls] || 0) + 1; });
    const verifyMix = Object.entries(vc).map(([cls, n]) => [cls, n, (R.CLASS[cls] && R.CLASS[cls].note) || ""]);
    const paths = (D.readiness || []).map((p) => ({ path: p.path, verdict: p.verdict, ok: p.items.every((i) => i.ok), note: p.note, items: p.items }));
    // citation registry (G7) — one row per source, enriched with document
    // metadata, a source-reliability score/tier and a page/section locator
    const factsBySrc = {}; R.KB.forEach((f) => { factsBySrc[f.source] = (factsBySrc[f.source] || 0) + 1; });
    const SRC_META = {
      "DOC-001": { author: "Founders",        dept: "Corporate Strategy", version: "1.4", rel: 58, tier: "Tier-3 · internal",      loc: "§2 Market · §5 GTM", related: "DOC-010", uploaded: "28 May", parsed: "28 May" },
      "DOC-002": { author: "Counsel (draft)", dept: "Legal",             version: "0.9", rel: 70, tier: "Tier-2 · filing draft", loc: "Art. III–IV", related: "DOC-011", uploaded: "28 May", parsed: "28 May" },
      "DOC-003": { author: "Counsel (draft)", dept: "Legal",             version: "1.0", rel: 68, tier: "Tier-2 · instrument",   loc: "§1 Cap · §4 Conv.", uploaded: "30 May", parsed: "30 May" },
      "DOC-005": { author: "Counsel (draft)", dept: "Legal",             version: "0.6", rel: 55, tier: "Tier-3 · draft",        loc: "§3 Risk", uploaded: "30 May", parsed: "31 May" },
      "DOC-006": { author: "Ops",             dept: "Compliance",        version: "0.4", rel: 50, tier: "Tier-3 · worksheet",    loc: "§Form D timing", uploaded: "31 May", parsed: "31 May" },
      "DOC-010": { author: "Finance",         dept: "Finance",           version: "2.1", rel: 45, tier: "Tier-3 · model",        loc: "Tabs: P&L · Unit econ", related: "DOC-001", uploaded: "28 May", parsed: "29 May" },
      "DOC-011": { author: "Counsel (draft)", dept: "Legal",             version: "0.9", rel: 66, tier: "Tier-2 · stock ledger", loc: "Schedule A", uploaded: "30 May", parsed: "30 May" },
      "DOC-012": { author: "BD",              dept: "Partnerships",      version: "0.5", rel: 52, tier: "Tier-3 · unsigned",     loc: "§2 Terms", isNew: true, uploaded: "16 Jun", parsed: "16 Jun" },
      "DOC-013": { author: "BD",              dept: "Partnerships",      version: "1.0", rel: 48, tier: "Tier-3 · internal",      loc: "Call brief", isNew: true, uploaded: "16 Jun", parsed: "16 Jun" },
    };
    const registry = Object.entries(R.SRC).map(([id, sd]) => {
      const m = SRC_META[id] || {};
      return { id, kind: sd.kind, name: sd.name, facts: factsBySrc[id] || 0, origin: sd.file,
        rel: m.rel != null ? m.rel : (sd.kind === "doc" ? 50 : 55), tier: m.tier || (sd.kind === "doc" ? "Tier-3 · internal" : "Tier-2 · platform"),
        version: m.version, author: m.author, dept: m.dept || (sd.kind === "doc" ? null : "Platform"), loc: m.loc, related: m.related,
        uploaded: m.uploaded || sd.uploaded, parsed: m.parsed || sd.parsed, new: !!m.isNew };
    });
    const kpis = [
      ["combined round", usd(R.OFFERINGS.reduce((s, o) => s + o.target, 0)), "Reg D $2.0M + Reg CF $700K · one SAFE"],
      ["safe cap", "$16M", "YC post-money · ~16.9% dilution"],
      ["committed", usd(R.DEMAND.committed), "no commitments yet — pre-launch"],
      ["revenue today", "$0", "pre-revenue · product in development"],
      ["entity status", "Jul 1", "incorporation target — docs in draft · no EIN"],
      ["post-raise runway", "12–18 mo", "milestone-bound → Series A $8–12M"],
    ];
    window.INTEL_REPORTS = window.INTEL_REPORTS || {};
    window.INTEL_REPORTS["raisable-seed"] = {
      classId: "equity",
      version: "v5.1",
      asOf: "18 Jun 2026",
      digest: {
        prev: "v5", asOf: "18 Jun 2026", since: "v5 · 18 Jun 2026",
        items: [
          { status: "new",     where: "Sources",         ref: "DOC-012 · DOC-013", text: "TX founding-tier alliance proposal (Texture BD-of-record + CoreNest capital intro) and the CoreNest call brief landed in the data room on 16 Jun — both unsigned." },
          { status: "new",     where: "Strategic Review", ref: "OPP-02",            text: "Founding-tier tokenization rail via TX logged as a partnership opportunity — high impact, contingent on execution." },
          { status: "updated", where: "Diligence",        ref: "X-06",              text: "New contradiction — the CoreNest brief repeats the 100k+ filings figure the investor-hub canon bans." },
        ],
      },
      opportunities: [
        { id: "OPP-01", title: "Partner-led CAC engine",  cat: "growth",      impact: "high", conf: 62, desc: "CBS providers and brokers already hold the issuers and are paid on success — a near-zero-CAC acquisition channel if the alliance executes.", evidence: "DOC-001 GTM · CAC $500–800 vs ~$14K GM-LTV target (model, H)." },
        { id: "OPP-02", title: "TX tokenization rail",    cat: "partnership", impact: "high", conf: 55, new: true, desc: "The TX founding-tier alliance bundles BD-of-record (Texture), capital intro (CoreNest) and a tokenization rail in one package — compressing the rail build.", evidence: "DOC-012 at signature (P); contingent on cap intro, not executed (GAP-03)." },
        { id: "OPP-03", title: "Acceptance-data moat",    cat: "product",     impact: "med",  conf: 58, desc: "Each offering feeds the broker-acceptance dataset; the compounding loop over what clears review is defensible beyond the document templates.", evidence: "Thesis pillar 'compounding loop' — no operating data yet (H)." },
        { id: "OPP-04", title: "Reg CF retail tier",      cat: "pricing",     impact: "med",  conf: 50, desc: "One SAFE across Reg D + Reg CF opens a retail tier and an upsell path from the $199–499/mo base into the $3.6–12K/yr blended ARPA.", evidence: "DOC-013 tiers vs DOC-001 ARPA (X-05, resolved)." },
      ],
      graphInsights: {
        stat: [["objects", "21"], ["relationships", "30"], ["edges at risk", "3"]],
        note: "The deal spine closes — Company → Project → Offering → Security → Asset → Company — but the root entity is pre-incorporation and three distribution / commitment edges are at signature, not executed.",
        relations: [
          { from: "Raisable Inc.", rel: "root of spine", to: "(pre-inc.)", status: "at-risk", note: "The spine's root entity does not legally exist until Jul 1 incorporation (GAP-01)." },
          { from: "TX (alliance)", rel: "BD agreement →", to: "Texture Capital", status: "at-risk", note: "At signature, not executed; Texture clears the 506(c) rail (GAP-03)." },
          { from: "Reg CF Offering", rel: "distributed via →", to: "Funding portal (TBD)", status: "open", note: "No portal selected — the Reg CF rail is an unresolved node (GAP-06)." },
          { from: "TX", rel: "capital intro via →", to: "CoreNest", status: "at-risk", note: "Anchor candidate only; $0 committed (GAP-05)." },
          { from: "Reg D + Reg CF", rel: "sell →", to: "one YC SAFE", status: "firm", note: "A single instrument across both offerings — drafted (DOC-003)." },
        ],
        chains: [
          { label: "Deal spine", path: "Company → Project → Offering → Security → Asset → Company", status: "firm", note: "Closed, validated loop — structurally complete." },
          { label: "Distribution", path: "Offering → Texture / portal → clears exemption", status: "at-risk", note: "506(c) rail at signature; CF rail unselected." },
          { label: "Root binding", path: "Raisable Inc. (pre-inc.) → everything downstream", status: "at-risk", note: "Every downstream edge waits on Jul 1 incorporation." },
        ],
        insight: "The graph topology is sound — the deal spine forms a complete, validated loop — but it hangs off a root that isn't incorporated yet and two distribution edges that are signed, not executed. The structure is right; its bindings are pending, which is exactly what the readiness gates enforce.",
      },
      pageHead: {
        eyebrow: "Raisable Inc. · Raisable Inc. — Seed Round",
        title: "Offering Dossier — Intelligence Report",
        sub: "Continuous intelligence on Raisable's seed round.",
      },
      metrics: kpis,
      CLASS: R.CLASS,
      kbLen: R.KB.length,
      thesis: D.thesis,
      verdict: D.verdict,
      findings: D.findings,
      classCounts: R.classCounts(),
      strengths: D.strengths,
      asks: D.asks,
      risks: D.risks,
      diligence: {
        framing: { tag: "pre-incorporation", text: "Articles drafted to filing standard (DOC-002) but unfiled — target Jul 1, 2026. No EIN, no bank, no statements. Everything below is self-reported until the entity exists." },
        verifyMix,
        verification: D.verification,
        verifyNote: "material claims cross-checked against their single source — and where statements disagree",
        contradictions: D.contradictions,
        filings,
        gaps: D.gaps,
      },
      readiness: { paths, actions: D.actions },
      sources: {
        note: "Every fact cites one source — " + R.KB.length + " facts across " + Object.keys(R.SRC).length + " sources, each carrying a source-reliability score, version, a page/section locator and an upload · parse timestamp. Sourced facts live in the Knowledge Base; only the registry is tabled here.",
        registry,
        links: [["knowledge base", "kb"], ["knowledge graph", "graph"], ["entity registry", "entity"], ["workflow", "workflow"]],
      },
      classSections: {
        subject: () => <BusinessTab></BusinessTab>,
        instrument: () => <OfferingTab></OfferingTab>,
        underwriting: () => <FinModel></FinModel>,
      },
      footer: "DEMO DATA — assembled from the offering data room (documents · settings · onboarding). Classifications: V verified · P self-reported · A assumption · H hypothesis · Q questionable. Unaudited; not an offer to sell securities.",
    };
  })();
})();
