// ═══════════════════════════════════════════════════════════════════
// RAISABLE INVESTMENT — SHARED VIEWS
// The Investment-project surfaces, each mounted where it belongs:
//   · window.OfferingsTab          → Operations · Projects (the two offerings)
//   · window.RaisableInstanceGraph → Ontology · Object Explorer (instances)
//   · window.RaiseExecution        → Execution · Raise (financials, proceeds,
//                                    compliance & provenance)
// Reads window.RAISABLE; writes nothing.
// ═══════════════════════════════════════════════════════════════════
(function () {
  const { useState } = React;
  const R = window.RAISABLE;
  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 STATUS_TONE = { subscribed: "ok", "pending-docs": "warn", kyc: "info", filed: "ok", due: "warn", pending: "info", future: "neutral" };

  // shared ontology visual language (window.OKit) — palette, glyphs, category
  // helpers and the legend, declared once in OntologyKit.jsx and reused here,
  // on the Knowledge Graph, the Ontology Reference and the Entity Registry.
  const OK = window.OKit;
  const { CAT_COLOR, subjCat, subjColor, subjGlyph } = OK;

  // ── offering card — one per exemption path ────────────────────────
  function OfferingPanel({ o }) {
    const committed = o.raisedCommitted, pct = Math.round((committed / o.target) * 100);
    return (
      <div 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: "13px 16px", display: "flex", alignItems: "baseline", justifyContent: "space-between", gap: 10, flexWrap: "wrap" }}>
          <div style={{ display: "flex", alignItems: "baseline", gap: 10 }}>
            <span style={{ fontFamily: "var(--mono)", fontSize: "9px", letterSpacing: "0.1em", color: "var(--accent-hi)" }}>{o.id}</span>
            <span style={{ fontFamily: "var(--ui-display)", fontWeight: 600, fontSize: "var(--fs-md)" }}>{o.label}</span>
          </div>
          <span style={{ fontFamily: "var(--mono)", fontWeight: 600, fontSize: "13px" }}>{usd(o.target)}{o.max > o.target ? " – " + usd(o.max) : ""}</span>
        </div>
        <div style={{ padding: "13px 16px" }}>
          <div style={{ display: "flex", flexDirection: "column", gap: 5 }}>
            {[["security", o.security], ["terms", o.unitPrice + " · " + o.units], ["valuation", o.valuation], ["minimum", "$" + o.minInvestment.toLocaleString() + " per investor"], ["audience", o.audience], ["rails", o.rails], ["fees", o.fees], ["verification", o.verification]].map(([k, vv]) => (
              <div key={k} style={{ display: "grid", gridTemplateColumns: "92px 1fr", gap: 10, borderTop: "1px solid var(--rule-soft)", padding: "5px 0" }}>
                {mono(k)}<span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-2)", lineHeight: 1.5 }}>{vv}</span>
              </div>
            ))}
          </div>
          {/* coverage bar */}
          <div style={{ marginTop: 12 }}>
            <div style={{ display: "flex", justifyContent: "space-between", alignItems: "baseline", marginBottom: 4 }}>
              {mono("commitments vs target · aggregates")}
              <span style={{ fontFamily: "var(--mono)", fontSize: "10px", fontWeight: 600, color: committed > 0 ? "var(--ok)" : "var(--ink-4)" }}>{committed > 0 ? usd(committed) + " · " + pct + "%" + (pct > 100 ? " · oversubscribed" : "") : "no commitments yet"}</span>
            </div>
            <div style={{ height: 7, background: "var(--bg-3)", borderRadius: 4, overflow: "hidden" }}>
              <div style={{ width: Math.min(100, pct) + "%", height: "100%", background: committed > 0 ? "var(--ok)" : "var(--bg-3)", borderRadius: 4 }}></div>
            </div>
          </div>
          {/* timeline */}
          <div style={{ marginTop: 12 }}>
            {mono("timeline", { display: "block", marginBottom: 6 })}
            <div style={{ display: "flex", flexDirection: "column", gap: 3 }}>
              {o.timeline.map((t, i) => (
                <div key={i} style={{ display: "grid", gridTemplateColumns: "14px 88px 1fr", gap: 8, alignItems: "baseline" }}>
                  <span style={{ color: t.done ? "var(--ok)" : "var(--ink-5)", fontSize: "10px" }}>{t.done ? "●" : "○"}</span>
                  <span style={{ fontFamily: "var(--mono)", fontSize: "9px", color: "var(--ink-4)", whiteSpace: "nowrap" }}>{t.date}</span>
                  <span style={{ fontSize: "var(--fs-xs)", color: t.done ? "var(--ink-2)" : "var(--ink-3)" }}>{t.what}</span>
                </div>
              ))}
            </div>
          </div>
          {/* perks */}
          <div style={{ marginTop: 12 }}>
            {mono("investor perks (non-securities)", { display: "block", marginBottom: 6 })}
            <div style={{ display: "flex", flexDirection: "column", gap: 4 }}>
              {o.perks.map((p, i) => (
                <div key={i} style={{ display: "grid", gridTemplateColumns: "120px 1fr auto", gap: 8, alignItems: "baseline", borderTop: "1px solid var(--rule-soft)", padding: "4px 0" }}>
                  <span style={{ fontFamily: "var(--mono)", fontSize: "9px", fontWeight: 600, color: "var(--accent-lo)", whiteSpace: "nowrap" }}>{p.tier}</span>
                  <span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-2)" }}>{p.perk}</span>
                  <span style={{ fontFamily: "var(--mono)", fontSize: "8.5px", color: "var(--ink-4)", whiteSpace: "nowrap" }}>{p.cap}</span>
                </div>
              ))}
            </div>
          </div>
        </div>
      </div>
    );
  }

  // ── Operations · Projects — the offerings run ON the platform ─────
  // Meridian Capital — a customer project provisioned with one dual-tranche
  // offering: US accredited via Reg D 506(c), non-US persons via Reg S.
  const MERIDIAN_OFFERINGS = [
    {
      id: "OFF-MER-A", label: "Series A · Reg D 506(c) + Reg S", exemption: "EX-506c", state: "in-review",
      security: "Series A Preferred Stock", unitPrice: "$8.50 / share", units: "1,411,764",
      target: 10000000, max: 12000000, raisedCommitted: 4200000, minInvestment: 25000,
      valuation: "$48.0M pre-money", broker: "tzero", portal: null, rail: "tZERO",
      fees: "tZERO 5% placement + ATS listing fee · institutional terms",
      verification: "US tranche — tZERO ATS, verified accredited (506(c)) · Reg S tranche — offshore transaction, no directed selling efforts, 40-day distribution-compliance period",
      audience: "US accredited (Reg D 506(c)) + non-US persons (Reg S, Category 3)",
      timeline: [
        { date: "May 28, 2026", what: "Dual-tranche structure cleared by counsel",        done: true  },
        { date: "Jun 5, 2026",  what: "Reg S offshore offering memorandum finalized",      done: true  },
        { date: "Jul 1, 2026",  what: "Offering launch · both tranches live",              done: false },
        { date: "Aug 15, 2026", what: "Form D filing due (US tranche, 15d before sale)",   done: false },
        { date: "Oct 11, 2026", what: "Reg S distribution-compliance period ends",         done: false },
        { date: "Feb 28, 2027", what: "Target close",                                      done: false },
      ],
      perks: [
        { tier: "US · 506(c)",  perk: "Pro-rata rights + quarterly information rights",        cap: "Accredited" },
        { tier: "$250,000+",    perk: "Major-investor rights — board observer + MFN clause",     cap: "Max 4" },
        { tier: "Reg S · intl", perk: "Offshore subscription via offering memorandum",          cap: "Non-US only" },
      ],
    },
  ];
  const PROJECTS = [
    { id: "raisable", name: "Raisable", sub: "self · investment", count: 2 },
    { id: "meridian",  name: "Meridian Capital", sub: "Reg D 506(c) + Reg S", count: 1 },
    { id: "northbridge", name: "NorthBridge Fund", sub: "Reg CF", count: 0 },
  ];

  function OfferingsTab() {
    const [proj, setProj] = useState("raisable");
    const active = PROJECTS.find((p) => p.id === proj) || PROJECTS[0];
    return (
      <div>
        <div style={{ display: "flex", gap: 6, flexWrap: "wrap", marginBottom: 18 }}>
          {PROJECTS.map((p) => (
            <button key={p.id} onClick={() => setProj(p.id)} style={{ border: "1px solid " + (proj === p.id ? "var(--accent)" : "var(--rule-hard)"), background: proj === p.id ? "var(--accent-bg)" : "var(--bg)", color: proj === p.id ? "var(--accent-lo)" : "var(--ink-2)", padding: "8px 14px", borderRadius: "var(--r-2)", cursor: "pointer", display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 2, minWidth: 130 }}>
              <span style={{ fontFamily: "var(--ui-display)", fontWeight: 600, fontSize: "var(--fs-sm)", letterSpacing: "var(--ls-card)" }}>{p.name}</span>
              <span style={{ fontFamily: "var(--mono)", fontSize: "8.5px", letterSpacing: "0.08em", textTransform: "uppercase", color: proj === p.id ? "var(--accent-lo)" : "var(--ink-4)", opacity: 0.9 }}>{p.sub} · {p.count} offering{p.count !== 1 ? "s" : ""}</span>
            </button>
          ))}
        </div>

        {proj === "raisable" && (
          <div>
            <div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(380px, 1fr))", gap: 14 }}>
              {R.OFFERINGS.map((o) => <OfferingPanel key={o.id} o={o}></OfferingPanel>)}
            </div>
            <div style={{ display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap", marginTop: 14, border: "1px solid var(--rule-hard)", borderRadius: "var(--r-3)", padding: "11px 14px", background: "var(--bg)" }}>
              <window.Pill tone="accent">self · investment</window.Pill>
              <span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.5, flex: 1, minWidth: 260 }}>
                <b style={{ color: "var(--ink)", fontWeight: 600 }}>Raisable Investment</b> — Raisable Inc. as an issuer on its own platform, run like any customer project. Objects live in <button onClick={() => window.navigateTo("ontology")} style={{ border: "none", background: "none", padding: 0, cursor: "pointer", color: "var(--accent-lo)", fontSize: "inherit", fontFamily: "inherit", textDecoration: "underline" }}>Ontology · Object Explorer</button>; the investor-facing read is <button onClick={() => window.navigateTo("analytics")} style={{ border: "none", background: "none", padding: 0, cursor: "pointer", color: "var(--accent-lo)", fontSize: "inherit", fontFamily: "inherit", textDecoration: "underline" }}>Analytics · Investor Intelligence</button>.
              </span>
            </div>
            <p style={{ margin: "12px 0 0", fontFamily: "var(--mono)", fontSize: "9px", letterSpacing: "0.06em", color: "var(--ink-4)", lineHeight: 1.7 }}>
              {R.DEMAND.piiNote}
            </p>
          </div>
        )}

        {proj === "meridian" && (
          <div>
            <div style={{ display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap", marginBottom: 14, border: "1px solid var(--rule-hard)", borderRadius: "var(--r-3)", padding: "11px 14px", background: "var(--bg)" }}>
              <window.Pill tone="info">customer project</window.Pill>
              <span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.5, flex: 1, minWidth: 260 }}>
                <b style={{ color: "var(--ink)", fontWeight: 600 }}>Meridian Capital</b> — a single Series A raise split into two tranches: US accredited investors via <b style={{ color: "var(--ink-2)", fontWeight: 600 }}>Reg D 506(c)</b> and non-US persons via <b style={{ color: "var(--ink-2)", fontWeight: 600 }}>Reg S</b> (offshore, no directed selling into the US). One offering object, two exemption paths.
              </span>
            </div>
            <div style={{ display: "grid", gridTemplateColumns: "repeat(2, minmax(0, 1fr))", gap: 14 }}>
              {MERIDIAN_OFFERINGS.map((o) => <OfferingPanel key={o.id} o={o}></OfferingPanel>)}
            </div>
          </div>
        )}

        {proj === "northbridge" && (
          <div style={{ border: "1px solid var(--rule-hard)", borderRadius: "var(--r-3)", background: "var(--bg)", padding: "32px 20px", textAlign: "center" }}>
            <div style={{ fontFamily: "var(--ui-display)", fontWeight: 600, fontSize: "var(--fs-base)", color: "var(--ink-2)", marginBottom: 6 }}>{active.name}</div>
            <div style={{ fontFamily: "var(--mono)", fontSize: "9.5px", letterSpacing: "0.06em", textTransform: "uppercase", color: "var(--ink-4)" }}>No offerings yet · {active.sub}</div>
          </div>
        )}
      </div>
    );
  }

  // ── instance ontology graph — the offering objects, fully connected ──
  function RaisableInstanceGraph() {
    const [sel, setSel] = useState(null);
    const { nodes, edges } = R.graph();
    const v = R.validate();
    // columnar layout: issuer → offerings → gate/rails → reference axes
    const COLS = [
      ["PTY-tx", "PTY-corenest", "PTY-cbs", "PTY-founders"],
      ["CO-raisable", "PRJ-raisable"],
      ["OFF-RD-2026", "OFF-CF-2026"],
      ["SEC-safe", "ASSET-equity", "VAL-cap", "HLD-founders", "CHAIN-target", "DOC-room"],
      ["BRK-texture", "BRK-spcp", "BRK-tzero", "BRK-portal"],
      ["EX-506c", "EX-cf", "JUR-us"],
    ];
    const COL_HEAD = ["parties · capital intro", "issuer · venture", "offerings", "security · asset · chain · provenance", "rails · broker-dealer", "exemption · jurisdiction"];
    const W = 1440, NW = 172, NH = 50, COLW = W / COLS.length;
    const maxRows = Math.max(...COLS.map((c) => c.length));
    const H = 90 + maxRows * 86;
    const pos = {};
    COLS.forEach((col, ci) => {
      const x = COLW * ci + COLW / 2;
      const start = (H - 30) / 2 - ((col.length - 1) * 86) / 2 + 30;
      col.forEach((id, ri) => { pos[id] = { x, y: start + ri * 86 }; });
    });
    const node = Object.fromEntries(nodes.map((n) => [n.id, n]));
    const path = (a, b) => {
      const dx = (b.x - a.x) / 2;
      return `M ${a.x + (b.x > a.x ? NW / 2 : -NW / 2)} ${a.y} C ${a.x + dx} ${a.y} ${b.x - dx} ${b.y} ${b.x + (b.x > a.x ? -NW / 2 : NW / 2)} ${b.y}`;
    };
    return (
      <div style={{ border: "1px solid var(--rule-hard)", borderRadius: "var(--r-3)", background: "var(--bg)", padding: "10px 12px" }}>
        <div style={{ display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap", padding: "2px 4px 8px" }}>
          {mono("ontology objects · " + v.objects + " instances of " + v.classes + " World-Model subjects · " + v.links + " links")}
          <span style={{ marginLeft: "auto" }}>
            <window.Pill tone={v.ok ? "ok" : "err"}>{v.ok ? "fully connected · 0 dangling refs" : (v.issues.length + v.unreachable.length) + " graph issues"}</window.Pill>
          </span>
        </div>
        <svg viewBox={`0 0 ${W} ${H}`} style={{ width: "100%", height: "auto", display: "block" }}>
          <defs>
            <marker id="ii-arrow" markerWidth="8" markerHeight="8" refX="6" refY="4" orient="auto"><path d="M0,0 L8,4 L0,8 Z" fill="var(--ink-4)"></path></marker>
            <marker id="ii-arrow-on" markerWidth="8" markerHeight="8" refX="6" refY="4" orient="auto"><path d="M0,0 L8,4 L0,8 Z" fill="var(--accent)"></path></marker>
          </defs>
          {COLS.map((col, ci) => (
            <text key={ci} x={COLW * ci + COLW / 2} y={20} textAnchor="middle" fontFamily="var(--mono)" fontSize="9.5" fontWeight="700" letterSpacing="1.6" fill="var(--ink-4)" style={{ textTransform: "uppercase" }}>{COL_HEAD[ci]}</text>
          ))}
          {edges.map((e, i) => {
            const a = pos[e.from], b = pos[e.to];
            if (!a || !b) return null;
            const on = sel && (e.from === sel || e.to === sel);
            return (
              <g key={i} opacity={sel && !on ? 0.12 : 1}>
                <path d={path(a, b)} fill="none" stroke={on ? "var(--accent)" : "var(--ink-5)"} strokeWidth={on ? 1.8 : 1} markerEnd={on ? "url(#ii-arrow-on)" : "url(#ii-arrow)"} opacity={on ? 1 : 0.7}></path>
                {on && (() => { const mx = (a.x + b.x) / 2, my = (a.y + b.y) / 2 - 2; const bw = e.label.length * 5.6 + 14; return (
                  <g><rect x={mx - bw / 2} y={my - 9} width={bw} height={15} rx="2" fill="var(--bg)" stroke="var(--accent-bd)"></rect><text x={mx} y={my + 2} textAnchor="middle" fontFamily="var(--mono)" fontSize="8.5" fill="var(--accent-lo)">{e.label}</text></g>
                ); })()}
              </g>
            );
          })}
          {nodes.map((n) => {
            const p = pos[n.id]; if (!p) return null;
            const on = sel === n.id;
            const c = subjColor(n.of);
            const cat = subjCat(n.of);
            const reified = cat === "reified";
            const dashed = cat === "ref";
            const fill = on ? "var(--accent-bg)" : "var(--bg)";
            const stroke = on ? "var(--accent)" : c;
            const hex = `0,${NH / 2} 14,0 ${NW - 14},0 ${NW},${NH / 2} ${NW - 14},${NH} 14,${NH}`;
            const tx = reified ? 22 : 13;
            return (
              <g key={n.id} transform={`translate(${p.x - NW / 2}, ${p.y - NH / 2})`} style={{ cursor: "pointer" }} onClick={() => setSel(on ? null : n.id)}>
                <title>{n.id + " · " + (reified ? "reified edge of " : "object of ") + n.of}</title>
                {reified ? (
                  <polygon points={hex} fill={fill} stroke={stroke} strokeWidth={on ? 2 : 1.4}></polygon>
                ) : (
                  <rect width={NW} height={NH} rx="6" fill={fill} stroke={stroke} strokeWidth={on ? 2 : (dashed ? 1 : 1.4)} strokeDasharray={dashed && !on ? "4 3" : ""}></rect>
                )}
                <text x={tx} y="20" fontFamily="var(--ui-display)" fontSize="12" fontWeight="600" fill="var(--ink)">
                  <tspan fontFamily="var(--mono)" fontWeight="400" fill={on ? "var(--accent)" : c}>{subjGlyph(n.of)} </tspan>
                  {n.name.length > 20 ? n.name.slice(0, 19) + "…" : n.name}
                </text>
                <text x={tx} y="36" fontFamily="var(--mono)" fontSize="8" fill={reified ? c : "var(--ink-4)"} letterSpacing="0.4">{reified ? "reified edge" : n.kicker}</text>
              </g>
            );
          })}
        </svg>
        <OK.CategoryLegend style={{ padding: "8px 4px 2px", borderTop: "1px solid var(--rule-soft)", marginTop: 4 }}></OK.CategoryLegend>
        <div style={{ display: "flex", gap: 14, flexWrap: "wrap", padding: "8px 6px 2px", alignItems: "baseline" }}>
          {sel && node[sel] ? (
            <span style={{ display: "inline-flex", alignItems: "baseline", gap: 8 }}>
              <span style={{ width: 8, height: 8, borderRadius: 2, background: subjColor(node[sel].of), alignSelf: "center", flex: "0 0 auto" }}></span>
              {mono(sel)}<span style={{ fontFamily: "var(--mono)", fontSize: "9px", fontWeight: 600, color: "var(--accent-lo)", border: "1px solid var(--accent-bd)", borderRadius: "var(--r-1)", padding: "1px 6px" }}>{node[sel].of}</span>
              <span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-3)" }}>{node[sel].kicker}</span>
            </span>
          ) : mono("click an object to trace its links · coloured by ontology subject category · the World Model")}
          <span style={{ marginLeft: "auto" }}>{mono("every node is an instance of a World-Model subject")}</span>
        </div>
      </div>
    );
  }

  // ── financial snapshot + ARR ramp (Business Execution) ─────────────
  function FinancialSnapshot() {
    const F = R.FINANCIALS;
    const maxArr = Math.max(...F.arrRamp.map((r) => r.arr));
    return (
      <div style={{ display: "grid", gridTemplateColumns: "1fr 1.3fr", gap: 14 }}>
        <div style={{ border: "1px solid var(--rule-hard)", borderRadius: "var(--r-3)", background: "var(--bg)", padding: "12px 14px" }}>
          {mono("snapshot · " + 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: "5px 0" }}>
              {mono(k)}<span style={{ fontFamily: "var(--mono)", fontSize: "10.5px", fontWeight: 600, color: "var(--ink-2)", whiteSpace: "nowrap" }}>{vv}</span>
            </div>
          ))}
          <div style={{ marginTop: 10 }}>
            {mono("revenue mix", { display: "block", marginBottom: 6 })}
            {F.revMix.length === 0 && <p style={{ margin: 0, fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.55 }}>{F.revMixNote}</p>}
            {F.revMix.map((m) => (
              <div key={m.stream} style={{ display: "grid", gridTemplateColumns: "1fr 44px", gap: 8, alignItems: "center", padding: "3px 0" }}>
                <div>
                  <div style={{ fontSize: "var(--fs-xs)", color: "var(--ink-2)" }}>{m.stream}</div>
                  <div style={{ height: 5, background: "var(--bg-3)", borderRadius: 3, overflow: "hidden", marginTop: 3 }}><div style={{ width: m.pct + "%", height: "100%", background: "var(--accent)", borderRadius: 3 }}></div></div>
                </div>
                <span style={{ fontFamily: "var(--mono)", fontSize: "9.5px", fontWeight: 600, color: "var(--accent-lo)", textAlign: "right" }}>{m.pct}%</span>
              </div>
            ))}
          </div>
        </div>
        <div style={{ border: "1px solid var(--rule-hard)", borderRadius: "var(--r-3)", background: "var(--bg)", padding: "12px 14px", display: "flex", flexDirection: "column" }}>
          {mono("projected ARR ramp · plan hypothesis · starts from a $0 actual · DOC-001", { display: "block", marginBottom: 10 })}
          <div style={{ flex: 1, display: "grid", gridTemplateColumns: "repeat(5, 1fr)", gap: 12, alignItems: "end", minHeight: 150 }}>
            {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) * 120), background: r.year === "2026" ? "var(--accent)" : "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()} cust.</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>
    );
  }

  // ── use of proceeds + filings + provenance (Business Execution) ────
  function ProceedsAndCompliance() {
    return (
      <div style={{ display: "grid", gridTemplateColumns: "1fr 1.2fr", gap: 14 }}>
        <div style={{ border: "1px solid var(--rule-hard)", borderRadius: "var(--r-3)", background: "var(--bg)", padding: "12px 14px" }}>
          {mono("use of proceeds · identical split across both offerings", { display: "block", marginBottom: 8 })}
          {R.USE_OF_PROCEEDS.map((u) => (
            <div key={u.cat} style={{ borderTop: "1px solid var(--rule-soft)", padding: "6px 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)" }}>{u.pct}%</span>
              </div>
              <div style={{ height: 6, background: "var(--bg-3)", borderRadius: 3, overflow: "hidden", margin: "5px 0 3px" }}><div style={{ width: u.pct * 2 + "%", 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 style={{ display: "flex", flexDirection: "column", gap: 14 }}>
          <div style={{ border: "1px solid var(--rule-hard)", borderRadius: "var(--r-3)", background: "var(--bg)", padding: "12px 14px" }}>
            {mono("filings & compliance gates · readiness milestones", { display: "block", marginBottom: 8 })}
            {R.FILINGS.map((f) => (
              <div key={f.id} style={{ display: "grid", gridTemplateColumns: "auto 1fr", gap: 10, alignItems: "baseline", borderTop: "1px solid var(--rule-soft)", padding: "6px 0" }}>
                <window.Pill tone={STATUS_TONE[f.status]}>{f.status}</window.Pill>
                <div>
                  <div style={{ fontSize: "var(--fs-sm)", color: "var(--ink)", fontWeight: 500 }}>{f.name}</div>
                  <div style={{ fontSize: "var(--fs-xs)", color: "var(--ink-3)", marginTop: 2 }}>{f.detail}</div>
                </div>
              </div>
            ))}
          </div>
          <div style={{ border: "1px solid var(--rule-hard)", borderRadius: "var(--r-3)", background: "var(--bg)", padding: "12px 14px" }}>
            {mono("provenance · data room → KB facts", { display: "block", marginBottom: 8 })}
            <p style={{ margin: "0 0 8px", fontSize: "var(--fs-xs)", color: "var(--ink-3)", lineHeight: 1.55 }}>
              {R.KB.length} knowledge-base facts extracted from <span style={{ fontFamily: "var(--mono)", fontSize: "10px", color: "var(--ink-2)" }}>offering data room · documents / settings / onboarding</span> — each fact carries exactly one source — a data-room document, the offering settings, or the onboarding profile (the ENT-kbkey contract).
            </p>
            <div style={{ display: "flex", gap: 6, flexWrap: "wrap" }}>
              {Object.entries(R.SRC).map(([id, s]) => (
                <span key={id} title={s.file} style={{ display: "inline-flex", alignItems: "baseline", gap: 6, border: "1px solid var(--rule-hard)", borderRadius: "var(--r-1)", padding: "3px 8px", background: "var(--bg-2)" }}>
                  <span style={{ fontFamily: "var(--mono)", fontSize: "8.5px", color: "var(--accent-lo)", letterSpacing: "0.04em" }}>{id}</span>
                  <span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-3)" }}>{s.name}</span>
                </span>
              ))}
            </div>
          </div>
        </div>
      </div>
    );
  }

  // ── Execution · Raise — the business-execution read of the raise ──
  function RaiseExecution() {
    return (
      <div>
        <div style={{ display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap", marginBottom: 14 }}>
          <window.Pill tone="accent">Raisable Business</window.Pill>
          <span style={{ fontSize: "var(--fs-xs)", color: "var(--ink-3)" }}>The operating-company side of the raise — where the capital goes and what must be filed. The investor-facing dossier reads the same facts under <button onClick={() => window.navigateTo("analytics")} style={{ border: "none", background: "none", padding: 0, cursor: "pointer", color: "var(--accent-lo)", fontSize: "inherit", fontFamily: "inherit", textDecoration: "underline" }}>Analytics · Investor Intelligence</button>.</span>
        </div>
        <window.SectionHead sub="pre-incorporation — no entity, no statements yet · plan targets from DOC-010">Financial Intelligence</window.SectionHead>
        <FinancialSnapshot></FinancialSnapshot>
        <window.SectionHead sub="where the capital goes · what must be filed · where every fact came from">Proceeds, Compliance & Provenance</window.SectionHead>
        <ProceedsAndCompliance></ProceedsAndCompliance>
      </div>
    );
  }

  Object.assign(window, { OfferingsTab, RaisableInstanceGraph, RaiseExecution });
})();
