(function(){
/* FORGE · Space tenant (Aetherion / KESTREL-3) — Line readiness queue.
   Wave A1 / Agent #16 — clean-room slot allocation, TVAC + EMI + laser-tracker
   status, operator certification roster, hinge re-test schedule (ECO-AET-0042),
   and a TVAC redundancy risk panel.

   Single screen registered at /line/queue as ScreenAetherionLine.
   Babel-standalone. NO ES imports / exports. Globals expected:
     React, Pill, Btn, I, getActiveTenant(), useActiveTenant(),
     navigate(), registerSpaceRoute() (defensive — own registry-init).

   Style: cool blues over deep navy, monospace digits, no emoji. Mass in g,
   power in W, ISO-8601 Zulu timestamps, ±tolerances in µm or mm where
   load-bearing. Mirrors ScreenLineReadiness in pump/act4-screens.jsx but
   tuned to space-flight clean-room economics.
*/

const { useState: uSAL, useEffect: uEAL, useMemo: uMAL, useRef: uRAL } = React;

/* Local helpers — _al_ prefixed to avoid collisions with pump/act4 atoms. */

// Wave 12D · w12d-aet-light-rest — accent rebound to the on-cream mission blue.
const SPACE_ACCENT = "#2D5BEA";

// Hoisted style atoms — extracted from inline JSX for react-doctor compliance.
const _al_avatarBase = {
  display: "inline-flex", alignItems: "center", justifyContent: "center",
  borderRadius: "50%",
  background: "color-mix(in oklch, " + SPACE_ACCENT + " 14%, var(--bg-2))",
  color: SPACE_ACCENT,
  border: "1px solid color-mix(in oklch, " + SPACE_ACCENT + " 30%, var(--line))",
  fontFamily: "var(--font-mono)", fontSize: 12, letterSpacing: "0.04em", fontWeight: 600,
};
const _al_toolbarStyle = {
  display: "flex", alignItems: "center", justifyContent: "space-between", gap: 8,
  padding: "6px 10px", background: "var(--bg-1)",
  borderBottom: "1px solid var(--line)", height: 38, flexShrink: 0,
};
const _al_slotHeaderStyle = {
  display: "grid", gridTemplateColumns: "60px 1fr 1fr",
  padding: "5px 12px",
  borderBottom: "1px solid var(--line-soft)", background: "var(--bg-2)",
  position: "sticky", top: 0, zIndex: 2,
};
const _al_certHeaderStyle = {
  display: "grid",
  gridTemplateColumns: "1fr 56px 56px 56px 56px",
  padding: "5px 12px",
  borderBottom: "1px solid var(--line-soft)", background: "var(--bg-2)",
  position: "sticky", top: 0, zIndex: 2, gap: 4,
};
const _al_pickedFooterStyle = {
  padding: "6px 12px",
  borderTop: "1px solid var(--line)",
  background: "color-mix(in oklch, #2D5BEA 6%, var(--bg-1))",
  fontSize: 12, color: "var(--ink-2)",
  display: "flex", justifyContent: "space-between", alignItems: "center",
};

function useAlTenant() {
  return useActiveTenant();
}

function _al_initials(n) {
  if (!n) return "—";
  const parts = String(n).replace(/[^A-Za-z. ]/g, "").split(/\s+/).filter(Boolean);
  if (!parts.length) return "—";
  return ((parts[0][0] || "") + (parts[1] ? parts[1][0] : (parts[0][1] || ""))).toUpperCase();
}

function _al_avatar(name, size) {
  size = size || 22;
  return (
    <span style={{ ..._al_avatarBase, width: size, height: size }}>{_al_initials(name)}</span>
  );
}

function _al_dot(tone) {
  const map = { ok: "var(--ok)", warn: "var(--warn)", err: "var(--err)", info: "var(--info)", accent: SPACE_ACCENT, mute: "var(--ink-4)" };
  const c = map[tone] || tone || "var(--ink-4)";
  return <span style={{
    display: "inline-block", width: 7, height: 7, borderRadius: "50%",
    background: c, boxShadow: "0 0 0 2px color-mix(in oklch, " + c + " 18%, transparent)",
    flexShrink: 0,
  }} />;
}

function _al_severityTone(s) {
  return s === "critical" ? "err" : s === "high" ? "warn" : s === "med" ? "info" : "mute";
}

function _AlToolbar({ children, right }) {
  return (
    <div style={_al_toolbarStyle}>
      <div style={{ display: "flex", alignItems: "center", gap: 6, flexWrap: "wrap" }}>{children}</div>
      <div style={{ display: "flex", alignItems: "center", gap: 6 }}>{right}</div>
    </div>
  );
}

function _AlModal({ title, body, onCancel, onConfirm, confirmLabel }) {
  return (
    <div style={{
      position: "fixed", inset: 0, background: "rgba(11,18,32,0.55)",
      display: "flex", alignItems: "center", justifyContent: "center", zIndex: 50,
    }}>
      <div style={{
        width: 560, maxWidth: "92vw", background: "var(--bg-0)",
        border: "1px solid var(--line)", borderRadius: 4,
        boxShadow: "0 12px 40px rgba(0,0,0,0.32)",
      }}>
        <div style={{
          padding: "10px 12px", borderBottom: "1px solid var(--line)",
          display: "flex", justifyContent: "space-between", alignItems: "center",
        }}>
          <span className="label" style={{ color: "#2D5BEA" }}>{title}</span>
          <Btn size="sm" onClick={onCancel}>Close</Btn>
        </div>
        <div style={{ padding: 14 }}>{body}</div>
        <div style={{
          padding: "10px 12px", borderTop: "1px solid var(--line)",
          display: "flex", justifyContent: "flex-end", gap: 6,
        }}>
          <Btn onClick={onCancel}>Cancel</Btn>
          <Btn variant="primary" onClick={onConfirm}>{confirmLabel || "OK"}</Btn>
        </div>
      </div>
    </div>
  );
}

/* ════════════════════════════════════════════════════════════════════
   ScreenAetherionLine — /line/queue
   Clean-room readiness for tomorrow's KESTREL-3 integration shift.
   Mirrors the pump ScreenLineReadiness 4-column layout but for space.
   ──────────────────────────────────────────────────────────────────── */

function ScreenAetherionLine() {
  const T = useAlTenant() || {};

  /* ── Clean-room slot allocation ─────────────────────────────────── */
  // ISO 14644-1 Class 7. Two bays — Bay-A (granite bench, integration) and
  // Bay-B (TVAC anteroom, kit-stage). 16 slots/day in 30-min increments
  // from 06:00 to 14:00 Zulu (Sunnyvale local 23:00→07:00, mission-shift).
  const SLOT_BLOCKS = [
    { t: "06:00", a: "STARTUP",    b: "—" },
    { t: "06:30", a: "ITAR-PURGE", b: "—" },
    { t: "07:00", a: "INTG-S3",    b: "TVAC-PREP" },
    { t: "07:30", a: "INTG-S3",    b: "TVAC-PREP" },
    { t: "08:00", a: "INTG-S3",    b: "TVAC-PREP" },
    { t: "08:30", a: "ALIGN-LT",   b: "TVAC-RUN" },
    { t: "09:00", a: "ALIGN-LT",   b: "TVAC-RUN" },
    { t: "09:30", a: "ALIGN-LT",   b: "TVAC-RUN" },
    { t: "10:00", a: "—",          b: "TVAC-RUN" },
    { t: "10:30", a: "DEPLOY-RIG", b: "TVAC-RUN" },
    { t: "11:00", a: "DEPLOY-RIG", b: "TVAC-RUN" },
    { t: "11:30", a: "DEPLOY-RIG", b: "TVAC-RUN" },
    { t: "12:00", a: "BOROSCOPE",  b: "TVAC-RUN" },
    { t: "12:30", a: "BOROSCOPE",  b: "TVAC-RUN" },
    { t: "13:00", a: "WIPEDOWN",   b: "TVAC-COOL" },
    { t: "13:30", a: "SHUTDOWN",   b: "TVAC-COOL" },
  ];

  const slotLegend = [
    { code: "INTG-S3",    label: "Integration · star-tracker boresight",  tone: "accent" },
    { code: "ALIGN-LT",   label: "Laser-tracker alignment ≤25 µm @ 2 m",  tone: "accent" },
    { code: "DEPLOY-RIG", label: "Solar-array deploy rig (4 m vacuum)",   tone: "info"   },
    { code: "BOROSCOPE",  label: "Hinge HG-03 borescope post-rebuild",    tone: "warn"   },
    { code: "TVAC-PREP",  label: "TVAC pumpdown · 1e-5 torr",             tone: "info"   },
    { code: "TVAC-RUN",   label: "TVAC-AET-014R · cycle 14 → 24",         tone: "warn"   },
    { code: "TVAC-COOL",  label: "Chamber cool-down + GN₂ purge",         tone: "mute"   },
    { code: "ITAR-PURGE", label: "Visitor purge · US-persons confirm",    tone: "mute"   },
    { code: "WIPEDOWN",   label: "Class 7 wipedown · ISO 14644-2 verify", tone: "mute"   },
    { code: "STARTUP",    label: "HEPA spool-up + particle baseline",     tone: "mute"   },
    { code: "SHUTDOWN",   label: "Lights-out · alarm arm",                tone: "mute"   },
  ];
  const _legendByCode = {};
  for (let i = 0; i < slotLegend.length; i++) _legendByCode[slotLegend[i].code] = slotLegend[i];

  function slotTone(code) {
    if (code === "—") return null;
    const e = _legendByCode[code];
    return e ? e.tone : "mute";
  }

  /* ── Chamber + tracker fleet status ─────────────────────────────── */
  const chambers = [
    { id: "TVAC-A", name: "TVAC chamber · Bemco 4 ft³",          state: "in-use",     spec: "1.5 m × 1.8 m · 1e-5 torr · −60 / +125 °C", note: "TVAC-AET-014R running cycle 18/24 · ETA 12:40Z" },
    { id: "TVAC-B", name: "TVAC chamber · Tenney Jr. (backup)",  state: "down",       spec: "0.6 m × 0.6 m · 1e-4 torr",                  note: "Mech-pump seal leak · vendor ticket BMI-2026-0307 · ETA repair 2026-05-14" },
    { id: "EMI-A",  name: "EMI anechoic · Anechoic-South",       state: "ready",      spec: "MIL-STD-461G CE/CS/RE/RS · 30 MHz – 18 GHz", note: "Calibrated 2026-04-30 · next due 2026-10-30" },
    { id: "VIB-A",  name: "Vibration · 1500 lbf shaker",         state: "scheduled",  spec: "GEVS-STD-7000 + 3 dB · sine + random",       note: "Reserved 2026-05-12 09:00Z · Falcon 9 user-guide profile" },
    { id: "SHK-A",  name: "Shock · pyroshock half-sine 2000 g",  state: "ready",      spec: "0.5 ms half-sine · 100 Hz – 10 kHz",         note: "Last fired 2026-04-18 · 14 articles to date" },
  ];

  /* ── Laser-tracker calibration ──────────────────────────────────── */
  const trackers = [
    { id: "LT-01", name: "Leica AT960 · primary",     calib: "2026-04-22Z", due: "2026-10-22Z", state: "ready",  spec: "≤15 µm @ 2 m · 6-DoF probe", warm_min: 30 },
    { id: "LT-02", name: "Leica AT403 · secondary",   calib: "2026-03-08Z", due: "2026-09-08Z", state: "ready",  spec: "≤25 µm @ 2 m",                warm_min: 25 },
    { id: "API-1", name: "API Radian Pro · loaner",   calib: "2026-05-04Z", due: "2026-11-04Z", state: "in-cal", spec: "≤30 µm @ 2 m",                warm_min: 40 },
  ];

  /* ── Operator certification roster ──────────────────────────────── */
  // Each operator is gated on: clean-room access (CR-7), ESD (ESD-S20),
  // ITAR clearance (US-person attested), AS9100 internal-audit signoff,
  // plus station-specific endorsements. Numeric = months until expiry.
  const operators = [
    {
      name: "M. Sato",        role: "Mech Lead · s3 Integration",        shift: "A",
      cr7: 18, esd: 11, itar: true,  audit: 9,  endorsements: ["LT-01", "DEPLOY-RIG", "ECO-OWNER"],
    },
    {
      name: "R. Okafor",      role: "Test Engineer · s4 TVAC + EMI",     shift: "A",
      cr7: 22, esd: 14, itar: true,  audit: 12, endorsements: ["TVAC-A", "EMI-A", "VIB-A"],
    },
    {
      name: "K. Bhat",        role: "Harness Tech · s2 Subassy",         shift: "A",
      cr7: 6,  esd: 3,  itar: true,  audit: 2,  endorsements: ["MIL-DTL-38999", "ECSS-Q-ST-70-08"],
    },
    {
      name: "L. Petrov",      role: "Quality · s1 Receiving + AS9102",   shift: "A",
      cr7: 14, esd: 10, itar: true,  audit: 7,  endorsements: ["AS9102-FAI", "CofC-VERIFY"],
    },
    {
      name: "J. Reyes",       role: "Mech Tech · s3 Integration",        shift: "A",
      cr7: 9,  esd: 5,  itar: true,  audit: 4,  endorsements: ["LT-02", "BOROSCOPE"],
    },
    {
      name: "A. Chen",        role: "EE Tech · s4 EMI floater",          shift: "B (backup)",
      cr7: 1,  esd: 6,  itar: false, audit: 3,  endorsements: ["EMI-A"], blocked: "ITAR re-attest pending · HR ticket #4412",
    },
  ];

  function certBadge(months) {
    if (months <= 1)  return <Pill tone="err">expires {months}mo</Pill>;
    if (months <= 3)  return <Pill tone="warn">{months}mo</Pill>;
    return <Pill tone="ok">{months}mo</Pill>;
  }

  /* ── Hinge re-test schedule (ECO-AET-0042) ──────────────────────── */
  const hingeRetest = [
    { hinge: "HG-01", rev: "C", torque_nm: 0.55, audit_z: "2026-05-09T07:30Z", state: "passed",     note: "0.54 Nm · within band" },
    { hinge: "HG-02", rev: "C", torque_nm: 0.55, audit_z: "2026-05-09T07:45Z", state: "passed",     note: "0.55 Nm · nominal" },
    { hinge: "HG-03", rev: "C", torque_nm: 0.55, audit_z: "2026-05-09T08:00Z", state: "in-flight",  note: "TVAC-AET-014R cycle 18/24 · strain trace nominal" },
    { hinge: "HG-04", rev: "C", torque_nm: 0.55, audit_z: "2026-05-09T08:15Z", state: "scheduled",  note: "Borescope after TVAC complete" },
  ];

  /* ── Risk panel: TVAC redundancy ────────────────────────────────── */
  const tvacRisk = {
    headline: "Single-chamber exposure — TVAC-B offline",
    severity: "critical",
    open_z: "2026-05-09T06:12Z",
    impact: "If TVAC-A faults during cycle 18-24 of TVAC-AET-014R, ECO-0042 retest slips ≥9 d. ACC at 2026-07-15 has 11 d slack.",
    mitigations: [
      { id: "MIT-1", text: "Bemco service ticket BMI-2026-0307 prioritized · ETA repair 2026-05-14",                     state: "in-flight" },
      { id: "MIT-2", text: "Standby slot reserved at NTS Santa Clarita 2.0 m chamber (3 h drive · IPA-wipe envelope)",    state: "ready" },
      { id: "MIT-3", text: "Hinge HG-03 borescope can confirm pre-load without full thermal cycle (qualitative only)",    state: "ready" },
      { id: "MIT-4", text: "Mission Director briefed · waiver path via WAIVER-AET-005 if TVAC-A faults mid-cycle",        state: "standby" },
    ],
  };

  /* ── Local UI state ─────────────────────────────────────────────── */
  const [showRedund, setShowRedund] = uSAL(false);
  const [pickedSlot, setPickedSlot] = uSAL(null);
  // W14B — toast for "Book standby slot" mutate result.
  const [toast, setToast] = uSAL(null);

  uEAL(() => {
    const onTenant = () => { setShowRedund(false); setPickedSlot(null); setToast(null); };
    if (typeof window !== "undefined") {
      window.addEventListener("forge:tenant-change", onTenant);
      return () => window.removeEventListener("forge:tenant-change", onTenant);
    }
    return undefined;
  }, []);

  uEAL(() => {
    if (!toast) return undefined;
    const t = setTimeout(() => setToast(null), 3000);
    return () => clearTimeout(t);
  }, [toast]);

  /* ── W14B · Book standby slot → mutate slot_bookings ────────────── */
  function _alBookStandby() {
    const u = (typeof window !== "undefined") ? window.__forgeCurrentUser : null;
    const actor = (u && u.name) || "—";
    const queuedOk = function (err) { return err && (err.status === 404 || err.status === 400); };
    if (window.forgeApi && typeof window.forgeApi.mutate === "function") {
      window.forgeApi.mutate("slot_bookings", {
        op: "add", path: "/-",
        value: {
          facility: "NTS Santa Clarita · 2.0 m TVAC",
          window_start: "2026-05-10T06:00Z",
          window_end:   "2026-05-10T14:00Z",
          charge_code: "CC-AET-RISK-2026-014",
          booked_by: actor,
          ts: Date.now(),
        },
      }).then(function () {
        setToast({ kind: "ok", msg: "Standby booked · RISK_MITIGATION_BOOKED emitted" });
      }).catch(function (err) {
        if (queuedOk(err)) {
          setToast({ kind: "ok", msg: "RISK_MITIGATION_BOOKED queued" });
        } else {
          setToast({ kind: "err", msg: "Booking failed · " + (err && err.message || "unknown") });
        }
      });
    } else {
      setToast({ kind: "ok", msg: "RISK_MITIGATION_BOOKED queued" });
    }
    setShowRedund(false);
  }

  /* ── Header summary stats ───────────────────────────────────────── */
  const certRisk = operators.filter(o => o.cr7 <= 3 || o.esd <= 3 || !o.itar).length;
  const tvacOk   = chambers.filter(c => c.state === "down").length === 0;
  const trackerReady = trackers.filter(t => t.state === "ready").length;

  /* ── Render ─────────────────────────────────────────────────────── */
  return (
    <div style={{
      display: "flex", flexDirection: "column", height: "100%", minHeight: 0,
      // Cool-blue tint overlay only on this screen, no global theme bleed.
      background: "color-mix(in oklch, var(--bg-0) 4%, var(--bg-0))",
    }}>
      <_AlToolbar
        right={
          <>
            <Btn icon="Calendar" onClick={() => window.forgeToast && window.forgeToast("Slot calendar queued — wired in v2")}>Slot calendar</Btn>
            <Btn icon="File" onClick={() => window.forgeToast && window.forgeToast("Export readiness PDF queued — wired in v2")}>Export readiness PDF</Btn>
            <Btn variant="primary" icon="Check" disabled title="coming in v2">Lock line · 2026-05-10 / Shift A</Btn>
          </>
        }
      >
        <span style={{ fontSize: 12, color: "var(--ink-4)" }}>
          Tomorrow ·{" "}
          <b className="mono" style={{ color: "#2D5BEA" }}>2026-05-10Z / Shift A</b>
          &nbsp;·&nbsp;target hinge HG-03 retest closeout &nbsp;·&nbsp;
          <span style={{ color: tvacRisk.severity === "critical" ? "var(--err)" : "var(--warn)" }}>
            TVAC-B down · 1 op blocked · {trackerReady}/3 trackers green
          </span>
        </span>
      </_AlToolbar>

      <div style={{
        flex: 1, display: "grid",
        gridTemplateColumns: "1.25fr 1fr 1fr 1fr",
        minHeight: 0,
      }}>

        {/* ════════════════ Column 1 — Slot allocation ════════════════ */}
        <div style={{ borderRight: "1px solid var(--line)", display: "flex", flexDirection: "column", minHeight: 0 }}>
          <div className="label" style={{
            padding: "8px 12px", borderBottom: "1px solid var(--line)",
            background: "var(--bg-1)", display: "flex", justifyContent: "space-between",
          }}>
            <span>CLEAN-ROOM SLOTS · CLASS 7 · 2026-05-10Z</span>
            <span style={{ color: "#2D5BEA" }}>Bay-A · Bay-B</span>
          </div>

          <div style={{ flex: 1, overflow: "auto" }}>
            {/* Header strip */}
            <div className="label" style={_al_slotHeaderStyle}>
              <div>UTC</div>
              <div>BAY-A · INTG</div>
              <div>BAY-B · TVAC</div>
            </div>

            {SLOT_BLOCKS.map(s => {
              const tA = slotTone(s.a);
              const tB = slotTone(s.b);
              const cellStyle = (tone) => ({
                padding: "6px 8px",
                fontSize: 12, fontFamily: "var(--font-mono)",
                color: "var(--ink-2)",
                background: tone
                  ? "color-mix(in oklch, " + (
                      tone === "accent" ? "#2D5BEA" :
                      tone === "info"   ? "var(--info)" :
                      tone === "warn"   ? "var(--warn)" :
                      tone === "err"    ? "var(--err)"  :
                      "var(--ink-4)"
                    ) + " 12%, transparent)"
                  : "transparent",
                borderRight: "1px solid var(--line-soft)",
                borderRadius: 2,
              });
              return (
                <div key={s.t}
                  role="button"
                  tabIndex={0}
                  style={{
                    display: "grid", gridTemplateColumns: "60px 1fr 1fr",
                    padding: "4px 12px",
                    borderBottom: "1px solid var(--line-soft)",
                    alignItems: "stretch",
                  }}
                  onClick={() => setPickedSlot(s.t)}
                  onKeyDown={(e) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); setPickedSlot(s.t); } }}
                >
                  <div className="mono" style={{
                    fontSize: 12, color: "var(--ink-3)",
                    display: "flex", alignItems: "center",
                  }}>{s.t}</div>
                  <div style={cellStyle(tA)}>{s.a}</div>
                  <div style={cellStyle(tB)}>{s.b}</div>
                </div>
              );
            })}

            <div style={{ padding: 12, fontSize: 12, lineHeight: 1.55, color: "var(--ink-3)" }}>
              <div className="label" style={{ marginBottom: 6 }}>SLOT LEGEND</div>
              {slotLegend.map(l => (
                <div key={l.code} style={{ display: "flex", alignItems: "center", gap: 6, marginBottom: 3 }}>
                  {_al_dot(l.tone)}
                  <span className="mono" style={{ width: 92, color: "var(--ink-2)" }}>{l.code}</span>
                  <span style={{ color: "var(--ink-3)" }}>{l.label}</span>
                </div>
              ))}
              <div style={{ marginTop: 8, color: "var(--ink-4)" }}>
                Slot durations are 30 min; particle counts logged at every state
                change to <span className="mono">/auditor/cleanroom-log.json</span>.
              </div>
            </div>
          </div>
        </div>

        {/* ════════ Column 2 — TVAC + EMI + Vib + Laser tracker ════════ */}
        <div style={{ borderRight: "1px solid var(--line)", display: "flex", flexDirection: "column", minHeight: 0 }}>
          <div className="label" style={{
            padding: "8px 12px", borderBottom: "1px solid var(--line)",
            background: "var(--bg-1)", display: "flex", justifyContent: "space-between",
          }}>
            <span>CHAMBERS &amp; TRACKERS</span>
            <span style={{ color: tvacOk ? "var(--ok)" : "var(--err)" }}>
              {chambers.filter(c => c.state === "down").length} down · {trackerReady} trackers ready
            </span>
          </div>

          <div style={{ flex: 1, overflow: "auto" }}>
            {/* Chamber rows */}
            {chambers.map(c => {
              const tone =
                c.state === "down"      ? "err"  :
                c.state === "in-use"    ? "info" :
                c.state === "scheduled" ? "warn" :
                                          "ok";
              return (
                <div key={c.id} style={{
                  padding: "10px 12px",
                  borderBottom: "1px solid var(--line-soft)",
                  background: c.state === "down"
                    ? "color-mix(in oklch, var(--err) 7%, transparent)"
                    : "transparent",
                }}>
                  <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center" }}>
                    <span className="mono" style={{ fontSize: 12, color: "var(--ink-3)" }}>{c.id}</span>
                    <Pill tone={tone}>{c.state}</Pill>
                  </div>
                  <div style={{ marginTop: 4, fontSize: 12, color: "var(--ink)" }}>{c.name}</div>
                  <div className="mono" style={{ marginTop: 2, fontSize: 12, color: "var(--ink-4)" }}>{c.spec}</div>
                  <div style={{ marginTop: 6, fontSize: 12, color: "var(--ink-2)" }}>{c.note}</div>
                </div>
              );
            })}

            {/* Laser-tracker subsection */}
            <div className="label" style={{
              padding: "8px 12px", borderTop: "1px solid var(--line)",
              background: "var(--bg-1)",
            }}>
              LASER TRACKERS
            </div>
            {trackers.map(t => {
              const tone = t.state === "ready" ? "ok" : t.state === "in-cal" ? "warn" : "info";
              return (
                <div key={t.id} style={{
                  padding: "10px 12px",
                  borderBottom: "1px solid var(--line-soft)",
                }}>
                  <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center" }}>
                    <span className="mono" style={{ fontSize: 12, color: "var(--ink-3)" }}>{t.id}</span>
                    <Pill tone={tone}>{t.state}</Pill>
                  </div>
                  <div style={{ fontSize: 12, color: "var(--ink)", marginTop: 4 }}>{t.name}</div>
                  <div className="mono" style={{ fontSize: 12, color: "var(--ink-4)", marginTop: 2 }}>
                    {t.spec} · warm-up <span style={{ color: "var(--ink-3)" }}>{t.warm_min}m</span>
                  </div>
                  <div style={{
                    marginTop: 6, fontSize: 12, color: "var(--ink-3)",
                    display: "flex", justifyContent: "space-between",
                  }}>
                    <span>cal <span className="mono">{t.calib}</span></span>
                    <span>due <span className="mono">{t.due}</span></span>
                  </div>
                </div>
              );
            })}
          </div>
        </div>

        {/* ════════════ Column 3 — Operator certification roster ════════════ */}
        <div style={{ borderRight: "1px solid var(--line)", display: "flex", flexDirection: "column", minHeight: 0 }}>
          <div className="label" style={{
            padding: "8px 12px", borderBottom: "1px solid var(--line)",
            background: "var(--bg-1)", display: "flex", justifyContent: "space-between",
          }}>
            <span>OPERATORS · SHIFT A</span>
            <span style={{ color: certRisk > 0 ? "var(--warn)" : "var(--ok)" }}>
              {operators.length - certRisk}/{operators.length} cleared · {certRisk} flagged
            </span>
          </div>

          <div style={{ flex: 1, overflow: "auto" }}>
            {/* Column header */}
            <div className="label" style={_al_certHeaderStyle}>
              <div>OPERATOR</div>
              <div style={{ textAlign: "right" }}>CR-7</div>
              <div style={{ textAlign: "right" }}>ESD</div>
              <div style={{ textAlign: "right" }}>ITAR</div>
              <div style={{ textAlign: "right" }}>AUDIT</div>
            </div>

            {operators.map(o => {
              const flagged = o.cr7 <= 1 || o.esd <= 1 || !o.itar;
              return (
                <div key={o.name} style={{
                  padding: "10px 12px", borderBottom: "1px solid var(--line-soft)",
                  background: flagged ? "color-mix(in oklch, var(--err) 5%, transparent)" : "transparent",
                }}>
                  <div style={{
                    display: "grid",
                    gridTemplateColumns: "1fr 56px 56px 56px 56px",
                    alignItems: "center", gap: 4,
                  }}>
                    <div style={{ display: "flex", alignItems: "center", gap: 8, minWidth: 0 }}>
                      {_al_avatar(o.name, 24)}
                      <div style={{ minWidth: 0 }}>
                        <div style={{ color: "var(--ink)", fontSize: 12 }}>{o.name}</div>
                        <div style={{ fontSize: 12, color: "var(--ink-4)" }}>{o.role}</div>
                      </div>
                    </div>
                    <div style={{ display: "flex", justifyContent: "flex-end" }}>{certBadge(o.cr7)}</div>
                    <div style={{ display: "flex", justifyContent: "flex-end" }}>{certBadge(o.esd)}</div>
                    <div style={{ display: "flex", justifyContent: "flex-end" }}>
                      {o.itar ? <Pill tone="ok">cleared</Pill> : <Pill tone="err">blocked</Pill>}
                    </div>
                    <div style={{ display: "flex", justifyContent: "flex-end" }}>{certBadge(o.audit)}</div>
                  </div>

                  {/* Endorsements */}
                  <div style={{ marginTop: 6, display: "flex", flexWrap: "wrap", gap: 4 }}>
                    {o.endorsements.map(en => (
                      <span key={en} className="mono" style={{
                        fontSize: 12, padding: "2px 6px", borderRadius: 2,
                        background: "color-mix(in oklch, #2D5BEA 10%, var(--bg-2))",
                        color: "#2D5BEA",
                        border: "1px solid color-mix(in oklch, #2D5BEA 25%, var(--line))",
                        letterSpacing: "0.04em",
                      }}>{en}</span>
                    ))}
                  </div>

                  {o.blocked && (
                    <div style={{
                      marginTop: 6, padding: "6px 8px",
                      background: "color-mix(in oklch, var(--err) 8%, transparent)",
                      border: "1px dashed var(--err)", borderRadius: 3,
                      fontSize: 12, color: "var(--ink-2)",
                    }}>{o.blocked}</div>
                  )}
                </div>
              );
            })}

            <div style={{ padding: 12, fontSize: 12, color: "var(--ink-4)", lineHeight: 1.5 }}>
              CR-7 · ISO 14644-1 Class 7 cleanroom access · ESD · IEC 61340-5-1 ·
              ITAR · 22 CFR §120.62 US-person attestation · AUDIT · AS9100 9.2 internal-audit signoff.
              Months shown are time-to-expiry.
            </div>
          </div>
        </div>

        {/* ════════════ Column 4 — Hinge re-test + risk panel ════════════ */}
        <div style={{ display: "flex", flexDirection: "column", minHeight: 0 }}>
          <div className="label" style={{
            padding: "8px 12px", borderBottom: "1px solid var(--line)",
            background: "var(--bg-1)", display: "flex", justifyContent: "space-between",
          }}>
            <span>HINGE RETEST · ECO-AET-0042</span>
            <span style={{ color: "var(--warn)" }}>
              {hingeRetest.filter(h => h.state === "passed").length}/{hingeRetest.length} closed
            </span>
          </div>

          <div style={{ flex: 1, overflow: "auto" }}>
            {hingeRetest.map(h => {
              const tone = h.state === "passed" ? "ok" : h.state === "in-flight" ? "warn" : "info";
              return (
                <div key={h.hinge} style={{
                  padding: "10px 12px",
                  borderBottom: "1px solid var(--line-soft)",
                  background: h.state === "in-flight"
                    ? "color-mix(in oklch, #2D5BEA 6%, transparent)"
                    : "transparent",
                }}>
                  <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center" }}>
                    <span className="mono" style={{ color: "var(--ink-2)", fontSize: 12 }}>
                      KESTREL-3.60.HG.{h.hinge.slice(-2)}
                    </span>
                    <Pill tone={tone}>{h.state}</Pill>
                  </div>
                  <div style={{
                    display: "grid", gridTemplateColumns: "1fr 1fr",
                    marginTop: 6, fontSize: 12, color: "var(--ink-3)",
                  }}>
                    <span>rev <b className="mono" style={{ color: "var(--ink-2)" }}>{h.rev}</b></span>
                    <span>spec <b className="mono" style={{ color: "var(--ink-2)" }}>{h.torque_nm.toFixed(2)} Nm</b></span>
                  </div>
                  <div className="mono" style={{ fontSize: 12, color: "var(--ink-4)", marginTop: 4 }}>
                    audit {h.audit_z}
                  </div>
                  <div style={{ marginTop: 6, fontSize: 12, color: "var(--ink-2)" }}>{h.note}</div>
                </div>
              );
            })}

            {/* Risk panel */}
            <div style={{
              margin: 12, padding: 12,
              background: "color-mix(in oklch, var(--err) 7%, var(--bg-1))",
              border: "1px solid var(--err)", borderRadius: 3,
            }}>
              <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center" }}>
                <span className="label" style={{ color: "var(--err)" }}>RISK · TVAC REDUNDANCY</span>
                <Pill tone={_al_severityTone(tvacRisk.severity)}>{tvacRisk.severity}</Pill>
              </div>
              <div style={{ marginTop: 8, fontSize: 12, color: "var(--ink)", fontWeight: 500 }}>
                {tvacRisk.headline}
              </div>
              <div className="mono" style={{ marginTop: 4, fontSize: 12, color: "var(--ink-4)" }}>
                opened {tvacRisk.open_z}
              </div>
              <div style={{ marginTop: 8, fontSize: 12, color: "var(--ink-2)", lineHeight: 1.55 }}>
                {tvacRisk.impact}
              </div>

              <div className="label" style={{ marginTop: 10, marginBottom: 4, color: "var(--ink-3)" }}>
                MITIGATIONS
              </div>
              {tvacRisk.mitigations.map(m => {
                const tone = m.state === "ready" ? "ok" : m.state === "in-flight" ? "warn" : "info";
                return (
                  <div key={m.id} style={{
                    display: "flex", alignItems: "flex-start", gap: 8,
                    padding: "5px 0", borderBottom: "1px dashed var(--line-soft)",
                    fontSize: 12, color: "var(--ink-2)",
                  }}>
                    <span className="mono" style={{ color: "var(--ink-4)", width: 44 }}>{m.id}</span>
                    <span style={{ flex: 1 }}>{m.text}</span>
                    <Pill tone={tone}>{m.state}</Pill>
                  </div>
                );
              })}

              <div style={{ marginTop: 10, display: "flex", gap: 6 }}>
                <Btn onClick={() => window.forgeToast && window.forgeToast("Mission Director brief queued — wired in v2")}>Brief Mission Director</Btn>
                <Btn variant="primary" onClick={() => setShowRedund(true)}>
                  Approve NTS standby
                </Btn>
              </div>
            </div>

            {/* Verdict */}
            <div style={{ padding: 12, fontSize: 12, color: "var(--ink-3)", lineHeight: 1.55 }}>
              <div className="label" style={{ marginBottom: 4 }}>READINESS VERDICT</div>
              Line is{" "}
              <b style={{ color: "var(--warn)" }}>conditionally ready</b> for shift A on{" "}
              <span className="mono" style={{ color: "var(--ink-2)" }}>2026-05-10Z</span>.
              ECO-AET-0042 closeout pivots on TVAC-A holding through cycle 24. K. Bhat
              ESD recert ({operators.find(o => o.name === "K. Bhat").esd}mo) and
              A. Chen ITAR re-attest must clear before s4 floater coverage is restored.
              If TVAC-A and HG-03 borescope both pass by{" "}
              <span className="mono" style={{ color: "var(--ink-2)" }}>13:00Z</span>,
              ACC at 2026-07-15 holds with 11 d slack.
            </div>
          </div>
        </div>
      </div>

      {/* Picked-slot footer (light affordance, not a modal) */}
      {pickedSlot && (
        <div style={_al_pickedFooterStyle}>
          <span>
            Selected slot{" "}
            <b className="mono" style={{ color: "#2D5BEA" }}>{pickedSlot}Z</b>
            {" · click again to confirm reservation"}
          </span>
          <Btn size="sm" onClick={() => setPickedSlot(null)}>Clear</Btn>
        </div>
      )}

      {showRedund && (
        <_AlModal
          title="NTS Santa Clarita standby reservation"
          body={
            <div style={{ fontSize: 12, color: "var(--ink-2)", lineHeight: 1.55 }}>
              <p style={{ marginTop: 0 }}>
                Reserving the NTS Santa Clarita 2.0 m TVAC chamber as standby for the
                period <b className="mono">2026-05-10Z 06:00 → 14:00</b>.
              </p>
              <ul style={{ marginTop: 8, paddingLeft: 18 }}>
                <li>Transit envelope: 3 h IPA-wipe truck under N₂ purge.</li>
                <li>Cost: {(window.forgeI18n && window.forgeI18n.formatMoneyMinor && window.forgeI18n.formatMoneyMinor("480000", "USD")) || "$4,800"}/day standby + {(window.forgeI18n && window.forgeI18n.formatMoneyMinor && window.forgeI18n.formatMoneyMinor("120000", "USD")) || "$1,200"}/h if activated.</li>
                <li>Charge code <span className="mono">CC-AET-RISK-2026-014</span>.</li>
                <li>Mission Director M. Sato pre-briefed at 2026-05-09T06:18Z.</li>
              </ul>
              <p style={{ marginTop: 10, color: "var(--ink-3)" }}>
                Confirming will emit a <span className="mono">RISK_MITIGATION_BOOKED</span>{" "}
                receipt to the auditor ledger.
              </p>
            </div>
          }
          onCancel={() => setShowRedund(false)}
          onConfirm={_alBookStandby}
          confirmLabel="Book standby slot"
        />
      )}

      {/* W14B · toast for modal-confirm mutate results ─────────────── */}
      {toast && (
        <div style={{
          position: "fixed", bottom: 24, right: 24,
          background: toast.kind === "err" ? "var(--err, #b00020)" : "var(--ink)",
          color: "var(--bg-0)",
          padding: "8px 14px", borderRadius: 4, fontSize: 12,
          boxShadow: "0 6px 20px rgba(0,0,0,0.18)", zIndex: 60,
        }}>
          {toast.msg}
        </div>
      )}
    </div>
  );
}

/* ════════════════════════════════════════════════════════════════════
   Route registration — defensive. Wave A1 task #12 lands the canonical
   space registry; until then this file installs a tiny shim so the
   route survives a hot-reload in any order.
   ──────────────────────────────────────────────────────────────────── */

(function _registerAetherionLine() {
  if (typeof window === "undefined") return;

  if (typeof window.registerSpaceRoute !== "function") {
    if (!Array.isArray(window.SPACE_ROUTES)) window.SPACE_ROUTES = [];
    window.registerSpaceRoute = function (route) {
      const ix = window.SPACE_ROUTES.findIndex(function (r) { return r.path === route.path; });
      if (ix >= 0) window.SPACE_ROUTES[ix] = route;
      else         window.SPACE_ROUTES.push(route);
      return route;
    };
    if (typeof window.listSpaceRoutes !== "function") {
      window.listSpaceRoutes = function () { return window.SPACE_ROUTES.slice(); };
    }
  }

  window.registerSpaceRoute({
    path: "/line/queue",
    mode: "line",
    title: "Line readiness · KESTREL-3",
    renderer: function () { return React.createElement(ScreenAetherionLine); },
  });

  // Expose component for command-palette / dashboard composition.
  window.ScreenAetherionLine = ScreenAetherionLine;
})();
})();
