// FORGE — seed data. All fictional part numbers for a "Hydrokinetic Turbine Unit HTU-220"
// Generic industrial equipment, avoids any real product.

const PROGRAM = {
  id: "PGM-HTU-220",
  code: "HTU-220",
  name: "HTU-220 · Hydrokinetic Turbine Unit",
  customer: "Internal · New Product Development",
  phase: "Detailed Design",
  nextMilestone: "DR-3 · Critical Design Review",
  nextDate: "2026-05-14",
  revision: "C",
  lead: "S. Okafor",
  progress: 0.62,
};

const KPIS = [
  { k: "Active parts",        v: "1,284",   d: "+42 wk",  trend: "up"   },
  { k: "E-BOM revs pending",  v: "17",      d: "−5 wk",   trend: "down" },
  { k: "M-BOM coverage",      v: "91.4%",   d: "+3.1 pt", trend: "up"   },
  { k: "Sim jobs queued",     v: "9",       d: "3 running", trend: "flat"},
  { k: "Open ECOs",           v: "6",       d: "2 crit",  trend: "flat" },
  { k: "ERP sync drift",      v: "0.4%",    d: "within SLA", trend: "down"},
];

const NAV = [
  { g: "Program", items: [
    { id: "dashboard",    label: "Overview",          icon: "Home"      },
    { id: "onboarding",   label: "Onboarding",        icon: "Sparkle"   },
  ]},
  { g: "Plan", items: [
    { id: "plc",          label: "Product Lifecycle",   icon: "Satellite" },
    { id: "gantt",        label: "Schedule · plan://",  icon: "Calendar"  },
  ]},
  { g: "Build", items: [
    { id: "ebom",         label: "E-BOM",              icon: "Tree"      },
    { id: "ebomtombom",   label: "E-BOM → M-BOM",      icon: "Diff"      },
    { id: "mbom",         label: "M-BOM · Routing",    icon: "Factory"   },
    { id: "workflows",    label: "Workflow Hub · build://",  icon: "Flow"      },
    { id: "eco",          label: "Change Orders",       icon: "Git"       },
    { id: "approvals",    label: "Approvals",           icon: "Check"     },
    { id: "erp",          label: "ERP Release",         icon: "Plug"      },
  ]},
  { g: "Line", items: [
    { id: "line",         label: "Line · line://",      icon: "Factory"   },
    { id: "analytics",    label: "Analytics",           icon: "BarChart"  },
    { id: "connectors",   label: "Connectors",          icon: "Link"      },
  ]},
  { g: "Traveler", items: [
    { id: "traveler",     label: "Traveler · traveler://", icon: "Wrench"  },
  ]},
  { g: "Governance", items: [
    { id: "auditor",      label: "Auditor · ledger",    icon: "Check"     },
  ]},
  { g: "Organization", items: [
    { id: "people",       label: "People & HR",         icon: "Person"    },
    { id: "docs",         label: "Documents",           icon: "File"      },
    { id: "maintenance",  label: "Maintenance",         icon: "Wrench"    },
    { id: "integrations", label: "Integrations",        icon: "DB"        },
  ]},
];

// Part catalog — nested tree, engineering view
const EBOM = {
  id: "HTU-220",
  pn: "HTU-220.00.00",
  name: "HTU-220 · Turbine Unit Assembly",
  type: "ASM", qty: 1, rev: "C", mat: "—", source: "DESIGN",
  status: "in-work",
  children: [
    { id: "R", pn: "HTU-220.10.00", name: "Rotor Assembly", type: "ASM", qty: 1, rev: "C", mat: "—", source: "DESIGN", status: "in-work",
      children: [
        { pn: "HTU-220.10.01", name: "Hub · Forged", type: "PRT", qty: 1, rev: "B", mat: "Ti-6Al-4V", source: "MAKE", status: "released" },
        { pn: "HTU-220.10.02", name: "Blade · Airfoil A", type: "PRT", qty: 3, rev: "C", mat: "CFRP layup L-7", source: "MAKE", status: "in-work" },
        { pn: "HTU-220.10.03", name: "Pitch Bearing", type: "PRT", qty: 3, rev: "A", mat: "17-4PH", source: "BUY",  status: "released" },
        { pn: "HTU-220.10.04", name: "Spinner Cone", type: "PRT", qty: 1, rev: "A", mat: "Al 6061-T6", source: "MAKE", status: "released" },
      ]
    },
    { id: "N", pn: "HTU-220.20.00", name: "Nacelle Assembly", type: "ASM", qty: 1, rev: "C", mat: "—", source: "DESIGN", status: "in-work",
      children: [
        { pn: "HTU-220.20.01", name: "Main Shaft",       type: "PRT", qty: 1, rev: "B", mat: "42CrMo4", source: "MAKE", status: "released" },
        { pn: "HTU-220.20.02", name: "Gearbox · 3-stage",type: "ASM", qty: 1, rev: "C", mat: "—",       source: "BUY",  status: "in-work",
          children: [
            { pn: "HTU-220.20.02.01", name: "Sun Gear",   type: "PRT", qty: 1, rev: "A", mat: "18CrNiMo7-6", source: "BUY", status: "released" },
            { pn: "HTU-220.20.02.02", name: "Planet Gear",type: "PRT", qty: 3, rev: "A", mat: "18CrNiMo7-6", source: "BUY", status: "released" },
            { pn: "HTU-220.20.02.03", name: "Ring Gear",  type: "PRT", qty: 1, rev: "A", mat: "18CrNiMo7-6", source: "BUY", status: "released" },
          ]},
        { pn: "HTU-220.20.03", name: "Generator · PMSG 1.2 MW", type: "ASM", qty: 1, rev: "B", mat: "—", source: "BUY",  status: "released" },
        { pn: "HTU-220.20.04", name: "Brake Caliper",   type: "PRT", qty: 2, rev: "A", mat: "GG25",  source: "BUY",  status: "released" },
        { pn: "HTU-220.20.05", name: "Cooling Manifold",type: "PRT", qty: 1, rev: "B", mat: "Al 6061-T6", source: "MAKE", status: "in-work" },
      ]},
    { id: "M", pn: "HTU-220.30.00", name: "Monopile · Structural", type: "ASM", qty: 1, rev: "B", mat: "—", source: "DESIGN", status: "released",
      children: [
        { pn: "HTU-220.30.01", name: "Base Flange",  type: "PRT", qty: 1, rev: "B", mat: "S355J2+N", source: "MAKE", status: "released" },
        { pn: "HTU-220.30.02", name: "Tower Shell",  type: "PRT", qty: 1, rev: "B", mat: "S355J2+N", source: "MAKE", status: "released" },
        { pn: "HTU-220.30.03", name: "Fastener Kit", type: "KIT", qty: 1, rev: "A", mat: "A4-80",    source: "BUY",  status: "released" },
      ]},
    { id: "E", pn: "HTU-220.40.00", name: "Electrical Cabinet", type: "ASM", qty: 1, rev: "C", mat: "—", source: "DESIGN", status: "in-work",
      children: [
        { pn: "HTU-220.40.01", name: "Converter · 1.2 MW", type: "ASM", qty: 1, rev: "C", mat: "—", source: "BUY", status: "in-work" },
        { pn: "HTU-220.40.02", name: "Harness Loom",       type: "KIT", qty: 1, rev: "B", mat: "Cu/PVC", source: "MAKE", status: "in-work" },
        { pn: "HTU-220.40.03", name: "Controller · ECU-7", type: "PRT", qty: 1, rev: "A", mat: "—",    source: "BUY",  status: "released" },
      ]},
  ]
};

// Manufacturing BOM — re-structured by assembly sequence, adds consumables + ops routing
const MBOM = {
  pn: "M·HTU-220", name: "HTU-220 · Manufacturing Plan",
  stations: [
    { id: "ST-10", name: "ST-10 Rotor Build", hours: 6.5, ops: 4, wi: "WI-210-B", parts: [
      { pn: "HTU-220.10.01", name: "Hub · Forged", qty: 1, op: "OP-010 Press-fit", time: "0.8h" },
      { pn: "HTU-220.10.02", name: "Blade · Airfoil A", qty: 3, op: "OP-020 Pitch align", time: "2.1h" },
      { pn: "HTU-220.10.03", name: "Pitch Bearing",     qty: 3, op: "OP-020 Pitch align", time: "—" },
      { pn: "HTU-220.10.04", name: "Spinner Cone",      qty: 1, op: "OP-030 Close-out",   time: "0.6h" },
      { pn: "CONS·Loctite-262", name: "Loctite 262 · 50ml", qty: 1, op: "OP-020", time: "—", cons: true },
      { pn: "CONS·Torq-Cert",   name: "Torque Record Sheet",  qty: 1, op: "OP-030", time: "—", cons: true },
    ]},
    { id: "ST-20", name: "ST-20 Nacelle Build", hours: 11.2, ops: 6, wi: "WI-220-D", parts: [
      { pn: "HTU-220.20.01", name: "Main Shaft",      qty: 1, op: "OP-110 Lay-down", time: "0.4h" },
      { pn: "HTU-220.20.02", name: "Gearbox · 3-stage", qty: 1, op: "OP-120 Bolt-up", time: "3.5h" },
      { pn: "HTU-220.20.03", name: "Generator · PMSG 1.2 MW", qty: 1, op: "OP-130 Couple", time: "2.4h" },
      { pn: "HTU-220.20.04", name: "Brake Caliper",   qty: 2, op: "OP-140 Brake set", time: "1.1h" },
      { pn: "HTU-220.20.05", name: "Cooling Manifold",qty: 1, op: "OP-150 Hose kit", time: "1.4h" },
      { pn: "CONS·Grease-EP2", name: "Grease EP-2 · 1kg", qty: 2, op: "OP-120", time: "—", cons: true },
    ]},
    { id: "ST-30", name: "ST-30 Monopile Stack", hours: 4.0, ops: 3, wi: "WI-230-A", parts: [
      { pn: "HTU-220.30.01", name: "Base Flange",  qty: 1, op: "OP-210 Weld-prep",  time: "1.4h" },
      { pn: "HTU-220.30.02", name: "Tower Shell",  qty: 1, op: "OP-220 Stack",      time: "1.8h" },
      { pn: "HTU-220.30.03", name: "Fastener Kit", qty: 1, op: "OP-230 Torque seq", time: "0.8h" },
    ]},
    { id: "ST-40", name: "ST-40 Electrical Integration", hours: 7.6, ops: 5, wi: "WI-240-C", parts: [
      { pn: "HTU-220.40.01", name: "Converter · 1.2 MW", qty: 1, op: "OP-310 Mount",   time: "1.2h" },
      { pn: "HTU-220.40.02", name: "Harness Loom",       qty: 1, op: "OP-320 Pull-to-plan", time: "3.8h" },
      { pn: "HTU-220.40.03", name: "Controller · ECU-7", qty: 1, op: "OP-330 Flash FW", time: "0.6h" },
      { pn: "CONS·HeatShrink", name: "Heat-shrink kit Ø4–16", qty: 1, op: "OP-320", time: "—", cons: true },
    ]},
    { id: "ST-50", name: "ST-50 FAT · Factory Acceptance Test", hours: 4.0, ops: 2, wi: "WI-250-A", parts: [
      { pn: "TEST·DYN-12", name: "Spin-balance + no-load run", qty: 1, op: "OP-410 FAT", time: "2.0h", test: true },
      { pn: "TEST·HV-34",  name: "HV insulation test",         qty: 1, op: "OP-420 FAT", time: "1.0h", test: true },
    ]},
  ]
};

// Transformation rules applied to turn E-BOM into M-BOM
const TRANSFORMS = [
  { id: "T1", kind: "regroup",    name: "Regroup by assembly station", desc: "E-BOM hierarchy → ST-10..50 stations" },
  { id: "T2", kind: "add",        name: "Inject consumables",           desc: "Add adhesives, lubricants, fasteners from Supplier Kits" },
  { id: "T3", kind: "add",        name: "Inject test stages",           desc: "FAT procedures as virtual parts" },
  { id: "T4", kind: "route",      name: "Attach routing & work instr.", desc: "Bind each item to OP-code + WI doc" },
  { id: "T5", kind: "substitute", name: "Alternate part resolution",    desc: "Supplier A/B swap rules for long-lead items" },
  { id: "T6", kind: "explode",    name: "Phantom assembly explosion",   desc: "Flatten phantoms into top-level picklist" },
  { id: "T7", kind: "validate",   name: "ERP mapping validation",       desc: "Verify item-master fields before sync" },
];

// Simulation studies
const STUDIES = [
  { id: "SIM-0412", name: "Blade · Modal",                  domain: "structural",  mesh: "1.24M tet",  solver: "Lanczos",       cores: 48,  eta: "12m",  status: "running",   progress: 0.44 },
  { id: "SIM-0411", name: "Blade · Static bending 1.5g",    domain: "structural",  mesh: "2.08M tet",  solver: "Direct sparse", cores: 32,  eta: "—",    status: "complete",  progress: 1.00 },
  { id: "SIM-0410", name: "Rotor · CFD wake (URANS, k-ω)",  domain: "cfd",         mesh: "46.1M poly", solver: "Coupled P-V",   cores: 384, eta: "2h 40m", status: "running", progress: 0.18 },
  { id: "SIM-0409", name: "Gearbox · Thermal steady",       domain: "thermal",     mesh: "0.92M tet",  solver: "Conjugate HT",  cores: 24,  eta: "—",    status: "complete",  progress: 1.00 },
  { id: "SIM-0408", name: "Nacelle · Thermal-structural",   domain: "coupled",     mesh: "3.6M tet",   solver: "Co-sim",        cores: 128, eta: "queued", status: "queued",  progress: 0.00 },
  { id: "SIM-0407", name: "Generator · EM no-load",         domain: "em",          mesh: "0.6M",       solver: "Time-stepping", cores: 16,  eta: "—",    status: "complete",  progress: 1.00 },
  { id: "SIM-0406", name: "Rotor · NVH 0–200 Hz",           domain: "vibration",   mesh: "0.8M",       solver: "Modal sup.",    cores: 16,  eta: "—",    status: "failed",    progress: 0.72 },
  { id: "SIM-0405", name: "Full unit · MBD operating loads",domain: "mbd",         mesh: "rigid",      solver: "MSC-style",     cores: 8,   eta: "—",    status: "complete",  progress: 1.00 },
];

// ECOs
const ECOS = [
  { id: "ECO-2611", title: "Blade laminate L-7 → L-8 (fatigue margin)",  owner: "J. Park",   target: "HTU-220.10.02", sev: "high",   state: "board-review",  opened: "2d" },
  { id: "ECO-2610", title: "Cooling manifold outlet Ø14 → Ø16",          owner: "A. Ibrahim",target: "HTU-220.20.05", sev: "medium", state: "impact-analysis", opened: "4d" },
  { id: "ECO-2609", title: "Supplier swap · Pitch bearing alt B",         owner: "S. Okafor", target: "HTU-220.10.03", sev: "low",    state: "approved",      opened: "9d" },
  { id: "ECO-2608", title: "Harness loom · reroute around cabinet door",  owner: "M. Chen",   target: "HTU-220.40.02", sev: "medium", state: "ecn-issued",    opened: "12d" },
  { id: "ECO-2607", title: "Torque spec update · flange bolts M24",       owner: "R. Larsen", target: "HTU-220.30.01", sev: "low",    state: "closed",        opened: "21d" },
];

// ERP release queue
const ERP_QUEUE = [
  { pn: "HTU-220.10.02", name: "Blade · Airfoil A",        rev: "C", item: "ITM-0041", state: "awaiting-sync",  drift: "fields mismatched: UOM, lot-size" },
  { pn: "HTU-220.20.05", name: "Cooling Manifold",         rev: "B", item: "ITM-0058", state: "validating",     drift: "—" },
  { pn: "HTU-220.20.02.02", name: "Planet Gear",           rev: "A", item: "ITM-0033", state: "synced",         drift: "—" },
  { pn: "HTU-220.40.02", name: "Harness Loom",             rev: "B", item: "ITM-0072", state: "blocked",        drift: "no cost-center on rev B" },
  { pn: "HTU-220.30.02", name: "Tower Shell",              rev: "B", item: "ITM-0081", state: "synced",         drift: "—" },
  { pn: "CONS·Grease-EP2", name: "Grease EP-2 · 1kg",      rev: "—", item: "ITM-9912", state: "synced",         drift: "—" },
  { pn: "HTU-220.40.01", name: "Converter · 1.2 MW",       rev: "C", item: "ITM-0069", state: "awaiting-sync",  drift: "PO-lead 90d > plan" },
];

// Approvals timeline events
const APPROVALS = [
  { t: "09:41", who: "S. Okafor",  role: "PGM Lead",   action: "Reviewed",  obj: "DR-3 pre-read",     state: "ok"   },
  { t: "09:28", who: "J. Park",    role: "Struct.",    action: "Submitted", obj: "ECO-2611",          state: "info" },
  { t: "08:55", who: "A. Ibrahim", role: "Thermal",    action: "Approved",  obj: "SIM-0409 report",   state: "ok"   },
  { t: "Yday",  who: "M. Chen",    role: "Mfg. Eng.",  action: "Rejected",  obj: "ECO-2608 rev-1",    state: "err"  },
  { t: "Yday",  who: "R. Larsen",  role: "Quality",    action: "Signed-off",obj: "ECO-2609",          state: "ok"   },
  { t: "-2d",   who: "ERP Planner",role: "Supply",     action: "Flagged",   obj: "HTU-220.40.02",     state: "warn" },
];

// Onboarding steps
const ONBOARD = [
  { id: 1, label: "Identify",     title: "Who's joining?",        sub: "Name, role, clearance, squads" },
  { id: 2, label: "Access",       title: "Pick toolchain access", sub: "CAD seat, CAE seat, PLM role, ERP scope" },
  { id: 3, label: "Program",      title: "Assign to program",     sub: "HTU-220 · area + workstream" },
  { id: 4, label: "Parts sandbox",title: "Part-data sandbox",     sub: "Clone E-BOM subtree to personal workspace" },
  { id: 5, label: "Sim seat",     title: "Reserve sim seat",      sub: "Cluster quota · license · solver pref" },
  { id: 6, label: "Handoff",      title: "ERP handoff mapping",   sub: "Item-master fields for your area" },
  { id: 7, label: "Ready",        title: "Go live",               sub: "First-day checklist + mentor" },
];

// Persona presets (changes insp panel + highlights)
const PERSONAS = {
  design:   { id: "design",   label: "Design Eng.",    tone: "Geometry + materials focus" },
  sim:      { id: "sim",      label: "Simulation Eng.",tone: "Physics, solvers, compute" },
  mfg:      { id: "mfg",      label: "Mfg. Eng.",      tone: "Routing, stations, WI" },
  pgm:      { id: "pgm",      label: "Program Mgr.",   tone: "Milestones, risk, status" },
  erp:      { id: "erp",      label: "ERP Planner",    tone: "Item master, supply, cost" },
};

// ── OAM Satellite BOM (flat list, p = parent num) ──
const OAM_BOM_FLAT = [
  { num:"1",    p:null, name:"66L FUEL TANK ASSY FOR OAM",        qty:2,  d:47, m:64, t:0 },
  { num:"1.1",  p:"1",  name:"TOP DISH",                          qty:2,  d:60, m:13, t:0 },
  { num:"1.2",  p:"1",  name:"METALLIC DIAPHRAGM",                qty:2,  d:10, m:88, t:0 },
  { num:"1.3",  p:"1",  name:"TOP DISC",                          qty:2,  d:60, m:50, t:0 },
  { num:"1.4",  p:"1",  name:"BOTTOM DISH",                       qty:2,  d:71, m:63, t:0 },
  { num:"1.5",  p:"1",  name:"M18 WASHER",                        qty:4,  d:86, m:75, t:0 },
  { num:"1.6",  p:"1",  name:"M18 EXTD NUT NIPPLE ADAPTER",       qty:2,  d:43, m:38, t:0 },
  { num:"1.7",  p:"1",  name:"M18 ADAPTOR",                       qty:2,  d:0,  m:88, t:0 },
  { num:"1.8",  p:"1",  name:"M12 WASHER",                        qty:2,  d:57, m:75, t:0 },
  { num:"1.9",  p:"1",  name:"M12 ADAPTOR",                       qty:2,  d:71, m:75, t:0 },
  { num:"1.10", p:"1",  name:"M12 NIPPLE NN 6MM OD",              qty:2,  d:29, m:75, t:0 },
  { num:"1.11", p:"1",  name:"M12 NUT 6MM OD NN",                 qty:2,  d:71, m:63, t:0 },
  { num:"1.12", p:"1",  name:"M18 NIPPLE 8MM OD 6 ID",            qty:2,  d:86, m:88, t:0 },
  { num:"1.13", p:"1",  name:"SPLIT AND LOCKNUT ASSY",            qty:2,  d:22, m:25, t:0 },
  { num:"1.14", p:"1",  name:"PROPELLENT TANK BOTTOM FLANGE",     qty:2,  d:30, m:75, t:0 },
  { num:"1.15", p:"1",  name:"M5 PLAIN WASHER",                   qty:16, d:29, m:50, t:0 },
  { num:"1.16", p:"1",  name:"M5 12L SOCKET HEAD SCREW",          qty:8,  d:14, m:83, t:0 },
  { num:"1.17", p:"1",  name:"M5 16L SOCKET HEAD SCREW",          qty:8,  d:0,  m:100,t:0 },
  { num:"1.18", p:"1",  name:"M18 NUT 8MM OD",                    qty:2,  d:29, m:88, t:0 },
  { num:"1.19", p:"1",  name:"M18 NIPPLE 10MM OD 12 ID",          qty:2,  d:57, m:50, t:0 },
  { num:"1.20", p:"1",  name:"M18X1 5 NUT OD 12",                 qty:2,  d:86, m:88, t:0 },
  { num:"1.21", p:"1",  name:"M6X1D HELICOIL",                    qty:8,  d:71, m:0,  t:0 },
  { num:"2",    p:null, name:"TIE ROD ASSEMBLY",                   qty:4,  d:29, m:56, t:0 },
  { num:"2.1",  p:"2",  name:"OAM TANK TOP FLANGE 1",             qty:4,  d:90, m:88, t:0 },
  { num:"2.2",  p:"2",  name:"OAM TANK SIDE CLEVIS",              qty:4,  d:70, m:88, t:0 },
  { num:"2.3",  p:"2",  name:"SKF SA 6 E-1",                      qty:4,  d:0,  m:100,t:0 },
  { num:"2.4",  p:"2",  name:"OAM VERTICAL DECK CLEVIS",          qty:4,  d:10, m:75, t:0 },
  { num:"2.5",  p:"2",  name:"M6 PLAIN WASHER",                   qty:12, d:29, m:50, t:0 },
  { num:"2.6",  p:"2",  name:"M4 PLAIN WASHER",                   qty:12, d:57, m:83, t:0 },
  { num:"2.7",  p:"2",  name:"SOCKET HEAD SCREW M4 OAM",          qty:4,  d:14, m:67, t:0 },
  { num:"2.8",  p:"2",  name:"M4 HEX NUT",                        qty:8,  d:14, m:17, t:0 },
  { num:"2.9",  p:"2",  name:"CLEVIS JOINT PIVOTPIN",             qty:4,  d:0,  m:50, t:0 },
  { num:"2.10", p:"2",  name:"M5 PLAIN WASHER",                   qty:16, d:14, m:83, t:0 },
  { num:"2.11", p:"2",  name:"M5 35L SOCKET HEAD SCREW",          qty:8,  d:14, m:50, t:0 },
  { num:"2.12", p:"2",  name:"M5 HEX NUT",                        qty:8,  d:71, m:0,  t:0 },
  { num:"2.13", p:"2",  name:"M6X1 HEX NUT",                      qty:4,  d:29, m:17, t:0 },
  { num:"2.14", p:"2",  name:"M6X10L SOCKET HEAD SCREW",          qty:8,  d:0,  m:17, t:0 },
  { num:"3",    p:null, name:"TIE ROD ASSEMBLY 2",                 qty:4,  d:70, m:100,t:0 },
  { num:"4",    p:null, name:"66L OXIDISER TANK ASSY FOR OAM",     qty:2,  d:0,  m:20, t:0 },
  { num:"5",    p:null, name:"LIQUID FILTER ASSY",                 qty:2,  d:29, m:20, t:0 },
  { num:"6",    p:null, name:"RAMAN-MINI ASSEMBLY GROUND",         qty:4,  d:14, m:63, t:0 },
  { num:"6.1",  p:"6",  name:"RAMAN MINI VAC AR 20",              qty:4,  d:14, m:63, t:0 },
  { num:"7",    p:null, name:"COLD GAS ASSY",                      qty:2,  d:40, m:100,t:0 },
  { num:"8",    p:null, name:"COLD GAS ASSY MIRROR",              qty:2,  d:80, m:40, t:0 },
  { num:"9",    p:null, name:"9L GAS BOTTLE ASSY FOR OAM",         qty:4,  d:90, m:40, t:0 },
  { num:"10",   p:null, name:"M5 PLAIN WASHER",                    qty:40, d:0,  m:33, t:0 },
  { num:"11",   p:null, name:"M5 35L SOCKET HEAD SCREW",           qty:4,  d:29, m:33, t:0 },
  { num:"12",   p:null, name:"M5 HEX NUT",                         qty:20, d:43, m:0,  t:0 },
  { num:"13",   p:null, name:"FUEL TERMINALS",                      qty:1,  d:60, m:100,t:0 },
  { num:"14",   p:null, name:"OXIDIZER TERMINAL",                   qty:1,  d:20, m:57, t:0 },
  { num:"15",   p:null, name:"SOCKET HEAD SCREW M5 25",            qty:16, d:86, m:83, t:0 },
  { num:"16",   p:null, name:"RAMAN II ENGINE ASSEMBLY LATEST",    qty:1,  d:86, m:60, t:0 },
  { num:"17",   p:null, name:"PLUMBING AS PER SLAM TEST",          qty:1,  d:60, m:0,  t:0 },
  { num:"18",   p:null, name:"GL-P10002",                           qty:1,  d:86, m:0,  t:0 },
  { num:"19",   p:null, name:"WELDTEE-12MM",                       qty:3,  d:0,  m:20, t:0 },
  { num:"20",   p:null, name:"GL-P20001",                           qty:1,  d:57, m:80, t:0 },
  { num:"21",   p:null, name:"SS-8M0-4-SWAGELOKCOMPANY-3D-03",     qty:1,  d:14, m:80, t:0 },
  { num:"22",   p:null, name:"8MMUNIONTEESWAGELOK",                qty:3,  d:57, m:20, t:0 },
  { num:"23",   p:null, name:"GL-1C0001",                           qty:1,  d:0,  m:20, t:0 },
  { num:"24",   p:null, name:"GL-1A0001",                           qty:1,  d:14, m:0,  t:0 },
  { num:"25",   p:null, name:"WELDREDUCERELBOW-12-8MM",            qty:1,  d:29, m:80, t:0 },
  { num:"26",   p:null, name:"GL-STUDPR0001",                       qty:1,  d:29, m:0,  t:0 },
  { num:"27",   p:null, name:"STUD-PR10001",                        qty:1,  d:29, m:100,t:0 },
  { num:"28",   p:null, name:"STUD-PR20001",                        qty:1,  d:71, m:0,  t:0 },
  { num:"29",   p:null, name:"STUD-PR30001",                        qty:1,  d:0,  m:0,  t:0 },
  { num:"30",   p:null, name:"SSTH8TM12TM12SWAGELOKHOSE",          qty:20, d:71, m:80, t:0 },
  { num:"31",   p:null, name:"GLOX-20001",                          qty:1,  d:57, m:40, t:0 },
  { num:"32",   p:null, name:"GL-F20001",                           qty:1,  d:86, m:60, t:0 },
  { num:"33",   p:null, name:"GL-F10001",                           qty:1,  d:71, m:60, t:0 },
  { num:"34",   p:null, name:"GL-OX10001",                          qty:1,  d:57, m:60, t:0 },
  { num:"35",   p:null, name:"WELDELBOW-12MM",                      qty:3,  d:71, m:80, t:0 },
  { num:"36",   p:null, name:"WELDELBOW-6MM",                       qty:1,  d:29, m:60, t:0 },
  { num:"37",   p:null, name:"OXVL0001",                            qty:1,  d:86, m:60, t:0 },
  { num:"38",   p:null, name:"6MMUNIONTEESWAGE",                   qty:1,  d:0,  m:100,t:0 },
  { num:"39",   p:null, name:"OXVL-A0001",                          qty:1,  d:86, m:40, t:0 },
  { num:"40",   p:null, name:"OXVL-B0001",                          qty:1,  d:14, m:20, t:0 },
  { num:"41",   p:null, name:"12MMUNIONSWAGETEE",                  qty:1,  d:43, m:0,  t:0 },
  { num:"42",   p:null, name:"OXDL-A0001",                          qty:1,  d:0,  m:80, t:0 },
  { num:"43",   p:null, name:"OXDL-B0001",                          qty:1,  d:71, m:40, t:0 },
  { num:"44",   p:null, name:"5WAY-PLINE",                          qty:1,  d:29, m:86, t:0 },
  { num:"45",   p:null, name:"BDV",                                  qty:1,  d:86, m:57, t:0 },
  { num:"46",   p:null, name:"OXFL-S0001",                          qty:1,  d:71, m:0,  t:0 },
  { num:"47",   p:null, name:"12TO6MMREDUCER",                     qty:1,  d:14, m:20, t:0 },
  { num:"48",   p:null, name:"OXFL0001",                            qty:1,  d:29, m:100,t:0 },
  { num:"49",   p:null, name:"CROSS 12X10 12X10 1/4 BSPP F6",      qty:1,  d:0,  m:0,  t:0 },
  { num:"50",   p:null, name:"OXL-CE0002",                          qty:1,  d:14, m:60, t:0 },
  { num:"51",   p:null, name:"6MMWELDTEE",                          qty:1,  d:14, m:20, t:0 },
  { num:"52",   p:null, name:"HOSE-OXDL-10001",                    qty:1,  d:14, m:100,t:0 },
  { num:"53",   p:null, name:"HOSE-OXDL-20001",                    qty:1,  d:0,  m:100,t:0 },
  { num:"54",   p:null, name:"GL-TP30001",                          qty:1,  d:14, m:80, t:0 },
  { num:"55",   p:null, name:"FDL-A0001",                           qty:1,  d:86, m:0,  t:0 },
  { num:"56",   p:null, name:"FDL-B0001",                           qty:1,  d:57, m:20, t:0 },
  { num:"57",   p:null, name:"FDL0001",                             qty:1,  d:14, m:60, t:0 },
  { num:"58",   p:null, name:"FFL-S0001",                           qty:1,  d:57, m:100,t:0 },
  { num:"59",   p:null, name:"FL-C0001",                            qty:1,  d:0,  m:100,t:0 },
  { num:"60",   p:null, name:"FL-CE0001",                           qty:1,  d:14, m:40, t:0 },
  { num:"61",   p:null, name:"FFL0001",                             qty:1,  d:29, m:60, t:0 },
  { num:"62",   p:null, name:"FVL0001",                             qty:1,  d:29, m:100,t:0 },
  { num:"63",   p:null, name:"FVL-B0001",                           qty:1,  d:14, m:40, t:0 },
  { num:"64",   p:null, name:"FVL-A0001",                           qty:1,  d:86, m:100,t:0 },
  { num:"65",   p:null, name:"HOSE-FDL-10001",                     qty:1,  d:86, m:20, t:0 },
  { num:"66",   p:null, name:"HOSE-FDL-20001",                     qty:1,  d:29, m:60, t:0 },
  { num:"67",   p:null, name:"CB9120",                              qty:52, d:86, m:20, t:0 },
  { num:"68",   p:null, name:"CB4064V3-8",                          qty:1,  d:86, m:60, t:0 },
  { num:"69",   p:null, name:"CB4064V3-12",                         qty:1,  d:29, m:20, t:0 },
  { num:"70",   p:null, name:"SSFLEXHOSE50N",                      qty:1,  d:0,  m:0,  t:0 },
  { num:"71",   p:null, name:"HOSEFL-Y10001",                      qty:1,  d:14, m:60, t:0 },
  { num:"72",   p:null, name:"HOSE-OXY10001",                      qty:1,  d:14, m:60, t:0 },
  { num:"73",   p:null, name:"HOSE-FL-P10001",                     qty:1,  d:71, m:0,  t:0 },
  { num:"74",   p:null, name:"HOSE-OXL-P10001",                    qty:1,  d:57, m:100,t:0 },
  { num:"75",   p:null, name:"HOSE-FLY20001",                      qty:1,  d:57, m:60, t:0 },
  { num:"76",   p:null, name:"HOSE-OXL-Y20001",                    qty:1,  d:71, m:0,  t:0 },
  { num:"77",   p:null, name:"HOSE-FL-P20001",                     qty:1,  d:43, m:100,t:0 },
  { num:"78",   p:null, name:"HOSE-OXL-P20002",                    qty:1,  d:0,  m:100,t:0 },
  { num:"79",   p:null, name:"CB4064V3-16",                         qty:1,  d:0,  m:100,t:0 },
  { num:"80",   p:null, name:"CB4064V3-24",                         qty:1,  d:57, m:60, t:0 },
  { num:"81",   p:null, name:"12MMUNIONSWAGELOK",                  qty:1,  d:43, m:20, t:0 },
  { num:"82",   p:null, name:"GL-TP20001",                          qty:1,  d:29, m:60, t:0 },
  { num:"83",   p:null, name:"HOSE-1010001",                       qty:1,  d:86, m:60, t:0 },
  { num:"84",   p:null, name:"HOSE-1020001",                       qty:1,  d:43, m:40, t:0 },
  { num:"85",   p:null, name:"POTLINE0001",                         qty:1,  d:71, m:60, t:0 },
  { num:"86",   p:null, name:"PFTLINE0001",                         qty:1,  d:29, m:80, t:0 },
  { num:"87",   p:null, name:"FL-50A0001",                          qty:1,  d:0,  m:0,  t:0 },
  { num:"88",   p:null, name:"FL-50F0001",                          qty:1,  d:57, m:60, t:0 },
  { num:"89",   p:null, name:"FL-50B0001",                          qty:1,  d:86, m:0,  t:0 },
  { num:"90",   p:null, name:"FL-50D0001",                          qty:1,  d:57, m:60, t:0 },
  { num:"91",   p:null, name:"OXL-50A0001",                         qty:1,  d:0,  m:60, t:0 },
  { num:"92",   p:null, name:"OXL-50C0001",                         qty:1,  d:14, m:40, t:0 },
  { num:"93",   p:null, name:"OXL-50E0001",                         qty:1,  d:43, m:80, t:0 },
  { num:"94",   p:null, name:"OXL-50B0001",                         qty:1,  d:43, m:100,t:0 },
  { num:"95",   p:null, name:"OXL-50D0001",                         qty:1,  d:86, m:100,t:0 },
  { num:"96",   p:null, name:"RAMAN-2 TIE ROD ASSEMBLY",           qty:1,  d:86, m:43, t:0 },
  { num:"97",   p:null, name:"GPL-N20001",                          qty:1,  d:14, m:60, t:0 },
  { num:"98",   p:null, name:"8MMTO6MMREDUCERWELD",                qty:1,  d:0,  m:80, t:0 },
  { num:"99",   p:null, name:"GPL-N2A0001",                         qty:1,  d:71, m:20, t:0 },
  { num:"100",  p:null, name:"GPL-N2C0001",                         qty:1,  d:14, m:0,  t:0 },
  { num:"101",  p:null, name:"GPLN2D0001",                          qty:1,  d:14, m:60, t:0 },
  { num:"102",  p:null, name:"6MMUNIONSWAGELOK",                   qty:1,  d:29, m:0,  t:0 },
  { num:"103",  p:null, name:"GPL-N2B0001",                         qty:1,  d:71, m:20, t:0 },
  { num:"104",  p:null, name:"PT G1 4 3",                           qty:1,  d:43, m:60, t:0 },
  { num:"105",  p:null, name:"12MM-1-4-BSP-F-DK-LOK",              qty:1,  d:86, m:60, t:0 },
  { num:"106",  p:null, name:"1/4 PT WASHER",                      qty:1,  d:86, m:40, t:0 },
  { num:"107",  p:null, name:"8MM-UNION-SWAGE-ELBOW-DKLOK",       qty:1,  d:43, m:80, t:0 },
  { num:"108",  p:null, name:"12-8REDUCERTEE",                     qty:1,  d:29, m:60, t:0 },
  { num:"109",  p:null, name:"GL-CGT-20002",                        qty:1,  d:43, m:100,t:0 },
  { num:"110",  p:null, name:"GL-PA0001",                           qty:1,  d:14, m:0,  t:0 },
  { num:"111",  p:null, name:"GL-1E0001",                           qty:1,  d:29, m:100,t:0 },
  { num:"112",  p:null, name:"GL-1F0001",                           qty:1,  d:29, m:60, t:0 },
  { num:"113",  p:null, name:"FL-500003",                           qty:1,  d:71, m:60, t:0 },
  { num:"114",  p:null, name:"OXL-500001",                          qty:1,  d:29, m:80, t:0 },
  { num:"115",  p:null, name:"FL-50C0002",                          qty:1,  d:29, m:0,  t:0 },
  { num:"116",  p:null, name:"8MM-UNION-DK-LOK",                   qty:1,  d:14, m:0,  t:0 },
  { num:"117",  p:null, name:"GL-CGT-1A0001",                       qty:1,  d:86, m:40, t:0 },
  { num:"118",  p:null, name:"CGTLINE0001",                         qty:1,  d:57, m:80, t:0 },
  { num:"119",  p:null, name:"THERMAL BLANKET",                     qty:1,  d:29, m:80, t:0 },
  { num:"120",  p:null, name:"OAM-THERMAL-BOOT RETAINER STRIP",    qty:1,  d:57, m:20, t:0 },
  { num:"121",  p:null, name:"M6x12 12.9",                          qty:1,  d:0,  m:100,t:0 },
  { num:"122",  p:null, name:"OAM-THERMAL-BOOT RETAINER STRIP-2",  qty:1,  d:14, m:80, t:0 },
];

// ── Gantt tasks (start/end = month index, 0=Jan 2026) ──
const GANTT_TASKS = [
  // Engineering
  { id:"E01", lane:"eng",  name:"System Requirements Review",    start:0,   end:1.5, status:"done",    ms:true  },
  { id:"E02", lane:"eng",  name:"Preliminary Design Review",     start:1.5, end:3,   status:"done"             },
  { id:"E03", lane:"eng",  name:"Propulsion System Design",      start:1,   end:5.5, status:"active"           },
  { id:"E04", lane:"eng",  name:"Critical Design Review (CDR)",  start:3.5, end:5,   status:"active",  ms:true  },
  { id:"E05", lane:"eng",  name:"Tank Structural Analysis",      start:3,   end:7,   status:"pending"          },
  { id:"E06", lane:"eng",  name:"Integration Design",            start:5,   end:8,   status:"pending"          },
  { id:"E07", lane:"eng",  name:"Design Freeze",                 start:8,   end:8,   status:"pending", ms:true  },
  // Procurement
  { id:"P01", lane:"proc", name:"Long-Lead Procurement Kickoff", start:1,   end:2.5, status:"done"             },
  { id:"P02", lane:"proc", name:"Fuel Tank Order (Item 1)",      start:2,   end:6,   status:"active"           },
  { id:"P03", lane:"proc", name:"Swagelok & Fittings",           start:2.5, end:5,   status:"active"           },
  { id:"P04", lane:"proc", name:"Engine Assembly (Item 16)",     start:3.5, end:9,   status:"pending"          },
  { id:"P05", lane:"proc", name:"Oxidiser Tank (Item 4)",        start:4,   end:8,   status:"pending"          },
  { id:"P06", lane:"proc", name:"Cold Gas System (Items 7-9)",   start:3,   end:7,   status:"active"           },
  { id:"P07", lane:"proc", name:"Supplier Qualification Audit",  start:5,   end:6,   status:"pending"          },
  // Manufacturing
  { id:"M01", lane:"mfg",  name:"Tank Component Fabrication",    start:5,   end:8,   status:"pending"          },
  { id:"M02", lane:"mfg",  name:"Propulsion Module Assembly",    start:7,   end:10,  status:"pending"          },
  { id:"M03", lane:"mfg",  name:"Cold Gas System Assembly",      start:7.5, end:10,  status:"pending"          },
  { id:"M04", lane:"mfg",  name:"Plumbing & Routing",            start:8.5, end:10.5,status:"pending"          },
  { id:"M05", lane:"mfg",  name:"Electrical Integration",        start:9,   end:11,  status:"pending"          },
  { id:"M06", lane:"mfg",  name:"Environmental Test (TVAC)",     start:10.5,end:11.5,status:"pending", ms:true  },
  { id:"M07", lane:"mfg",  name:"Factory Acceptance Test",       start:11,  end:12,  status:"pending", ms:true  },
];

// ── People / Teams ──
const PEOPLE = [
  { id:"P001", name:"Arjun Mehta",    role:"Program Director",      team:"management",  dept:"Engineering",    loc:"Bangalore", status:"active", joined:"2021-03-01" },
  { id:"P002", name:"Sana Raza",      role:"Chief Systems Eng.",     team:"engineering", dept:"Engineering",    loc:"Bangalore", status:"active", joined:"2022-01-10" },
  { id:"P003", name:"Dev Krishnan",   role:"Propulsion Lead",        team:"engineering", dept:"Engineering",    loc:"Bangalore", status:"active", joined:"2021-06-15" },
  { id:"P004", name:"Priya Nair",     role:"Structures Eng.",        team:"engineering", dept:"Engineering",    loc:"Hyderabad", status:"active", joined:"2023-02-20" },
  { id:"P005", name:"Rohan Joshi",    role:"Thermal Eng.",           team:"engineering", dept:"Engineering",    loc:"Bangalore", status:"active", joined:"2022-09-01" },
  { id:"P006", name:"Aditi Singh",    role:"Procurement Manager",    team:"procurement", dept:"Supply Chain",   loc:"Mumbai",    status:"active", joined:"2020-11-05" },
  { id:"P007", name:"Vikram Sethi",   role:"Supply Chain Analyst",   team:"procurement", dept:"Supply Chain",   loc:"Mumbai",    status:"active", joined:"2023-05-12" },
  { id:"P008", name:"Meera Patel",    role:"Supplier Quality Eng.",  team:"procurement", dept:"Supply Chain",   loc:"Mumbai",    status:"active", joined:"2022-07-18" },
  { id:"P009", name:"Suresh Kumar",   role:"Plant Operations Lead",  team:"manufacturing",dept:"Manufacturing", loc:"Hyderabad", status:"active", joined:"2019-04-01" },
  { id:"P010", name:"Lakshmi Das",    role:"Assembly Technician",    team:"manufacturing",dept:"Manufacturing", loc:"Hyderabad", status:"active", joined:"2021-08-10" },
  { id:"P011", name:"Kiran Reddy",    role:"Quality Inspector",      team:"manufacturing",dept:"Manufacturing", loc:"Hyderabad", status:"active", joined:"2022-03-22" },
  { id:"P012", name:"Farhan Ali",     role:"CAD Engineer",           team:"engineering", dept:"Engineering",    loc:"Bangalore", status:"active", joined:"2023-01-09" },
];

// ── Documents ──
const DOCS = [
  { id:"DOC-001", name:"OAM System Requirements",      rev:"C", type:"SRS",    status:"approved", owner:"Sana Raza",   updated:"2026-03-10" },
  { id:"DOC-002", name:"OAM CDR Package",              rev:"A", type:"CDR",    status:"review",   owner:"Arjun Mehta", updated:"2026-04-20" },
  { id:"DOC-003", name:"Propulsion ICD",               rev:"B", type:"ICD",    status:"approved", owner:"Dev Krishnan",updated:"2026-03-28" },
  { id:"DOC-004", name:"Fuel Tank Structural Report",  rev:"A", type:"REPORT", status:"draft",    owner:"Priya Nair",  updated:"2026-04-15" },
  { id:"DOC-005", name:"Thermal Control Plan",         rev:"A", type:"PLAN",   status:"approved", owner:"Rohan Joshi", updated:"2026-02-14" },
  { id:"DOC-006", name:"Manufacturing Plan — MFG-001", rev:"B", type:"MFG",    status:"approved", owner:"Suresh Kumar",updated:"2026-04-01" },
  { id:"DOC-007", name:"Supplier Qualification Matrix",rev:"A", type:"QUAL",   status:"review",   owner:"Aditi Singh", updated:"2026-04-18" },
  { id:"DOC-008", name:"FAT Procedure OAM-FAT-01",     rev:"A", type:"TEST",   status:"draft",    owner:"Kiran Reddy", updated:"2026-04-22" },
  { id:"DOC-009", name:"Plumbing Schematic P&ID",      rev:"C", type:"DWG",    status:"approved", owner:"Dev Krishnan",updated:"2026-03-05" },
  { id:"DOC-010", name:"Risk Register",                rev:"F", type:"RISK",   status:"live",     owner:"Arjun Mehta", updated:"2026-04-24" },
];

// ── Maintenance ──
const MAINTENANCE = [
  { id:"EQ-01", name:"CMM · Coordinate Measuring Machine", location:"Metrology Lab",    lastService:"2026-02-10", nextService:"2026-08-10", status:"ok",   owner:"Kiran Reddy"  },
  { id:"EQ-02", name:"Hydraulic Press 50T",                location:"Fab Shop A",        lastService:"2026-01-20", nextService:"2026-07-20", status:"ok",   owner:"Suresh Kumar" },
  { id:"EQ-03", name:"Torque Station TRQ-4",               location:"Assembly Cell-02",  lastService:"2026-03-02", nextService:"2026-06-02", status:"warn", owner:"Lakshmi Das"  },
  { id:"EQ-04", name:"Vibration Test Rig VT-2000",         location:"Test Bay 1",        lastService:"2025-11-15", nextService:"2026-05-15", status:"warn", owner:"Kiran Reddy"  },
  { id:"EQ-05", name:"Leak Test Console LT-03",            location:"Test Bay 2",        lastService:"2026-04-01", nextService:"2026-10-01", status:"ok",   owner:"Suresh Kumar" },
  { id:"EQ-06", name:"CNC Mill DMG Mori NVX 5100",        location:"Fab Shop B",        lastService:"2026-03-22", nextService:"2026-09-22", status:"ok",   owner:"Suresh Kumar" },
  { id:"EQ-07", name:"TVAC Chamber TC-400",                location:"Environmental Lab", lastService:"2025-12-01", nextService:"2026-06-01", status:"err",  owner:"Kiran Reddy"  },
  { id:"EQ-08", name:"3D Printer · Markforged X7",        location:"Rapid Proto Lab",   lastService:"2026-04-10", nextService:"2026-07-10", status:"ok",   owner:"Dev Krishnan" },
];

// ── Vertical client configs ──
const VERTICALS = {
  space: {
    id: "space", label: "Space & Satellite", accent: "blue",
    icon: "Satellite", color: "var(--cool)",
    tagline: "Zero-defect · qualification-driven · mission-critical",
    examples: "Small sats · Launch vehicles · Deep space probes",
    chars: ["Qualification stage gating (SRR→PDR→CDR→FAB→ASSY→I&T→TVAC→ACC)","Mass & power budget in BOM","ITAR / export-control configuration","Flight heritage & configuration management","Clean-room + calibration tracking"],
    defaultModules: ["ebom","mbom","workflows","eco","plc","gantt","analytics","connectors","docs","people","auditor"],
    bomExtra: ["Mass (g)","Power (W)","Heritage","Qual Status"],
    lifecycleStages: ["SRR","PDR","CDR","FAB","ASSY","I&T","TVAC","ACC","LAUNCH"],
    erps: ["Odoo","NetSuite","Custom","SAP"],
    cads: ["CATIA V5","Siemens NX","SolidWorks","Creo"],
    subVerticals: [
      { id:"leo-smallsat", label:"LEO smallsat constellation", desc:"3U–24U platforms, batch builds, ~6-month design cycles" },
      { id:"deep-space",   label:"Deep-space / interplanetary", desc:"single-flight unit, 5-10y cycles, radiation-hardened heritage" },
      { id:"launch-veh",   label:"Launch vehicle / propulsion", desc:"propellant systems, pyrotechnics, range-safety compliance" },
      { id:"cubesat",      label:"CubeSat / educational", desc:"COTS-heavy, 1U–6U form factors, university partnerships" },
      { id:"defense-payload", label:"Defense-classified payload", desc:"ITAR/EAR-controlled, SCIF-bound, NIST 800-171 + CMMC" },
    ],
    personaPresets: ["Mission Systems Eng","Propulsion","Thermal","Avionics/GNC","Structures","Q&MA","Program/CDR Lead","Cleanroom Tech"],
    regulations: ["ITAR","EAR","AS9100","NASA-STD-8739","ECSS-Q-ST-70","ITU coordination","FCC Part 25"],
    erpFlavors: ["one-off custom","commercial COTS","NASA APPEL/PDM","none yet"],
    steps: [
      { id:1, label:"Mission",       title:"Mission Profile",           sub:"Name, orbit, mass envelope, customer, launch target" },
      { id:2, label:"Systems",       title:"Spacecraft Systems",        sub:"Subsystem breakdown & responsible engineers" },
      { id:3, label:"BOM Config",    title:"BOM Configuration",         sub:"Mass/power budgets, part classes, heritage strategy" },
      { id:4, label:"Qualification", title:"Qualification Scheme",      sub:"Milestone gates, environmental test sequence" },
      { id:5, label:"Compliance",    title:"Compliance & Operations",   sub:"ITAR, EAR, cleanroom class, documentation standard" },
      { id:6, label:"Modules",       title:"Activate Modules",          sub:"Choose which Forge modules to enable" },
    ],
  },
  mittelstand: {
    id: "mittelstand", label: "Mittelstand Manufacturing", accent: "orange",
    icon: "Factory", color: "var(--accent)",
    tagline: "ISO-certified · precision engineering · ERP-driven",
    examples: "Machine tools · Automotive parts · Industrial equipment",
    chars: ["ISO 9001 / IATF 16949 quality workflows","Work instruction & NCR/CAPA management","Deep ERP integration (SAP B1 · proALPHA · Infor)","CNC machine maintenance & calibration","Cost & lead-time tracking in BOM"],
    defaultModules: ["ebom","mbom","workflows","eco","erp","docs","maintenance","people","analytics","line","traveler"],
    bomExtra: ["Tolerance","Cost (€)","Lead Time","Supplier"],
    lifecycleStages: ["Concept","Design","Prototype","Validation","Production","EOL"],
    erps: ["SAP B1","proALPHA","Infor LN","Dynamics 365"],
    cads: ["SOLIDWORKS","CATIA V5","Siemens NX","Inventor"],
    subVerticals: [
      { id:"machine-tool",     label:"Machine tool builder", desc:"5-axis CNC, EDM, grinding centers; long-lead castings + precision optics" },
      { id:"auto-tier1",       label:"Automotive tier-1 supplier", desc:"IATF 16949, PPAP, FMEA, runs measured in 100k+ pieces" },
      { id:"industrial-electromech", label:"Industrial electromechanical", desc:"Pumps, motors, gearboxes; mid-volume mixed-mode production" },
      { id:"medtech-device",   label:"Med-device contract mfg.", desc:"ISO 13485 + FDA 21 CFR 820, DHR/DHF traceability" },
      { id:"agri-machinery",   label:"Agricultural machinery", desc:"Heavy welded fabrications, EU-Stage-V emissions, dealer aftermarket" },
    ],
    personaPresets: ["Konstruktionsleitung","Fertigungsplanung","Werkleiter","QM-Leitung","SCM/Einkauf","IT/ERP","Servicetechniker"],
    regulations: ["ISO 9001","IATF 16949","ISO 13485","ISO 14001","CE-MD","RoHS","REACH"],
    erpFlavors: ["SAP S/4 (full)","SAP B1 (mid)","proALPHA","Infor LN","Dynamics 365","custom in-house"],
    steps: [
      { id:1, label:"Company",       title:"Company Identity",          sub:"Name, size, industry segment, quality certifications" },
      { id:2, label:"Portfolio",     title:"Product Portfolio",         sub:"Product families, part numbering scheme, BOM import" },
      { id:3, label:"Manufacturing", title:"Manufacturing Setup",       sub:"Production type, assembly cells, shift patterns" },
      { id:4, label:"ERP & CAD",     title:"ERP & CAD Integration",     sub:"Connect your ERP and CAD/PDM systems" },
      { id:5, label:"Quality",       title:"Quality & Compliance",      sub:"NCR/CAPA workflow, inspection plans, customer reqs." },
      { id:6, label:"Modules",       title:"Activate Modules",          sub:"Choose which Forge modules to enable" },
    ],
  },
  pump: {
    id: "pump", label: "Process Equipment Mfg.", accent: "green",
    icon: "Bolt", color: "var(--ok)",
    tagline: "Configured products · installed base · aftermarket service",
    examples: "Submersible pumps · Compressors · Heat exchangers",
    chars: ["Product configurator (variants, options, rules)","Installed base & serial number tracking","Aftermarket spare-parts catalog & service intervals","ATEX / API 610 / NSF certification management","Field service scheduling & warranty tracking"],
    defaultModules: ["ebom","mbom","workflows","eco","plc","docs","maintenance","people","analytics","erp","traveler","line"],
    bomExtra: ["Pressure Rating","Material Grade","Cert","Spare?"],
    lifecycleStages: ["Concept","Design","Proto","Field Test","Production","Aftermarket"],
    erps: ["SAP S/4","Dynamics 365","Oracle","IFS"],
    cads: ["SolidWorks","Inventor","Creo","AutoCAD"],
    subVerticals: [
      { id:"submersible-pump", label:"Submersible / slurry pumps", desc:"ATEX-rated wet-pit and dewatering; high-chrome wet ends, mechanical seals" },
      { id:"centrifugal-pump", label:"API-610 centrifugal pumps", desc:"Refinery + petrochem service; OH/BB types, API 682 sealing systems" },
      { id:"compressor",       label:"Industrial compressors", desc:"Reciprocating + screw; ATEX-rated, oil-flooded vs oil-free variants" },
      { id:"heat-exchanger",   label:"Shell-and-tube heat exchanger", desc:"TEMA + ASME-VIII, custom tube-bundle config, hydrotest evidence" },
      { id:"valves-actuators", label:"Industrial valves + actuators", desc:"API 6D / 600, fugitive-emissions ISO 15848, SIL-rated assemblies" },
    ],
    personaPresets: ["Application Engineer","Mechanical Designer","Hydraulic Designer","Mfg Engineer","Field Service","Aftermarket Sales","Quality / NCR Lead"],
    regulations: ["API 610","API 682","ATEX","IECEx","ASME VIII","ISO 15848","NSF/ANSI 61","CE-PED"],
    erpFlavors: ["SAP S/4 + CPQ","Oracle Fusion","IFS Cloud","Dynamics 365","Epicor Kinetic"],
    steps: [
      { id:1, label:"Business",      title:"Business Profile",          sub:"Market segments, product families, OEM vs aftermarket" },
      { id:2, label:"Configurator",  title:"Product Configurator",      sub:"Base models, option codes, configuration rules" },
      { id:3, label:"Installed Base",title:"Installed Base",            sub:"Customer records, serial numbers, site data" },
      { id:4, label:"Aftermarket",   title:"Aftermarket Catalog",       sub:"Spare-parts strategy, service intervals, warranty" },
      { id:5, label:"Certs",         title:"Materials & Certifications",sub:"Material grades, pressure ratings, ATEX/API/NSF" },
      { id:6, label:"Modules",       title:"Activate Modules",          sub:"Choose which Forge modules to enable" },
    ],
  },
  pyrolysis: {
    id: "pyrolysis", label: "Pyrolysis / Biochar Line", accent: "amber",
    icon: "Factory", color: "oklch(0.59 0.12 95)",
    tagline: "ATEX-rated thermal trains · BIS-graded char · 90-day EPCC clock",
    examples: "Feedstock prep · pyrolysis reactor · FES baghouse · char cooler · packaging",
    chars: [
      "ATEX-rated equipment across the hot zone — reactor, char cooler, FES ducting",
      "FES + duct spools sized to customer furnace layout, GA-frozen before fab",
      "Engineered carbon train with BIS-graded biochar and IS conformance for char product",
      "EPCC 90-day W1–W12 gate plan from kickoff to cold commissioning",
      "Daily machine task zoom: feed moisture, reactor temp profile, residence time, char fixed carbon %",
    ],
    defaultModules: ["ebom","mbom","workflows","eco","plc","gantt","traveler","line","auditor","docs","maintenance"],
    bomExtra: ["ATEX Zone","Material Grade","BIS Cert","Lead Time"],
    lifecycleStages: ["Design Basis","P&ID Freeze","GA Freeze","Long-Lead PO","Fabrication","FAT","Site Erection","Cold Commissioning","Hot Commissioning"],
    erps: ["SAP S/4","Dynamics 365","Odoo","custom"],
    cads: ["SOLIDWORKS","Inventor","AutoCAD Plant 3D","Creo"],
    subVerticals: [
      { id:"feedstock-prep",     label:"Feedstock prep + drying", desc:"Biomass receiving, sizing, drying to target moisture envelope" },
      { id:"pyrolysis-reactor",  label:"Pyrolysis reactor skid", desc:"CFB/auger/rotary kiln configurations · ATEX hot zone, residence-time control" },
      { id:"fes-baghouse",       label:"FES + duct spools", desc:"Flue-gas extraction baghouse + ducting · PTFE membrane bags, fan-curve sized" },
      { id:"char-cooler-pack",   label:"Char cooler + packaging", desc:"Engineered carbon cooling, screening, BIS-graded biochar bagging line" },
      { id:"turnkey-line",       label:"Turnkey biochar line", desc:"Full EPCC: feedstock → reactor → FES → cooler → packaging on one 90-day clock" },
    ],
    personaPresets: ["Process Engineer","Mechanical Designer","Instrumentation/PLC","Mfg Engineer","Site Erection Lead","QA / BIS Lab","Procurement","Commissioning Lead"],
    regulations: ["ATEX","IECEx","BIS biochar grade","IS engineered carbon","ASME VIII","CPCB CTE/CTO","APPCB","CE-PED"],
    erpFlavors: ["SAP S/4","Dynamics 365","Odoo","custom in-house","none yet"],
    steps: [
      { id:1, label:"Program",       title:"Program Profile",           sub:"Customer, plant capacity (t/yr), feedstock, EPCC scope" },
      { id:2, label:"Process Train", title:"Process Train",             sub:"Feedstock prep → reactor → FES → char cooler → packaging" },
      { id:3, label:"Integrations",  title:"SCADA · ERP · LIMS",        sub:"Reactor SCADA tags, ERP batch lots, LIMS char QC" },
      { id:4, label:"Gate Plan",     title:"90-day W1–W12 Gate Plan",   sub:"Design basis → P&ID → GA → long-lead → fab → FAT → erection" },
      { id:5, label:"Compliance",    title:"ATEX · BIS · CPCB",         sub:"ATEX zoning, BIS lab certs, IS engineered carbon, CPCB consents" },
      { id:6, label:"Modules",       title:"Activate Modules",          sub:"Choose which Forge modules to enable" },
    ],
  },
};

const MODULE_CATALOG = [
  { id:"ebom",        name:"E-BOM",              icon:"Tree",      group:"Engineering",   desc:"Engineering BOM with revision control and where-used" },
  { id:"mbom",        name:"M-BOM & Routing",    icon:"Factory",   group:"Engineering",   desc:"Manufacturing BOM with assembly stations, work instructions" },
  { id:"workflows",   name:"Workflow Hub",        icon:"Flow",      group:"Operations",    desc:"Agentic task coordination across engineering, procurement & manufacturing" },
  { id:"eco",         name:"Change Orders",       icon:"Git",       group:"Operations",    desc:"ECO/ECR with multi-stage approval workflows" },
  { id:"plc",         name:"Product Lifecycle",   icon:"Satellite", group:"Operations",    desc:"Qualification stage tracking with D/M/T progress bars" },
  { id:"gantt",       name:"Schedule · Gantt",    icon:"Calendar",  group:"Operations",    desc:"Cross-team programme schedule with milestone tracking" },
  { id:"analytics",   name:"Analytics",           icon:"BarChart",  group:"Operations",    desc:"BI dashboards, KPIs, and programme health metrics" },
  { id:"connectors",  name:"Connectors",          icon:"Link",      group:"Integrations",  desc:"Trigger workflows in CAD, CAE, ERP, MES, SCM systems" },
  { id:"erp",         name:"ERP Release Queue",   icon:"Plug",      group:"Integrations",  desc:"Item-master sync and release queue to ERP" },
  { id:"integrations",name:"Integration Status",  icon:"DB",        group:"Integrations",  desc:"Connector health, field mapping, sync events" },
  { id:"people",      name:"People & HR",         icon:"Person",    group:"Organisation",  desc:"Team roster, org chart, capacity planning" },
  { id:"docs",        name:"Documents",           icon:"File",      group:"Organisation",  desc:"Document registry with version control and approvals" },
  { id:"maintenance", name:"Maintenance",         icon:"Wrench",    group:"Organisation",  desc:"Equipment service schedules and calibration tracking" },
];

// ── Integrations · per-tenant adapter sets ──
// Each tenant gets a stack reflecting its real industry: Tritan (pump CDMO),
// Aetherion (microsat, ITAR/AS9100), Mittelstand (German Mittelstand mill).
const INTEGRATIONS_BY_TENANT = {
  tritan: [
    { id:"INT-SW",     name:"SolidWorks · CAD",        type:"CAD",  status:"connected", lastSync:"3h ago",  records:"1,284 pts", latency:"—"     },
    { id:"INT-TALLY",  name:"Tally Prime · ERP",       type:"ERP",  status:"connected", lastSync:"2m ago",  records:"14,802",    latency:"120ms" },
    { id:"INT-FORGE",  name:"Forge MES",                type:"MES",  status:"connected", lastSync:"15m ago", records:"842",       latency:"88ms"  },
    { id:"INT-LIMS",   name:"LIMS · Quality lab",      type:"QMS",  status:"connected", lastSync:"1h ago",  records:"310",       latency:"95ms"  },
    { id:"INT-VQP",    name:"VQP 2.0 · Supplier portal", type:"SCM",status:"connected", lastSync:"4m ago",  records:"28 vendors",latency:"60ms"  },
  ],
  aetherion: [
    { id:"INT-NX",      name:"Siemens NX · CAD",       type:"CAD",   status:"connected", lastSync:"3h ago",  records:"1,820 prt", latency:"—"     },
    { id:"INT-TEAMCNT", name:"Teamcenter · PLM",       type:"PLM",   status:"connected", lastSync:"6m ago",  records:"38,420",    latency:"180ms" },
    { id:"INT-NASA",    name:"NASA NDE feed",           type:"QMS",   status:"connected", lastSync:"24h ago", records:"126 tests", latency:"—"     },
    { id:"INT-AS9100",  name:"AS9100 audit log",       type:"QMS",   status:"connected", lastSync:"1h ago",  records:"212 events",latency:"—"     },
    { id:"INT-ITAR",    name:"ITAR registry",           type:"GOV",   status:"warn",      lastSync:"4h ago",  records:"export ctrl",latency:"timeout"},
  ],
  mittelstand: [
    { id:"INT-HEIDEN", name:"Heidenhain TNC",          type:"CNC",   status:"connected", lastSync:"4m ago",  records:"6 mills",   latency:"—"     },
    { id:"INT-SAPB1",  name:"SAP Business One",        type:"ERP",   status:"connected", lastSync:"2m ago",  records:"4,210",     latency:"120ms" },
    { id:"INT-PROALPHA",name:"proALPHA",                type:"ERP",   status:"connected", lastSync:"9m ago",  records:"2,801",     latency:"160ms" },
    { id:"INT-ZEISS",  name:"Zeiss CMM",                type:"QMS",   status:"connected", lastSync:"1h ago",  records:"308 FAI",   latency:"—"     },
    { id:"INT-VDA",    name:"VDA Band 6.3 · audit",   type:"QMS",   status:"warn",      lastSync:"6h ago",  records:"—",         latency:"timeout"},
  ],
};

function getIntegrationsFor(tenantId) {
  if (!tenantId) return INTEGRATIONS_BY_TENANT.tritan;
  if (tenantId === "htu220") tenantId = "aetherion";
  return INTEGRATIONS_BY_TENANT[tenantId] || INTEGRATIONS_BY_TENANT.tritan;
}

// Backward-compatible export: legacy callers reading INTEGRATIONS still see a
// default set (Tritan), but new code should call getIntegrationsFor(tenantId).
const INTEGRATIONS = INTEGRATIONS_BY_TENANT.tritan;

// Build nested tree from OAM_BOM_FLAT for use in E-BOM screen
(function() {
  const cm = {};
  OAM_BOM_FLAT.forEach(x => { if (x.p) { (cm[x.p] = cm[x.p] || []).push(x); } });
  function mkNode(item) {
    const kids = (cm[item.num] || []).map(mkNode);
    return {
      id: item.num,
      pn: "OAM-" + item.num.replace(/\./g, "-"),
      name: item.name,
      type: kids.length ? "ASM" : "PRT",
      qty: item.qty, rev: "A",
      mat: item.m === 100 && item.d < 50 ? "COTS" : item.d >= 80 ? "SPEC" : "—",
      source: item.m > item.d ? "BUY" : "MAKE",
      status: item.d >= 80 ? "released" : item.d > 0 ? "in-work" : "not-started",
      d: item.d, m: item.m, t: item.t,
      children: kids,
    };
  }
  const topItems = (() => { const out = []; for (const x of OAM_BOM_FLAT) { if (!x.p) out.push(mkNode(x)); } return out; })();
  window.OAM_EBOM_TREE = {
    id: "OAM", pn: "OAM-00-00", name: "OAM · Orbital Adjustment Module",
    type: "ASM", qty: 1, rev: "A", mat: "—", source: "DESIGN",
    status: "in-work", d: 41, m: 52, t: 0, children: topItems,
  };
})();

Object.assign(window, { PROGRAM, KPIS, NAV, EBOM, MBOM, TRANSFORMS, STUDIES, ECOS, ERP_QUEUE, APPROVALS, ONBOARD, PERSONAS, OAM_BOM_FLAT, GANTT_TASKS, PEOPLE, DOCS, MAINTENANCE, INTEGRATIONS, INTEGRATIONS_BY_TENANT, getIntegrationsFor, VERTICALS, MODULE_CATALOG });
