(function(){
/* FORGE · Aetherion (Space tenant) — Act 4 screens.
   Wave A1 / Space / Agent #6.

   Three screens registered at end of file. Babel-standalone in-browser
   pattern. NO ES imports / exports.

   Globals expected (defensively resolved):
     React, registerSpaceRoute() / registerPumpRoute(),
     window.AECard, window.AEPill, window.AEBtn, window.AEToolbar,
     window.AEStatRow, window.AESectionTitle, window.AEFlash,
     window.AEMassPowerBadge.

   Screens:
     ScreenAetherionRouting        /build/routing
     ScreenAetherionDesignGates    /build/gates
     ScreenAetherionLineReadiness  /line/readiness

   Style: React.createElement (no JSX), inline styles, cool blues palette,
   monospace numerics with mandatory units. No emoji. No glyph stand-ins.
*/

const _AE_h = React.createElement;
const { useState: uS_AE4, useEffect: uE_AE4, useMemo: uM_AE4, useRef: uR_AE4 } = React;

/* ──────────────────────────────────────────────────────────────────────
   Defensive atom resolution — if cross-cutting hasn't loaded, fall back
   to a minimal inline shim so the screen still renders.
   ────────────────────────────────────────────────────────────────────── */

const _AECard = (typeof window !== "undefined" && window.AECard) || function (p) {
  return _AE_h(
    "div",
    {
      style: {
        padding: (p && p.pad) || 16,
        border: "1px solid var(--line)",
        borderRadius: 8,
        background: "var(--bg-1)",
        color: "var(--ink)",
      },
    },
    p && p.children
  );
};

const _AEPill = (typeof window !== "undefined" && window.AEPill) || function (p) {
  const tone = (p && p.tone) || "info";
  const map = {
    pass: "var(--ok)",
    fail: "var(--err)",
    warn: "var(--warn)",
    info: "#2D5BEA",
    qual: "#2D5BEA",
    trl9: "var(--ok)",
    mute: "var(--ink-3)",
  };
  const c = map[tone] || map.info;
  return _AE_h(
    "span",
    {
      style: {
        display: "inline-flex",
        alignItems: "center",
        gap: 4,
        padding: "2px 8px",
        borderRadius: 999,
        border: "1px solid " + c,
        color: c,
        background: "transparent",
        fontFamily: "var(--font-mono, ui-monospace, monospace)",
        fontSize: 12,
        letterSpacing: "0.04em",
        textTransform: "uppercase",
      },
    },
    p && p.children
  );
};

const _AEBtn = (typeof window !== "undefined" && window.AEBtn) || function (p) {
  const variant = (p && p.variant) || "ghost";
  const styles = {
    primary: { background: "#2D5BEA", color: "var(--bg-0)", border: "1px solid #2D5BEA" },
    ghost: { background: "transparent", color: "var(--ink)", border: "1px solid var(--line)" },
    destructive: { background: "transparent", color: "var(--err)", border: "1px solid var(--err)" },
  };
  return _AE_h(
    "button",
    {
      onClick: p && p.onClick,
      disabled: p && p.disabled,
      style: Object.assign(
        {
          padding: "6px 12px",
          borderRadius: 4,
          fontSize: 12,
          letterSpacing: "0.04em",
          textTransform: "uppercase",
          fontFamily: "var(--font-mono, ui-monospace, monospace)",
          cursor: (p && p.disabled) ? "not-allowed" : "pointer",
          opacity: (p && p.disabled) ? 0.45 : 1,
        },
        styles[variant] || styles.ghost,
        (p && p.style) || {}
      ),
    },
    p && p.children
  );
};

const _AEToolbar = (typeof window !== "undefined" && window.AEToolbar) || function (p) {
  return _AE_h(
    "div",
    {
      style: {
        display: "flex",
        alignItems: "center",
        justifyContent: "space-between",
        gap: 8,
        padding: "8px 12px",
        borderBottom: "1px solid var(--line)",
        background: "var(--bg-0)",
      },
    },
    _AE_h("div", { style: { display: "flex", gap: 8, alignItems: "center", flexWrap: "wrap" } }, p && p.left),
    _AE_h("div", { style: { display: "flex", gap: 8, alignItems: "center" } }, p && p.right)
  );
};

const _AEStatRow = (typeof window !== "undefined" && window.AEStatRow) || function (p) {
  return _AE_h(
    "div",
    {
      style: {
        display: "flex",
        justifyContent: "space-between",
        alignItems: "baseline",
        padding: "6px 0",
        borderBottom: "1px dashed var(--line)",
        fontSize: 12,
      },
    },
    _AE_h("span", { style: { color: "var(--ink-3)", textTransform: "uppercase", letterSpacing: "0.06em", fontSize: 12 } }, p && p.label),
    _AE_h(
      "span",
      {
        style: {
          color: "var(--ink)",
          fontFamily: (p && p.mono !== false) ? "var(--font-mono, ui-monospace, monospace)" : "inherit",
        },
      },
      [p && p.value, p && p.unit ? " " + p.unit : ""].join("")
    )
  );
};

const _AESectionTitle = (typeof window !== "undefined" && window.AESectionTitle) || function (p) {
  return _AE_h(
    "div",
    { style: { marginBottom: 12 } },
    _AE_h(
      "div",
      {
        style: {
          fontFamily: "var(--font-mono, ui-monospace, monospace)",
          fontSize: 12,
          color: "var(--ink-3)",
          letterSpacing: "0.12em",
          textTransform: "uppercase",
          marginBottom: 4,
        },
      },
      p && p.kicker
    ),
    _AE_h(
      "div",
      { style: { fontSize: 18, color: "var(--ink)", letterSpacing: "-0.005em" } },
      p && p.title
    )
  );
};

const _AEFlash = (typeof window !== "undefined" && window.AEFlash) || function (p) {
  const tone = (p && p.tone) || "info";
  const map = { ok: "var(--ok)", warn: "var(--warn)", error: "var(--err)", info: "#2D5BEA" };
  const c = map[tone] || map.info;
  return _AE_h(
    "div",
    {
      style: {
        padding: "10px 14px",
        border: "1px solid " + c,
        borderLeft: "3px solid " + c,
        borderRadius: 4,
        color: "var(--ink)",
        background: "rgba(79,143,255,0.06)",
        fontSize: 12,
        lineHeight: 1.45,
      },
    },
    p && p.children
  );
};

/* ──────────────────────────────────────────────────────────────────────
   Shared inline helpers — kept tiny, no exports.
   ────────────────────────────────────────────────────────────────────── */

function _ae4_kicker(text) {
  return _AE_h(
    "div",
    {
      style: {
        fontFamily: "var(--font-mono, ui-monospace, monospace)",
        fontSize: 12,
        color: "var(--ink-3)",
        letterSpacing: "0.12em",
        textTransform: "uppercase",
      },
    },
    text
  );
}

function _ae4_mono(text, color) {
  return _AE_h(
    "span",
    {
      style: {
        fontFamily: "var(--font-mono, ui-monospace, monospace)",
        color: color || "var(--ink)",
        letterSpacing: "0.02em",
      },
    },
    text
  );
}

function _ae4_dot(color) {
  return _AE_h("span", {
    style: {
      display: "inline-block",
      width: 8,
      height: 8,
      borderRadius: "50%",
      background: color || "#2D5BEA",
      boxShadow: "0 0 0 2px rgba(79,143,255,0.18)",
      flexShrink: 0,
    },
  });
}

function _ae4_stationToneFor(state) {
  if (state === "active") return "#2D5BEA";
  if (state === "blocked") return "var(--err)";
  if (state === "queued") return "var(--warn)";
  if (state === "idle") return "var(--ink-3)";
  if (state === "done") return "var(--ok)";
  return "var(--ink-3)";
}

/* ════════════════════════════════════════════════════════════════════
   Screen 1 — ScreenAetherionRouting
   /build/routing
   Clean-room ISO 14644-1 Class 7 cell flow. Click a station for detail.
   ──────────────────────────────────────────────────────────────────── */

const _AE4_STATIONS = [
  {
    id: "s01",
    code: "RX-01",
    name: "Receiving + Incoming Inspection",
    cell: "Class-7 RX-01",
    state: "done",
    operator: "K. Patel",
    operatorRole: "Quality Tech II",
    takt: "42 min",
    dwell: "12 h N2 purge",
    tooling: ["MIL-DTL-38999 mating fixture", "TID cert scanner", "ESD wrist strap log"],
    qualGates: "QG-AET-01..05",
    wip: 2,
    yield: "99.4%",
    note: "Kit-level intake. CofC mandatory. N2 bag-and-purge >12 h before any optical surface mating.",
  },
  {
    id: "s02",
    code: "BS-02",
    name: "Subassy Bench + Harness Routing",
    cell: "Class-7 BS-02",
    state: "active",
    operator: "M. Sato",
    operatorRole: "Mech Lead",
    takt: "6 h 20 min",
    dwell: "ESD continuity verify on entry/exit",
    tooling: ["Laser-aligned trace board", "HRD-AET-001 routing key", "Glenair crimp 2050-101"],
    qualGates: "QG-AET-06..14",
    wip: 1,
    yield: "97.8%",
    note: "EPS, OBC, ADCS deck, payload optical bench. Harness laid per HRD-AET-001 with continuity log.",
  },
  {
    id: "s03",
    code: "HR-03",
    name: "Harness Routing Cell",
    cell: "Class-7 HR-03",
    state: "active",
    operator: "L. Nguyen",
    operatorRole: "Harness Tech III",
    takt: "3 h 50 min",
    dwell: "Overbraid pull-test before exit",
    tooling: ["MIL-DTL-38999 series III tool kit", "Overbraid pull tester (50 N)", "Continuity matrix RM-3500"],
    qualGates: "QG-AET-12..14",
    wip: 1,
    yield: "98.6%",
    note: "Harness final dress + overbraid. Glenair 801 backshells torqued to 0.8 Nm.",
  },
  {
    id: "s04",
    code: "IA-04",
    name: "Integration + Alignment",
    cell: "Class-7 IA-04 · Granite",
    state: "queued",
    operator: "R. Okafor",
    operatorRole: "I&T Lead",
    takt: "11 h",
    dwell: "Star-tracker boresight settle 90 min",
    tooling: ["Leica AT960 laser tracker", "Granite bench 2.4 m", "4 m vacuum-deploy rig"],
    qualGates: "QG-AET-15..21",
    wip: 0,
    yield: "98.0%",
    note: "Star tracker → imager focal plane via AT960. Boresight ≤25 µm at 2 m. Solar deployment in 4 m rig.",
  },
  {
    id: "s05",
    code: "TV-05",
    name: "TVAC Chamber",
    cell: "TVAC-1.5m · Class-7 anteroom",
    state: "blocked",
    operator: "S. Iyer",
    operatorRole: "Test Engineer",
    takt: "24 cycles · 96 h",
    dwell: "1e-5 torr pumpdown 8 h",
    tooling: ["1.5 m TVAC chamber TVAC-014", "Strain-gauge harness HG-03", "Pre-load torque audit kit"],
    qualGates: "QG-AET-22..25",
    wip: 0,
    yield: "92.1%",
    note: "ECO-AET-0042 retest TVAC-AET-014R queued. 24 cycles −40 / +85 °C. Strain-gauge + torque audit cycle 24.",
  },
  {
    id: "s06",
    code: "EM-06",
    name: "EMI / EMC Anechoic",
    cell: "Anechoic-South · Class 7",
    state: "queued",
    operator: "H. Reyes",
    operatorRole: "EMC Engineer",
    takt: "16 h",
    dwell: "Antenna calibration 60 min",
    tooling: ["MIL-STD-461G CE/CS/RE/RS suite", "RF anechoic chamber 6 m", "Spectrum analyzer N9020B"],
    qualGates: "QG-AET-26..27",
    wip: 0,
    yield: "96.4%",
    note: "MIL-STD-461G: CE101/102/106, CS101/114/115/116, RE101/102, RS103. Falcon 9 user-guide envelope +3 dB.",
  },
  {
    id: "s07",
    code: "VB-07",
    name: "Vibration Table",
    cell: "Shaker-1500 · Class 7",
    state: "queued",
    operator: "T. Costa",
    operatorRole: "Mech Test",
    takt: "9 h",
    dwell: "Sine survey + random vib + sine again",
    tooling: ["1500 lbf electrodynamic shaker", "Triax accelerometer set", "Sine-survey 5..2000 Hz"],
    qualGates: "QG-AET-28",
    wip: 0,
    yield: "97.9%",
    note: "GEVS / NASA-STD-7001 envelope, +3 dB margin per Falcon 9 user guide. Sine survey before and after random.",
  },
  {
    id: "s08",
    code: "SH-08",
    name: "Pyroshock",
    cell: "Shock-Pad · Class 7",
    state: "queued",
    operator: "T. Costa",
    operatorRole: "Mech Test",
    takt: "3 h",
    dwell: "Inspection 30 min post-shock",
    tooling: ["Pyroshock fixture 2000g half-sine", "High-rate accelerometer 100 kHz", "Functional cmd/tlm bench"],
    qualGates: "QG-AET-29",
    wip: 0,
    yield: "98.7%",
    note: "2000g half-sine 0.5 ms survival, three axes, three shots each. Functional test between axes.",
  },
  {
    id: "s09",
    code: "AC-09",
    name: "Acceptance + Flight CofC",
    cell: "Class-7 AC-09",
    state: "idle",
    operator: "Mission Director",
    operatorRole: "Sign-off authority",
    takt: "5 h",
    dwell: "CG measurement to ±1 mm",
    tooling: ["Mass-properties stand", "CG plumb fixture", "Flight CofC packet"],
    qualGates: "QG-AET-30",
    wip: 0,
    yield: "100%",
    note: "Final mass-properties (CG ±1 mm). Flight CofC packet bound. ITAR export record signed before crate-out.",
  },
];

function _AE4_StationCard(props) {
  const s = props.station;
  const selected = props.selected === s.id;
  const tone = _ae4_stationToneFor(s.state);
  return _AE_h(
    "div",
    {
      onClick: function () { props.onSelect && props.onSelect(s.id); },
      style: {
        cursor: "pointer",
        padding: 14,
        background: selected ? "rgba(79,143,255,0.08)" : "var(--bg-1)",
        border: "1px solid " + (selected ? "#2D5BEA" : "var(--line)"),
        borderRadius: 6,
        minWidth: 180,
        display: "flex",
        flexDirection: "column",
        gap: 8,
        transition: "background 120ms ease",
      },
    },
    _AE_h(
      "div",
      { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8 } },
      _AE_h(
        "div",
        { style: { display: "flex", alignItems: "center", gap: 6 } },
        _ae4_dot(tone),
        _ae4_mono(s.code, "#2D5BEA")
      ),
      _AE_h(
        "span",
        {
          style: {
            fontFamily: "var(--font-mono, ui-monospace, monospace)",
            fontSize: 12,
            color: tone,
            textTransform: "uppercase",
            letterSpacing: "0.08em",
          },
        },
        s.state
      )
    ),
    _AE_h(
      "div",
      { style: { fontSize: 12, color: "var(--ink)", lineHeight: 1.35 } },
      s.name
    ),
    _AE_h(
      "div",
      { style: { fontSize: 12, color: "var(--ink-3)", fontFamily: "var(--font-mono, ui-monospace, monospace)" } },
      s.cell
    ),
    _AE_h(
      "div",
      { style: { display: "flex", justifyContent: "space-between", marginTop: 4 } },
      _AE_h("span", { style: { fontSize: 12, color: "var(--ink-3)", textTransform: "uppercase", letterSpacing: "0.06em" } }, "WIP"),
      _ae4_mono(String(s.wip))
    ),
    _AE_h(
      "div",
      { style: { display: "flex", justifyContent: "space-between" } },
      _AE_h("span", { style: { fontSize: 12, color: "var(--ink-3)", textTransform: "uppercase", letterSpacing: "0.06em" } }, "Takt"),
      _ae4_mono(s.takt)
    )
  );
}

function _AE4_StationDetail(props) {
  const s = props.station;
  if (!s) {
    return _AE_h(
      _AECard,
      { pad: 18 },
      _AE_h(
        "div",
        { style: { fontSize: 12, color: "var(--ink-3)" } },
        "Select a station from the canvas to view operator, takt, dwell, tooling, and active qual gates."
      )
    );
  }
  const tone = _ae4_stationToneFor(s.state);
  return _AE_h(
    _AECard,
    { pad: 18 },
    _AE_h(
      "div",
      { style: { marginBottom: 14 } },
      _ae4_kicker("Station " + s.code),
      _AE_h(
        "div",
        { style: { fontSize: 18, color: "var(--ink)", marginTop: 4, lineHeight: 1.3 } },
        s.name
      ),
      _AE_h(
        "div",
        { style: { display: "flex", gap: 6, marginTop: 8, flexWrap: "wrap" } },
        _AE_h(_AEPill, { tone: s.state === "active" ? "info" : (s.state === "blocked" ? "fail" : (s.state === "done" ? "pass" : "warn")) }, s.state),
        _AE_h(_AEPill, { tone: "qual" }, "ISO 14644-1 Class 7"),
        _AE_h(_AEPill, { tone: "info" }, s.cell)
      )
    ),
    _AE_h(_AEStatRow, { label: "Operator", value: s.operator + " · " + s.operatorRole, mono: false }),
    _AE_h(_AEStatRow, { label: "Takt time", value: s.takt }),
    _AE_h(_AEStatRow, { label: "Dwell", value: s.dwell }),
    _AE_h(_AEStatRow, { label: "WIP", value: String(s.wip) }),
    _AE_h(_AEStatRow, { label: "Yield (28d)", value: s.yield }),
    _AE_h(_AEStatRow, { label: "Qual gates", value: s.qualGates }),
    _AE_h(
      "div",
      { style: { marginTop: 14 } },
      _ae4_kicker("Tooling"),
      _AE_h(
        "ul",
        { style: { listStyle: "none", padding: 0, margin: "8px 0 0 0", display: "flex", flexDirection: "column", gap: 4 } },
        (s.tooling || []).map(function (t, i) {
          return _AE_h(
            "li",
            {
              key: i,
              style: {
                fontSize: 12,
                fontFamily: "var(--font-mono, ui-monospace, monospace)",
                color: "var(--ink)",
                paddingLeft: 12,
                position: "relative",
              },
            },
            _AE_h("span", { style: { position: "absolute", left: 0, color: "#2D5BEA" } }, "·"),
            t
          );
        })
      )
    ),
    _AE_h(
      "div",
      { style: { marginTop: 14, paddingTop: 12, borderTop: "1px dashed var(--line)", fontSize: 12, color: "var(--ink)", lineHeight: 1.5 } },
      s.note
    ),
    _AE_h(
      "div",
      { style: { display: "flex", gap: 8, marginTop: 16 } },
      _AE_h(_AEBtn, { variant: "primary" }, "Open traveler"),
      _AE_h(_AEBtn, { variant: "ghost" }, "Cell log"),
      _AE_h(_AEBtn, { variant: "ghost" }, "ESD log")
    )
  );
}

function ScreenAetherionRouting() {
  const [selected, setSelected] = uS_AE4("s05");
  const [filter, setFilter] = uS_AE4("all");

  const stations = uM_AE4(function () {
    if (filter === "all") return _AE4_STATIONS;
    if (filter === "active") return _AE4_STATIONS.filter(function (s) { return s.state === "active"; });
    if (filter === "blocked") return _AE4_STATIONS.filter(function (s) { return s.state === "blocked"; });
    if (filter === "queued") return _AE4_STATIONS.filter(function (s) { return s.state === "queued"; });
    return _AE4_STATIONS;
  }, [filter]);

  const detail = uM_AE4(function () {
    return _AE4_STATIONS.find(function (s) { return s.id === selected; });
  }, [selected]);

  return _AE_h(
    "div",
    {
      style: {
        minHeight: "100vh",
        background: "var(--bg-0)",
        color: "var(--ink)",
        fontFamily: "var(--font-ui, system-ui)",
        display: "flex",
        flexDirection: "column",
      },
    },
    _AE_h(_AEToolbar, {
      left: [
        _AE_h("span", { key: "kicker", style: { fontFamily: "var(--font-mono, ui-monospace, monospace)", fontSize: 12, color: "var(--ink-3)", letterSpacing: "0.12em", textTransform: "uppercase" } }, "Aetherion · Build · Routing"),
        _AE_h(_AEPill, { key: "p1", tone: "info" }, "KESTREL-3 · 12U"),
        _AE_h(_AEPill, { key: "p2", tone: "qual" }, "ISO 14644-1 Class 7"),
        _AE_h(_AEPill, { key: "p3", tone: "warn" }, "ECO-AET-0042 retest queued"),
      ],
      right: [
        _AE_h(_AEBtn, { key: "f1", variant: filter === "all" ? "primary" : "ghost", onClick: function () { setFilter("all"); } }, "All"),
        _AE_h(_AEBtn, { key: "f2", variant: filter === "active" ? "primary" : "ghost", onClick: function () { setFilter("active"); } }, "Active"),
        _AE_h(_AEBtn, { key: "f3", variant: filter === "blocked" ? "primary" : "ghost", onClick: function () { setFilter("blocked"); } }, "Blocked"),
        _AE_h(_AEBtn, { key: "f4", variant: filter === "queued" ? "primary" : "ghost", onClick: function () { setFilter("queued"); } }, "Queued"),
      ],
    }),
    _AE_h(
      "div",
      {
        style: {
          padding: 24,
          display: "grid",
          gridTemplateColumns: "minmax(0, 1fr) 380px",
          gap: 20,
          flex: 1,
          minHeight: 0,
        },
      },
      _AE_h(
        "div",
        { style: { display: "flex", flexDirection: "column", gap: 18, minWidth: 0 } },
        _AE_h(_AESectionTitle, {
          kicker: "Clean-room cell flow",
          title: "Receiving → Bench → Harness → I&A → TVAC → EMI → Vibration → Shock → Acceptance",
        }),
        _AE_h(_AEFlash, { tone: "warn" }, "TV-05 chamber blocked: ECO-AET-0042 retest TVAC-AET-014R window 2026-05-25 → 2026-05-28. Strain-gauge + torque audit at cycle 24. Vibration table on standby."),
        _AE_h(
          "div",
          {
            style: {
              display: "flex",
              flexWrap: "wrap",
              gap: 10,
              padding: 18,
              background: "var(--bg-1)",
              border: "1px solid var(--line)",
              borderRadius: 8,
              alignItems: "flex-start",
            },
          },
          stations.map(function (s, i) {
            return _AE_h(
              React.Fragment,
              { key: s.id },
              _AE_h(_AE4_StationCard, { station: s, selected: selected, onSelect: setSelected }),
              i < stations.length - 1
                ? _AE_h(
                    "div",
                    {
                      style: {
                        alignSelf: "center",
                        color: "var(--line)",
                        fontFamily: "var(--font-mono, ui-monospace, monospace)",
                        fontSize: 14,
                      },
                    },
                    "→"
                  )
                : null
            );
          })
        ),
        _AE_h(
          _AECard,
          { pad: 18 },
          _ae4_kicker("Cell occupancy snapshot"),
          _AE_h(
            "div",
            { style: { display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 14, marginTop: 10 } },
            _AE_h(_AEStatRow, { label: "Active cells", value: "3 / 9" }),
            _AE_h(_AEStatRow, { label: "Blocked cells", value: "1 / 9" }),
            _AE_h(_AEStatRow, { label: "Queued cells", value: "4 / 9" }),
            _AE_h(_AEStatRow, { label: "Class-7 entries (24h)", value: "27" }),
            _AE_h(_AEStatRow, { label: "ESD events (24h)", value: "0" }),
            _AE_h(_AEStatRow, { label: "Particulate (avg)", value: "182,000", unit: "particles/m3" })
          )
        ),
        _AE_h(
          _AECard,
          { pad: 18 },
          _ae4_kicker("Routing notes"),
          _AE_h(
            "div",
            { style: { marginTop: 8, fontSize: 12, color: "var(--ink)", lineHeight: 1.55 } },
            "Single-path through TVAC → EMI → Vibration is enforced at the route level. No skip-routing past Acceptance without Mission Director sign-off. Cell entry is gated on N2 dwell ≥12 h plus ESD continuity log on the carrier card. Operators rotate at 6 h per AS9100 8.5.1.3 fatigue policy."
          )
        )
      ),
      _AE_h(
        "div",
        { style: { display: "flex", flexDirection: "column", gap: 14 } },
        _AE_h(_AE4_StationDetail, { station: detail })
      )
    )
  );
}

/* ════════════════════════════════════════════════════════════════════
   Screen 2 — ScreenAetherionDesignGates
   /build/gates
   9-gate flow with bulk-edit checkboxes per action item.
   ──────────────────────────────────────────────────────────────────── */

const _AE4_GATES = [
  {
    id: "g01",
    code: "SRR",
    name: "Systems Requirements Review",
    state: "passed",
    closed: "2025-03-04",
    chair: "M. Sato",
    actions: [
      { id: "srr-1", label: "Mass budget locked at 14.000 kg cap with 10% margin policy", done: true },
      { id: "srr-2", label: "Power budget locked at 70 W BOL · 32 W payload", done: true },
      { id: "srr-3", label: "Delta-v budget closed at 30 m/s for end-of-life deorbit", done: true },
      { id: "srr-4", label: "ITAR data segregation plan approved (US-persons-only S3)", done: true },
      { id: "srr-5", label: "AS9100 8.1.1 risk register opened with 22 entries", done: true },
      { id: "srr-6", label: "Sub-supplier shortlist (Honeybee, ISIS, AAC Clyde, BCT, Sodern, Glenair)", done: true },
      { id: "srr-7", label: "Falcon 9 Transporter-15 manifest LOA filed", done: true },
    ],
  },
  {
    id: "g02",
    code: "PDR",
    name: "Preliminary Design Review",
    state: "passed",
    closed: "2025-06-18",
    chair: "M. Sato",
    actions: [
      { id: "pdr-1", label: "Propulsion trade study — cold-gas R-236fa over Hall thruster", done: true },
      { id: "pdr-2", label: "Star tracker / RW selection — Sodern Auriga + 3× BCT RWp050", done: true },
      { id: "pdr-3", label: "Solar array 4× deployable wing modeled to 70 W BOL", done: true },
      { id: "pdr-4", label: "Thermal MLI + Aerogel wrap baselined", done: true },
      { id: "pdr-5", label: "Hinge fastener selection — M3 A2-70 + Nord-Lock (PDR baseline)", done: true },
      { id: "pdr-6", label: "Harness routing key HRD-AET-001 issued for FAB-A", done: true },
    ],
  },
  {
    id: "g03",
    code: "CDR",
    name: "Critical Design Review",
    state: "passed",
    closed: "2025-10-22",
    chair: "M. Sato",
    actions: [
      { id: "cdr-1", label: "Mass margin closed at 11.4% (CDR snapshot)", done: true },
      { id: "cdr-2", label: "ECSS-Q-ST-70-08 manual soldering training cleared on 6 techs", done: true },
      { id: "cdr-3", label: "ECSS-E-ST-32-08 mech part stress envelope signed", done: true },
      { id: "cdr-4", label: "EEE parts derating (ECSS-Q-ST-70) BOM scrubbed", done: true },
      { id: "cdr-5", label: "Cleanroom log integrated to ledger (Class-7 entry trace)", done: true },
    ],
  },
  {
    id: "g04",
    code: "FAB-A",
    name: "Fabrication / WO release wave A",
    state: "passed",
    closed: "2026-01-30",
    chair: "L. Nguyen",
    actions: [
      { id: "fab-a-1", label: "WO-AET-001 released against KESTREL-3.10.* structure", done: true },
      { id: "fab-a-2", label: "Harness wave A built per HRD-AET-001 (continuity log signed)", done: true },
      { id: "fab-a-3", label: "FAI per AS9102 rev B filed for KESTREL-3.10.01", done: true },
      { id: "fab-a-4", label: "Honeybee hinge sub KESTREL-3.60.HG kit-in (rev B)", done: true },
    ],
  },
  {
    id: "g05",
    code: "ASSY",
    name: "Assembly",
    state: "in-flight",
    closed: null,
    chair: "R. Okafor",
    actions: [
      { id: "assy-1", label: "EPS + OBC stack mate (KESTREL-3.20.*)", done: true },
      { id: "assy-2", label: "ADCS deck mate with star-tracker ICD verify", done: true },
      { id: "assy-3", label: "Payload optical bench dowel + bolt to primary structure", done: true },
      { id: "assy-4", label: "Harness routing wave A pull-test pass", done: true },
      { id: "assy-5", label: "Harness routing wave B (FAB-B re-issue) — pending", done: false },
      { id: "assy-6", label: "Hinge sub KESTREL-3.60.HG.03 rev C install (post-ECO)", done: false },
    ],
  },
  {
    id: "g06",
    code: "I&T",
    name: "Integration & Test",
    state: "in-flight",
    closed: null,
    chair: "R. Okafor",
    actions: [
      { id: "it-1", label: "Star tracker boresight to imager focal plane (≤25 µm at 2 m)", done: true },
      { id: "it-2", label: "Solar array deployment in 4 m vacuum-deploy rig", done: true },
      { id: "it-3", label: "Functional cmd/tlm — end-to-end with EGSE", done: true },
      { id: "it-4", label: "Hinge re-install + torque audit (post-ECO)", done: false },
      { id: "it-5", label: "Re-run ESD continuity after hinge swap", done: false },
    ],
  },
  {
    id: "g07",
    code: "TVAC",
    name: "Thermal Vacuum",
    state: "retest",
    closed: null,
    chair: "S. Iyer",
    actions: [
      { id: "tvac-1", label: "TVAC-AET-014 — 24 cycles −40 / +85 °C, 90 min ramps", done: true, note: "Hinge HG-03 50 µm pre-load loss at cycle 14" },
      { id: "tvac-2", label: "ECO-AET-0042 raised against KESTREL-3.60.HG.03", done: true },
      { id: "tvac-3", label: "TVAC-AET-014R retest — 24 cycles, partial run", done: false, note: "target 2026-05-28" },
      { id: "tvac-4", label: "Strain-gauge + torque audit at cycle 24", done: false },
      { id: "tvac-5", label: "Pyroshock 2000g half-sine 0.5 ms survival", done: false },
    ],
  },
  {
    id: "g08",
    code: "ACC",
    name: "Flight Acceptance",
    state: "upcoming",
    closed: null,
    chair: "Mission Director",
    actions: [
      { id: "acc-1", label: "Mech qual report (sine + random vib, GEVS+3 dB)", done: false },
      { id: "acc-2", label: "EMI / EMC report MIL-STD-461G CE/CS/RE/RS", done: false },
      { id: "acc-3", label: "Radiation TID report ≥30 krad Si total dose", done: false },
      { id: "acc-4", label: "Vibration report (Falcon 9 user guide + 3 dB margin)", done: false },
      { id: "acc-5", label: "TVAC report 24 cycles + pumpdown to 1e-5 torr", done: false },
      { id: "acc-6", label: "Cleanroom log Class-7 + ISO 14644-2 monthly verifications", done: false },
      { id: "acc-7", label: "Mass-properties measurement (CG ± 1 mm)", done: false },
      { id: "acc-8", label: "Flight CofC packet bound", done: false },
    ],
  },
  {
    id: "g09",
    code: "LAUNCH",
    name: "Launch Manifest Lock",
    state: "upcoming",
    closed: null,
    chair: "Mission Director",
    actions: [
      { id: "lau-1", label: "Falcon 9 Transporter-15 manifest confirmed", done: false },
      { id: "lau-2", label: "ITAR export record bound to crate-out", done: false },
      { id: "lau-3", label: "Customer pre-launch sign-off (Aperture Earth)", done: false },
      { id: "lau-4", label: "Crate seal + tamper-evident bag log", done: false },
    ],
  },
];

function _AE4_GateRow(props) {
  const g = props.gate;
  const selected = props.selected === g.id;
  const total = g.actions.length;
  const done = g.actions.filter(function (a) { return a.done; }).length;
  const pct = total ? Math.round((done / total) * 100) : 0;
  const stateTone = (function (s) {
    if (s === "passed") return "pass";
    if (s === "in-flight") return "info";
    if (s === "retest") return "warn";
    if (s === "upcoming") return "mute";
    return "info";
  })(g.state);
  return _AE_h(
    "div",
    {
      onClick: function () { props.onSelect && props.onSelect(g.id); },
      style: {
        cursor: "pointer",
        padding: "12px 14px",
        background: selected ? "rgba(79,143,255,0.08)" : "var(--bg-1)",
        border: "1px solid " + (selected ? "#2D5BEA" : "var(--line)"),
        borderRadius: 6,
        display: "grid",
        gridTemplateColumns: "60px 1fr 100px 90px 60px",
        gap: 12,
        alignItems: "center",
      },
    },
    _ae4_mono(g.code, "#2D5BEA"),
    _AE_h(
      "div",
      { style: { display: "flex", flexDirection: "column", gap: 2 } },
      _AE_h("div", { style: { fontSize: 12, color: "var(--ink)" } }, g.name),
      _AE_h(
        "div",
        { style: { fontSize: 12, color: "var(--ink-3)", fontFamily: "var(--font-mono, ui-monospace, monospace)" } },
        "Chair " + g.chair + (g.closed ? " · closed " + g.closed : "")
      )
    ),
    _AE_h(_AEPill, { tone: stateTone }, g.state),
    _AE_h(
      "div",
      { style: { display: "flex", flexDirection: "column", gap: 4 } },
      _AE_h(
        "div",
        { style: { height: 6, background: "var(--line)", borderRadius: 3, overflow: "hidden" } },
        _AE_h("div", {
          style: {
            width: pct + "%",
            height: "100%",
            background: pct === 100 ? "var(--ok)" : "#2D5BEA",
          },
        })
      ),
      _AE_h(
        "div",
        { style: { fontSize: 12, color: "var(--ink-3)", fontFamily: "var(--font-mono, ui-monospace, monospace)" } },
        done + " / " + total
      )
    ),
    _ae4_mono(pct + "%")
  );
}

function _AE4_GateDetail(props) {
  const g = props.gate;
  const checks = props.checks;
  const setChecks = props.setChecks;
  if (!g) {
    return _AE_h(
      _AECard,
      { pad: 18 },
      _AE_h(
        "div",
        { style: { fontSize: 12, color: "var(--ink-3)" } },
        "Select a gate to bulk-edit action items, view chair, close date, and review state."
      )
    );
  }
  const stateTone = (function (s) {
    if (s === "passed") return "pass";
    if (s === "in-flight") return "info";
    if (s === "retest") return "warn";
    return "mute";
  })(g.state);
  function toggle(actionId) {
    const next = Object.assign({}, checks);
    next[actionId] = !next[actionId];
    setChecks(next);
  }
  function bulkSet(target) {
    const next = Object.assign({}, checks);
    g.actions.forEach(function (a) { next[a.id] = target; });
    setChecks(next);
  }
  return _AE_h(
    _AECard,
    { pad: 18 },
    _AE_h(
      "div",
      { style: { marginBottom: 12 } },
      _ae4_kicker("Gate " + g.code),
      _AE_h(
        "div",
        { style: { fontSize: 18, color: "var(--ink)", marginTop: 4 } },
        g.name
      ),
      _AE_h(
        "div",
        { style: { display: "flex", gap: 6, marginTop: 8, flexWrap: "wrap" } },
        _AE_h(_AEPill, { tone: stateTone }, g.state),
        g.closed ? _AE_h(_AEPill, { tone: "info" }, "Closed " + g.closed) : null,
        _AE_h(_AEPill, { tone: "qual" }, "Chair " + g.chair)
      )
    ),
    _AE_h(
      "div",
      {
        style: {
          display: "flex",
          gap: 6,
          padding: "8px 0",
          borderTop: "1px dashed var(--line)",
          borderBottom: "1px dashed var(--line)",
          marginBottom: 12,
        },
      },
      _AE_h(_AEBtn, { variant: "ghost", onClick: function () { bulkSet(true); } }, "Bulk · check all"),
      _AE_h(_AEBtn, { variant: "ghost", onClick: function () { bulkSet(false); } }, "Bulk · clear all"),
      _AE_h(_AEBtn, { variant: "primary" }, "Save bulk")
    ),
    _AE_h(
      "div",
      { style: { display: "flex", flexDirection: "column", gap: 6 } },
      g.actions.map(function (a) {
        const checked = !!checks[a.id];
        return _AE_h(
          "label",
          {
            key: a.id,
            style: {
              display: "grid",
              gridTemplateColumns: "20px 1fr",
              gap: 10,
              alignItems: "start",
              padding: "8px 10px",
              background: checked ? "rgba(60,192,122,0.06)" : "transparent",
              border: "1px solid " + (checked ? "rgba(60,192,122,0.4)" : "var(--line)"),
              borderRadius: 4,
              cursor: "pointer",
              fontSize: 12,
              color: "var(--ink)",
            },
          },
          _AE_h("input", {
            type: "checkbox",
            checked: checked,
            onChange: function () { toggle(a.id); },
            style: { marginTop: 2, accentColor: "#2D5BEA" },
          }),
          _AE_h(
            "div",
            null,
            _AE_h("div", { style: { lineHeight: 1.45 } }, a.label),
            a.note
              ? _AE_h(
                  "div",
                  {
                    style: {
                      marginTop: 4,
                      fontSize: 12,
                      color: "var(--warn)",
                      fontFamily: "var(--font-mono, ui-monospace, monospace)",
                      letterSpacing: "0.04em",
                      textTransform: "uppercase",
                    },
                  },
                  "note · " + a.note
                )
              : null
          )
        );
      })
    )
  );
}

function ScreenAetherionDesignGates() {
  const [selected, setSelected] = uS_AE4("g07");
  const [filter, setFilter] = uS_AE4("all");
  const [checks, setChecks] = uS_AE4(function () {
    const init = {};
    _AE4_GATES.forEach(function (g) {
      g.actions.forEach(function (a) { init[a.id] = a.done; });
    });
    return init;
  });

  const gates = uM_AE4(function () {
    if (filter === "all") return _AE4_GATES;
    return _AE4_GATES.filter(function (g) { return g.state === filter; });
  }, [filter]);

  const detail = uM_AE4(function () {
    return _AE4_GATES.find(function (g) { return g.id === selected; });
  }, [selected]);

  const totals = uM_AE4(function () {
    let total = 0, done = 0;
    _AE4_GATES.forEach(function (g) {
      g.actions.forEach(function (a) {
        total += 1;
        if (checks[a.id]) done += 1;
      });
    });
    return { total: total, done: done, pct: total ? Math.round((done / total) * 100) : 0 };
  }, [checks]);

  return _AE_h(
    "div",
    {
      style: {
        minHeight: "100vh",
        background: "var(--bg-0)",
        color: "var(--ink)",
        fontFamily: "var(--font-ui, system-ui)",
        display: "flex",
        flexDirection: "column",
      },
    },
    _AE_h(_AEToolbar, {
      left: [
        _AE_h("span", { key: "k", style: { fontFamily: "var(--font-mono, ui-monospace, monospace)", fontSize: 12, color: "var(--ink-3)", letterSpacing: "0.12em", textTransform: "uppercase" } }, "Aetherion · Build · Design Gates"),
        _AE_h(_AEPill, { key: "p1", tone: "info" }, "9 gates"),
        _AE_h(_AEPill, { key: "p2", tone: "qual" }, "AS9100 8.3.4"),
        _AE_h(_AEPill, { key: "p3", tone: "warn" }, "TVAC retest in flight"),
      ],
      right: [
        _AE_h(_AEBtn, { key: "f1", variant: filter === "all" ? "primary" : "ghost", onClick: function () { setFilter("all"); } }, "All"),
        _AE_h(_AEBtn, { key: "f2", variant: filter === "in-flight" ? "primary" : "ghost", onClick: function () { setFilter("in-flight"); } }, "In flight"),
        _AE_h(_AEBtn, { key: "f3", variant: filter === "retest" ? "primary" : "ghost", onClick: function () { setFilter("retest"); } }, "Retest"),
        _AE_h(_AEBtn, { key: "f4", variant: filter === "upcoming" ? "primary" : "ghost", onClick: function () { setFilter("upcoming"); } }, "Upcoming"),
      ],
    }),
    _AE_h(
      "div",
      { style: { padding: 24, display: "grid", gridTemplateColumns: "minmax(0, 1fr) 420px", gap: 20, flex: 1, minHeight: 0 } },
      _AE_h(
        "div",
        { style: { display: "flex", flexDirection: "column", gap: 16, minWidth: 0 } },
        _AE_h(_AESectionTitle, {
          kicker: "Lifecycle gates",
          title: "SRR · PDR · CDR · FAB-A · ASSY · I&T · TVAC · ACC · LAUNCH",
        }),
        _AE_h(
          _AECard,
          { pad: 16 },
          _AE_h(
            "div",
            { style: { display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 16 } },
            _AE_h(_AEStatRow, { label: "Action items", value: String(totals.total) }),
            _AE_h(_AEStatRow, { label: "Closed", value: String(totals.done) }),
            _AE_h(_AEStatRow, { label: "Coverage", value: totals.pct + "%" }),
            _AE_h(_AEStatRow, { label: "Open NCRs", value: "2", unit: "(1 critical)" })
          )
        ),
        _AE_h(
          "div",
          { style: { display: "flex", flexDirection: "column", gap: 8 } },
          gates.map(function (g) {
            return _AE_h(_AE4_GateRow, { key: g.id, gate: g, selected: selected, onSelect: setSelected });
          })
        ),
        _AE_h(
          _AECard,
          { pad: 16 },
          _ae4_kicker("Gate review cadence"),
          _AE_h(
            "div",
            { style: { marginTop: 8, fontSize: 12, color: "var(--ink)", lineHeight: 1.55 } },
            "Bi-weekly Mech CCB on Tuesdays. Q&MA review every Friday. Mission Director sign-off recorded against the ledger as a signed receipt; sign-off is single-sourced and ITAR-aware (US-persons-only plane). All gate transitions emit a ledger event of type GATE_TRANSITION with prior + next state, chair, and closing actions."
          )
        )
      ),
      _AE_h(
        "div",
        { style: { display: "flex", flexDirection: "column", gap: 14 } },
        _AE_h(_AE4_GateDetail, { gate: detail, checks: checks, setChecks: setChecks })
      )
    )
  );
}

/* ════════════════════════════════════════════════════════════════════
   Screen 3 — ScreenAetherionLineReadiness
   /line/readiness
   Clean-room slot allocation, TVAC chamber availability, laser tracker
   calibration, ECO-AET-0042 hinge retest schedule. T-124d banner.
   ──────────────────────────────────────────────────────────────────── */

const _AE4_DAYS = (function () {
  const out = [];
  const start = new Date("2026-05-09T00:00:00Z");
  for (let i = 0; i < 14; i++) {
    const d = new Date(start.getTime() + i * 86400000);
    const iso = d.toISOString().slice(0, 10);
    out.push(iso);
  }
  return out;
})();

const _AE4_CELL_SLOTS = [
  { cell: "RX-01", iso: "Class 7", schedule: { 0: "kit RX-018", 1: "kit RX-019", 3: "kit RX-020" } },
  { cell: "BS-02", iso: "Class 7", schedule: { 0: "EPS mate", 1: "OBC stack", 2: "ADCS deck", 4: "payload bench" } },
  { cell: "HR-03", iso: "Class 7", schedule: { 1: "harness B", 2: "harness B", 3: "pull-test" } },
  { cell: "IA-04", iso: "Class 7", schedule: { 5: "boresight", 6: "boresight", 7: "deploy test" } },
  { cell: "TV-05", iso: "Class 7 anteroom", schedule: { 16: "TVAC-014R prep", 17: "TVAC-014R run", 18: "TVAC-014R run", 19: "TVAC-014R audit" } },
  { cell: "EM-06", iso: "Class 7", schedule: { 22: "EMC chamber prep", 23: "EMC sweep" } },
  { cell: "VB-07", iso: "Class 7", schedule: { 25: "sine survey", 26: "random vib" } },
  { cell: "SH-08", iso: "Class 7", schedule: { 28: "pyroshock X", 29: "pyroshock Y/Z" } },
  { cell: "AC-09", iso: "Class 7", schedule: { 30: "mass-prop", 31: "CofC bind" } },
];

const _AE4_TVAC_WINDOW = [
  { day: "2026-05-25", state: "prep", note: "Chamber pumpdown rehearsal · 1e-5 torr verify" },
  { day: "2026-05-26", state: "run", note: "Cycles 1..6 · −40 / +85 °C · 90 min ramps" },
  { day: "2026-05-27", state: "run", note: "Cycles 7..18 · strain-gauge live" },
  { day: "2026-05-28", state: "run", note: "Cycles 19..24 · torque audit at cycle 24" },
  { day: "2026-05-29", state: "audit", note: "Post-cycle inspection · CofC packet update" },
];

const _AE4_LASER_TRACKER = {
  unit: "Leica AT960",
  serial: "AT960-2147",
  lastCal: "2026-04-04",
  nextCal: "2026-07-04",
  uncertainty: "± 0.025 mm at 2 m",
  cert: "ISO 17025 · NPL traceable",
};

const _AE4_HINGE_RETEST = [
  { id: "hg-01", part: "KESTREL-3.60.HG.01", state: "rebuilt", torque: "0.55 Nm", preload: "nominal" },
  { id: "hg-02", part: "KESTREL-3.60.HG.02", state: "rebuilt", torque: "0.56 Nm", preload: "nominal" },
  { id: "hg-03", part: "KESTREL-3.60.HG.03", state: "retest queued", torque: "—", preload: "—", note: "ECO-AET-0042 hero hinge" },
  { id: "hg-04", part: "KESTREL-3.60.HG.04", state: "rebuilt", torque: "0.55 Nm", preload: "nominal" },
];

const _AE4_RISKS = [
  { id: "r1", label: "TVAC chamber availability slips by 2 days", severity: "critical", trigger: "ACC slips beyond 2026-07-15" },
  { id: "r2", label: "Hinge HG-03 cycle 24 torque < 0.50 Nm", severity: "high", trigger: "ECO-AET-0042 reopened, CR-2026-014 cancelled" },
  { id: "r3", label: "EMC chamber RF-floor breach > -90 dBm", severity: "med", trigger: "Re-baseline susceptibility floor" },
  { id: "r4", label: "Laser tracker drift > 0.040 mm at 2 m", severity: "med", trigger: "Pause IA-04 until ISO 17025 recal" },
];

function _AE4_CalCell(props) {
  const text = props.text;
  const filled = !!text;
  const isTvac = filled && /TVAC/.test(text);
  return _AE_h(
    "div",
    {
      style: {
        height: 38,
        border: "1px solid " + (filled ? (isTvac ? "var(--warn)" : "var(--line)") : "var(--bg-1)"),
        background: filled ? (isTvac ? "rgba(224,161,78,0.10)" : "rgba(79,143,255,0.06)") : "var(--bg-0)",
        borderRadius: 3,
        padding: "4px 6px",
        fontSize: 12,
        fontFamily: "var(--font-mono, ui-monospace, monospace)",
        color: filled ? (isTvac ? "var(--warn)" : "var(--ink)") : "var(--line)",
        letterSpacing: "0.02em",
        display: "flex",
        alignItems: "center",
        overflow: "hidden",
        textOverflow: "ellipsis",
        whiteSpace: "nowrap",
      },
    },
    text || "—"
  );
}

function _AE4_TvacWindow() {
  return _AE_h(
    _AECard,
    { pad: 18 },
    _ae4_kicker("TVAC chamber · TVAC-AET-014R retest window"),
    _AE_h(
      "div",
      { style: { fontSize: 13, color: "var(--ink)", marginTop: 4, marginBottom: 12 } },
      "Solar-array hinge retest after ECO-AET-0042. 24 cycles −40 / +85 °C. Pumpdown to 1e-5 torr. Strain-gauge + torque audit at cycle 24."
    ),
    _AE_h(
      "div",
      { style: { display: "flex", flexDirection: "column", gap: 6 } },
      _AE4_TVAC_WINDOW.map(function (w) {
        const tone = w.state === "prep" ? "#2D5BEA" : (w.state === "audit" ? "var(--ok)" : "var(--warn)");
        return _AE_h(
          "div",
          {
            key: w.day,
            style: {
              display: "grid",
              gridTemplateColumns: "100px 80px 1fr",
              gap: 10,
              padding: "8px 10px",
              background: "var(--bg-0)",
              border: "1px solid var(--line)",
              borderRadius: 4,
              alignItems: "center",
            },
          },
          _ae4_mono(w.day, "#2D5BEA"),
          _AE_h(_AEPill, { tone: w.state === "audit" ? "pass" : (w.state === "prep" ? "info" : "warn") }, w.state),
          _AE_h(
            "div",
            { style: { fontSize: 12, color: "var(--ink)", lineHeight: 1.4 } },
            w.note
          )
        );
      })
    )
  );
}

function _AE4_LaserPanel() {
  const lt = _AE4_LASER_TRACKER;
  return _AE_h(
    _AECard,
    { pad: 18 },
    _ae4_kicker("Laser tracker · IA-04"),
    _AE_h(
      "div",
      { style: { fontSize: 14, color: "var(--ink)", marginTop: 4 } },
      lt.unit + " · " + lt.serial
    ),
    _AE_h("div", { style: { marginTop: 12 } },
      _AE_h(_AEStatRow, { label: "Last calibration", value: lt.lastCal }),
      _AE_h(_AEStatRow, { label: "Next calibration", value: lt.nextCal }),
      _AE_h(_AEStatRow, { label: "Uncertainty", value: lt.uncertainty }),
      _AE_h(_AEStatRow, { label: "Certification", value: lt.cert, mono: false })
    ),
    _AE_h(
      "div",
      { style: { marginTop: 14, padding: 10, background: "rgba(79,143,255,0.06)", border: "1px solid var(--line)", borderRadius: 4, fontSize: 12, color: "var(--ink)", lineHeight: 1.5 } },
      "Boresight verification: star-tracker → imager focal plane shall close to ≤ 25 µm at 2 m. Tracker is reserved for IA-04 cell on 2026-05-14 → 2026-05-16."
    )
  );
}

function _AE4_HingeRetest() {
  return _AE_h(
    _AECard,
    { pad: 18 },
    _ae4_kicker("ECO-AET-0042 · hinge retest schedule"),
    _AE_h(
      "div",
      { style: { fontSize: 13, color: "var(--ink)", marginTop: 4, marginBottom: 12 } },
      "M3 A2-70 → A286 + Belleville stack. Vibra-Tite 213 cure 24 h. Re-torque audit at +1 day."
    ),
    _AE_h(
      "div",
      { style: { display: "grid", gridTemplateColumns: "1fr 100px 90px 80px", gap: 4, marginBottom: 6, paddingBottom: 4, borderBottom: "1px solid var(--line)" } },
      _AE_h("span", { style: { fontSize: 12, color: "var(--ink-3)", textTransform: "uppercase", letterSpacing: "0.08em" } }, "Hinge / part"),
      _AE_h("span", { style: { fontSize: 12, color: "var(--ink-3)", textTransform: "uppercase", letterSpacing: "0.08em" } }, "State"),
      _AE_h("span", { style: { fontSize: 12, color: "var(--ink-3)", textTransform: "uppercase", letterSpacing: "0.08em" } }, "Torque"),
      _AE_h("span", { style: { fontSize: 12, color: "var(--ink-3)", textTransform: "uppercase", letterSpacing: "0.08em" } }, "Pre-load")
    ),
    _AE_h(
      "div",
      { style: { display: "flex", flexDirection: "column", gap: 4 } },
      _AE4_HINGE_RETEST.map(function (h) {
        const isHero = h.id === "hg-03";
        return _AE_h(
          "div",
          {
            key: h.id,
            style: {
              display: "grid",
              gridTemplateColumns: "1fr 100px 90px 80px",
              gap: 4,
              padding: "8px 6px",
              background: isHero ? "rgba(224,161,78,0.08)" : "var(--bg-0)",
              border: "1px solid " + (isHero ? "var(--warn)" : "var(--line)"),
              borderRadius: 4,
              alignItems: "center",
            },
          },
          _AE_h(
            "div",
            null,
            _ae4_mono(h.part),
            h.note ? _AE_h("div", { style: { fontSize: 12, color: "var(--warn)", marginTop: 2, fontFamily: "var(--font-mono, ui-monospace, monospace)" } }, h.note) : null
          ),
          _AE_h(_AEPill, { tone: h.state === "rebuilt" ? "pass" : "warn" }, h.state),
          _ae4_mono(h.torque),
          _ae4_mono(h.preload)
        );
      })
    )
  );
}

function _AE4_RiskList() {
  return _AE_h(
    _AECard,
    { pad: 18 },
    _ae4_kicker("Line-readiness risks"),
    _AE_h(
      "div",
      { style: { display: "flex", flexDirection: "column", gap: 6, marginTop: 10 } },
      _AE4_RISKS.map(function (r) {
        const tone = r.severity === "critical" ? "fail" : (r.severity === "high" ? "warn" : "info");
        return _AE_h(
          "div",
          {
            key: r.id,
            style: {
              padding: "10px 12px",
              background: "var(--bg-0)",
              border: "1px solid var(--line)",
              borderRadius: 4,
              display: "grid",
              gridTemplateColumns: "1fr auto",
              gap: 10,
              alignItems: "center",
            },
          },
          _AE_h(
            "div",
            null,
            _AE_h("div", { style: { fontSize: 12, color: "var(--ink)", lineHeight: 1.4 } }, r.label),
            _AE_h("div", { style: { fontSize: 12, color: "var(--ink-3)", marginTop: 4, fontFamily: "var(--font-mono, ui-monospace, monospace)" } }, "trigger · " + r.trigger)
          ),
          _AE_h(_AEPill, { tone: tone }, r.severity)
        );
      })
    )
  );
}

function _AE4_CleanroomGrid() {
  return _AE_h(
    _AECard,
    { pad: 18 },
    _AE_h(
      "div",
      { style: { display: "flex", justifyContent: "space-between", alignItems: "baseline", marginBottom: 12 } },
      _ae4_kicker("Clean-room slot allocation · 14-day window"),
      _AE_h(
        "div",
        { style: { fontSize: 12, color: "var(--ink-3)", fontFamily: "var(--font-mono, ui-monospace, monospace)" } },
        _AE4_DAYS[0] + " → " + _AE4_DAYS[_AE4_DAYS.length - 1]
      )
    ),
    _AE_h(
      "div",
      { style: { overflowX: "auto" } },
      _AE_h(
        "div",
        {
          style: {
            display: "grid",
            gridTemplateColumns: "120px repeat(14, minmax(60px, 1fr))",
            gap: 4,
            minWidth: 1000,
          },
        },
        _AE_h("div", null),
        _AE4_DAYS.map(function (d) {
          return _AE_h(
            "div",
            {
              key: d,
              style: {
                fontSize: 12,
                color: "var(--ink-3)",
                fontFamily: "var(--font-mono, ui-monospace, monospace)",
                letterSpacing: "0.04em",
                textAlign: "center",
                padding: "0 2px",
                whiteSpace: "nowrap",
                overflow: "hidden",
                textOverflow: "ellipsis",
              },
            },
            d.slice(5)
          );
        }),
        _AE4_CELL_SLOTS.map(function (cell, ridx) {
          const cells = [
            _AE_h(
              "div",
              {
                key: "label-" + ridx,
                style: {
                  fontSize: 12,
                  color: "var(--ink)",
                  fontFamily: "var(--font-mono, ui-monospace, monospace)",
                  display: "flex",
                  flexDirection: "column",
                  justifyContent: "center",
                  paddingRight: 6,
                },
              },
              _AE_h("div", null, cell.cell),
              _AE_h("div", { style: { fontSize: 12, color: "var(--ink-3)" } }, cell.iso)
            ),
          ];
          for (let i = 0; i < 14; i++) {
            cells.push(_AE_h(_AE4_CalCell, { key: "c-" + ridx + "-" + i, text: cell.schedule[i] || "" }));
          }
          return cells;
        })
      )
    )
  );
}

function ScreenAetherionLineReadiness() {
  const daysToLaunch = 124;
  const accDate = "2026-07-15";
  const launchDate = "2026-09-10";

  return _AE_h(
    "div",
    {
      style: {
        minHeight: "100vh",
        background: "var(--bg-0)",
        color: "var(--ink)",
        fontFamily: "var(--font-ui, system-ui)",
        display: "flex",
        flexDirection: "column",
      },
    },
    _AE_h(_AEToolbar, {
      left: [
        _AE_h("span", { key: "k", style: { fontFamily: "var(--font-mono, ui-monospace, monospace)", fontSize: 12, color: "var(--ink-3)", letterSpacing: "0.12em", textTransform: "uppercase" } }, "Aetherion · Line · Readiness"),
        _AE_h(_AEPill, { key: "p1", tone: "info" }, "KESTREL-3"),
        _AE_h(_AEPill, { key: "p2", tone: "qual" }, "ISO 14644-1 Class 7"),
        _AE_h(_AEPill, { key: "p3", tone: "warn" }, "ECO-AET-0042 retest"),
      ],
      right: [
        _AE_h(_AEBtn, { key: "b1", variant: "ghost" }, "Export schedule"),
        _AE_h(_AEBtn, { key: "b2", variant: "primary" }, "Lock window"),
      ],
    }),
    _AE_h(
      "div",
      { style: { padding: "20px 24px 4px" } },
      _AE_h(
        "div",
        {
          style: {
            display: "grid",
            gridTemplateColumns: "1fr 1fr 1fr",
            gap: 14,
            padding: 18,
            background: "linear-gradient(135deg, rgba(79,143,255,0.10), rgba(79,143,255,0.02))",
            border: "1px solid #2D5BEA",
            borderRadius: 8,
          },
        },
        _AE_h(
          "div",
          null,
          _ae4_kicker("Days to launch"),
          _AE_h(
            "div",
            {
              style: {
                fontSize: 36,
                fontFamily: "var(--font-mono, ui-monospace, monospace)",
                color: "#2D5BEA",
                letterSpacing: "-0.02em",
                marginTop: 4,
              },
            },
            "T-" + daysToLaunch + "d"
          ),
          _AE_h(
            "div",
            { style: { fontSize: 12, color: "var(--ink-3)", fontFamily: "var(--font-mono, ui-monospace, monospace)" } },
            "T-0 " + launchDate + " · Falcon 9 Transporter-15"
          )
        ),
        _AE_h(
          "div",
          null,
          _ae4_kicker("Acceptance gate"),
          _AE_h(
            "div",
            { style: { fontSize: 22, color: "var(--ink)", marginTop: 4, fontFamily: "var(--font-mono, ui-monospace, monospace)" } },
            accDate
          ),
          _AE_h(
            "div",
            { style: { fontSize: 12, color: "var(--ink-3)", fontFamily: "var(--font-mono, ui-monospace, monospace)" } },
            "ACC sign-off · Mission Director"
          )
        ),
        _AE_h(
          "div",
          null,
          _ae4_kicker("Slack remaining"),
          _AE_h(
            "div",
            { style: { fontSize: 22, color: "var(--ok)", marginTop: 4, fontFamily: "var(--font-mono, ui-monospace, monospace)" } },
            "9d on critical path"
          ),
          _AE_h(
            "div",
            { style: { fontSize: 12, color: "var(--ink-3)", fontFamily: "var(--font-mono, ui-monospace, monospace)" } },
            "TVAC retest · ACC · LAUNCH lock"
          )
        )
      )
    ),
    _AE_h(
      "div",
      { style: { padding: 24, display: "grid", gridTemplateColumns: "minmax(0, 1fr) 380px", gap: 20, flex: 1, minHeight: 0 } },
      _AE_h(
        "div",
        { style: { display: "flex", flexDirection: "column", gap: 18, minWidth: 0 } },
        _AE_h(_AESectionTitle, {
          kicker: "Line readiness",
          title: "Clean-room slot allocation · TVAC chamber · laser tracker · hinge retest",
        }),
        _AE_h(_AEFlash, { tone: "info" }, "Manifest lock target 2026-09-10. Critical path runs through TVAC-AET-014R retest 2026-05-25 → 2026-05-29, then EMC and vibration in series. Crate-out from AC-09 by 2026-08-22 to clear customs and integrator handover."),
        _AE_h(_AE4_CleanroomGrid),
        _AE_h(_AE4_TvacWindow),
        _AE_h(_AE4_HingeRetest)
      ),
      _AE_h(
        "div",
        { style: { display: "flex", flexDirection: "column", gap: 14 } },
        _AE_h(_AE4_LaserPanel),
        _AE_h(_AE4_RiskList),
        _AE_h(
          _AECard,
          { pad: 18 },
          _ae4_kicker("Mass + power snapshot"),
          _AE_h(
            "div",
            { style: { marginTop: 8 } },
            _AE_h(_AEStatRow, { label: "Mass margin", value: "11.0%", unit: "(1.54 kg / 14.00 kg)" }),
            _AE_h(_AEStatRow, { label: "Current dry mass", value: "12460", unit: "g" }),
            _AE_h(_AEStatRow, { label: "Mass cap", value: "14000", unit: "g" }),
            _AE_h(_AEStatRow, { label: "Power BOL", value: "70.0", unit: "W" }),
            _AE_h(_AEStatRow, { label: "Power payload", value: "32.0", unit: "W" }),
            _AE_h(_AEStatRow, { label: "Power margin", value: "8", unit: "W" })
          )
        ),
        _AE_h(
          _AECard,
          { pad: 18 },
          _ae4_kicker("Compliance gates open"),
          _AE_h(
            "div",
            { style: { display: "flex", flexDirection: "column", gap: 6, marginTop: 10 } },
            _AE_h(
              "div",
              { style: { fontSize: 12, color: "var(--ink)", lineHeight: 1.5 } },
              "AS9100 8.5.1.3 production process verification · FAI on KESTREL-3.60.HG.03 rev C pending"
            ),
            _AE_h(
              "div",
              { style: { fontSize: 12, color: "var(--ink)", lineHeight: 1.5 } },
              "ECSS-Q-ST-70-08 manual soldering trace open on 2 work orders"
            ),
            _AE_h(
              "div",
              { style: { fontSize: 12, color: "var(--ink)", lineHeight: 1.5 } },
              "ECSS-E-ST-10-03 environmental test matrix — TVAC partial, EMI/EMC pending"
            ),
            _AE_h(
              "div",
              { style: { fontSize: 12, color: "var(--ink)", lineHeight: 1.5 } },
              "ITAR export record — bind at FAB-B drawing pull, signed at crate-out"
            )
          )
        )
      )
    )
  );
}

/* ──────────────────────────────────────────────────────────────────────
   Route registration — defensive. Prefer space registry, fall back to
   pump registry, finally attach to window so lazy-loaders can resolve.
   ────────────────────────────────────────────────────────────────────── */

(function _AE4_register() {
  const routes = [
    { path: "/build/routing",   mode: "build", title: "Aetherion · Routing",       renderer: function () { return React.createElement(ScreenAetherionRouting); } },
    { path: "/build/gates",     mode: "build", title: "Aetherion · Design Gates",  renderer: function () { return React.createElement(ScreenAetherionDesignGates); } },
    { path: "/line/readiness",  mode: "line",  title: "Aetherion · Line Readiness",renderer: function () { return React.createElement(ScreenAetherionLineReadiness); } },
  ];

  const reg = (typeof registerSpaceRoute === "function")
    ? registerSpaceRoute
    : (typeof registerPumpRoute === "function" ? registerPumpRoute : null);
  if (reg) {
    routes.forEach(function (r) {
      try { reg(r); } catch (e) { /* swallow */ }
    });
  }

  if (typeof window !== "undefined") {
    window.ScreenAetherionRouting = ScreenAetherionRouting;
    window.ScreenAetherionDesignGates = ScreenAetherionDesignGates;
    window.ScreenAetherionLineReadiness = ScreenAetherionLineReadiness;
    window.AETHERION_ACT4_ROUTES = routes;
  }
})();
})();
