// CALENDAR PLATFORM — Master Data Layer
const T = window.ArbiterTokens;

// Calendar platform accent
const cal = {
  amber: '#D97706',
  amberBg: 'rgba(217,119,6,0.06)',
  amberText: '#D97706',
  container: { flex: 1, overflow: 'auto', background: T.color.bg.primary },
  header: { padding: '16px 24px', borderBottom: `1px solid ${T.color.border.light}`, background: T.color.bg.card, display: 'flex', alignItems: 'center', justifyContent: 'space-between' },
  headerTitle: { display: 'flex', alignItems: 'center', gap: '12px' },
  calIcon: { width: '32px', height: '32px', borderRadius: '6px', background: 'linear-gradient(135deg, #D97706 0%, #B45309 100%)', display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: '14px', fontWeight: 700, color: '#fff' },
  title: { fontSize: '18px', fontWeight: 700, color: T.color.text.primary, letterSpacing: '-0.02em' },
  subtitle: { fontSize: '12px', color: T.color.text.tertiary, marginTop: '1px' },
  tabs: { display: 'flex', gap: '0', borderBottom: `1px solid ${T.color.border.light}`, background: T.color.bg.card, padding: '0 24px' },
  tab: { padding: '10px 16px', fontSize: '12px', fontWeight: 500, color: T.color.text.tertiary, cursor: 'pointer', border: 'none', background: 'none', borderBottom: '2px solid transparent', fontFamily: T.font.family, transition: 'all 0.15s', marginBottom: '-1px' },
  tabActive: { color: '#D97706', borderBottomColor: '#D97706', fontWeight: 600 },
  body: { padding: '20px 24px' },
  card: { background: T.color.bg.card, border: `1px solid ${T.color.border.light}`, borderRadius: T.radius.lg, overflow: 'hidden', marginBottom: '16px' },
  cardH: { padding: '10px 16px', borderBottom: `1px solid ${T.color.border.light}`, fontSize: '12px', fontWeight: 600, color: T.color.text.primary, display: 'flex', alignItems: 'center', justifyContent: 'space-between' },
  stat: { display: 'flex', flexDirection: 'column', gap: '2px', padding: '12px 16px', background: T.color.bg.secondary, borderRadius: '6px', border: `1px solid ${T.color.border.light}` },
  statLabel: { fontSize: '10px', fontWeight: 600, color: T.color.text.tertiary, textTransform: 'uppercase', letterSpacing: '0.08em' },
  statValue: { fontSize: '22px', fontWeight: 700, letterSpacing: '-0.02em', lineHeight: 1.1, color: T.color.text.primary },
  tag: { display: 'inline-flex', alignItems: 'center', padding: '2px 8px', borderRadius: '10px', fontSize: '10px', fontWeight: 600 },
  filterBtn: { padding: '4px 10px', borderRadius: T.radius.md, border: `1px solid ${T.color.border.light}`, background: T.color.bg.card, fontSize: '11px', fontWeight: 500, color: T.color.text.secondary, cursor: 'pointer', fontFamily: T.font.family },
  filterBtnActive: { background: '#D97706', color: '#fff', borderColor: '#D97706' },
};

window.cal = cal;

// ── DOCKET DEADLINES ──
const DOCKET_DEADLINES = [
  // Redstone v. Meridian
  { id: 'DL-001', matter: 'Redstone v. Meridian', matterId: 'M-2024-0312', date: '2026-04-21', label: 'Discovery response — Set 3', type: 'discovery', priority: 'high', status: 'due', assignee: 'L. Torres', rule: 'FRCP 33(b)(2) — 30 days', chainParent: null, chainChildren: ['DL-004'], notes: 'Final set of interrogatories. Responses must be verified.' },
  { id: 'DL-002', matter: 'Redstone v. Meridian', matterId: 'M-2024-0312', date: '2026-05-01', label: 'Deposition — Controller R. Davis', type: 'deposition', priority: 'high', status: 'scheduled', assignee: 'L. Torres', rule: 'FRCP 30 — Notice served Apr 19', chainParent: null, chainChildren: [], notes: 'Key witness for Q3 2022 gap. Prep session Apr 28.' },
  { id: 'DL-003', matter: 'Redstone v. Meridian', matterId: 'M-2024-0312', date: '2026-05-14', label: 'Discovery cutoff', type: 'court-deadline', priority: 'critical', status: 'upcoming', assignee: 'M. Kirkland', rule: 'CMO — Jan 20, 2026', chainParent: null, chainChildren: ['DL-005'], notes: 'Hard deadline per Case Management Order.' },
  { id: 'DL-004', matter: 'Redstone v. Meridian', matterId: 'M-2024-0312', date: '2026-05-14', label: 'Opposition to MSJ', type: 'brief', priority: 'critical', status: 'drafting', assignee: 'M. Kirkland', rule: 'FRCP 56 — 21 days after service', chainParent: 'DL-003', chainChildren: ['DL-006'], notes: 'Draft v3 in review. Final due May 14.' },
  { id: 'DL-005', matter: 'Redstone v. Meridian', matterId: 'M-2024-0312', date: '2026-06-01', label: 'Motions in limine', type: 'motion', priority: 'high', status: 'upcoming', assignee: 'M. Kirkland', rule: 'Local Rule 56.1', chainParent: 'DL-003', chainChildren: ['DL-007'], notes: 'File after discovery closes. Daubert motion for defense expert.' },
  { id: 'DL-006', matter: 'Redstone v. Meridian', matterId: 'M-2024-0312', date: '2026-06-02', label: 'Pretrial conference', type: 'hearing', priority: 'high', status: 'upcoming', assignee: 'M. Kirkland', rule: 'FRCP 16', chainParent: 'DL-004', chainChildren: [], notes: 'With Judge Reynolds. Bring proposed exhibit list.' },
  { id: 'DL-007', matter: 'Redstone v. Meridian', matterId: 'M-2024-0312', date: '2026-06-15', label: 'Pretrial brief due', type: 'brief', priority: 'high', status: 'upcoming', assignee: 'M. Kirkland', rule: 'Local Rule', chainParent: 'DL-005', chainChildren: ['DL-009'], notes: '' },
  { id: 'DL-008', matter: 'Redstone v. Meridian', matterId: 'M-2024-0312', date: '2026-06-08', label: 'Proposed jury instructions', type: 'court-deadline', priority: 'medium', status: 'upcoming', assignee: 'L. Torres', rule: 'CMO', chainParent: null, chainChildren: [], notes: 'Include special verdict form.' },
  { id: 'DL-009', matter: 'Redstone v. Meridian', matterId: 'M-2024-0312', date: '2026-07-15', label: 'Trial date', type: 'trial', priority: 'critical', status: 'upcoming', assignee: 'M. Kirkland', rule: 'CMO — Jan 20, 2026', chainParent: 'DL-007', chainChildren: [], notes: 'Estimated 4–5 days. Courtroom 14B.' },
  // Pacific Shipping
  { id: 'DL-010', matter: 'Pacific Shipping Antitrust', matterId: 'M-2024-0298', date: '2026-04-25', label: 'Deposition — J. Harmon', type: 'deposition', priority: 'high', status: 'scheduled', assignee: 'S. Chen', rule: 'FRCP 30', chainParent: null, chainChildren: [], notes: '' },
  { id: 'DL-011', matter: 'Pacific Shipping Antitrust', matterId: 'M-2024-0298', date: '2026-06-30', label: 'Class certification hearing', type: 'hearing', priority: 'critical', status: 'upcoming', assignee: 'S. Chen', rule: 'FRCP 23', chainParent: null, chainChildren: [], notes: 'Key hearing. Brief due Jun 15.' },
  // Thornton
  { id: 'DL-012', matter: 'Thornton Estate', matterId: 'M-2024-0284', date: '2026-04-23', label: 'Expert report due', type: 'court-deadline', priority: 'critical', status: 'due', assignee: 'R. Vasquez', rule: 'FRCP 26(a)(2)', chainParent: null, chainChildren: ['DL-013'], notes: 'Dr. Patel report. Final review today.' },
  { id: 'DL-013', matter: 'Thornton Estate', matterId: 'M-2024-0284', date: '2026-05-02', label: 'Trial date', type: 'trial', priority: 'critical', status: 'upcoming', assignee: 'R. Vasquez', rule: 'Court Order', chainParent: 'DL-012', chainChildren: [], notes: '12 days away. Witness prep in progress.' },
  // Blackwell
  { id: 'DL-014', matter: 'Blackwell IP', matterId: 'M-2024-0271', date: '2026-04-28', label: 'Motion to compel response', type: 'motion', priority: 'medium', status: 'upcoming', assignee: 'M. Kirkland', rule: 'FRCP 37', chainParent: null, chainChildren: [], notes: '' },
  // Chen v. Atlas
  { id: 'DL-015', matter: 'Chen v. Atlas', matterId: 'M-2024-0265', date: '2026-05-05', label: 'Mediation session', type: 'hearing', priority: 'medium', status: 'upcoming', assignee: 'A. Petrov', rule: 'Court-ordered', chainParent: null, chainChildren: [], notes: 'Mediator: Hon. R. Briggs (ret.)' },
  // Marshall
  { id: 'DL-016', matter: 'Marshall Employment', matterId: 'M-2024-0201', date: '2026-05-10', label: 'Settlement conference', type: 'hearing', priority: 'low', status: 'upcoming', assignee: 'R. Vasquez', rule: 'Court-ordered', chainParent: null, chainChildren: [], notes: '' },
  // Sterling
  { id: 'DL-017', matter: 'Sterling Pharma FCPA', matterId: 'M-2024-0259', date: '2026-05-20', label: 'DOJ status report due', type: 'brief', priority: 'high', status: 'upcoming', assignee: 'S. Chen', rule: 'DOJ Agreement', chainParent: null, chainChildren: [], notes: 'Quarterly cooperation update.' },
];

// ── ATTORNEYS / RESOURCES ──
const ATTORNEYS = [
  { id: 'ATT-1', name: 'M. Kirkland', role: 'Senior Partner', initials: 'MK', color: '#2563EB', capacity: 45, matters: 4, deadlinesThisWeek: 3, deadlinesNextWeek: 2, conflicts: [] },
  { id: 'ATT-2', name: 'S. Chen', role: 'Partner', initials: 'SC', color: '#6B21A8', capacity: 50, matters: 2, deadlinesThisWeek: 1, deadlinesNextWeek: 2, conflicts: ['Apr 25 — double-booked: Pacific depo + Blackwell call'] },
  { id: 'ATT-3', name: 'R. Vasquez', role: 'Partner', initials: 'RV', color: '#B8860B', capacity: 40, matters: 3, deadlinesThisWeek: 2, deadlinesNextWeek: 1, conflicts: [] },
  { id: 'ATT-4', name: 'A. Petrov', role: 'Associate', initials: 'AP', color: '#1B7A4A', capacity: 55, matters: 2, deadlinesThisWeek: 0, deadlinesNextWeek: 1, conflicts: [] },
  { id: 'ATT-5', name: 'L. Torres', role: 'Senior Associate', initials: 'LT', color: '#C23030', capacity: 55, matters: 3, deadlinesThisWeek: 2, deadlinesNextWeek: 3, conflicts: ['May 1 — Davis depo conflicts with Sterling doc review deadline'] },
  { id: 'ATT-6', name: 'J. Park', role: 'Associate', initials: 'JP', color: '#4A5A80', capacity: 60, matters: 3, deadlinesThisWeek: 0, deadlinesNextWeek: 1, conflicts: [] },
];

// ── COURT RULES ──
const COURT_RULES = [
  { id: 'CR-01', jurisdiction: 'S.D.N.Y.', rule: 'FRCP 12(a)(1)', description: 'Answer due 21 days after service of summons', triggerEvent: 'Service of Process', days: 21, type: 'response' },
  { id: 'CR-02', jurisdiction: 'S.D.N.Y.', rule: 'FRCP 33(b)(2)', description: 'Interrogatory responses due 30 days after service', triggerEvent: 'Interrogatories Served', days: 30, type: 'discovery' },
  { id: 'CR-03', jurisdiction: 'S.D.N.Y.', rule: 'FRCP 34(b)(2)(A)', description: 'Document production due 30 days after request', triggerEvent: 'RFP Served', days: 30, type: 'discovery' },
  { id: 'CR-04', jurisdiction: 'S.D.N.Y.', rule: 'FRCP 36(a)(3)', description: 'RFA responses due 30 days after service', triggerEvent: 'RFA Served', days: 30, type: 'discovery' },
  { id: 'CR-05', jurisdiction: 'S.D.N.Y.', rule: 'FRCP 56(b)', description: 'MSJ may be filed 30 days after close of discovery', triggerEvent: 'Discovery Cutoff', days: 30, type: 'motion' },
  { id: 'CR-06', jurisdiction: 'S.D.N.Y.', rule: 'FRCP 56(c)', description: 'Opposition to MSJ due 21 days after service', triggerEvent: 'MSJ Filed', days: 21, type: 'response' },
  { id: 'CR-07', jurisdiction: 'S.D.N.Y.', rule: 'FRCP 26(a)(2)(D)', description: 'Expert disclosure 90 days before trial', triggerEvent: 'Trial Date', days: -90, type: 'disclosure' },
  { id: 'CR-08', jurisdiction: 'S.D.N.Y.', rule: 'FRCP 26(a)(2)(D)(ii)', description: 'Rebuttal expert 30 days after initial disclosure', triggerEvent: 'Expert Disclosure', days: 30, type: 'disclosure' },
  { id: 'CR-09', jurisdiction: 'S.D.N.Y.', rule: 'Local Rule 56.1', description: 'Statement of undisputed facts with MSJ', triggerEvent: 'MSJ Filing', days: 0, type: 'motion' },
  { id: 'CR-10', jurisdiction: 'S.D.N.Y.', rule: 'FRCP 16(e)', description: 'Final pretrial conference — court sets date', triggerEvent: 'Court Order', days: 0, type: 'hearing' },
  { id: 'CR-11', jurisdiction: 'Federal', rule: 'FRCP 30(a)(1)', description: 'Deposition — reasonable notice required', triggerEvent: 'Notice Served', days: 14, type: 'deposition' },
  { id: 'CR-12', jurisdiction: 'Federal', rule: 'FRCP 45(d)(2)', description: 'Subpoena — 14 days for production', triggerEvent: 'Subpoena Served', days: 14, type: 'discovery' },
];

// ── SOL TRACKER ──
const SOL_TRACKER = [
  { matter: 'Redstone v. Meridian', claim: 'Breach of Contract', sol: '6 years (NY)', expires: '2028-03-15', status: 'Safe', daysRemaining: 695 },
  { matter: 'Redstone v. Meridian', claim: 'Fraud', sol: '6 years (NY) — discovery rule', expires: '2029-09-15', status: 'Safe', daysRemaining: 1244 },
  { matter: 'Redstone v. Meridian', claim: 'Breach of Fiduciary Duty', sol: '3 years (DE)', expires: '2027-05-26', status: 'Monitor', daysRemaining: 401 },
  { matter: 'Chen v. Atlas', claim: 'Securities Fraud', sol: '2 years (Exchange Act §10b)', expires: '2026-11-15', status: 'Urgent', daysRemaining: 209 },
  { matter: 'Pacific Shipping', claim: 'Sherman Act §1', sol: '4 years (Clayton Act)', expires: '2028-06-01', status: 'Safe', daysRemaining: 773 },
  { matter: 'Sterling Pharma', claim: 'FCPA — Criminal', sol: '5 years', expires: '2029-01-15', status: 'Safe', daysRemaining: 1001 },
];

// ── JURISDICTION RULE PACKS ──
const JURISDICTION_RULE_PACKS = [
  { id: 'JRP-SDNY',  name: 'S.D.N.Y.',            type: 'Federal — District', rules: 18, matters: 3, updated: '2026-03-12', maintainer: 'Firm KM', status: 'active', notes: 'Individual Practice rules for Judges Reynolds, Chen, Kaplan.' },
  { id: 'JRP-EDNY',  name: 'E.D.N.Y.',            type: 'Federal — District', rules: 16, matters: 1, updated: '2026-02-28', maintainer: 'Firm KM', status: 'active', notes: '' },
  { id: 'JRP-DEL',   name: 'Delaware Chancery',   type: 'State — Chancery',   rules: 14, matters: 1, updated: '2026-03-01', maintainer: 'Firm KM', status: 'active', notes: 'Expedited proceedings common.' },
  { id: 'JRP-CACA',  name: 'C.D. Cal.',           type: 'Federal — District', rules: 17, matters: 2, updated: '2026-03-22', maintainer: 'Firm KM', status: 'active', notes: '' },
  { id: 'JRP-NDCAL', name: 'N.D. Cal.',           type: 'Federal — District', rules: 17, matters: 1, updated: '2026-04-02', maintainer: 'Firm KM', status: 'active', notes: '' },
  { id: 'JRP-FED',   name: 'Federal (general)',   type: 'Federal — Rules',    rules: 22, matters: 7, updated: '2026-04-10', maintainer: 'Firm KM', status: 'active', notes: 'FRCP baseline across all federal matters.' },
  { id: 'JRP-NY',    name: 'New York CPLR',       type: 'State — Rules',      rules: 12, matters: 0, updated: '2026-01-18', maintainer: 'Firm KM', status: 'draft',  notes: 'State-court baseline; activate when NY matter opened.' },
];

// ── COURT HOLIDAYS / CLOSURES ──
const COURT_HOLIDAYS = [
  { date: '2026-05-25', name: 'Memorial Day',          jurisdictions: ['Federal','State'], skipForCalc: true },
  { date: '2026-06-19', name: 'Juneteenth',            jurisdictions: ['Federal','State'], skipForCalc: true },
  { date: '2026-07-03', name: 'Independence Day (obs.)',jurisdictions: ['Federal','State'], skipForCalc: true },
  { date: '2026-09-07', name: 'Labor Day',             jurisdictions: ['Federal','State'], skipForCalc: true },
  { date: '2026-10-12', name: 'Columbus Day',          jurisdictions: ['Federal'],         skipForCalc: true },
  { date: '2026-11-11', name: 'Veterans Day',          jurisdictions: ['Federal','State'], skipForCalc: true },
  { date: '2026-11-26', name: 'Thanksgiving',          jurisdictions: ['Federal','State'], skipForCalc: true },
  { date: '2026-12-25', name: 'Christmas Day',         jurisdictions: ['Federal','State'], skipForCalc: true },
  { date: '2026-04-17', name: 'SDNY Chambers Closure', jurisdictions: ['S.D.N.Y.'],        skipForCalc: true, notes: 'Judge Reynolds chambers only.' },
];

// ── JUDGE STANDING ORDERS ──
const JUDGE_STANDING_ORDERS = [
  { id: 'JSO-1', judge: 'Hon. L. Reynolds',  court: 'S.D.N.Y.',            chambers: 'Courtroom 14B', pageLimits: { msj: 25, opp: 25, reply: 10 },  chambersCopy: true,  premotion: true,  continuanceLikelihood: 'low',  notes: 'Requires pre-motion conference. Strict on page limits.' },
  { id: 'JSO-2', judge: 'Hon. K. Chen',      court: 'S.D.N.Y.',            chambers: 'Courtroom 21A', pageLimits: { msj: 30, opp: 30, reply: 15 },  chambersCopy: true,  premotion: false, continuanceLikelihood: 'medium',notes: 'Flexible on format, strict on deadlines.' },
  { id: 'JSO-3', judge: 'Hon. D. Kaplan',    court: 'S.D.N.Y.',            chambers: 'Courtroom 11B', pageLimits: { msj: 25, opp: 25, reply: 10 },  chambersCopy: false, premotion: true,  continuanceLikelihood: 'low',  notes: 'Individual Practices require joint letter.' },
  { id: 'JSO-4', judge: 'V.C. S. Glasscock', court: 'Delaware Chancery',   chambers: 'Georgetown',    pageLimits: { msj: 40, opp: 40, reply: 20 },  chambersCopy: true,  premotion: false, continuanceLikelihood: 'high', notes: 'Expedited proceedings; flexible on scheduling.' },
  { id: 'JSO-5', judge: 'Hon. A. Martinez',  court: 'C.D. Cal.',           chambers: 'Courtroom 8C',  pageLimits: { msj: 25, opp: 25, reply: 10 },  chambersCopy: true,  premotion: false, continuanceLikelihood: 'medium',notes: 'Strict 25-page MSJ limit, including tables.' },
];

// ── TRIGGER EVENTS / CASCADE RUNS ──
const CASCADE_RUNS = [
  { id: 'CAS-1', matter: 'Redstone v. Meridian',     trigger: 'Discovery cutoff set',    triggerDate: '2026-05-14', jurisdiction: 'S.D.N.Y.', generated: 6, ranAt: '2026-01-20T09:30:00-05:00', ranBy: 'M. Kirkland' },
  { id: 'CAS-2', matter: 'Pacific Shipping Antitrust',trigger: 'Class cert briefing set', triggerDate: '2026-06-30', jurisdiction: 'S.D.N.Y.', generated: 4, ranAt: '2026-03-02T11:10:00-05:00', ranBy: 'S. Chen' },
  { id: 'CAS-3', matter: 'Thornton Estate',          trigger: 'Trial set',               triggerDate: '2026-05-02', jurisdiction: 'N.Y. Surrogate', generated: 5, ranAt: '2026-02-18T14:22:00-05:00', ranBy: 'R. Vasquez' },
  { id: 'CAS-4', matter: 'Blackwell IP',             trigger: 'Motion to compel filed',  triggerDate: '2026-04-28', jurisdiction: 'C.D. Cal.',  generated: 2, ranAt: '2026-04-14T10:00:00-07:00', ranBy: 'M. Kirkland' },
];

// ── PACER / DOCKET SYNC ENTRIES ──
const PACER_ENTRIES = [
  { id: 'PC-1', matter: 'Redstone v. Meridian',     docketNo: '1:24-cv-03122', entry: '#187 ORDER re Motion in Limine — set hearing Jun 2 @ 10am',    date: '2026-04-18', ingested: true,  promotedToDeadline: true,  deadlineId: 'DL-006' },
  { id: 'PC-2', matter: 'Redstone v. Meridian',     docketNo: '1:24-cv-03122', entry: '#188 MINUTE ENTRY — telephonic conf held Apr 19',             date: '2026-04-19', ingested: true,  promotedToDeadline: false, deadlineId: null },
  { id: 'PC-3', matter: 'Pacific Shipping Antitrust',docketNo: '1:24-cv-04089', entry: '#92 SCHEDULING ORDER — class cert hearing Jun 30',            date: '2026-04-15', ingested: true,  promotedToDeadline: true,  deadlineId: 'DL-011' },
  { id: 'PC-4', matter: 'Blackwell IP',             docketNo: '2:24-cv-06711', entry: '#45 NOTICE of Motion to Compel — Plaintiff',                  date: '2026-04-14', ingested: true,  promotedToDeadline: true,  deadlineId: 'DL-014' },
  { id: 'PC-5', matter: 'Chen v. Atlas',            docketNo: '1:24-cv-05011', entry: '#73 ORDER re Mediation — set for May 5, 2026',               date: '2026-04-10', ingested: true,  promotedToDeadline: true,  deadlineId: 'DL-015' },
  { id: 'PC-6', matter: 'Sterling Pharma FCPA',     docketNo: 'DOJ-2024-FCPA-88',entry: 'DOJ letter — quarterly cooperation status due May 20',      date: '2026-04-02', ingested: true,  promotedToDeadline: true,  deadlineId: 'DL-017' },
  { id: 'PC-7', matter: 'Redstone v. Meridian',     docketNo: '1:24-cv-03122', entry: '#189 NOTICE of Deposition — Controller R. Davis, May 1',      date: '2026-04-19', ingested: true,  promotedToDeadline: true,  deadlineId: 'DL-002' },
  { id: 'PC-8', matter: 'Pacific Shipping Antitrust',docketNo: '1:24-cv-04089', entry: '#93 PLAINTIFF Letter re scheduling — sets Harmon depo Apr 25',date: '2026-04-17', ingested: true,  promotedToDeadline: true,  deadlineId: 'DL-010' },
  { id: 'PC-9', matter: 'Thornton Estate',          docketNo: 'S-2024-0284',   entry: 'Court notice — expert reports due Apr 23',                    date: '2026-04-09', ingested: true,  promotedToDeadline: true,  deadlineId: 'DL-012' },
  { id: 'PC-10',matter: 'Marshall Employment',      docketNo: '3:24-cv-00991', entry: 'Court notice — settlement conf set May 10',                   date: '2026-04-05', ingested: true,  promotedToDeadline: true,  deadlineId: 'DL-016' },
  { id: 'PC-11',matter: 'Redstone v. Meridian',     docketNo: '1:24-cv-03122', entry: '#190 ORDER — proposed jury instructions due Jun 8',           date: '2026-04-20', ingested: false, promotedToDeadline: false, deadlineId: null },
  { id: 'PC-12',matter: 'Blackwell IP',             docketNo: '2:24-cv-06711', entry: '#46 DEFENDANT response to motion to compel',                  date: '2026-04-19', ingested: false, promotedToDeadline: false, deadlineId: null },
];

// ── SERVICE OF PROCESS TRACKER ──
const SERVICE_OF_PROCESS = [
  { id: 'SOP-1', matter: 'Redstone v. Meridian',       party: 'Meridian Holdings',       method: 'Personal service',   server: 'L&R Process',    served: '2026-01-05', proof: 'Affidavit filed Jan 6', answerDue: '2026-01-26', answerFiled: '2026-02-28', status: 'late',    daysLate: 33 },
  { id: 'SOP-2', matter: 'Pacific Shipping Antitrust', party: 'Pacific Shipping Co.',    method: 'Certified mail',     server: 'USPS',           served: '2026-02-14', proof: 'Return receipt filed',   answerDue: '2026-03-07', answerFiled: '2026-03-05', status: 'on-time', daysLate: 0 },
  { id: 'SOP-3', matter: 'Blackwell IP',               party: 'Atlas Systems Inc.',      method: 'Waiver of service',  server: 'Counsel',        served: '2026-03-01', proof: 'Waiver filed',           answerDue: '2026-04-30', answerFiled: null,         status: 'pending', daysLate: 0 },
  { id: 'SOP-4', matter: 'Chen v. Atlas',              party: 'Atlas Systems Inc.',      method: 'Personal service',   server: 'L&R Process',    served: '2026-03-18', proof: 'Affidavit filed Mar 19', answerDue: '2026-04-08', answerFiled: '2026-04-06', status: 'on-time', daysLate: 0 },
  { id: 'SOP-5', matter: 'Marshall Employment',        party: 'Marshall Corp.',          method: 'Certified mail',     server: 'USPS',           served: '2026-03-22', proof: 'Return receipt pending', answerDue: '2026-04-12', answerFiled: null,         status: 'at-risk', daysLate: 0 },
];

// ── MOTIONS (practice tracker) ──
const MOTIONS = [
  { id: 'MO-1', matter: 'Redstone v. Meridian',     type: 'Motion for Summary Judgment',  movant: 'Defendant',       filed: '2026-03-24', oppDue: '2026-05-14', replyDue: '2026-05-28', argument: '2026-06-02', status: 'opp-drafting', ruling: null,      judge: 'Hon. L. Reynolds' },
  { id: 'MO-2', matter: 'Redstone v. Meridian',     type: 'Motion in Limine',             movant: 'Plaintiff',       filed: null,         oppDue: null,         replyDue: null,         argument: null,         status: 'drafting',     ruling: null,      judge: 'Hon. L. Reynolds' },
  { id: 'MO-3', matter: 'Blackwell IP',             type: 'Motion to Compel',             movant: 'Plaintiff',       filed: '2026-04-14', oppDue: '2026-04-28', replyDue: '2026-05-05', argument: null,         status: 'opp-due',      ruling: null,      judge: 'Hon. A. Martinez' },
  { id: 'MO-4', matter: 'Pacific Shipping Antitrust',type: 'Motion for Class Certification',movant: 'Plaintiff',     filed: '2026-03-01', oppDue: '2026-05-15', replyDue: '2026-06-12', argument: '2026-06-30', status: 'reply-due',    ruling: null,      judge: 'Hon. K. Chen' },
  { id: 'MO-5', matter: 'Thornton Estate',          type: 'Motion in Limine (Daubert)',   movant: 'Petitioner',      filed: '2026-04-10', oppDue: '2026-04-24', replyDue: '2026-04-30', argument: null,         status: 'opp-due',      ruling: null,      judge: 'Surrogate Wells' },
  { id: 'MO-6', matter: 'Chen v. Atlas',            type: 'Motion to Dismiss',            movant: 'Defendant',       filed: '2026-04-10', oppDue: '2026-05-01', replyDue: '2026-05-15', argument: null,         status: 'opp-due',      ruling: null,      judge: 'Hon. D. Kaplan' },
  { id: 'MO-7', matter: 'Sterling Pharma FCPA',     type: 'Motion for Protective Order',  movant: 'Respondent',      filed: '2026-02-14', oppDue: '2026-02-28', replyDue: '2026-03-07', argument: '2026-03-20', status: 'ruled',        ruling: 'Granted', judge: 'Hon. K. Chen' },
];

// ── CONTINUANCES ──
const CONTINUANCES = [
  { id: 'CT-1', matter: 'Redstone v. Meridian',     originalDate: '2026-04-15', newDate: '2026-05-14', request: 'Discovery cutoff extension',   requestedBy: 'Joint',    basis: 'Third-party subpoena delay',    status: 'granted', impact: '6 downstream deadlines shifted' },
  { id: 'CT-2', matter: 'Pacific Shipping Antitrust',originalDate: '2026-05-15', newDate: '2026-06-30', request: 'Class cert hearing',          requestedBy: 'Defense',   basis: 'Expert witness availability',   status: 'granted', impact: '4 downstream deadlines shifted' },
  { id: 'CT-3', matter: 'Marshall Employment',      originalDate: '2026-04-15', newDate: '2026-05-10', request: 'Settlement conference',       requestedBy: 'Plaintiff', basis: 'Mediator calendar',             status: 'granted', impact: 'No downstream' },
  { id: 'CT-4', matter: 'Blackwell IP',             originalDate: null,          newDate: null,          request: 'Trial continuance',          requestedBy: 'Plaintiff', basis: 'Trial team conflict',           status: 'pending', impact: 'Awaiting ruling' },
  { id: 'CT-5', matter: 'Chen v. Atlas',            originalDate: '2026-04-05', newDate: null,          request: 'MTD response extension',      requestedBy: 'Plaintiff', basis: 'New counsel appearance',        status: 'denied',  impact: 'No change — original date stands' },
];

// ── HEARING PREP ROOMS ──
const HEARING_PREP = [
  { id: 'HP-1', matter: 'Redstone v. Meridian',     hearing: 'Pretrial conference',        date: '2026-06-02', judge: 'Hon. L. Reynolds', venue: 'Courtroom 14B', leadCounsel: 'M. Kirkland', witnessesCount: 6, exhibitsCount: 124, prepItems: 12, prepDone: 5,  logistics: 'Tech test scheduled May 30' },
  { id: 'HP-2', matter: 'Redstone v. Meridian',     hearing: 'MSJ argument',              date: '2026-06-02', judge: 'Hon. L. Reynolds', venue: 'Courtroom 14B', leadCounsel: 'M. Kirkland', witnessesCount: 0, exhibitsCount: 28,  prepItems: 7,  prepDone: 3,  logistics: 'Paper copy required' },
  { id: 'HP-3', matter: 'Pacific Shipping Antitrust',hearing: 'Class certification',      date: '2026-06-30', judge: 'Hon. K. Chen',     venue: 'Courtroom 21A', leadCounsel: 'S. Chen',     witnessesCount: 3, exhibitsCount: 58,  prepItems: 10, prepDone: 2,  logistics: 'Video feed for remote experts' },
  { id: 'HP-4', matter: 'Thornton Estate',          hearing: 'Trial',                    date: '2026-05-02', judge: 'Surrogate Wells',  venue: 'Surrogate Ct 3', leadCounsel: 'R. Vasquez',  witnessesCount: 4, exhibitsCount: 32,  prepItems: 15, prepDone: 8,  logistics: 'Binders due to chambers May 1' },
  { id: 'HP-5', matter: 'Chen v. Atlas',            hearing: 'Mediation',                date: '2026-05-05', judge: 'Hon. R. Briggs (ret.)', venue: 'JAMS NY',   leadCounsel: 'A. Petrov',   witnessesCount: 0, exhibitsCount: 12,  prepItems: 6,  prepDone: 4,  logistics: 'Opening demands exchanged Apr 25' },
];

// ── WITNESS AVAILABILITY MATRIX ──
const WITNESS_AVAILABILITY = [
  { id: 'WA-1', name: 'R. Davis (Controller)',      matter: 'Redstone v. Meridian',     role: 'Fact',    blackout: ['2026-04-27','2026-04-28','2026-05-15'], availableFrom: '2026-05-01', availableTo: '2026-05-10', scheduled: '2026-05-01' },
  { id: 'WA-2', name: 'Dr. J. Patel (Valuation)',   matter: 'Thornton Estate',          role: 'Expert',  blackout: ['2026-04-29','2026-05-02'],              availableFrom: '2026-04-23', availableTo: '2026-05-06', scheduled: '2026-04-23' },
  { id: 'WA-3', name: 'J. Harmon (VP Ops)',         matter: 'Pacific Shipping Antitrust',role: 'Fact',   blackout: ['2026-05-01','2026-05-02'],              availableFrom: '2026-04-25', availableTo: '2026-05-10', scheduled: '2026-04-25' },
  { id: 'WA-4', name: 'S. Caldwell (IT forensics)', matter: 'Redstone v. Meridian',     role: 'Expert',  blackout: ['2026-05-18','2026-05-19'],              availableFrom: '2026-05-05', availableTo: '2026-05-22', scheduled: null },
  { id: 'WA-5', name: 'A. Hidalgo (HR)',            matter: 'Marshall Employment',      role: 'Fact',    blackout: [],                                       availableFrom: '2026-04-23', availableTo: '2026-05-15', scheduled: null },
  { id: 'WA-6', name: 'Dr. M. Okafor (Industry)',   matter: 'Pacific Shipping Antitrust',role: 'Expert', blackout: ['2026-05-20'],                            availableFrom: '2026-05-01', availableTo: '2026-06-15', scheduled: null },
];

// ── ESCALATION RULES ──
const ESCALATION_RULES = [
  { id: 'ER-1', trigger: 'T-30', priority: 'critical', recipients: ['Lead Counsel'],                        channel: 'Email',  enabled: true,  description: 'Initial 30-day warning on critical deadlines.' },
  { id: 'ER-2', trigger: 'T-14', priority: 'critical', recipients: ['Lead Counsel','Matter Partner'],       channel: 'Email',  enabled: true,  description: 'Partner-level visibility 14 days out.' },
  { id: 'ER-3', trigger: 'T-7',  priority: 'critical', recipients: ['Lead Counsel','Matter Partner'],       channel: 'Slack',  enabled: true,  description: 'Slack digest with status check.' },
  { id: 'ER-4', trigger: 'T-3',  priority: 'critical', recipients: ['Lead Counsel','Matter Partner','Managing Partner'], channel: 'SMS+Email', enabled: true, description: 'Escalate to Managing Partner.' },
  { id: 'ER-5', trigger: 'T-1',  priority: 'critical', recipients: ['Lead Counsel','Matter Partner','Managing Partner','Client'], channel: 'SMS+Email', enabled: true, description: 'Full stakeholder notice with readiness check.' },
  { id: 'ER-6', trigger: 'T-14', priority: 'high',     recipients: ['Lead Counsel'],                        channel: 'Email',  enabled: true,  description: '' },
  { id: 'ER-7', trigger: 'T-7',  priority: 'high',     recipients: ['Lead Counsel','Matter Partner'],       channel: 'Email',  enabled: true,  description: '' },
  { id: 'ER-8', trigger: 'T-3',  priority: 'high',     recipients: ['Lead Counsel','Matter Partner'],       channel: 'SMS',    enabled: true,  description: '' },
];

// ── CLIENT STATUS REPORTS ──
const CLIENT_REPORTS = [
  { id: 'CR-RPT-1', matter: 'Redstone v. Meridian',     cadence: 'Weekly',   lastSent: '2026-04-18', nextDue: '2026-04-25', recipients: ['J. Redstone (GC)'],     status: 'queued' },
  { id: 'CR-RPT-2', matter: 'Pacific Shipping Antitrust',cadence: 'Bi-weekly',lastSent: '2026-04-13', nextDue: '2026-04-27', recipients: ['B. Zhao (Deputy GC)'],  status: 'queued' },
  { id: 'CR-RPT-3', matter: 'Thornton Estate',          cadence: 'Weekly',   lastSent: '2026-04-16', nextDue: '2026-04-23', recipients: ['Executors (2)'],         status: 'sent'   },
  { id: 'CR-RPT-4', matter: 'Sterling Pharma FCPA',     cadence: 'Monthly',  lastSent: '2026-04-01', nextDue: '2026-05-01', recipients: ['CCO','Audit Chair'],     status: 'queued' },
  { id: 'CR-RPT-5', matter: 'Marshall Employment',      cadence: 'Monthly',  lastSent: '2026-04-01', nextDue: '2026-05-01', recipients: ['HR SVP'],                status: 'queued' },
];

// ── WORKLOAD FORECAST ──
const WORKLOAD_FORECAST = [
  { attorney: 'M. Kirkland', weekOf: '2026-04-20', committed: 48, forecast: 62, overloadRisk: 'high' },
  { attorney: 'M. Kirkland', weekOf: '2026-04-27', committed: 52, forecast: 58, overloadRisk: 'high' },
  { attorney: 'S. Chen',     weekOf: '2026-04-20', committed: 44, forecast: 50, overloadRisk: 'medium' },
  { attorney: 'S. Chen',     weekOf: '2026-04-27', committed: 40, forecast: 48, overloadRisk: 'medium' },
  { attorney: 'L. Torres',   weekOf: '2026-04-20', committed: 46, forecast: 55, overloadRisk: 'high' },
  { attorney: 'L. Torres',   weekOf: '2026-04-27', committed: 44, forecast: 50, overloadRisk: 'medium' },
  { attorney: 'R. Vasquez',  weekOf: '2026-04-20', committed: 42, forecast: 48, overloadRisk: 'medium' },
  { attorney: 'R. Vasquez',  weekOf: '2026-04-27', committed: 30, forecast: 36, overloadRisk: 'low' },
  { attorney: 'A. Petrov',   weekOf: '2026-04-20', committed: 32, forecast: 40, overloadRisk: 'low' },
  { attorney: 'J. Park',     weekOf: '2026-04-20', committed: 36, forecast: 42, overloadRisk: 'low' },
];

// ── CONFLICT CHECKS (scheduling-time) ──
const CONFLICT_CHECKS = [
  { id: 'CC-1', attempt: 'Schedule Davis depo', proposed: '2026-05-01', attorney: 'L. Torres', conflict: 'Sterling doc review deadline same day', severity: 'warn',   suggestion: 'Move to 2026-05-04', resolved: false },
  { id: 'CC-2', attempt: 'Schedule Harmon depo',proposed: '2026-04-25', attorney: 'S. Chen',   conflict: 'Blackwell call 2pm overlap',            severity: 'block',  suggestion: 'Move depo to 10am',  resolved: true  },
  { id: 'CC-3', attempt: 'Schedule MIL hearing',proposed: '2026-06-02', attorney: 'M. Kirkland',conflict: 'Pretrial conf same courtroom 1pm',     severity: 'info',   suggestion: 'Courtroom OK — stacked',resolved: true  },
];

// ── EXPERT DISCLOSURE SCHEDULES ──
const EXPERT_DISCLOSURES = [
  { id: 'ED-1', matter: 'Redstone v. Meridian',     trialDate: '2026-07-15', initialDue: '2026-04-16', rebuttalDue: '2026-05-16', surrebuttalDue: '2026-06-15', expert: 'Dr. J. Weiss (Valuation)', status: 'initial-filed'  },
  { id: 'ED-2', matter: 'Thornton Estate',          trialDate: '2026-05-02', initialDue: '2026-04-23', rebuttalDue: null,         surrebuttalDue: null,         expert: 'Dr. J. Patel (Valuation)',  status: 'due-this-week' },
  { id: 'ED-3', matter: 'Pacific Shipping Antitrust',trialDate: '2026-09-15', initialDue: '2026-06-17', rebuttalDue: '2026-07-17', surrebuttalDue: null,         expert: 'Dr. M. Okafor (Industry)',  status: 'scheduled'      },
  { id: 'ED-4', matter: 'Chen v. Atlas',            trialDate: '2026-11-05', initialDue: '2026-08-07', rebuttalDue: '2026-09-06', surrebuttalDue: null,         expert: 'TBD',                       status: 'scheduled'      },
];

// ── MATTER EVENT BUNDLE TEMPLATES ──
const EVENT_TEMPLATES = [
  { id: 'ET-1', name: 'Federal Civil Case (SDNY)',      deadlines: 14, trigger: 'Complaint Filed',        jurisdictions: ['S.D.N.Y.'],      uses: 7 },
  { id: 'ET-2', name: 'Federal Civil Case (general)',   deadlines: 12, trigger: 'Complaint Filed',        jurisdictions: ['Federal'],       uses: 4 },
  { id: 'ET-3', name: 'DE Chancery Expedited',          deadlines: 9,  trigger: 'Complaint Filed',        jurisdictions: ['Delaware Chancery'], uses: 1 },
  { id: 'ET-4', name: 'FCPA Investigation',             deadlines: 10, trigger: 'DOJ Letter',             jurisdictions: ['DOJ'],           uses: 2 },
  { id: 'ET-5', name: 'Class Cert Briefing Schedule',   deadlines: 6,  trigger: 'Class Cert Order',       jurisdictions: ['S.D.N.Y.'],      uses: 3 },
  { id: 'ET-6', name: 'Trial Countdown (T-90)',         deadlines: 12, trigger: 'Trial Date Set',         jurisdictions: ['Federal'],       uses: 8 },
  { id: 'ET-7', name: 'MSJ Briefing (FRCP 56)',         deadlines: 5,  trigger: 'Discovery Cutoff',       jurisdictions: ['Federal'],       uses: 6 },
];

// ── DEADLINE DEFENSIBILITY AUDIT ──
const DEFENSIBILITY_AUDIT = [
  { id: 'DA-1', deadlineId: 'DL-004', event: 'created',  actor: 'M. Kirkland', at: '2026-01-20T09:33:00-05:00', reason: 'Cascade from discovery cutoff',       evidence: 'CAS-1' },
  { id: 'DA-2', deadlineId: 'DL-004', event: 'approved', actor: 'Matter Partner', at: '2026-01-20T10:00:00-05:00', reason: 'Cascade verification',                evidence: 'CAS-1' },
  { id: 'DA-3', deadlineId: 'DL-003', event: 'extended', actor: 'M. Kirkland', at: '2026-03-18T14:15:00-04:00', reason: 'Joint continuance for third-party subpoena', evidence: 'CT-1' },
  { id: 'DA-4', deadlineId: 'DL-012', event: 'created',  actor: 'R. Vasquez',  at: '2026-02-18T14:22:00-05:00', reason: 'Cascade from trial',                   evidence: 'CAS-3' },
  { id: 'DA-5', deadlineId: 'DL-012', event: 'status',   actor: 'R. Vasquez',  at: '2026-04-19T16:45:00-04:00', reason: 'Marked due (T-4) — expert signoff pending', evidence: '' },
  { id: 'DA-6', deadlineId: 'DL-011', event: 'extended', actor: 'S. Chen',     at: '2026-03-02T11:12:00-05:00', reason: 'Defense continuance granted',          evidence: 'CT-2' },
  { id: 'DA-7', deadlineId: 'DL-014', event: 'created',  actor: 'M. Kirkland', at: '2026-04-14T10:05:00-07:00', reason: 'Docket sync — PACER entry',            evidence: 'PC-4' },
];

Object.assign(window, {
  DOCKET_DEADLINES, ATTORNEYS, COURT_RULES, SOL_TRACKER,
  JURISDICTION_RULE_PACKS, COURT_HOLIDAYS, JUDGE_STANDING_ORDERS,
  CASCADE_RUNS, PACER_ENTRIES, SERVICE_OF_PROCESS, MOTIONS, CONTINUANCES,
  HEARING_PREP, WITNESS_AVAILABILITY, ESCALATION_RULES, CLIENT_REPORTS,
  WORKLOAD_FORECAST, CONFLICT_CHECKS, EXPERT_DISCLOSURES, EVENT_TEMPLATES,
  DEFENSIBILITY_AUDIT,
});
