// MATTER-LEVEL WAR ROOM v2 — Seed data for 20 opportunities (MW1–MW20)
// Organized into 5 hubs: Motions & Discovery, Depositions & Experts,
// Trial Prep, Parallel Risk, Decision Economics
(function () {
  const today = new Date('2026-04-22');
  const addDays = (d, n) => { const x = new Date(d); x.setDate(x.getDate()+n); return x.toISOString().slice(0,10); };

  // ── MW1. Motion Strategy Orchestrator ──────────────────────────────
  const motions = [
    { id: 'MO-001', title: 'Motion to Compel Related-Party Discovery', type: 'Discovery', status: 'drafting', priority: 'high',
      filingTarget: addDays(today, 7), hearingTarget: addDays(today, 35), judge: 'Reynolds',
      winPct: 72, strategicValue: 'High — unlocks Apex transaction emails', costUsd: 18500, leadAtty: 'Mitchell',
      basis: ['FRCP 26(b)(1)', 'FRCP 37(a)'], dependencies: ['Privilege log challenge'] },
    { id: 'MO-002', title: 'Motion for Partial Summary Judgment — Breach of Contract', type: 'Dispositive', status: 'research', priority: 'critical',
      filingTarget: addDays(today, 45), hearingTarget: addDays(today, 90), judge: 'Reynolds',
      winPct: 48, strategicValue: 'Leverage — forces settlement posture', costUsd: 82000, leadAtty: 'Park',
      basis: ['Delaware §141(e)', 'MSA §4.2'], dependencies: ['Harrington admissions', 'Apex documents'] },
    { id: 'MO-003', title: 'Motion in Limine — Exclude Defense Valuation Expert', type: 'Evidentiary', status: 'queued', priority: 'high',
      filingTarget: addDays(today, 120), hearingTarget: addDays(today, 135), judge: 'Reynolds',
      winPct: 61, strategicValue: 'Critical — removes primary damages rebuttal', costUsd: 24500, leadAtty: 'Chen',
      basis: ['Daubert', 'FRE 702'], dependencies: ['Vance deposition'] },
    { id: 'MO-004', title: 'Motion to Strike Affirmative Defense (Business Judgment)', type: 'Pleading', status: 'filed', priority: 'medium',
      filingTarget: addDays(today, -10), hearingTarget: addDays(today, 20), judge: 'Reynolds',
      winPct: 35, strategicValue: 'Narrow defenses at trial', costUsd: 12000, leadAtty: 'Park',
      basis: ['FRCP 12(f)', 'Self-dealing exception'], dependencies: [] },
    { id: 'MO-005', title: 'Motion for Protective Order — Confidential Financials', type: 'Discovery', status: 'drafting', priority: 'medium',
      filingTarget: addDays(today, 14), hearingTarget: addDays(today, 40), judge: 'Reynolds',
      winPct: 88, strategicValue: 'Routine — protects client data', costUsd: 8500, leadAtty: 'Mitchell',
      basis: ['FRCP 26(c)'], dependencies: [] },
  ];

  // ── MW2. Motion in Limine Battleground ─────────────────────────────
  const motionsInLimine = [
    { id: 'MIL-01', issue: 'Exclude Vance valuation opinions', filedBy: 'Plaintiff', grantOdds: 61, impact: 'high',
      rationale: 'Methodology inconsistent with prior testimony in 3 cases; unreliable under Daubert.',
      caseStrengthDelta: +8, evShift: 1_800_000, supportingExhibits: ['EX-H12', 'EX-V03'] },
    { id: 'MIL-02', issue: 'Exclude Redstone prior unrelated investment losses', filedBy: 'Defendant', grantOdds: 72, impact: 'medium',
      rationale: 'FRE 403 — prejudice outweighs probative value.',
      caseStrengthDelta: -4, evShift: -600_000, supportingExhibits: ['EX-R07'] },
    { id: 'MIL-03', issue: 'Admit Harrington prior securities settlement', filedBy: 'Plaintiff', grantOdds: 28, impact: 'high',
      rationale: 'FRE 404(b) — pattern of misrepresentation.',
      caseStrengthDelta: +12, evShift: 3_200_000, supportingExhibits: ['EX-SEC-19'] },
    { id: 'MIL-04', issue: 'Exclude settlement negotiations evidence', filedBy: 'Defendant', grantOdds: 94, impact: 'low',
      rationale: 'FRE 408.',
      caseStrengthDelta: -1, evShift: 0, supportingExhibits: [] },
    { id: 'MIL-05', issue: 'Admit CEO LinkedIn posts about Q3 performance', filedBy: 'Plaintiff', grantOdds: 55, impact: 'medium',
      rationale: 'Party admission; FRE 801(d)(2).',
      caseStrengthDelta: +5, evShift: 900_000, supportingExhibits: ['EX-LI-04'] },
    { id: 'MIL-06', issue: 'Exclude hearsay statements from departed CFO', filedBy: 'Defendant', grantOdds: 40, impact: 'high',
      rationale: 'Hearsay within hearsay; no exception applies.',
      caseStrengthDelta: -9, evShift: -2_100_000, supportingExhibits: ['EX-OS-11'] },
    { id: 'MIL-07', issue: 'Admit market-moving news article on Meridian', filedBy: 'Plaintiff', grantOdds: 22, impact: 'low',
      rationale: 'FRE 807 residual; corroborates damages.',
      caseStrengthDelta: +2, evShift: 400_000, supportingExhibits: ['EX-NEWS-02'] },
  ];

  // ── MW3. Discovery Workflow & Burden Map ───────────────────────────
  const discoveryRequests = [
    { id: 'RFP-12', type: 'RFP', served: addDays(today,-45), due: addDays(today,-15), status: 'overdue', docsProduced: 1240, docsExpected: 3800, completenessPct: 33, objections: 6, metAndConferHeld: true },
    { id: 'RFP-15', type: 'RFP', served: addDays(today,-30), due: addDays(today,0),   status: 'due-today', docsProduced: 420,  docsExpected: 900,  completenessPct: 47, objections: 2, metAndConferHeld: false },
    { id: 'RFP-18', type: 'RFP', served: addDays(today,-20), due: addDays(today,10),  status: 'on-track', docsProduced: 180,  docsExpected: 450,  completenessPct: 40, objections: 1, metAndConferHeld: false },
    { id: 'INT-04', type: 'Interrogatories', served: addDays(today,-40), due: addDays(today,-10), status: 'overdue', docsProduced: 0, docsExpected: 1, completenessPct: 0, objections: 4, metAndConferHeld: true },
    { id: 'RFA-02', type: 'RFA', served: addDays(today,-25), due: addDays(today,5),   status: 'on-track', docsProduced: 0, docsExpected: 1, completenessPct: 0, objections: 0, metAndConferHeld: false },
    { id: 'RFP-20', type: 'RFP', served: addDays(today,-10), due: addDays(today,20),  status: 'on-track', docsProduced: 0, docsExpected: 250, completenessPct: 0, objections: 0, metAndConferHeld: false },
  ];

  // ── MW4. eDiscovery / TAR Performance ──────────────────────────────
  const tar = {
    totalDocs: 842_300, reviewed: 631_000, relevant: 48_400, privileged: 3_210, hot: 412,
    richnessPct: 7.7, precisionPct: 84.2, recallPct: 76.8, f1: 0.803,
    costToDate: 612_400, costProjected: 843_000, costPerGb: 2_850,
    avgReviewerCost: 62, avgDocsPerHour: 48,
    rounds: [
      { round: 1, trained: 2000, precision: 62, recall: 51 },
      { round: 2, trained: 5000, precision: 74, recall: 63 },
      { round: 3, trained: 9500, precision: 81, recall: 71 },
      { round: 4, trained: 14_200, precision: 84, recall: 77 },
    ],
  };

  // ── MW5. Privilege & Waiver Exposure ───────────────────────────────
  const privilegeLog = [
    { id: 'PR-112', custodian: 'Harrington, J.', date: '2023-07-14', type: 'email', basis: 'AC Privilege', waiverRisk: 0.62, reason: 'Included outside PR firm on chain', disputed: true },
    { id: 'PR-118', custodian: 'Chen, R.', date: '2023-08-22', type: 'memo', basis: 'Work Product', waiverRisk: 0.28, reason: 'Sent to board, not atty direction', disputed: true },
    { id: 'PR-124', custodian: 'Harrington, J.', date: '2023-09-03', type: 'email', basis: 'AC Privilege', waiverRisk: 0.81, reason: 'Business advice, not legal', disputed: true },
    { id: 'PR-131', custodian: 'Chen, R.', date: '2023-10-11', type: 'draft-contract', basis: 'Work Product', waiverRisk: 0.15, reason: 'Core atty work product', disputed: false },
    { id: 'PR-139', custodian: 'Chen, R.', date: '2023-11-02', type: 'email', basis: 'Common Interest', waiverRisk: 0.44, reason: 'No formal JDA in place', disputed: true },
    { id: 'PR-147', custodian: 'Osei, K.', date: '2024-01-18', type: 'email', basis: 'AC Privilege', waiverRisk: 0.70, reason: 'Post-employment communication', disputed: true },
  ];

  // ── MW6. Deposition Strategy Board ─────────────────────────────────
  const depositions = [
    { id: 'DEP-01', deponent: 'Harrington, J.', role: 'Defendant CEO', status: 'complete', scheduled: '2025-11-14', duration: 7, pages: 412,
      goals: ['Lock in Apex timeline', 'Establish scienter', 'Impeach with emails'],
      adminsScored: 8, goalsHit: 3, pivotalExchanges: [
        { page: 87, summary: 'Admitted Apex incorporated 6 days before first transfer', impact: 9 },
        { page: 92, summary: 'Acknowledged no board vote on related-party deals', impact: 8 },
        { page: 148, summary: 'Evasive on email chain Bates MH-0012440', impact: 6 },
      ] },
    { id: 'DEP-02', deponent: 'Chen, R.', role: 'Defendant GC', status: 'scheduled', scheduled: '2026-05-08', duration: 5, pages: 0,
      goals: ['Probe privilege log', 'Expose knowledge of Apex', 'Board meeting advice'], adminsScored: 0, goalsHit: 0, pivotalExchanges: [] },
    { id: 'DEP-03', deponent: 'Osei, K.', role: 'Former CFO', status: 'complete', scheduled: '2025-12-04', duration: 4, pages: 218,
      goals: ['Financial reporting practices', 'Directive from CEO', 'Reason for departure'],
      adminsScored: 5, goalsHit: 2, pivotalExchanges: [
        { page: 94, summary: 'Confirmed CEO directed revenue reclassification', impact: 8 },
      ] },
    { id: 'DEP-04', deponent: 'Vance, T.', role: 'Defense Expert', status: 'scheduled', scheduled: '2026-06-12', duration: 6, pages: 0,
      goals: ['Daubert ammunition', 'Methodology inconsistency', 'Fee bias'], adminsScored: 0, goalsHit: 0, pivotalExchanges: [] },
    { id: 'DEP-05', deponent: 'Redstone, D.', role: 'Plaintiff CEO', status: 'defended', scheduled: '2025-10-22', duration: 6, pages: 378,
      goals: ['Defend — minimize damage'], adminsScored: 2, goalsHit: 6, pivotalExchanges: [] },
  ];

  // ── MW7. Expert Witness Command Center ─────────────────────────────
  const experts = [
    { id: 'EX-01', name: 'Dr. Sarah Mitchell', side: 'plaintiff', domain: 'Damages — Lost Profits', retainer: 85_000, hourlyRate: 875, hoursBilled: 142,
      reportStatus: 'disclosed', daubertRisk: 0.12, priorCases: 47, priorDaubertExclusions: 1,
      strengthScore: 92, opposingExpert: 'EX-03', reportDueDates: { opening: '2026-03-01', rebuttal: '2026-05-15' } },
    { id: 'EX-02', name: 'Prof. Alan Kessler', side: 'plaintiff', domain: 'Corporate Governance', retainer: 60_000, hourlyRate: 650, hoursBilled: 88,
      reportStatus: 'draft', daubertRisk: 0.18, priorCases: 22, priorDaubertExclusions: 0,
      strengthScore: 84, opposingExpert: 'EX-04', reportDueDates: { opening: '2026-03-15', rebuttal: '2026-05-28' } },
    { id: 'EX-03', name: 'Thomas Vance', side: 'defense', domain: 'Valuation', retainer: 0, hourlyRate: 700, hoursBilled: 0,
      reportStatus: 'pending', daubertRisk: 0.61, priorCases: 19, priorDaubertExclusions: 4,
      strengthScore: 55, opposingExpert: 'EX-01', reportDueDates: { opening: '2026-04-15', rebuttal: '2026-06-01' } },
    { id: 'EX-04', name: 'Dr. Maya Patel', side: 'defense', domain: 'Corporate Governance', retainer: 0, hourlyRate: 0, hoursBilled: 0,
      reportStatus: 'pending', daubertRisk: 0.22, priorCases: 15, priorDaubertExclusions: 0,
      strengthScore: 78, opposingExpert: 'EX-02', reportDueDates: { opening: '2026-04-20', rebuttal: '2026-06-10' } },
  ];

  // ── MW8. Cross-Examination Playbook ────────────────────────────────
  const crossExam = [
    { id: 'CX-01', witness: 'Harrington, J.', topic: 'Apex Incorporation Timeline',
      loop: ['Incorporation date?', 'First transfer date?', 'How many days apart?', 'Did you control Apex?'],
      impeachmentAmmo: ['Depo p.87–92', 'Apex filings', 'Email MH-0012440'],
      expectedAnswer: 'Deflect; claim "coincidence"',
      controlScore: 88 },
    { id: 'CX-02', witness: 'Harrington, J.', topic: 'Board Disclosure Duty',
      loop: ['MSA §4.2 reviewed?', 'Related-party rule understood?', 'Did you disclose Apex?', 'Why not?'],
      impeachmentAmmo: ['Board minutes', 'MSA excerpt', 'Depo p.104'],
      expectedAnswer: 'Forgot / oversight defense',
      controlScore: 82 },
    { id: 'CX-03', witness: 'Chen, R.', topic: 'Privilege Log Gaps',
      loop: ['When learned of Apex?', 'Advice given?', 'Documented?', 'Why withheld?'],
      impeachmentAmmo: ['Privilege log PR-124', 'Calendar entries'],
      expectedAnswer: 'Assert privilege; judge may compel',
      controlScore: 64 },
    { id: 'CX-04', witness: 'Vance, T.', topic: 'Methodology Inconsistency',
      loop: ['Prior case methodology?', 'Method here?', 'Why different?', 'Fee arrangement?'],
      impeachmentAmmo: ['Prior Daubert orders x3', 'Engagement letter'],
      expectedAnswer: 'Rationalize methodology shift',
      controlScore: 79 },
  ];

  // ── MW9. Trial Narrative Storyboard ────────────────────────────────
  const narrative = {
    theme: 'A CEO who treated his own company as a personal piggy bank.',
    openingBeats: [
      { beat: 1, title: 'The Promise', sec: 180, anchor: 'MSA signing ceremony', exhibit: 'EX-01', strength: 92 },
      { beat: 2, title: 'The Setup', sec: 210, anchor: 'Apex incorporated 6 days early', exhibit: 'EX-APEX-01', strength: 88 },
      { beat: 3, title: 'The Diversion', sec: 240, anchor: '23 transfers, $14.2M', exhibit: 'EX-WIRE-001', strength: 94 },
      { beat: 4, title: 'The Cover-Up', sec: 180, anchor: 'No board disclosure', exhibit: 'EX-BOARD-04', strength: 86 },
      { beat: 5, title: 'The Reckoning', sec: 120, anchor: 'Expected verdict', exhibit: 'EX-DAMAGES-MITCHELL', strength: 90 },
    ],
    closingBeats: [
      { beat: 1, title: 'Recall the Promise', sec: 120, strength: 85 },
      { beat: 2, title: 'Walk the Evidence', sec: 300, strength: 92 },
      { beat: 3, title: 'Address Defenses', sec: 180, strength: 78 },
      { beat: 4, title: 'The Number', sec: 120, strength: 88 },
    ],
    demonstratives: 8, videoClips: 4, exhibits: 142,
  };

  // ── MW10. Mock Trial & Focus Group Analytics ───────────────────────
  const mockTrial = {
    panels: 3, jurorsPerPanel: 12, totalRespondents: 36,
    avgAward: 16_800_000, medianAward: 14_500_000,
    liabilityFinding: 78, // pct who found for plaintiff
    themeReactions: [
      { theme: 'Piggy bank CEO', favorability: 84, recall: 92 },
      { theme: 'Sophisticated investor', favorability: 58, recall: 71 },
      { theme: 'Technical contract breach', favorability: 42, recall: 54 },
      { theme: 'Broken trust', favorability: 79, recall: 85 },
    ],
    juroProfiles: [
      { persona: 'Retired accountant, 58 M', bias: 'Plaintiff', award: 18_500_000, notes: 'Financial literacy — followed Apex timeline easily.' },
      { persona: 'Small biz owner, 44 F', bias: 'Plaintiff', award: 21_000_000, notes: 'Strong moral framing; outraged by self-dealing.' },
      { persona: 'Tech contractor, 31 M', bias: 'Defense', award: 2_500_000, notes: 'Saw Redstone as "should have done DD".' },
      { persona: 'Public school teacher, 49 F', bias: 'Plaintiff', award: 14_200_000, notes: 'Sympathetic; moderate award instinct.' },
    ],
    keyExhibitReactions: [
      { exhibit: 'EX-APEX-01 (incorporation docs)', impact: 9.1 },
      { exhibit: 'EX-WIRE-001 (23 transfers)', impact: 9.4 },
      { exhibit: 'EX-BOARD-04 (minutes)', impact: 7.8 },
    ],
  };

  // ── MW11. Courtroom Ops & Tech Logistics ───────────────────────────
  const courtroomOps = {
    courthouse: 'U.S. District Court, D. Del., Wilmington',
    courtroom: '6B', judge: 'Reynolds',
    techSupport: { provider: 'TrialGraphix', onsiteCost: 48_000, remoteCost: 12_000 },
    evidencePresentation: 'OnCue + TrialDirector',
    checklist: [
      { item: 'Demonstratives loaded', status: 'done', owner: 'Park' },
      { item: 'Video clips time-coded', status: 'in-progress', owner: 'Tech' },
      { item: 'Exhibit binders (12 copies)', status: 'pending', owner: 'Paralegal' },
      { item: 'Witness prep rooms reserved', status: 'done', owner: 'Paralegal' },
      { item: 'Jury presentation rehearsal', status: 'pending', owner: 'Park' },
      { item: 'ELMO / doc camera tested', status: 'pending', owner: 'Tech' },
      { item: 'Backup projector', status: 'done', owner: 'Tech' },
      { item: 'Court reporter coordination', status: 'done', owner: 'Paralegal' },
      { item: 'Realtime transcript feed', status: 'in-progress', owner: 'Tech' },
      { item: 'War room at hotel (Kimpton)', status: 'done', owner: 'Admin' },
    ],
    travelCost: 68_000, hotelNights: 84, meals: 32_000,
  };

  // ── MW12. Document Authentication Tracker ──────────────────────────
  const authentications = [
    { exhibit: 'EX-WIRE-001', description: '23 wire transfer records', path: 'Business records + custodian affidavit', status: 'stipulated', risk: 'low' },
    { exhibit: 'EX-APEX-01', description: 'Apex Ventures incorporation docs', path: 'Public records', status: 'stipulated', risk: 'low' },
    { exhibit: 'EX-BOARD-04', description: 'Board minutes Oct 2023', path: 'Corporate secretary testimony', status: 'pending', risk: 'medium' },
    { exhibit: 'EX-EMAIL-MH-0012440', description: 'CEO internal email chain', path: 'Custodian + metadata', status: 'pending', risk: 'medium' },
    { exhibit: 'EX-LI-04', description: 'LinkedIn post', path: 'Screenshot + platform records', status: 'contested', risk: 'high' },
    { exhibit: 'EX-SEC-19', description: 'Prior SEC settlement', path: 'Public filing', status: 'stipulated', risk: 'low' },
    { exhibit: 'EX-OS-11', description: 'Osei resignation letter', path: 'Witness testimony', status: 'pending', risk: 'medium' },
  ];

  // ── MW13. Parallel Proceedings Tracker ─────────────────────────────
  const parallelProceedings = [
    { id: 'PP-01', forum: 'SEC Enforcement Division', status: 'active', opened: '2025-09-12', risk: 'high',
      summary: 'Formal order of investigation into Meridian disclosures. Wells notice anticipated Q3 2026.',
      impact: 'Collateral estoppel risk; parallel subpoenas overlap 70%.',
      coordination: 'Tolling agreement proposed; motion to stay civil deposition filed.' },
    { id: 'PP-02', forum: 'DOJ Criminal Division', status: 'preliminary', opened: '2026-01-18', risk: 'high',
      summary: 'Grand jury subpoenas issued for Harrington, Chen emails.',
      impact: 'Fifth Amendment invocations likely; scheduling coordination required.',
      coordination: 'Joint defense agreement declined by defendant.' },
    { id: 'PP-03', forum: 'Delaware Chancery Court', status: 'stayed', opened: '2025-06-30', risk: 'medium',
      summary: 'Derivative action by minority shareholders.',
      impact: 'Shared discovery; potential MDL consolidation.',
      coordination: 'Cross-designation of depositions agreed.' },
    { id: 'PP-04', forum: 'FINRA Arbitration', status: 'dormant', opened: '2025-04-22', risk: 'low',
      summary: 'Broker-dealer claim by downstream investor.',
      impact: 'Minor; watch for adverse findings.',
      coordination: 'None.' },
  ];

  // ── MW14. Regulatory & Congressional Risk ──────────────────────────
  const regulatory = [
    { id: 'REG-01', agency: 'SEC Division of Enforcement', stage: 'investigation', likelihood: 0.82, severity: 'material',
      penaltyRange: [8_000_000, 22_000_000], disgorgementRange: [14_000_000, 18_000_000], injunctionRisk: true,
      lastContact: '2026-04-02', nextMilestone: 'Wells response due 2026-06-15' },
    { id: 'REG-02', agency: 'DOJ Fraud Section', stage: 'preliminary', likelihood: 0.48, severity: 'severe',
      penaltyRange: [0, 0], disgorgementRange: [0, 0], injunctionRisk: false, lastContact: '2026-02-14', nextMilestone: 'Grand jury return Q4 2026' },
    { id: 'REG-03', agency: 'Delaware AG', stage: 'monitoring', likelihood: 0.22, severity: 'moderate',
      penaltyRange: [500_000, 2_000_000], disgorgementRange: [0, 0], injunctionRisk: false, lastContact: '2026-03-01', nextMilestone: 'Awaiting civil outcome' },
    { id: 'REG-04', agency: 'U.S. Senate Banking Committee', stage: 'inquiry', likelihood: 0.31, severity: 'reputational',
      penaltyRange: [0, 0], disgorgementRange: [0, 0], injunctionRisk: false, lastContact: '2026-03-28', nextMilestone: 'Staff briefing requested 2026-05-10' },
  ];

  // ── MW15. Media & Reputational War Map ─────────────────────────────
  const media = {
    sentiment: { positive: 18, neutral: 42, negative: 40 },
    reach: 12_800_000, articleCount: 47, broadcastSegments: 12, socialMentions: 38_400,
    keyOutlets: [
      { outlet: 'WSJ', tone: 'neutral', lastArticle: '2026-04-10', reach: 3_100_000 },
      { outlet: 'Bloomberg', tone: 'negative-defense', lastArticle: '2026-04-15', reach: 2_400_000 },
      { outlet: 'NYT DealBook', tone: 'negative-defense', lastArticle: '2026-04-08', reach: 1_800_000 },
      { outlet: 'FT', tone: 'neutral', lastArticle: '2026-03-22', reach: 1_200_000 },
      { outlet: 'Reuters', tone: 'neutral', lastArticle: '2026-04-18', reach: 2_600_000 },
    ],
    narrativeRisks: [
      { risk: 'Analogy to high-profile fraud cases', level: 'high', mitigation: 'Differentiation statement drafted' },
      { risk: 'Social media amplification of Apex timeline', level: 'medium', mitigation: 'Daily monitoring' },
      { risk: 'Plaintiff testimony leaks', level: 'low', mitigation: 'Protective order in place' },
    ],
    prSpendYtd: 240_000,
  };

  // ── MW16. Adverse Precedent Watcher ────────────────────────────────
  const precedents = [
    { id: 'PRE-01', caseName: 'In re Caremark Int\'l', jurisdiction: 'Del. Ch.', year: 1996, alignment: -0.35, citation: '698 A.2d 959',
      holding: 'Oversight liability requires sustained or systemic failure of board.', impactArea: 'Fiduciary duty', changeSinceFiling: 'stable' },
    { id: 'PRE-02', caseName: 'Marchand v. Barnhill', jurisdiction: 'Del.', year: 2019, alignment: +0.58, citation: '212 A.3d 805',
      holding: 'Bad-faith oversight claims survive motion to dismiss where board abandoned duty.', impactArea: 'Fiduciary duty', changeSinceFiling: 'reinforced' },
    { id: 'PRE-03', caseName: 'Halliburton II', jurisdiction: 'U.S.', year: 2014, alignment: -0.22, citation: '573 U.S. 258',
      holding: 'Price impact rebuttal available at class certification.', impactArea: 'Securities fraud', changeSinceFiling: 'stable' },
    { id: 'PRE-04', caseName: 'In re Investors Bancorp', jurisdiction: 'Del.', year: 2017, alignment: +0.40, citation: '177 A.3d 1208',
      holding: 'Self-dealing triggers entire fairness review; no business judgment deference.', impactArea: 'Self-dealing', changeSinceFiling: 'reinforced' },
    { id: 'PRE-05', caseName: 'Salman v. United States', jurisdiction: 'U.S.', year: 2016, alignment: +0.12, citation: '580 U.S. 39',
      holding: 'Personal benefit requirement met by gift to friend or relative.', impactArea: 'Insider trading', changeSinceFiling: 'stable' },
    { id: 'PRE-06', caseName: 'Tornetta v. Musk', jurisdiction: 'Del. Ch.', year: 2024, alignment: +0.28, citation: '2024 WL 343699',
      holding: 'Controller compensation subject to entire fairness even with board approval.', impactArea: 'Self-dealing', changeSinceFiling: 'emerging' },
  ];

  // ── MW17. Damages Monte Carlo Modeler ──────────────────────────────
  const damagesModel = {
    baseCase: 14_200_000,
    rangeLow: 8_500_000, rangeHigh: 28_400_000,
    components: [
      { name: 'Direct diversion (wire transfers)', central: 14_200_000, range: [12_800_000, 15_600_000], certainty: 0.92 },
      { name: 'Lost profits (projected)', central: 6_400_000, range: [2_800_000, 11_000_000], certainty: 0.58 },
      { name: 'Punitive multiplier', central: 0, range: [0, 14_200_000], certainty: 0.28 },
      { name: 'Pre-judgment interest', central: 1_850_000, range: [1_200_000, 2_400_000], certainty: 0.88 },
      { name: 'Attorney fees (if awarded)', central: 0, range: [0, 4_500_000], certainty: 0.22 },
    ],
    distributions: { p10: 6_800_000, p25: 10_400_000, p50: 14_200_000, p75: 19_800_000, p90: 25_100_000 },
    monteCarloRuns: 10_000, evUsd: 15_640_000,
  };

  // ── MW18. Settlement Decision Tree EV ──────────────────────────────
  const settlementTree = {
    nodes: [
      { id: 'root', label: 'Settle vs. Trial', kind: 'decision' },
      { id: 'settle-now', label: 'Settle now @ $9M', kind: 'outcome', ev: 9_000_000, cost: 0, prob: 1.0, parent: 'root', branch: 'settle' },
      { id: 'trial-branch', label: 'Go to trial', kind: 'chance', parent: 'root', branch: 'trial' },
      { id: 'win', label: 'Win at trial', kind: 'outcome', ev: 17_400_000, cost: 3_200_000, prob: 0.72, parent: 'trial-branch' },
      { id: 'loss', label: 'Loss at trial', kind: 'outcome', ev: 0, cost: 3_200_000, prob: 0.28, parent: 'trial-branch' },
      { id: 'appeal-branch', label: 'Appeal', kind: 'chance', parent: 'loss' },
      { id: 'appeal-win', label: 'Reversed on appeal', kind: 'outcome', ev: 14_200_000, cost: 900_000, prob: 0.22, parent: 'appeal-branch' },
      { id: 'appeal-loss', label: 'Affirmed', kind: 'outcome', ev: 0, cost: 900_000, prob: 0.78, parent: 'appeal-branch' },
    ],
    summary: { settleNowEv: 9_000_000, trialEvNet: 12_528_000 - 3_200_000, recommendation: 'Proceed to trial; trial EV exceeds settlement by $336K after costs — reevaluate if costs exceed $3.5M.' },
  };

  // ── MW19. Litigation Finance & Budget Cockpit ─────────────────────
  const budget = {
    totalAuthorized: 4_800_000, spentToDate: 2_640_000, committed: 620_000, remaining: 1_540_000,
    burnRatePerMonth: 285_000,
    phases: [
      { phase: 'Pleadings',   budget: 380_000, spent: 412_000, variance: -32_000 },
      { phase: 'Discovery',   budget: 1_400_000, spent: 1_380_000, variance: +20_000 },
      { phase: 'Experts',     budget: 800_000, spent: 520_000, variance: +280_000 },
      { phase: 'Motions',     budget: 620_000, spent: 328_000, variance: +292_000 },
      { phase: 'Trial Prep',  budget: 900_000, spent: 0, variance: +900_000 },
      { phase: 'Trial',       budget: 700_000, spent: 0, variance: +700_000 },
    ],
    litigationFinance: {
      provider: 'Burford Capital',
      facilityUsd: 6_000_000, drawnUsd: 1_800_000, undrawnUsd: 4_200_000,
      costOfCapital: 0.18, successMultiple: 2.5, waterfallRank: 1,
      triggerEvents: ['Adverse MSJ ruling', 'Settlement < $12M', 'Trial loss'],
    },
    afa: { kind: 'hybrid', capUsd: 4_800_000, successFeePct: 0.15, collar: [0.9, 1.1] },
  };

  // ── MW20. Insurance Coverage Cockpit ───────────────────────────────
  const coverage = {
    policies: [
      { id: 'POL-001', type: 'D&O Primary', carrier: 'AIG', limit: 15_000_000, retention: 500_000, attachmentPoint: 0, coverageStatus: 'accepted-with-rov', noticeDate: '2024-04-12', rovPoints: ['Fraud exclusion applicability', 'Insured vs. Insured exclusion'] },
      { id: 'POL-002', type: 'D&O Excess 1', carrier: 'Chubb', limit: 10_000_000, retention: 0, attachmentPoint: 15_000_000, coverageStatus: 'follow-form', noticeDate: '2024-04-12', rovPoints: [] },
      { id: 'POL-003', type: 'D&O Excess 2', carrier: 'XL Catlin', limit: 10_000_000, retention: 0, attachmentPoint: 25_000_000, coverageStatus: 'follow-form', noticeDate: '2024-04-12', rovPoints: [] },
      { id: 'POL-004', type: 'E&O', carrier: 'Travelers', limit: 5_000_000, retention: 250_000, attachmentPoint: 0, coverageStatus: 'denied', noticeDate: '2024-05-20', rovPoints: ['Contract exclusion'] },
    ],
    totalTowerUsd: 40_000_000,
    defenseCostsBilledToCarrier: 1_820_000,
    defenseCostsPending: 320_000,
    coverageCounsel: 'Wiley Rein LLP',
    coveragePositionScore: 72, // 0–100 favorability
    disputes: [
      { id: 'CD-01', carrier: 'AIG', issue: 'Fraud exclusion — carve-back for "final adjudication" dispute', status: 'in-negotiation', exposureUsd: 8_000_000 },
      { id: 'CD-02', carrier: 'Travelers', issue: 'E&O denial appeal', status: 'filed', exposureUsd: 5_000_000 },
    ],
  };

  window.MATTER_WR_DATA = {
    motions, motionsInLimine, discoveryRequests, tar, privilegeLog,
    depositions, experts, crossExam,
    narrative, mockTrial, courtroomOps, authentications,
    parallelProceedings, regulatory, media, precedents,
    damagesModel, settlementTree, budget, coverage,
  };

  // Helpers shared across MatterWarRoom components
  window.mw = {
    money: (n) => {
      if (n == null) return '—';
      if (Math.abs(n) >= 1e6) return '$' + (n/1e6).toFixed(1) + 'M';
      if (Math.abs(n) >= 1e3) return '$' + Math.round(n/1e3) + 'K';
      return '$' + Math.round(n);
    },
    pct: (n, digits=0) => (n*100).toFixed(digits) + '%',
    pctRaw: (n, digits=0) => n.toFixed(digits) + '%',
    statusColor: (s) => {
      const map = { done:'#22C55E', complete:'#22C55E', filed:'#22C55E', stipulated:'#22C55E',
                    'in-progress':'#3B82F6', scheduled:'#3B82F6', drafting:'#3B82F6', 'on-track':'#3B82F6', disclosed:'#3B82F6',
                    pending:'#F59E0B', research:'#F59E0B', queued:'#F59E0B', draft:'#F59E0B', 'due-today':'#F59E0B',
                    overdue:'#EF4444', denied:'#EF4444', contested:'#EF4444', rejected:'#EF4444',
                    dormant:'#94A3C4', stayed:'#94A3C4', defended:'#A855F7', 'accepted-with-rov':'#3B82F6',
                    'follow-form':'#22C55E', preliminary:'#F59E0B', active:'#EF4444', monitoring:'#3B82F6', inquiry:'#F59E0B' };
      return map[s] || '#94A3C4';
    },
  };
})();
