// JURISDICTIONS PLATFORM — seed data (courts, judges, rules, admissions, forms)
(function(){

const COURTS = [
  { id:'C-USDC-SDNY', name:'U.S. District Court — Southern District of New York', short:'SDNY', type:'Federal', circuit:'2nd Circuit', state:'NY', city:'New York', chiefJudge:'J-LSS', filingSystem:'CM/ECF', filingFeeCivil:405, rulesUrl:'nysd.uscourts.gov/rules', formsUrl:'nysd.uscourts.gov/forms', clerkPhone:'(212) 805-0136', address:'500 Pearl Street, New York, NY 10007', efileMandatory:true, motionPractice:'Pre-motion letter required', juryDemand:'14 days after last pleading' },
  { id:'C-USDC-EDNY', name:'U.S. District Court — Eastern District of New York', short:'EDNY', type:'Federal', circuit:'2nd Circuit', state:'NY', city:'Brooklyn', chiefJudge:'J-MMB', filingSystem:'CM/ECF', filingFeeCivil:405, rulesUrl:'nyed.uscourts.gov/rules', formsUrl:'nyed.uscourts.gov/forms', clerkPhone:'(718) 613-2600', address:'225 Cadman Plaza East, Brooklyn, NY 11201', efileMandatory:true, motionPractice:'Individual practices vary', juryDemand:'14 days after last pleading' },
  { id:'C-USDC-NDCA', name:'U.S. District Court — Northern District of California', short:'NDCA', type:'Federal', circuit:'9th Circuit', state:'CA', city:'San Francisco', chiefJudge:'J-RSW', filingSystem:'CM/ECF', filingFeeCivil:405, rulesUrl:'cand.uscourts.gov/rules', formsUrl:'cand.uscourts.gov/forms', clerkPhone:'(415) 522-2000', address:'450 Golden Gate Ave, San Francisco, CA 94102', efileMandatory:true, motionPractice:'35-day notice for motions', juryDemand:'14 days after last pleading' },
  { id:'C-USDC-DDE',  name:'U.S. District Court — District of Delaware', short:'DDE',  type:'Federal', circuit:'3rd Circuit', state:'DE', city:'Wilmington', chiefJudge:'J-CFC', filingSystem:'CM/ECF', filingFeeCivil:405, rulesUrl:'ded.uscourts.gov/rules', formsUrl:'ded.uscourts.gov/forms', clerkPhone:'(302) 573-6170', address:'844 N. King Street, Wilmington, DE 19801', efileMandatory:true, motionPractice:'Meet-and-confer required', juryDemand:'14 days after last pleading' },
  { id:'C-USDC-NDIL', name:'U.S. District Court — Northern District of Illinois', short:'NDIL', type:'Federal', circuit:'7th Circuit', state:'IL', city:'Chicago', chiefJudge:'J-RMD', filingSystem:'CM/ECF', filingFeeCivil:405, rulesUrl:'ilnd.uscourts.gov/rules', formsUrl:'ilnd.uscourts.gov/forms', clerkPhone:'(312) 435-5670', address:'219 S. Dearborn St, Chicago, IL 60604', efileMandatory:true, motionPractice:'LR 78.1 presentment', juryDemand:'14 days after last pleading' },
  { id:'C-USCA2',     name:'U.S. Court of Appeals — Second Circuit', short:'2d Cir.', type:'Appellate', circuit:'2nd Circuit', state:'NY', city:'New York', chiefJudge:'J-DL', filingSystem:'CM/ECF-ACE', filingFeeCivil:505, rulesUrl:'ca2.uscourts.gov/rules', formsUrl:'ca2.uscourts.gov/forms', clerkPhone:'(212) 857-8500', address:'40 Foley Square, New York, NY 10007', efileMandatory:true, motionPractice:'FRAP 27', juryDemand:'N/A' },
  { id:'C-USCA9',     name:'U.S. Court of Appeals — Ninth Circuit', short:'9th Cir.', type:'Appellate', circuit:'9th Circuit', state:'CA', city:'San Francisco', chiefJudge:'J-MWT', filingSystem:'CM/ECF-ACE', filingFeeCivil:505, rulesUrl:'ca9.uscourts.gov/rules', formsUrl:'ca9.uscourts.gov/forms', clerkPhone:'(415) 355-8000', address:'95 7th Street, San Francisco, CA 94103', efileMandatory:true, motionPractice:'FRAP 27', juryDemand:'N/A' },
  { id:'C-SCOTUS',    name:'Supreme Court of the United States', short:'SCOTUS', type:'Supreme', circuit:'N/A', state:'DC', city:'Washington', chiefJudge:'J-JGR', filingSystem:'Electronic Filing System', filingFeeCivil:300, rulesUrl:'supremecourt.gov/rules', formsUrl:'supremecourt.gov/forms', clerkPhone:'(202) 479-3011', address:'1 First St NE, Washington, DC 20543', efileMandatory:true, motionPractice:'Rule 21', juryDemand:'N/A' },
  { id:'C-NYS-NYSUP', name:'New York Supreme Court — Commercial Division (NY County)', short:'NYSup Comm', type:'State', circuit:'1st Dept', state:'NY', city:'New York', chiefJudge:'J-AEB', filingSystem:'NYSCEF', filingFeeCivil:210, rulesUrl:'nycourts.gov/courts/comdiv/rules', formsUrl:'nycourts.gov/forms', clerkPhone:'(646) 386-3000', address:'60 Centre Street, New York, NY 10007', efileMandatory:true, motionPractice:'Commercial Division Rule 17', juryDemand:'15 days after last pleading' },
  { id:'C-NYS-NYAPP', name:'New York Appellate Division — First Department', short:'NY App Div 1', type:'Appellate', circuit:'1st Dept', state:'NY', city:'New York', chiefJudge:'J-RAM', filingSystem:'NYSCEF', filingFeeCivil:315, rulesUrl:'nycourts.gov/courts/ad1/rules', formsUrl:'nycourts.gov/courts/ad1/forms', clerkPhone:'(212) 340-0400', address:'27 Madison Ave, New York, NY 10010', efileMandatory:true, motionPractice:'CPLR 2214', juryDemand:'N/A' },
  { id:'C-CAS-LASUP', name:'Superior Court of California — Los Angeles County', short:'LA Sup', type:'State', circuit:'2nd Dist', state:'CA', city:'Los Angeles', chiefJudge:'J-SMW', filingSystem:'eCourt', filingFeeCivil:435, rulesUrl:'lacourt.org/rules', formsUrl:'lacourt.org/forms', clerkPhone:'(213) 633-0100', address:'111 N. Hill Street, Los Angeles, CA 90012', efileMandatory:true, motionPractice:'CCP 1005 (16 court days)', juryDemand:'5 days after demand' },
  { id:'C-DEL-CHAN',  name:'Delaware Court of Chancery', short:'Del. Ch.', type:'State', circuit:'Statewide', state:'DE', city:'Wilmington', chiefJudge:'J-KRM', filingSystem:'File & ServeXpress', filingFeeCivil:1000, rulesUrl:'courts.delaware.gov/chancery/rules', formsUrl:'courts.delaware.gov/chancery/forms', clerkPhone:'(302) 255-0544', address:'Leonard L. Williams Justice Center, Wilmington, DE 19801', efileMandatory:true, motionPractice:'Ch. Ct. R. 6', juryDemand:'N/A — equity court' },
];

const JUDGES = [
  { id:'J-LSS', name:'Hon. Laura Taylor Swain', courtId:'C-USDC-SDNY', role:'Chief Judge', appointed:'2000', appointedBy:'Clinton', undergrad:'Radcliffe', lawSchool:'Harvard Law', previousRole:'Bankruptcy Judge, SDNY', chambers:'Courtroom 17C', lawClerks:3, preferences:'Mandatory pre-motion letter. No reply briefs without leave. Oral argument by request only.', motionStats:{ granted:142, denied:189, partial:67 }, summaryJudgmentGrantRate:0.31, avgDispositionDays:412, rulingTendencies:'Plaintiff-friendly on discovery disputes; defense-leaning on Daubert. Tough on class certification.', knownFor:'Puerto Rico debt crisis (PROMESA); complex commercial litigation', standingOrders:['SO-SDNY-LSS-001','SO-SDNY-LSS-002'], recusalTopics:['PR debt','Prudential Insurance'], rating:4.2, caseload:287 },
  { id:'J-JPO', name:'Hon. J. Paul Oetken', courtId:'C-USDC-SDNY', role:'District Judge', appointed:'2011', appointedBy:'Obama', undergrad:'Yale', lawSchool:'Yale Law', previousRole:'AUSA, SDNY', chambers:'Courtroom 20C', lawClerks:3, preferences:'3-page pre-motion letters. MSJ hearings by default. No surreplies.', motionStats:{ granted:98, denied:134, partial:41 }, summaryJudgmentGrantRate:0.28, avgDispositionDays:389, rulingTendencies:'Generally plaintiff-friendly in employment; defense-friendly in securities.', knownFor:'First openly gay federal judge in NY; securities class actions', standingOrders:['SO-SDNY-JPO-001'], recusalTopics:['White House Counsel cases'], rating:4.5, caseload:241 },
  { id:'J-VAE', name:'Hon. Valerie E. Caproni', courtId:'C-USDC-SDNY', role:'District Judge', appointed:'2013', appointedBy:'Obama', undergrad:'NC State', lawSchool:'UGA Law', previousRole:'FBI General Counsel', chambers:'Courtroom 443', lawClerks:3, preferences:'Strict page limits. Courtesy copies required. Early Rule 16 conference.', motionStats:{ granted:112, denied:98, partial:52 }, summaryJudgmentGrantRate:0.41, avgDispositionDays:356, rulingTendencies:'Government-friendly on criminal matters; balanced in civil.', knownFor:'National security and white-collar criminal cases', standingOrders:['SO-SDNY-VAE-001'], recusalTopics:['FBI-related'], rating:4.0, caseload:263 },
  { id:'J-MMB', name:'Hon. Margo K. Brodie', courtId:'C-USDC-EDNY', role:'Chief Judge', appointed:'2011', appointedBy:'Obama', undergrad:'St. John\'s', lawSchool:'St. John\'s Law', previousRole:'AUSA, EDNY', chambers:'Courtroom 8D', lawClerks:3, preferences:'Pre-motion letters required. Strict discovery deadlines. No extensions without stipulation.', motionStats:{ granted:124, denied:151, partial:58 }, summaryJudgmentGrantRate:0.33, avgDispositionDays:398, rulingTendencies:'Active case management; grants discovery extensions cautiously.', knownFor:'NFL anthem protest case; criminal procedure', standingOrders:['SO-EDNY-MMB-001'], recusalTopics:[], rating:4.3, caseload:278 },
  { id:'J-RSW', name:'Hon. Richard Seeborg', courtId:'C-USDC-NDCA', role:'Chief Judge', appointed:'2010', appointedBy:'Obama', undergrad:'Oberlin', lawSchool:'Columbia Law', previousRole:'Magistrate Judge, NDCA', chambers:'Courtroom 3', lawClerks:3, preferences:'Tentative rulings issued Friday for Monday argument. No footnote citations.', motionStats:{ granted:89, denied:127, partial:38 }, summaryJudgmentGrantRate:0.29, avgDispositionDays:423, rulingTendencies:'Tech-literate; active in IP and class actions.', knownFor:'Google, Apple, Tesla class actions', standingOrders:['SO-NDCA-RSW-001'], recusalTopics:['Google (pre-2010 representation)'], rating:4.6, caseload:234 },
  { id:'J-CFC', name:'Hon. Colm F. Connolly', courtId:'C-USDC-DDE', role:'Chief Judge', appointed:'2018', appointedBy:'Trump', undergrad:'Notre Dame', lawSchool:'Duke Law', previousRole:'US Attorney, DDE', chambers:'Courtroom 4B', lawClerks:3, preferences:'Standing order on third-party litigation funding disclosure. Strict IP schedule.', motionStats:{ granted:76, denied:92, partial:31 }, summaryJudgmentGrantRate:0.35, avgDispositionDays:445, rulingTendencies:'Skeptical of litigation funding; enforces strict case schedules in patent cases.', knownFor:'Patent litigation; litigation funding transparency', standingOrders:['SO-DDE-CFC-001','SO-DDE-CFC-002'], recusalTopics:[], rating:3.9, caseload:198 },
  { id:'J-RMD', name:'Hon. Rebecca R. Pallmeyer', courtId:'C-USDC-NDIL', role:'Chief Judge', appointed:'1998', appointedBy:'Clinton', undergrad:'Valparaiso', lawSchool:'Chicago Law', previousRole:'Magistrate Judge, NDIL', chambers:'Courtroom 2541', lawClerks:3, preferences:'Page limits enforced. MSJ requires L.R. 56.1 statements.', motionStats:{ granted:156, denied:178, partial:71 }, summaryJudgmentGrantRate:0.27, avgDispositionDays:367, rulingTendencies:'Balanced; experienced with complex civil.', knownFor:'R. Kelly sex trafficking trial; commercial litigation', standingOrders:['SO-NDIL-RMD-001'], recusalTopics:[], rating:4.4, caseload:269 },
  { id:'J-KRM', name:'Hon. Kathaleen St. J. McCormick', courtId:'C-DEL-CHAN', role:'Chancellor', appointed:'2018', appointedBy:'Carney', undergrad:'Notre Dame', lawSchool:'Notre Dame Law', previousRole:'Partner, Young Conaway', chambers:'Leonard L. Williams JC', lawClerks:2, preferences:'Short, focused briefs. No string cites. Tentative rulings day-of.', motionStats:{ granted:34, denied:41, partial:19 }, summaryJudgmentGrantRate:0.38, avgDispositionDays:287, rulingTendencies:'Shareholder-friendly in M&A disputes; strict on fiduciary duty.', knownFor:'Twitter v. Musk; TransPerfect; corporate governance', standingOrders:['SO-DELCH-KRM-001'], recusalTopics:['Young Conaway matters'], rating:4.8, caseload:124 },
  { id:'J-AEB', name:'Hon. Andrea Masley', courtId:'C-NYS-NYSUP', role:'Justice — Commercial Division', appointed:'2017', appointedBy:'Cuomo', undergrad:'SUNY Binghamton', lawSchool:'Albany Law', previousRole:'Justice, Supreme Court', chambers:'60 Centre St, Part 48', lawClerks:2, preferences:'Commercial Division Rules strictly enforced. E-filing via NYSCEF.', motionStats:{ granted:67, denied:82, partial:34 }, summaryJudgmentGrantRate:0.30, avgDispositionDays:312, rulingTendencies:'Plaintiff-friendly on breach of contract; careful on pre-answer dismissal.', knownFor:'Sophisticated commercial disputes', standingOrders:[], recusalTopics:[], rating:4.1, caseload:187 },
  { id:'J-SMW', name:'Hon. Samantha P. Jessner', courtId:'C-CAS-LASUP', role:'Presiding Judge', appointed:'2009', appointedBy:'Schwarzenegger', undergrad:'Northwestern', lawSchool:'USC Gould', previousRole:'DAG, CA DOJ', chambers:'LA Mosk Courthouse', lawClerks:1, preferences:'Strict meet-and-confer before all motions. Department 1 IC calendar.', motionStats:{ granted:94, denied:112, partial:48 }, summaryJudgmentGrantRate:0.24, avgDispositionDays:478, rulingTendencies:'Efficient case manager; resists continuances.', knownFor:'Complex civil coordination', standingOrders:['SO-LASC-SMW-001'], recusalTopics:[], rating:4.0, caseload:312 },
  { id:'J-DL',  name:'Hon. Debra Ann Livingston', courtId:'C-USCA2',     role:'Chief Judge', appointed:'2007', appointedBy:'W. Bush', undergrad:'Princeton', lawSchool:'Harvard Law', previousRole:'Columbia Law Prof.', chambers:'40 Foley Sq.', lawClerks:4, preferences:'Oral argument rarely denied. 30 min per side standard.', motionStats:{ granted:null, denied:null, partial:null }, summaryJudgmentGrantRate:null, avgDispositionDays:298, rulingTendencies:'Conservative jurisprudence; strong on 4th Amendment.', knownFor:'Criminal procedure; administrative law', standingOrders:[], recusalTopics:['Columbia cases'], rating:4.3, caseload:184 },
  { id:'J-JGR', name:'Hon. John G. Roberts, Jr.', courtId:'C-SCOTUS', role:'Chief Justice', appointed:'2005', appointedBy:'W. Bush', undergrad:'Harvard', lawSchool:'Harvard Law', previousRole:'Judge, DC Cir.', chambers:'SCOTUS', lawClerks:4, preferences:'Stage-managed advocacy; strict time limits.', motionStats:{ granted:null, denied:null, partial:null }, summaryJudgmentGrantRate:null, avgDispositionDays:null, rulingTendencies:'Institutionalist; incremental.', knownFor:'Chief Justice; ACA cases; institutional leadership', standingOrders:[], recusalTopics:['personal financial holdings'], rating:4.6, caseload:80 },
];

const RULES = [
  { id:'R-FRCP-26',  courtId:'C-USDC-SDNY', category:'Civil Procedure', name:'FRCP 26 — Duty to Disclose; Discovery Scope', citation:'Fed. R. Civ. P. 26', summary:'Initial disclosures, expert disclosures, discovery scope, proportionality, protective orders.', effectiveDate:'2015-12-01', appliesTo:['Federal'], tags:['discovery','disclosures'] },
  { id:'R-FRCP-56',  courtId:'C-USDC-SDNY', category:'Civil Procedure', name:'FRCP 56 — Summary Judgment', citation:'Fed. R. Civ. P. 56', summary:'Standard, timing, materials, form of opposition, partial summary judgment.', effectiveDate:'2010-12-01', appliesTo:['Federal'], tags:['dispositive','msj'] },
  { id:'R-SDNY-LCR-1', courtId:'C-USDC-SDNY', category:'Local Rule', name:'SDNY Local Rule 7.1 — Motion Practice', citation:'S.D.N.Y. Civ. R. 7.1', summary:'Memoranda format, word limits (25 pages), notice requirements, courtesy copies.', effectiveDate:'2021-07-01', appliesTo:['C-USDC-SDNY'], tags:['motions','format'] },
  { id:'R-SDNY-LCR-56', courtId:'C-USDC-SDNY', category:'Local Rule', name:'SDNY Local Rule 56.1 — Statement of Material Facts', citation:'S.D.N.Y. Civ. R. 56.1', summary:'Separate statement of material facts required; opposing party must respond paragraph-by-paragraph.', effectiveDate:'2021-07-01', appliesTo:['C-USDC-SDNY'], tags:['msj','56.1'] },
  { id:'R-NDCA-LCR-7', courtId:'C-USDC-NDCA', category:'Local Rule', name:'NDCA Local Rule 7-2 — Motions', citation:'N.D. Cal. Civ. L.R. 7-2', summary:'35-day notice period. 25-page limit. Reply 15 pages. Tentative rulings common.', effectiveDate:'2020-09-01', appliesTo:['C-USDC-NDCA'], tags:['motions'] },
  { id:'R-NDCA-ADR', courtId:'C-USDC-NDCA', category:'Local Rule', name:'NDCA ADR Local Rule 3 — Mandatory ADR', citation:'N.D. Cal. ADR L.R. 3', summary:'Select ADR within 90 days of case management conference.', effectiveDate:'2018-01-01', appliesTo:['C-USDC-NDCA'], tags:['adr','settlement'] },
  { id:'R-DDE-LR-161', courtId:'C-USDC-DDE', category:'Local Rule', name:'DDE Local Rule 16.1 — Scheduling Order', citation:'D. Del. L.R. 16.1', summary:'Standard patent case schedule template. Markman deadlines. Claim construction briefing.', effectiveDate:'2022-01-01', appliesTo:['C-USDC-DDE'], tags:['patent','scheduling'] },
  { id:'R-DDE-LF-DISCL', courtId:'C-USDC-DDE', category:'Standing Order', name:'DDE Standing Order — Third-Party Litigation Funding Disclosure', citation:'DDE SO 4/18/22', summary:'All parties must disclose third-party funders within 30 days of case initiation.', effectiveDate:'2022-04-18', appliesTo:['C-USDC-DDE'], tags:['funding','disclosure'] },
  { id:'R-CPLR-3212', courtId:'C-NYS-NYSUP', category:'Civil Procedure', name:'CPLR § 3212 — Summary Judgment', citation:'N.Y. C.P.L.R. § 3212', summary:'Summary judgment available any time after joinder of issue. 120-day deadline after note of issue.', effectiveDate:'1997-01-01', appliesTo:['State:NY'], tags:['msj'] },
  { id:'R-CPLR-2214', courtId:'C-NYS-NYSUP', category:'Civil Procedure', name:'CPLR § 2214 — Motion Papers; Time', citation:'N.Y. C.P.L.R. § 2214', summary:'Notice of motion 8 days in advance; papers served 7 days; reply 1 day before hearing.', effectiveDate:'1997-01-01', appliesTo:['State:NY'], tags:['motions','timing'] },
  { id:'R-COMM-17', courtId:'C-NYS-NYSUP', category:'Commercial Division', name:'Commercial Division Rule 17 — Scheduling of Disclosure', citation:'22 NYCRR 202.70 R.17', summary:'Preliminary conference; discovery deadlines.', effectiveDate:'2023-07-01', appliesTo:['C-NYS-NYSUP'], tags:['commercial','discovery'] },
  { id:'R-CCP-1005', courtId:'C-CAS-LASUP', category:'Civil Procedure', name:'CCP § 1005 — Motion Notice', citation:'Cal. Code Civ. Proc. § 1005', summary:'16 court days notice for motions; opposition 9 court days before; reply 5 court days before.', effectiveDate:'2011-01-01', appliesTo:['State:CA'], tags:['motions','timing'] },
  { id:'R-CCP-437C', courtId:'C-CAS-LASUP', category:'Civil Procedure', name:'CCP § 437c — Summary Judgment', citation:'Cal. Code Civ. Proc. § 437c', summary:'75-day notice for MSJ. Separate statement of undisputed facts required.', effectiveDate:'2019-01-01', appliesTo:['State:CA'], tags:['msj'] },
  { id:'R-FRAP-27', courtId:'C-USCA2', category:'Appellate', name:'FRAP 27 — Motions', citation:'Fed. R. App. P. 27', summary:'Motion form, 20-page limit, response 10 days, reply 7 days.', effectiveDate:'2016-12-01', appliesTo:['Federal-Appellate'], tags:['motions','appeal'] },
  { id:'R-FRAP-32', courtId:'C-USCA2', category:'Appellate', name:'FRAP 32 — Form of Briefs', citation:'Fed. R. App. P. 32', summary:'Type-volume limits: 13,000 words principal brief, 6,500 reply.', effectiveDate:'2016-12-01', appliesTo:['Federal-Appellate'], tags:['briefs','appeal'] },
  { id:'R-DELCH-6', courtId:'C-DEL-CHAN', category:'Chancery Rule', name:'Court of Chancery Rule 6 — Time', citation:'Ch. Ct. R. 6', summary:'Briefing schedules are accelerated; reply briefs 5 days.', effectiveDate:'2018-01-01', appliesTo:['C-DEL-CHAN'], tags:['timing'] },
];

const DEADLINE_RULES = [
  { id:'DR-ANSWER-FED',       name:'Answer to Complaint (Federal)', courtId:'*-Federal', trigger:'Service of complaint', offsetDays:21, method:'calendar', excludeWeekends:false, source:'FRCP 12(a)(1)(A)', category:'Pleadings' },
  { id:'DR-ANSWER-WAIVER-FED',name:'Answer after waiver of service (Federal)', courtId:'*-Federal', trigger:'Request waiver sent', offsetDays:60, method:'calendar', excludeWeekends:false, source:'FRCP 4(d)(3)', category:'Pleadings' },
  { id:'DR-MSJ-FED',          name:'Motion for Summary Judgment (Federal)', courtId:'*-Federal', trigger:'Close of discovery', offsetDays:30, method:'calendar', excludeWeekends:false, source:'FRCP 56(b)', category:'Dispositive' },
  { id:'DR-APPEAL-FED',       name:'Notice of Appeal (Federal civil)', courtId:'*-Federal', trigger:'Entry of final judgment', offsetDays:30, method:'calendar', excludeWeekends:false, source:'FRAP 4(a)(1)', category:'Appellate' },
  { id:'DR-CERT-PETITION',    name:'Petition for Certiorari', courtId:'C-SCOTUS', trigger:'Lower-court judgment', offsetDays:90, method:'calendar', excludeWeekends:false, source:'Sup. Ct. R. 13', category:'Appellate' },
  { id:'DR-ANSWER-NY',        name:'Answer (New York state)', courtId:'C-NYS-NYSUP', trigger:'Service of summons', offsetDays:20, method:'calendar', excludeWeekends:false, source:'CPLR § 3012(a)', category:'Pleadings' },
  { id:'DR-ANSWER-NY-MAIL',   name:'Answer (NY, served by mail)', courtId:'C-NYS-NYSUP', trigger:'Mailing of process', offsetDays:30, method:'calendar', excludeWeekends:false, source:'CPLR § 3012(c)', category:'Pleadings' },
  { id:'DR-MSJ-NY',           name:'Motion for Summary Judgment (NY)', courtId:'C-NYS-NYSUP', trigger:'Note of issue', offsetDays:120, method:'calendar', excludeWeekends:false, source:'CPLR § 3212(a)', category:'Dispositive' },
  { id:'DR-ANSWER-CA',        name:'Answer (California)', courtId:'C-CAS-LASUP', trigger:'Service of summons', offsetDays:30, method:'calendar', excludeWeekends:false, source:'CCP § 412.20(a)(3)', category:'Pleadings' },
  { id:'DR-MSJ-CA',           name:'Motion for Summary Judgment (CA)', courtId:'C-CAS-LASUP', trigger:'Trial date', offsetDays:-75, method:'court', excludeWeekends:true, source:'CCP § 437c(a)(2)', category:'Dispositive' },
  { id:'DR-APPEAL-NY',        name:'Notice of Appeal (NY state)', courtId:'C-NYS-NYSUP', trigger:'Entry of judgment', offsetDays:30, method:'calendar', excludeWeekends:false, source:'CPLR § 5513', category:'Appellate' },
  { id:'DR-DISC-INITIAL-FED', name:'Initial Disclosures (Federal)', courtId:'*-Federal', trigger:'Rule 26(f) conference', offsetDays:14, method:'calendar', excludeWeekends:false, source:'FRCP 26(a)(1)(C)', category:'Discovery' },
  { id:'DR-EXPERT-FED',       name:'Expert Disclosure (Federal)', courtId:'*-Federal', trigger:'Trial date', offsetDays:-90, method:'calendar', excludeWeekends:false, source:'FRCP 26(a)(2)(D)', category:'Discovery' },
];

const STANDING_ORDERS = [
  { id:'SO-SDNY-LSS-001', judgeId:'J-LSS', title:'Pre-Motion Letter Requirement', date:'2022-06-01', summary:'All dispositive motions require 3-page pre-motion letter. Meet-and-confer documented.' },
  { id:'SO-SDNY-LSS-002', judgeId:'J-LSS', title:'Discovery Disputes Protocol', date:'2023-02-15', summary:'Informal conference before any discovery motion. Joint letter required.' },
  { id:'SO-SDNY-JPO-001', judgeId:'J-JPO', title:'Individual Rules of Practice', date:'2024-01-01', summary:'Pre-motion letters, no surreplies, courtesy copies by 5pm day of filing.' },
  { id:'SO-SDNY-VAE-001', judgeId:'J-VAE', title:'Case Management Order Template', date:'2023-09-01', summary:'Early Rule 16 conference. ESI protocol at outset.' },
  { id:'SO-EDNY-MMB-001', judgeId:'J-MMB', title:'Individual Practices', date:'2023-04-01', summary:'Pre-motion letters. Stipulations for all extensions. Discovery disputes via letter.' },
  { id:'SO-NDCA-RSW-001', judgeId:'J-RSW', title:'Tentative Rulings Protocol', date:'2022-08-01', summary:'Tentative rulings posted Friday by 2pm. Parties may waive oral argument.' },
  { id:'SO-DDE-CFC-001',  judgeId:'J-CFC', title:'Litigation Funding Disclosure', date:'2022-04-18', summary:'Mandatory disclosure of all third-party funders within 30 days.' },
  { id:'SO-DDE-CFC-002',  judgeId:'J-CFC', title:'Patent Case Schedule', date:'2023-01-01', summary:'Standard Markman timeline. Early claim construction.' },
  { id:'SO-NDIL-RMD-001', judgeId:'J-RMD', title:'Case Management Procedures', date:'2023-01-01', summary:'LR 56.1 statements enforced strictly. Page limits inflexible.' },
  { id:'SO-DELCH-KRM-001',judgeId:'J-KRM', title:'Expedited Proceedings Guidance', date:'2023-03-01', summary:'Focused briefs. No string cites. Sanctions for excess pages.' },
  { id:'SO-LASC-SMW-001', judgeId:'J-SMW', title:'Department 1 Protocol', date:'2024-01-01', summary:'IC calendar. Meet-and-confer mandatory. Continuance disfavored.' },
];

const ADMISSIONS = [
  { id:'AD-001', attorneyId:'A-001', attorneyName:'M. Kirkland',   courtId:'C-USDC-SDNY', barNumber:'MK4892',     admittedDate:'2008-06-15', status:'Active',    goodStanding:true,  cleDue:'2026-09-30', cleHoursRequired:24, cleHoursCompleted:18, renewalDate:'2026-12-31', annualFee:400 },
  { id:'AD-002', attorneyId:'A-001', attorneyName:'M. Kirkland',   courtId:'C-USDC-EDNY', barNumber:'MK4892',     admittedDate:'2009-01-20', status:'Active',    goodStanding:true,  cleDue:'2026-09-30', cleHoursRequired:24, cleHoursCompleted:18, renewalDate:'2026-12-31', annualFee:400 },
  { id:'AD-003', attorneyId:'A-001', attorneyName:'M. Kirkland',   courtId:'C-USCA2',     barNumber:'2d-3421',    admittedDate:'2011-03-10', status:'Active',    goodStanding:true,  cleDue:null,         cleHoursRequired:0,  cleHoursCompleted:0,  renewalDate:null,        annualFee:250 },
  { id:'AD-004', attorneyId:'A-001', attorneyName:'M. Kirkland',   courtId:'C-NYS-NYSUP', barNumber:'4589241',    admittedDate:'2008-01-15', status:'Active',    goodStanding:true,  cleDue:'2026-05-31', cleHoursRequired:24, cleHoursCompleted:24, renewalDate:'2026-01-15', annualFee:375 },
  { id:'AD-005', attorneyId:'A-002', attorneyName:'L. Torres',     courtId:'C-USDC-SDNY', barNumber:'LT7812',     admittedDate:'2015-09-20', status:'Active',    goodStanding:true,  cleDue:'2026-12-31', cleHoursRequired:24, cleHoursCompleted:12, renewalDate:'2027-01-31', annualFee:400 },
  { id:'AD-006', attorneyId:'A-002', attorneyName:'L. Torres',     courtId:'C-NYS-NYSUP', barNumber:'5012489',    admittedDate:'2015-06-15', status:'Active',    goodStanding:true,  cleDue:'2026-05-31', cleHoursRequired:24, cleHoursCompleted:20, renewalDate:'2026-05-31', annualFee:375 },
  { id:'AD-007', attorneyId:'A-003', attorneyName:'A. Petrov',     courtId:'C-USDC-NDCA', barNumber:'AP9245',     admittedDate:'2018-04-12', status:'Active',    goodStanding:true,  cleDue:'2027-02-28', cleHoursRequired:25, cleHoursCompleted:22, renewalDate:'2027-02-28', annualFee:430 },
  { id:'AD-008', attorneyId:'A-003', attorneyName:'A. Petrov',     courtId:'C-CAS-LASUP', barNumber:'298456',     admittedDate:'2017-11-20', status:'Active',    goodStanding:true,  cleDue:'2026-05-31', cleHoursRequired:25, cleHoursCompleted:22, renewalDate:'2027-02-28', annualFee:515 },
  { id:'AD-009', attorneyId:'A-004', attorneyName:'R. Shah',       courtId:'C-USDC-DDE',  barNumber:'RS1120',     admittedDate:'2020-05-20', status:'Active',    goodStanding:true,  cleDue:'2026-06-30', cleHoursRequired:24, cleHoursCompleted:8,  renewalDate:'2026-07-01', annualFee:450 },
  { id:'AD-010', attorneyId:'A-005', attorneyName:'S. Okafor',     courtId:'C-USDC-NDIL', barNumber:'SO6723',     admittedDate:'2014-08-18', status:'Active',    goodStanding:true,  cleDue:'2026-06-30', cleHoursRequired:30, cleHoursCompleted:30, renewalDate:'2026-07-01', annualFee:400 },
  { id:'AD-011', attorneyId:'A-005', attorneyName:'S. Okafor',     courtId:'C-USCA9',     barNumber:'9c-9981',    admittedDate:'2019-10-15', status:'Active',    goodStanding:true,  cleDue:null,         cleHoursRequired:0,  cleHoursCompleted:0,  renewalDate:null,        annualFee:250 },
  { id:'AD-012', attorneyId:'A-006', attorneyName:'D. Chen',       courtId:'C-USDC-SDNY', barNumber:'DC8874',     admittedDate:'2021-02-18', status:'CLE Due',   goodStanding:true,  cleDue:'2026-05-15', cleHoursRequired:24, cleHoursCompleted:2,  renewalDate:'2026-06-01', annualFee:400 },
  { id:'AD-013', attorneyId:'A-007', attorneyName:'J. Ndiaye',     courtId:'C-SCOTUS',    barNumber:'SC-4512',    admittedDate:'2013-05-20', status:'Active',    goodStanding:true,  cleDue:null,         cleHoursRequired:0,  cleHoursCompleted:0,  renewalDate:null,        annualFee:200 },
  { id:'AD-014', attorneyId:'A-008', attorneyName:'E. Volkov',     courtId:'C-USDC-EDNY', barNumber:'EV2267',     admittedDate:'2019-07-12', status:'Pending',   goodStanding:false, cleDue:null,         cleHoursRequired:0,  cleHoursCompleted:0,  renewalDate:null,        annualFee:400 },
];

const PRO_HAC_VICE = [
  { id:'PHV-001', attorneyId:'A-001', attorneyName:'M. Kirkland', courtId:'C-USDC-NDCA', matterId:'M-2024-011', matterName:'Redstone Labs v. NovaCore', status:'Granted', filedDate:'2024-11-10', grantedDate:'2024-11-22', localCounsel:'Wilson & Mendoza LLP', fee:317, expiresDate:'2026-12-31' },
  { id:'PHV-002', attorneyId:'A-002', attorneyName:'L. Torres',   courtId:'C-USDC-DDE',  matterId:'M-2024-019', matterName:'Armada v. Orion Pharma', status:'Granted', filedDate:'2025-01-15', grantedDate:'2025-01-28', localCounsel:'Young Conaway',      fee:400, expiresDate:'2027-01-15' },
  { id:'PHV-003', attorneyId:'A-003', attorneyName:'A. Petrov',   courtId:'C-USDC-SDNY', matterId:'M-2025-003', matterName:'Singh v. Apex Capital',   status:'Pending', filedDate:'2026-03-28', grantedDate:null,        localCounsel:'Kirkland office',    fee:200, expiresDate:null },
  { id:'PHV-004', attorneyId:'A-005', attorneyName:'S. Okafor',   courtId:'C-USDC-SDNY', matterId:'M-2025-007', matterName:'Beacon Fund litigation',  status:'Pending', filedDate:'2026-04-01', grantedDate:null,        localCounsel:'Kirkland office',    fee:200, expiresDate:null },
  { id:'PHV-005', attorneyId:'A-004', attorneyName:'R. Shah',     courtId:'C-CAS-LASUP', matterId:'M-2024-028', matterName:'Westview MA settlement',  status:'Expired', filedDate:'2024-06-20', grantedDate:'2024-07-02', localCounsel:'Grant Finch PC',     fee:500, expiresDate:'2025-12-31' },
  { id:'PHV-006', attorneyId:'A-006', attorneyName:'D. Chen',     courtId:'C-DEL-CHAN',  matterId:'M-2025-012', matterName:'Helios v. Oversight Co.', status:'Denied',  filedDate:'2025-02-10', grantedDate:null,        localCounsel:'Morris Nichols',     fee:1000, expiresDate:null, denialReason:'Insufficient local counsel declaration' },
];

const FORMS = [
  { id:'F-FED-AO-121', courtId:'C-USDC-SDNY', code:'AO 121', name:'Notice of Filing of a Copyright Action', category:'Civil', version:'2023-10', fillable:true, fileType:'PDF', requiredBy:'28 U.S.C. § 1338',
    efileCompatible:true, pageCount:2, estMinutes:10, signaturesRequired:['Filing attorney'], attachments:['Copyright registration certificate'], instructions:'File within 30 days of commencement per SDNY L.R. 1.3.', tags:['copyright','ip'],
    fields:[
      { name:'caseNumber', label:'Case Number', type:'text', mergeFrom:'matter.caseNumber', required:true },
      { name:'plaintiff',  label:'Plaintiff',   type:'text', mergeFrom:'matter.plaintiff', required:true },
      { name:'defendant',  label:'Defendant',   type:'text', mergeFrom:'matter.defendant', required:true },
      { name:'regNumber',  label:'Registration Number', type:'text', required:true },
      { name:'workTitle',  label:'Title of Work', type:'text', required:true },
    ],
    versions:[{ version:'2023-10', date:'2023-10-15', note:'Updated registration field', current:true }, { version:'2020-06', date:'2020-06-01', note:'Added e-filing path', current:false }],
  },
  { id:'F-FED-AO-187', courtId:'C-USDC-SDNY', code:'AO 187', name:'Exhibit and Witness List', category:'Trial', version:'2022-06', fillable:true, fileType:'PDF', requiredBy:'FRCP 26(a)(3)',
    efileCompatible:true, pageCount:3, estMinutes:20, signaturesRequired:['Lead trial counsel'], attachments:['Exhibit copies if not previously produced'], instructions:'Serve 30 days before trial.', tags:['trial','witness'],
    fields:[
      { name:'caseNumber', label:'Case Number', type:'text', mergeFrom:'matter.caseNumber', required:true },
      { name:'trialDate',  label:'Trial Date',  type:'date', mergeFrom:'matter.trialDate', required:true },
    ],
    versions:[{ version:'2022-06', date:'2022-06-10', note:'Current', current:true }],
  },
  { id:'F-FED-AO-440', courtId:'C-USDC-SDNY', code:'AO 440', name:'Summons in a Civil Action', category:'Civil', version:'2015-06', fillable:true, fileType:'PDF', requiredBy:'FRCP 4',
    efileCompatible:false, pageCount:2, estMinutes:5, signaturesRequired:['Clerk of Court (issued)'], attachments:['Complaint copy'], instructions:'Issued by Clerk after complaint filing; must be served with complaint within 90 days.', tags:['service','pleadings'],
    fields:[
      { name:'caseNumber', label:'Case Number', type:'text', mergeFrom:'matter.caseNumber', required:true },
      { name:'defendant',  label:'Defendant', type:'text', mergeFrom:'matter.defendant', required:true },
      { name:'defendantAddress', label:'Defendant Address', type:'text', required:true },
      { name:'plaintiffCounsel', label:'Plaintiff Counsel (Name & Firm)', type:'text', mergeFrom:'matter.leadAttorney', required:true },
    ],
    versions:[{ version:'2015-06', date:'2015-06-01', note:'Current', current:true }],
  },
  { id:'F-FED-IFP',    courtId:'C-USDC-SDNY', code:'AO 239', name:'Application to Proceed In Forma Pauperis', category:'Civil', version:'2024-01', fillable:true, fileType:'PDF', requiredBy:'28 U.S.C. § 1915',
    efileCompatible:true, pageCount:4, estMinutes:30, signaturesRequired:['Applicant'], attachments:['Financial affidavit'], instructions:'Must be signed under penalty of perjury.', tags:['ifp','fees'],
    fields:[], versions:[{ version:'2024-01', date:'2024-01-02', note:'Current', current:true }],
  },
  { id:'F-FED-JS-44',  courtId:'C-USDC-SDNY', code:'JS-44',  name:'Civil Cover Sheet', category:'Civil', version:'2023-04', fillable:true, fileType:'PDF', requiredBy:'Local Rule',
    efileCompatible:true, pageCount:2, estMinutes:8, signaturesRequired:['Filing attorney'], attachments:[], instructions:'Required with every new civil case.', tags:['cover-sheet','new-case'],
    fields:[
      { name:'plaintiff',   label:'Plaintiff',   type:'text', mergeFrom:'matter.plaintiff', required:true },
      { name:'defendant',   label:'Defendant',   type:'text', mergeFrom:'matter.defendant', required:true },
      { name:'county',      label:'County of Residence', type:'text', required:true },
      { name:'natureOfSuit',label:'Nature of Suit', type:'select', required:true },
      { name:'jurisdiction',label:'Basis of Jurisdiction', type:'select', required:true },
    ],
    versions:[{ version:'2023-04', date:'2023-04-01', note:'Current', current:true }, { version:'2022-01', date:'2022-01-15', note:'Deprecated', current:false }],
  },
  { id:'F-FED-AO-398', courtId:'C-USDC-SDNY', code:'AO 398', name:'Notice of Lawsuit and Request for Waiver', category:'Civil', version:'2017-01', fillable:true, fileType:'PDF', requiredBy:'FRCP 4(d)',
    efileCompatible:true, pageCount:2, estMinutes:10, signaturesRequired:['Plaintiff or counsel'], attachments:['Complaint copy','Waiver form (AO 399)'], instructions:'Defendant has 30 days to return waiver (60 for outside U.S.).', tags:['service','waiver'],
    fields:[], versions:[{ version:'2017-01', date:'2017-01-01', note:'Current', current:true }],
  },
  { id:'F-SDNY-PHV',   courtId:'C-USDC-SDNY', code:'SDNY-1', name:'Application for Pro Hac Vice Admission', category:'Admission', version:'2024-03', fillable:true, fileType:'PDF', requiredBy:'SDNY L.R. 1.3(c)',
    efileCompatible:true, pageCount:3, estMinutes:25, signaturesRequired:['Applicant','Sponsor (local counsel)'], attachments:['Certificate of good standing','$200 fee receipt'], instructions:'Certificate of good standing must be dated within 30 days.', tags:['phv','admission'],
    fields:[
      { name:'applicantName', label:'Applicant Name', type:'text', required:true },
      { name:'homeBar',       label:'Home Bar', type:'text', required:true },
      { name:'localCounsel',  label:'Sponsor (Local Counsel)', type:'text', required:true },
      { name:'matterId',      label:'Matter / Case', type:'text', mergeFrom:'matter.id', required:true },
    ],
    versions:[{ version:'2024-03', date:'2024-03-01', note:'Fee updated to $200', current:true }, { version:'2022-01', date:'2022-01-01', note:'Prior $150 fee', current:false }],
  },
  { id:'F-NYSCEF-001', courtId:'C-NYS-NYSUP', code:'NYSCEF-1', name:'E-Filing Authorization Form', category:'E-filing', version:'2023-07', fillable:true, fileType:'PDF', requiredBy:'22 NYCRR 202.5-b',
    efileCompatible:true, pageCount:1, estMinutes:3, signaturesRequired:['Filing attorney'], attachments:[], instructions:'Filed once per matter to opt into NYSCEF.', tags:['e-filing','nyscef'],
    fields:[], versions:[{ version:'2023-07', date:'2023-07-01', note:'Current', current:true }],
  },
  { id:'F-NY-PLD-COMPLAINT', courtId:'C-NYS-NYSUP', code:'NY-COMPLAINT', name:'Verified Complaint Template', category:'Pleadings', version:'2024-01', fillable:false, fileType:'DOCX', requiredBy:'CPLR',
    efileCompatible:true, pageCount:null, estMinutes:120, signaturesRequired:['Plaintiff (verification)','Plaintiff counsel'], attachments:['Exhibits'], instructions:'Template; customize per claim. Include verification page.', tags:['pleadings','template'],
    fields:[], versions:[{ version:'2024-01', date:'2024-01-10', note:'Current', current:true }],
  },
  { id:'F-CA-CM-010',  courtId:'C-CAS-LASUP', code:'CM-010', name:'Civil Case Cover Sheet', category:'Civil', version:'2024-01', fillable:true, fileType:'PDF', requiredBy:'CRC 3.220',
    efileCompatible:true, pageCount:2, estMinutes:8, signaturesRequired:['Filing attorney'], attachments:[], instructions:'Required with every new LA County civil filing.', tags:['cover-sheet','new-case'],
    fields:[
      { name:'caseNumber',  label:'Case Number', type:'text', mergeFrom:'matter.caseNumber', required:false },
      { name:'plaintiff',   label:'Plaintiff',   type:'text', mergeFrom:'matter.plaintiff', required:true },
      { name:'defendant',   label:'Defendant',   type:'text', mergeFrom:'matter.defendant', required:true },
      { name:'caseType',    label:'Case Type', type:'select', required:true },
      { name:'complexity',  label:'Complex Case', type:'checkbox', required:false },
    ],
    versions:[{ version:'2024-01', date:'2024-01-01', note:'Current', current:true }],
  },
  { id:'F-CA-POS-010', courtId:'C-CAS-LASUP', code:'POS-010', name:'Proof of Service of Summons', category:'Service', version:'2022-01', fillable:true, fileType:'PDF', requiredBy:'CCP § 417.10',
    efileCompatible:true, pageCount:2, estMinutes:10, signaturesRequired:['Process server'], attachments:[], instructions:'Return within 60 days of summons issuance.', tags:['service'],
    fields:[], versions:[{ version:'2022-01', date:'2022-01-01', note:'Current', current:true }],
  },
  { id:'F-CA-CM-110',  courtId:'C-CAS-LASUP', code:'CM-110', name:'Case Management Statement', category:'Scheduling', version:'2024-01', fillable:true, fileType:'PDF', requiredBy:'CRC 3.725',
    efileCompatible:true, pageCount:4, estMinutes:25, signaturesRequired:['Trial counsel for each party'], attachments:[], instructions:'Due 15 days before CMC.', tags:['scheduling','cmc'],
    fields:[], versions:[{ version:'2024-01', date:'2024-01-01', note:'Current', current:true }],
  },
  { id:'F-DDE-PHV',    courtId:'C-USDC-DDE',  code:'DDE-PHV', name:'Motion for Admission Pro Hac Vice', category:'Admission', version:'2023-01', fillable:true, fileType:'PDF', requiredBy:'D. Del. L.R. 83.5',
    efileCompatible:true, pageCount:4, estMinutes:30, signaturesRequired:['Applicant','Sponsor'], attachments:['Certificate of good standing','$75 fee receipt'], instructions:'Sponsor must be DDE-admitted and sign.', tags:['phv','admission'],
    fields:[], versions:[{ version:'2023-01', date:'2023-01-01', note:'Current', current:true }],
  },
  { id:'F-NDCA-PHV',   courtId:'C-USDC-NDCA', code:'NDCA-PHV', name:'Application for Admission Pro Hac Vice', category:'Admission', version:'2024-01', fillable:true, fileType:'PDF', requiredBy:'Civil L.R. 11-3',
    efileCompatible:true, pageCount:3, estMinutes:25, signaturesRequired:['Applicant','Sponsor'], attachments:['Certificate of good standing','$317 fee receipt'], instructions:'Include ADR certification.', tags:['phv','admission'],
    fields:[], versions:[{ version:'2024-01', date:'2024-01-01', note:'Current', current:true }],
  },
  { id:'F-FED-CIV-CV', courtId:'C-USDC-SDNY', code:'AO 133', name:'Bill of Costs', category:'Post-judgment', version:'2020-07', fillable:true, fileType:'PDF', requiredBy:'FRCP 54(d)',
    efileCompatible:true, pageCount:3, estMinutes:40, signaturesRequired:['Prevailing counsel'], attachments:['Itemized costs','Verification'], instructions:'File within 14 days after judgment.', tags:['post-judgment','costs'],
    fields:[], versions:[{ version:'2020-07', date:'2020-07-01', note:'Current', current:true }, { version:'2018-01', date:'2018-01-01', note:'Deprecated', current:false }],
    deprecated:false,
  },
  // Deprecated example
  { id:'F-FED-AO-240-OLD', courtId:'C-USDC-SDNY', code:'AO 240', name:'Application to Proceed Without Prepaying Fees (deprecated)', category:'Civil', version:'2013-11', fillable:true, fileType:'PDF', requiredBy:'28 U.S.C. § 1915',
    efileCompatible:false, pageCount:2, estMinutes:15, signaturesRequired:[], attachments:[], instructions:'Superseded by AO 239 (2024-01).', tags:['ifp','deprecated'],
    deprecated:true, supersededBy:'F-FED-IFP',
    fields:[], versions:[{ version:'2013-11', date:'2013-11-01', note:'Deprecated — use AO 239', current:true }],
  },
];

const FORM_PACKS = [
  { id:'PK-NEWCASE-SDNY',      name:'New Civil Case — SDNY',            courtId:'C-USDC-SDNY', description:'Everything needed to commence a federal civil action in SDNY.', formIds:['F-FED-JS-44','F-FED-AO-440','F-FED-AO-398'], estMinutes:25, category:'New Case' },
  { id:'PK-NEWCASE-LA',        name:'New Civil Case — LA Superior',     courtId:'C-CAS-LASUP', description:'Standard bundle for a new LA Superior filing.',             formIds:['F-CA-CM-010','F-CA-POS-010','F-CA-CM-110'], estMinutes:45, category:'New Case' },
  { id:'PK-PHV-NATIONWIDE',    name:'Pro Hac Vice — All Federal',       courtId:null,          description:'PHV application templates for SDNY, NDCA, and DDE.',         formIds:['F-SDNY-PHV','F-NDCA-PHV','F-DDE-PHV'], estMinutes:80, category:'Admission' },
  { id:'PK-TRIAL-PREP-SDNY',   name:'Trial Prep — SDNY',                courtId:'C-USDC-SDNY', description:'Pretrial exhibits and witness list bundle.',                formIds:['F-FED-AO-187'], estMinutes:20, category:'Trial' },
  { id:'PK-POSTJUDGMENT-FED',  name:'Post-Judgment — Federal',          courtId:'C-USDC-SDNY', description:'Bill of costs and recovery package.',                       formIds:['F-FED-CIV-CV'], estMinutes:40, category:'Post-judgment' },
  { id:'PK-COPYRIGHT-SDNY',    name:'Copyright Filing — SDNY',          courtId:'C-USDC-SDNY', description:'Case commencement + AO 121 notice.',                        formIds:['F-FED-JS-44','F-FED-AO-440','F-FED-AO-121'], estMinutes:30, category:'New Case' },
];

// Form completion tracker — progress per matter × form
const FORM_COMPLETIONS = [
  { id:'FC-1', matterId:'M-2025-003', matterName:'Singh v. Apex Capital',  formId:'F-FED-JS-44',  status:'Complete', completedAt:'2026-04-10', completedBy:'L. Torres' },
  { id:'FC-2', matterId:'M-2025-003', matterName:'Singh v. Apex Capital',  formId:'F-FED-AO-440', status:'Complete', completedAt:'2026-04-11', completedBy:'L. Torres' },
  { id:'FC-3', matterId:'M-2025-003', matterName:'Singh v. Apex Capital',  formId:'F-SDNY-PHV',   status:'In Progress', completedAt:null, completedBy:'A. Petrov' },
  { id:'FC-4', matterId:'M-2025-007', matterName:'Beacon Fund litigation', formId:'F-FED-JS-44',  status:'Complete', completedAt:'2026-04-15', completedBy:'S. Okafor' },
  { id:'FC-5', matterId:'M-2025-007', matterName:'Beacon Fund litigation', formId:'F-FED-AO-440', status:'Not Started', completedAt:null, completedBy:null },
  { id:'FC-6', matterId:'M-2025-007', matterName:'Beacon Fund litigation', formId:'F-SDNY-PHV',   status:'In Progress', completedAt:null, completedBy:'S. Okafor' },
  { id:'FC-7', matterId:'M-2024-028', matterName:'Westview MA settlement', formId:'F-CA-CM-010',  status:'Complete', completedAt:'2024-06-18', completedBy:'R. Shah' },
  { id:'FC-8', matterId:'M-2024-028', matterName:'Westview MA settlement', formId:'F-CA-CM-110',  status:'Complete', completedAt:'2024-07-22', completedBy:'R. Shah' },
];

const FAVORITE_FORM_IDS = ['F-FED-JS-44','F-FED-AO-440','F-SDNY-PHV'];

const VENUE_ANALYTICS = [
  { courtId:'C-USDC-SDNY', avgDispositionDays:412, msjGrantRate:0.32, remandRate:0.14, settlementRate:0.58, trialRate:0.04, plaintiffVerdictRate:0.48, avgAwardK:1240, annualFilings:12480 },
  { courtId:'C-USDC-EDNY', avgDispositionDays:398, msjGrantRate:0.29, remandRate:0.12, settlementRate:0.61, trialRate:0.05, plaintiffVerdictRate:0.52, avgAwardK: 892, annualFilings:8640 },
  { courtId:'C-USDC-NDCA', avgDispositionDays:423, msjGrantRate:0.34, remandRate:0.09, settlementRate:0.56, trialRate:0.04, plaintiffVerdictRate:0.45, avgAwardK:1820, annualFilings:7920 },
  { courtId:'C-USDC-DDE',  avgDispositionDays:445, msjGrantRate:0.38, remandRate:0.06, settlementRate:0.49, trialRate:0.07, plaintiffVerdictRate:0.41, avgAwardK:3240, annualFilings:1840 },
  { courtId:'C-USDC-NDIL', avgDispositionDays:367, msjGrantRate:0.28, remandRate:0.11, settlementRate:0.63, trialRate:0.04, plaintiffVerdictRate:0.50, avgAwardK: 782, annualFilings:9820 },
  { courtId:'C-NYS-NYSUP', avgDispositionDays:312, msjGrantRate:0.30, remandRate:0.00, settlementRate:0.68, trialRate:0.02, plaintiffVerdictRate:0.54, avgAwardK: 640, annualFilings:24600 },
  { courtId:'C-CAS-LASUP', avgDispositionDays:478, msjGrantRate:0.24, remandRate:0.00, settlementRate:0.72, trialRate:0.02, plaintiffVerdictRate:0.58, avgAwardK: 720, annualFilings:31240 },
  { courtId:'C-DEL-CHAN',  avgDispositionDays:287, msjGrantRate:0.38, remandRate:0.00, settlementRate:0.41, trialRate:0.13, plaintiffVerdictRate:0.48, avgAwardK:5420, annualFilings:1240 },
];

const ALERTS = [
  { id:'AL-001', type:'CLE_DUE',      severity:'High',     message:'D. Chen CLE due 2026-05-15 — only 2/24 hrs completed', relatedId:'AD-012', createdAt:'2026-04-20' },
  { id:'AL-002', type:'PHV_PENDING',  severity:'Medium',   message:'Pro hac vice application for A. Petrov (M-2025-003) pending 25 days', relatedId:'PHV-003', createdAt:'2026-04-22' },
  { id:'AL-003', type:'PHV_EXPIRED',  severity:'High',     message:'R. Shah pro hac vice expired 2025-12-31 — file renewal if case ongoing', relatedId:'PHV-005', createdAt:'2026-04-01' },
  { id:'AL-004', type:'RENEWAL_DUE',  severity:'High',     message:'L. Torres NY bar renewal due 2026-05-31', relatedId:'AD-006', createdAt:'2026-04-15' },
  { id:'AL-005', type:'STANDING_ORDER',severity:'Info',    message:'DDE Judge Connolly updated third-party funding disclosure SO', relatedId:'SO-DDE-CFC-001', createdAt:'2026-04-18' },
  { id:'AL-006', type:'RULE_UPDATE',  severity:'Medium',   message:'Commercial Division Rule 17 amended 2026-04-01', relatedId:'R-COMM-17', createdAt:'2026-04-02' },
  { id:'AL-007', type:'PHV_DENIED',   severity:'Critical', message:'D. Chen pro hac vice denied in Del. Ch. (M-2025-012) — local counsel declaration insufficient', relatedId:'PHV-006', createdAt:'2026-04-11' },
];

const computeKpis = () => {
  const activeAdmissions = ADMISSIONS.filter(a => a.status === 'Active').length;
  const cleDueSoon = ADMISSIONS.filter(a => {
    if (!a.cleDue) return false;
    const days = Math.round((new Date(a.cleDue) - new Date()) / 86400000);
    return days <= 60 && days >= 0;
  }).length;
  const phvPending = PRO_HAC_VICE.filter(p => p.status === 'Pending').length;
  const criticalAlerts = ALERTS.filter(a => a.severity === 'Critical' || a.severity === 'High').length;
  return {
    courts:        COURTS.length,
    judges:        JUDGES.length,
    rules:         RULES.length,
    activeAdmissions,
    cleDueSoon,
    phvPending,
    forms:         FORMS.length,
    alerts:        ALERTS.length,
    criticalAlerts,
  };
};

window.JURISDICTIONS_DATA = {
  courts: COURTS,
  judges: JUDGES,
  rules: RULES,
  deadlineRules: DEADLINE_RULES,
  standingOrders: STANDING_ORDERS,
  admissions: ADMISSIONS,
  proHacVice: PRO_HAC_VICE,
  forms: FORMS,
  formPacks: FORM_PACKS,
  formCompletions: FORM_COMPLETIONS,
  favoriteFormIds: FAVORITE_FORM_IDS,
  venueAnalytics: VENUE_ANALYTICS,
  alerts: ALERTS,
  kpis: computeKpis(),
};

})();
