const T = window.ArbiterTokens;

// ── ACCENT ──
const doc = {
  blue: '#2563EB', blueBg: 'rgba(37,99,235,0.06)', blueText: '#2563EB',
};
window.docAccent = doc;

// ── FOLDER STRUCTURE ──
const DOC_FOLDERS = [
  { id: 'F-ROOT', name: 'All Documents', parent: null, icon: '◫', count: 42 },
  { id: 'F-001', name: 'Redstone v. Meridian', parent: 'F-ROOT', icon: '◰', count: 12, matterId: 'M-2024-0312' },
  { id: 'F-001A', name: 'Pleadings', parent: 'F-001', icon: '▤', count: 3 },
  { id: 'F-001B', name: 'Discovery', parent: 'F-001', icon: '▦', count: 4 },
  { id: 'F-001C', name: 'Expert Reports', parent: 'F-001', icon: '◈', count: 2 },
  { id: 'F-001D', name: 'Correspondence', parent: 'F-001', icon: '◔', count: 3 },
  { id: 'F-002', name: 'Pacific Shipping Antitrust', parent: 'F-ROOT', icon: '◰', count: 8, matterId: 'M-2024-0298' },
  { id: 'F-003', name: 'Thornton Estate', parent: 'F-ROOT', icon: '◰', count: 5, matterId: 'M-2024-0284' },
  { id: 'F-004', name: 'Blackwell IP', parent: 'F-ROOT', icon: '◰', count: 4, matterId: 'M-2024-0271' },
  { id: 'F-005', name: 'Chen v. Atlas', parent: 'F-ROOT', icon: '◰', count: 3, matterId: 'M-2024-0265' },
  { id: 'F-006', name: 'Sterling Pharma FCPA', parent: 'F-ROOT', icon: '◰', count: 4, matterId: 'M-2024-0259' },
  { id: 'F-007', name: 'Firm Templates', parent: 'F-ROOT', icon: '•', count: 6 },
  { id: 'F-008', name: 'Shared With Me', parent: 'F-ROOT', icon: '◑', count: 3 },
];

// ── EXPANDED DOCUMENT SET ──
const DOC_ITEMS = [
  // Redstone v. Meridian
  { id: 1, name: 'Opposition to MSJ — Draft v3', type: 'Brief', matter: 'Redstone v. Meridian', matterId: 'M-2024-0312', folderId: 'F-001A', author: 'M. Kirkland', modified: '2026-04-18', created: '2026-04-10', size: '2.4 MB', ext: 'DOCX', status: 'Draft', starred: true, locked: false, lockedBy: null, confidentiality: 'Confidential', permissions: ['M. Kirkland','L. Torres','J. Park'], tags: ['MSJ','opposition','damages'], linkedTasks: ['T-001'], linkedDeadlines: ['DL-004'],
    versions: [{v:'3.0',date:'Apr 18',author:'M. Kirkland',size:'2.4 MB',notes:'Incorporated damage model revisions'},{v:'2.0',date:'Apr 14',author:'L. Torres',size:'2.1 MB',notes:'Added exhibit references'},{v:'1.0',date:'Apr 10',author:'M. Kirkland',size:'1.8 MB',notes:'Initial draft'}],
    comments: [{id:'c1',author:'L. Torres',time:'Apr 18, 3:14 PM',text:'Section III argument is strong. Suggest adding the Harrington depo cite at p.87.',resolved:false},{id:'c2',author:'M. Kirkland',time:'Apr 18, 4:02 PM',text:'Good call. Added. Also strengthened the damages section with Mitchell\'s updated numbers.',resolved:false},{id:'c3',author:'J. Park',time:'Apr 17, 11:30 AM',text:'Cite-checked through Section II. All good.',resolved:true}],
    activity: [{action:'Edited',user:'M. Kirkland',time:'2h ago'},{action:'Commented',user:'L. Torres',time:'3h ago'},{action:'Version 2.0 created',user:'L. Torres',time:'Apr 14'},{action:'Created',user:'M. Kirkland',time:'Apr 10'}] },
  { id: 2, name: 'Harrington Deposition Transcript', type: 'Transcript', matter: 'Redstone v. Meridian', matterId: 'M-2024-0312', folderId: 'F-001B', author: 'Court Reporter', modified: '2026-04-15', created: '2026-04-15', size: '847 KB', ext: 'PDF', status: 'Final', starred: false, locked: true, lockedBy: 'System', confidentiality: 'Confidential', permissions: ['M. Kirkland','L. Torres','J. Park','S. Chen'], tags: ['deposition','Harrington','testimony','admissions'], linkedTasks: [], linkedDeadlines: [],
    versions: [{v:'1.0',date:'Apr 15',author:'Court Reporter',size:'847 KB',notes:'Certified transcript'}],
    comments: [{id:'c4',author:'M. Kirkland',time:'Apr 16, 9:15 AM',text:'Key admissions at pp. 87-92. Flag for trial prep.',resolved:false}],
    activity: [{action:'Commented',user:'M. Kirkland',time:'Apr 16'},{action:'Uploaded',user:'L. Torres',time:'Apr 15'}] },
  { id: 3, name: 'Economic Damages Report — Mitchell', type: 'Expert Report', matter: 'Redstone v. Meridian', matterId: 'M-2024-0312', folderId: 'F-001C', author: 'S. Mitchell', modified: '2026-04-02', created: '2026-03-28', size: '5.1 MB', ext: 'PDF', status: 'Final', starred: true, locked: true, lockedBy: 'M. Kirkland', confidentiality: 'Highly Confidential', permissions: ['M. Kirkland','L. Torres'], tags: ['expert','damages','Mitchell','$14.2M'], linkedTasks: ['T-014'], linkedDeadlines: ['DL-005'],
    versions: [{v:'2.0',date:'Apr 02',author:'S. Mitchell',size:'5.1 MB',notes:'Final with updated damage range'},{v:'1.0',date:'Mar 28',author:'S. Mitchell',size:'4.8 MB',notes:'Initial report'}],
    comments: [{id:'c5',author:'M. Kirkland',time:'Apr 03, 10:00 AM',text:'Range of $14.2M-$18.7M is well-supported. Daubert-proof methodology.',resolved:false}],
    activity: [{action:'Locked',user:'M. Kirkland',time:'Apr 03'},{action:'Version 2.0 uploaded',user:'S. Mitchell',time:'Apr 02'},{action:'Created',user:'S. Mitchell',time:'Mar 28'}] },
  { id: 4, name: 'Antitrust Complaint — Filed', type: 'Pleading', matter: 'Pacific Shipping Antitrust', matterId: 'M-2024-0298', folderId: 'F-002', author: 'S. Chen', modified: '2026-03-20', created: '2026-03-18', size: '1.2 MB', ext: 'PDF', status: 'Filed', starred: false, locked: true, lockedBy: 'System', confidentiality: 'Public', permissions: ['All'], tags: ['complaint','antitrust','Sherman Act'], linkedTasks: [], linkedDeadlines: [],
    versions: [{v:'1.0',date:'Mar 20',author:'S. Chen',size:'1.2 MB',notes:'Filed with court'}],
    comments: [], activity: [{action:'Filed',user:'S. Chen',time:'Mar 20'}] },
  { id: 5, name: 'Shipping Route Analysis 2019–2024', type: 'Exhibit', matter: 'Pacific Shipping Antitrust', matterId: 'M-2024-0298', folderId: 'F-002', author: 'L. Torres', modified: '2026-04-10', created: '2026-04-08', size: '18.3 MB', ext: 'XLSX', status: 'Final', starred: false, locked: false, lockedBy: null, confidentiality: 'Confidential', permissions: ['S. Chen','L. Torres','J. Park'], tags: ['exhibit','shipping routes','data analysis'], linkedTasks: ['T-002'], linkedDeadlines: ['DL-010'],
    versions: [{v:'2.0',date:'Apr 10',author:'L. Torres',size:'18.3 MB',notes:'Added 2024 data'},{v:'1.0',date:'Apr 08',author:'L. Torres',size:'15.1 MB',notes:'Initial compilation'}],
    comments: [{id:'c6',author:'S. Chen',time:'Apr 11, 2:30 PM',text:'Good work. The route overlap data in Tab 3 is exactly what we need for the pricing argument.',resolved:false}],
    activity: [{action:'Commented',user:'S. Chen',time:'Apr 11'},{action:'Version 2.0',user:'L. Torres',time:'Apr 10'}] },
  { id: 6, name: 'Thornton Will — Original 2018', type: 'Evidence', matter: 'Thornton Estate', matterId: 'M-2024-0284', folderId: 'F-003', author: 'Estate Records', modified: '2026-02-14', created: '2018-06-20', size: '340 KB', ext: 'PDF', status: 'Final', starred: true, locked: true, lockedBy: 'System', confidentiality: 'Confidential', permissions: ['R. Vasquez','M. Kirkland'], tags: ['will','estate','original','2018'], linkedTasks: [], linkedDeadlines: [],
    versions: [{v:'1.0',date:'Feb 14',author:'Estate Records',size:'340 KB',notes:'Original scanned document'}],
    comments: [], activity: [{action:'Uploaded',user:'R. Vasquez',time:'Feb 14'}] },
  { id: 7, name: 'Expert Witness CV — Dr. Patel', type: 'Expert Report', matter: 'Thornton Estate', matterId: 'M-2024-0284', folderId: 'F-003', author: 'R. Vasquez', modified: '2026-04-01', created: '2026-03-28', size: '120 KB', ext: 'PDF', status: 'Final', starred: false, locked: false, lockedBy: null, confidentiality: 'Confidential', permissions: ['R. Vasquez'], tags: ['expert','CV','Patel'], linkedTasks: ['T-003'], linkedDeadlines: ['DL-012'],
    versions: [{v:'1.0',date:'Apr 01',author:'R. Vasquez',size:'120 KB',notes:'Updated CV'}],
    comments: [], activity: [{action:'Uploaded',user:'R. Vasquez',time:'Apr 01'}] },
  { id: 8, name: 'Patent Claim Chart — Blackwell v. Orion', type: 'Analysis', matter: 'Blackwell IP', matterId: 'M-2024-0271', folderId: 'F-004', author: 'J. Park', modified: '2026-04-16', created: '2026-04-12', size: '780 KB', ext: 'XLSX', status: 'Draft', starred: true, locked: false, lockedBy: null, confidentiality: 'Confidential', permissions: ['M. Kirkland','J. Park'], tags: ['patent','claim chart','prior art'], linkedTasks: ['T-004'], linkedDeadlines: ['DL-014'],
    versions: [{v:'2.0',date:'Apr 16',author:'J. Park',size:'780 KB',notes:'Added 12 new prior art references'},{v:'1.0',date:'Apr 12',author:'J. Park',size:'540 KB',notes:'Initial chart'}],
    comments: [{id:'c7',author:'M. Kirkland',time:'Apr 17, 8:45 AM',text:'References 14-26 are strong. Prioritize those for the invalidity argument.',resolved:false}],
    activity: [{action:'Commented',user:'M. Kirkland',time:'Apr 17'},{action:'Version 2.0',user:'J. Park',time:'Apr 16'}] },
  { id: 9, name: 'Settlement Offer — Atlas Financial', type: 'Correspondence', matter: 'Chen v. Atlas', matterId: 'M-2024-0265', folderId: 'F-005', author: 'Opposing Counsel', modified: '2026-04-17', created: '2026-04-17', size: '95 KB', ext: 'PDF', status: 'Review', starred: true, locked: false, lockedBy: null, confidentiality: 'Highly Confidential', permissions: ['A. Petrov','M. Kirkland'], tags: ['settlement','offer','$4.2M'], linkedTasks: ['T-005'], linkedDeadlines: ['DL-015'],
    versions: [{v:'1.0',date:'Apr 17',author:'Opposing Counsel',size:'95 KB',notes:'Received via email'}],
    comments: [{id:'c8',author:'A. Petrov',time:'Apr 17, 4:30 PM',text:'$4.2M offer is below our floor. Recommend counter at $8M.',resolved:false},{id:'c9',author:'M. Kirkland',time:'Apr 18, 9:00 AM',text:'Agreed. Draft counter-proposal by EOD Wednesday.',resolved:false}],
    activity: [{action:'Commented',user:'M. Kirkland',time:'Apr 18'},{action:'Commented',user:'A. Petrov',time:'Apr 17'},{action:'Received',user:'A. Petrov',time:'Apr 17'}] },
  { id: 10, name: 'FCPA Compliance Memo — Sterling', type: 'Memo', matter: 'Sterling Pharma', matterId: 'M-2024-0259', folderId: 'F-006', author: 'S. Chen', modified: '2026-04-19', created: '2026-04-15', size: '3.2 MB', ext: 'DOCX', status: 'Draft', starred: false, locked: false, lockedBy: null, confidentiality: 'Highly Confidential — AEO', permissions: ['S. Chen','M. Kirkland'], tags: ['FCPA','compliance','memo'], linkedTasks: ['T-006'], linkedDeadlines: ['DL-017'],
    versions: [{v:'2.0',date:'Apr 19',author:'S. Chen',size:'3.2 MB',notes:'Added Q1 2026 findings'},{v:'1.0',date:'Apr 15',author:'S. Chen',size:'2.8 MB',notes:'Initial draft'}],
    comments: [], activity: [{action:'Edited',user:'S. Chen',time:'Apr 19'}] },
  { id: 11, name: 'Financial Audit Report Q3 2025', type: 'Production', matter: 'Sterling Pharma', matterId: 'M-2024-0259', folderId: 'F-006', author: 'S. Chen', modified: '2026-04-20', created: '2026-04-20', size: '12.8 MB', ext: 'PDF', status: 'Final', starred: false, locked: false, lockedBy: null, confidentiality: 'Confidential', permissions: ['S. Chen','L. Torres'], tags: ['audit','financial','Q3 2025'], linkedTasks: ['T-006'], linkedDeadlines: [],
    versions: [{v:'1.0',date:'Apr 20',author:'S. Chen',size:'12.8 MB',notes:'Uploaded from client'}],
    comments: [], activity: [{action:'Uploaded',user:'S. Chen',time:'Today'}] },
  { id: 12, name: 'Eminent Domain Valuation Report', type: 'Expert Report', matter: 'Harbor District', matterId: 'M-2024-0243', folderId: 'F-ROOT', author: 'R. Vasquez', modified: '2026-04-08', created: '2026-04-05', size: '6.7 MB', ext: 'PDF', status: 'Final', starred: false, locked: false, lockedBy: null, confidentiality: 'Confidential', permissions: ['R. Vasquez'], tags: ['valuation','eminent domain','expert'], linkedTasks: ['T-007'], linkedDeadlines: [],
    versions: [{v:'1.0',date:'Apr 08',author:'R. Vasquez',size:'6.7 MB',notes:'Final report from appraiser'}],
    comments: [], activity: [{action:'Uploaded',user:'R. Vasquez',time:'Apr 08'}] },
  { id: 13, name: 'Merger Agreement — NovaTech/Apex', type: 'Contract', matter: 'NovaTech Merger', matterId: 'M-2024-0230', folderId: 'F-ROOT', author: 'A. Petrov', modified: '2026-03-28', created: '2026-03-25', size: '4.5 MB', ext: 'PDF', status: 'Final', starred: false, locked: true, lockedBy: 'A. Petrov', confidentiality: 'Highly Confidential', permissions: ['A. Petrov','M. Kirkland'], tags: ['merger','agreement','NovaTech'], linkedTasks: ['T-008'], linkedDeadlines: [],
    versions: [{v:'1.0',date:'Mar 28',author:'A. Petrov',size:'4.5 MB',notes:'Executed version'}],
    comments: [], activity: [{action:'Locked',user:'A. Petrov',time:'Mar 28'}] },
  { id: 14, name: 'Class Certification Motion', type: 'Brief', matter: 'Greenfield Environmental', matterId: 'M-2024-0218', folderId: 'F-ROOT', author: 'M. Kirkland', modified: '2026-04-14', created: '2026-04-10', size: '1.9 MB', ext: 'DOCX', status: 'Filed', starred: true, locked: true, lockedBy: 'System', confidentiality: 'Public', permissions: ['All'], tags: ['class cert','motion','environmental'], linkedTasks: ['T-009'], linkedDeadlines: ['DL-011'],
    versions: [{v:'3.0',date:'Apr 14',author:'M. Kirkland',size:'1.9 MB',notes:'Filed version'},{v:'2.0',date:'Apr 12',author:'M. Kirkland',size:'1.8 MB',notes:'Final review edits'},{v:'1.0',date:'Apr 10',author:'M. Kirkland',size:'1.6 MB',notes:'Initial draft'}],
    comments: [], activity: [{action:'Filed',user:'M. Kirkland',time:'Apr 14'}] },
  { id: 15, name: 'Privilege Log — All Matters Q1', type: 'Log', matter: 'Firm-wide', matterId: null, folderId: 'F-ROOT', author: 'J. Park', modified: '2026-04-12', created: '2026-04-01', size: '2.1 MB', ext: 'XLSX', status: 'Final', starred: false, locked: false, lockedBy: null, confidentiality: 'Internal', permissions: ['All Attorneys'], tags: ['privilege log','Q1','firm-wide'], linkedTasks: [], linkedDeadlines: [],
    versions: [{v:'1.0',date:'Apr 12',author:'J. Park',size:'2.1 MB',notes:'Q1 2026 compilation'}],
    comments: [], activity: [{action:'Uploaded',user:'J. Park',time:'Apr 12'}] },
  // Additional docs for depth
  { id: 16, name: 'Motion to Compel — Brief', type: 'Brief', matter: 'Redstone v. Meridian', matterId: 'M-2024-0312', folderId: 'F-001A', author: 'M. Kirkland', modified: '2026-04-08', created: '2026-04-05', size: '1.1 MB', ext: 'DOCX', status: 'Filed', starred: false, locked: true, lockedBy: 'System', confidentiality: 'Public', permissions: ['All'], tags: ['motion','compel','discovery'], linkedTasks: [], linkedDeadlines: [],
    versions: [{v:'1.0',date:'Apr 08',author:'M. Kirkland',size:'1.1 MB',notes:'Filed and granted Apr 10'}],
    comments: [], activity: [{action:'Filed',user:'M. Kirkland',time:'Apr 08'}] },
  { id: 17, name: 'Interrogatory Responses — Set 3 (Draft)', type: 'Discovery', matter: 'Redstone v. Meridian', matterId: 'M-2024-0312', folderId: 'F-001B', author: 'L. Torres', modified: '2026-04-20', created: '2026-04-18', size: '1.6 MB', ext: 'DOCX', status: 'Draft', starred: false, locked: false, lockedBy: null, confidentiality: 'Confidential', permissions: ['M. Kirkland','L. Torres'], tags: ['interrogatory','Set 3','discovery'], linkedTasks: ['T-001'], linkedDeadlines: ['DL-001'],
    versions: [{v:'1.0',date:'Apr 20',author:'L. Torres',size:'1.6 MB',notes:'Initial draft — due Apr 21'}],
    comments: [{id:'c10',author:'L. Torres',time:'Today, 10:15 AM',text:'Draft ready for partner review. Due tomorrow.',resolved:false}],
    activity: [{action:'Created',user:'L. Torres',time:'Today'}] },
  { id: 18, name: 'Deposition Outline — J. Harmon', type: 'Memo', matter: 'Pacific Shipping Antitrust', matterId: 'M-2024-0298', folderId: 'F-002', author: 'L. Torres', modified: '2026-04-20', created: '2026-04-19', size: '420 KB', ext: 'DOCX', status: 'Draft', starred: false, locked: false, lockedBy: null, confidentiality: 'Work Product', permissions: ['S. Chen','L. Torres'], tags: ['deposition','outline','Harmon'], linkedTasks: ['T-002'], linkedDeadlines: ['DL-010'],
    versions: [{v:'1.0',date:'Apr 20',author:'L. Torres',size:'420 KB',notes:'Initial outline'}],
    comments: [], activity: [{action:'Created',user:'L. Torres',time:'Today'}] },
  { id: 19, name: 'Source Code Protection Brief (Draft)', type: 'Brief', matter: 'Blackwell IP', matterId: 'M-2024-0271', folderId: 'F-004', author: 'J. Park', modified: '2026-04-19', created: '2026-04-18', size: '890 KB', ext: 'DOCX', status: 'Draft', starred: false, locked: false, lockedBy: null, confidentiality: 'Confidential', permissions: ['M. Kirkland','J. Park'], tags: ['source code','motion to compel','trade secret'], linkedTasks: ['T-011'], linkedDeadlines: ['DL-014'],
    versions: [{v:'1.0',date:'Apr 19',author:'J. Park',size:'890 KB',notes:'Initial draft'}],
    comments: [], activity: [{action:'Created',user:'J. Park',time:'Apr 19'}] },
  { id: 20, name: 'Mediation Statement (Draft)', type: 'Brief', matter: 'Chen v. Atlas', matterId: 'M-2024-0265', folderId: 'F-005', author: 'A. Petrov', modified: '2026-04-20', created: '2026-04-20', size: '280 KB', ext: 'DOCX', status: 'Draft', starred: false, locked: false, lockedBy: null, confidentiality: 'Confidential', permissions: ['A. Petrov','M. Kirkland'], tags: ['mediation','settlement','brief'], linkedTasks: ['T-005'], linkedDeadlines: ['DL-015'],
    versions: [{v:'1.0',date:'Apr 20',author:'A. Petrov',size:'280 KB',notes:'Skeleton draft — sections TBD'}],
    comments: [], activity: [{action:'Created',user:'A. Petrov',time:'Today'}] },
];

// ── TEMPLATES ──
const DOC_TEMPLATES = [
  { id: 'TPL-1', name: 'Motion Brief Template', type: 'Brief', ext: 'DOCX', author: 'Firm Standard', lastUsed: 'Apr 14', usageCount: 34 },
  { id: 'TPL-2', name: 'Deposition Outline Template', type: 'Memo', ext: 'DOCX', author: 'Firm Standard', lastUsed: 'Apr 19', usageCount: 28 },
  { id: 'TPL-3', name: 'Engagement Letter', type: 'Contract', ext: 'DOCX', author: 'Firm Standard', lastUsed: 'Apr 01', usageCount: 52 },
  { id: 'TPL-4', name: 'Privilege Log Template', type: 'Log', ext: 'XLSX', author: 'J. Park', lastUsed: 'Apr 12', usageCount: 15 },
  { id: 'TPL-5', name: 'Expert Designation Letter', type: 'Correspondence', ext: 'DOCX', author: 'Firm Standard', lastUsed: 'Mar 28', usageCount: 19 },
  { id: 'TPL-6', name: 'Settlement Agreement Template', type: 'Contract', ext: 'DOCX', author: 'Firm Standard', lastUsed: 'Apr 10', usageCount: 41 },
];

// ── SAVED SEARCHES ──
const DOC_SAVED_SEARCHES = [
  { id: 'SS-1', name: 'All drafts needing review', query: 'status:Draft', resultCount: 7 },
  { id: 'SS-2', name: 'Redstone hot documents', query: 'matter:"Redstone" tag:hot', resultCount: 3 },
  { id: 'SS-3', name: 'My recent edits', query: 'author:"M. Kirkland" modified:>7d', resultCount: 5 },
  { id: 'SS-4', name: 'Highly confidential docs', query: 'confidentiality:"Highly Confidential"', resultCount: 4 },
  { id: 'SS-5', name: 'Filed this month', query: 'status:Filed modified:month', resultCount: 3 },
];

// ── STORAGE ANALYTICS ──
const DOC_ANALYTICS = {
  totalDocs: 42, totalSize: '1.2 GB', avgVersion: 1.8,
  byMatter: [
    { name: 'Redstone v. Meridian', count: 12, size: '68 MB' },
    { name: 'Pacific Shipping', count: 8, size: '42 MB' },
    { name: 'Sterling Pharma', count: 4, size: '38 MB' },
    { name: 'Thornton Estate', count: 5, size: '12 MB' },
    { name: 'Blackwell IP', count: 4, size: '8 MB' },
    { name: 'Other', count: 9, size: '32 MB' },
  ],
  byType: [
    { name: 'Brief', count: 8 }, { name: 'Expert Report', count: 4 }, { name: 'Correspondence', count: 3 },
    { name: 'Exhibit', count: 3 }, { name: 'Memo', count: 3 }, { name: 'Contract', count: 2 },
    { name: 'Discovery', count: 5 }, { name: 'Other', count: 14 },
  ],
  recentActivity: [
    { action: 'Uploaded', doc: 'Financial Audit Report Q3 2025', user: 'S. Chen', time: '20m ago' },
    { action: 'Edited', doc: 'Opposition to MSJ — Draft v3', user: 'M. Kirkland', time: '2h ago' },
    { action: 'Commented', doc: 'Patent Claim Chart', user: 'M. Kirkland', time: '3h ago' },
    { action: 'Created', doc: 'Interrogatory Responses — Set 3', user: 'L. Torres', time: '5h ago' },
    { action: 'Version 2.0', doc: 'Shipping Route Analysis', user: 'L. Torres', time: '10h ago' },
    { action: 'Filed', doc: 'Class Certification Motion', user: 'M. Kirkland', time: 'Apr 14' },
  ],
};

// ── WORKSPACES (Team drives / Departments / Shared scopes) ──
const DOC_WORKSPACES = [
  { id: 'WS-PRIV',  name: 'My Workspace',           kind: 'Personal',   members: 1,  docs: 18, size: '92 MB',   icon: '◉', desc: 'Private drafts and scratch files.' },
  { id: 'WS-LIT',   name: 'Litigation — Complex',   kind: 'Department', members: 14, docs: 482, size: '5.4 GB',  icon: '◇', desc: 'Complex litigation team drive.' },
  { id: 'WS-CORP',  name: 'Corporate / M&A',         kind: 'Department', members: 9,  docs: 218, size: '3.1 GB',  icon: '◈', desc: 'M&A and corporate transactions.' },
  { id: 'WS-IP',    name: 'Intellectual Property',   kind: 'Department', members: 6,  docs: 143, size: '1.8 GB',  icon: '◆', desc: 'IP prosecution and litigation.' },
  { id: 'WS-COMPL', name: 'Compliance / Regulatory', kind: 'Department', members: 5,  docs: 96,  size: '840 MB',  icon: 'flag', desc: 'FCPA, SEC, and internal investigations.' },
  { id: 'WS-TRN',   name: 'Redstone Trial Team',     kind: 'Matter',     members: 7,  docs: 124, size: '1.4 GB',  icon: '▦', desc: 'Shared trial-prep workspace.' },
  { id: 'WS-SHARE', name: 'Shared With Me',          kind: 'Shared',     members: 0,  docs: 11,  size: '64 MB',   icon: '◑', desc: 'External and cross-team shares.' },
  { id: 'WS-ARCH',  name: 'Archive 2024',            kind: 'Archive',    members: 42, docs: 1203, size: '12.3 GB', icon: '◫', desc: 'Read-only archived matters.' },
];

// ── LEGAL HOLDS ──
const DOC_LEGAL_HOLDS = [
  { id: 'LH-001', name: 'Redstone v. Meridian — Litigation Hold',   matter: 'Redstone v. Meridian',      custodians: 14, docs: 482, status: 'Active',     issued: '2024-04-12', lastReminder: '2026-04-01', owner: 'M. Kirkland' },
  { id: 'LH-002', name: 'Pacific Shipping Antitrust — DOJ Subpoena', matter: 'Pacific Shipping Antitrust', custodians: 9,  docs: 218, status: 'Active',     issued: '2024-03-08', lastReminder: '2026-03-15', owner: 'S. Chen' },
  { id: 'LH-003', name: 'Sterling Pharma FCPA Investigation',        matter: 'Sterling Pharma',            custodians: 11, docs: 96,  status: 'Active',     issued: '2025-01-14', lastReminder: '2026-04-10', owner: 'S. Chen' },
  { id: 'LH-004', name: 'Greenfield Environmental Class Action',     matter: 'Greenfield Environmental',   custodians: 22, docs: 341, status: 'Active',     issued: '2025-06-20', lastReminder: '2026-03-28', owner: 'M. Kirkland' },
  { id: 'LH-005', name: 'Thornton Estate Contest',                   matter: 'Thornton Estate',            custodians: 4,  docs: 58,  status: 'Released',   issued: '2023-11-04', lastReminder: '2026-02-20', owner: 'R. Vasquez' },
  { id: 'LH-006', name: 'Chen v. Atlas Financial',                   matter: 'Chen v. Atlas',              custodians: 7,  docs: 142, status: 'Active',     issued: '2024-09-15', lastReminder: '2026-04-05', owner: 'A. Petrov' },
];

// ── RETENTION POLICIES ──
const DOC_RETENTION_POLICIES = [
  { id: 'RP-1', name: 'Closed Matter — 7 years',       trigger: 'Matter closed',      action: 'Archive then delete', durationYrs: 7, appliesTo: 'All matter docs',         docs: 2841, status: 'Active' },
  { id: 'RP-2', name: 'Engagement Letters — Permanent', trigger: 'Document created',   action: 'Archive',             durationYrs: null, appliesTo: 'type:Engagement Letter', docs: 312,  status: 'Active' },
  { id: 'RP-3', name: 'Drafts — 30 days post-final',    trigger: 'Final version created', action: 'Delete',           durationYrs: 0,    appliesTo: 'status:Draft',           docs: 148,  status: 'Active' },
  { id: 'RP-4', name: 'Privileged Comms — 10 years',    trigger: 'Matter closed',      action: 'Archive',             durationYrs: 10,   appliesTo: 'tag:privileged',         docs: 934,  status: 'Active' },
  { id: 'RP-5', name: 'Marketing Materials — 3 years',  trigger: 'Document created',   action: 'Delete',              durationYrs: 3,    appliesTo: 'folder:Marketing',       docs: 64,   status: 'Draft' },
];

// ── AUDIT TRAIL (recent) ──
const DOC_AUDIT_TRAIL = [
  { id: 'A-001', when: '2026-04-21 10:42', user: 'M. Kirkland', action: 'Downloaded',     doc: 'Economic Damages Report — Mitchell', ip: '10.12.4.88',  severity: 'Info' },
  { id: 'A-002', when: '2026-04-21 10:30', user: 'L. Torres',   action: 'Edited',         doc: 'Interrogatory Responses — Set 3',    ip: '10.12.4.92',  severity: 'Info' },
  { id: 'A-003', when: '2026-04-21 09:55', user: 'J. Park',     action: 'Shared link',    doc: 'Patent Claim Chart — Blackwell',     ip: '10.12.4.14',  severity: 'Warn' },
  { id: 'A-004', when: '2026-04-21 09:14', user: 'S. Chen',     action: 'Uploaded',       doc: 'Financial Audit Report Q3 2025',     ip: '10.12.4.37',  severity: 'Info' },
  { id: 'A-005', when: '2026-04-20 17:02', user: 'External',    action: 'Access denied',  doc: 'Settlement Offer — Atlas Financial', ip: '73.14.221.8', severity: 'Alert' },
  { id: 'A-006', when: '2026-04-20 16:48', user: 'A. Petrov',   action: 'Locked',         doc: 'Merger Agreement — NovaTech/Apex',   ip: '10.12.4.101', severity: 'Info' },
  { id: 'A-007', when: '2026-04-20 15:20', user: 'R. Vasquez',  action: 'Version created',doc: 'Eminent Domain Valuation Report',    ip: '10.12.4.55',  severity: 'Info' },
  { id: 'A-008', when: '2026-04-20 14:03', user: 'M. Kirkland', action: 'Changed ACL',    doc: 'Opposition to MSJ — Draft v3',       ip: '10.12.4.88',  severity: 'Warn' },
  { id: 'A-009', when: '2026-04-20 11:44', user: 'L. Torres',   action: 'Commented',      doc: 'Shipping Route Analysis 2019–2024',  ip: '10.12.4.92',  severity: 'Info' },
  { id: 'A-010', when: '2026-04-20 09:12', user: 'J. Park',     action: 'Signed out',     doc: 'Source Code Protection Brief (Draft)', ip: '10.12.4.14', severity: 'Info' },
  { id: 'A-011', when: '2026-04-19 18:30', user: 'S. Chen',     action: 'DLP block',      doc: '[redacted] SSN found in export',     ip: '10.12.4.37',  severity: 'Alert' },
  { id: 'A-012', when: '2026-04-19 16:08', user: 'M. Kirkland', action: 'Restored',       doc: 'Class Certification Motion v2',      ip: '10.12.4.88',  severity: 'Info' },
];

// ── CHECKED OUT DOCS (version control) ──
const DOC_CHECKOUTS = [
  { id: 'CO-1', docId: 3,  docName: 'Economic Damages Report — Mitchell',  lockedBy: 'M. Kirkland', since: '2026-04-03 10:00', notes: 'Trial prep review' },
  { id: 'CO-2', docId: 13, docName: 'Merger Agreement — NovaTech/Apex',     lockedBy: 'A. Petrov',   since: '2026-03-28 14:22', notes: 'Final redline' },
  { id: 'CO-3', docId: 2,  docName: 'Harrington Deposition Transcript',    lockedBy: 'System',      since: '2026-04-15 00:00', notes: 'Immutable — certified' },
  { id: 'CO-4', docId: 6,  docName: 'Thornton Will — Original 2018',       lockedBy: 'System',      since: '2026-02-14 00:00', notes: 'Immutable — evidence' },
  { id: 'CO-5', docId: 14, docName: 'Class Certification Motion',          lockedBy: 'System',      since: '2026-04-14 00:00', notes: 'Filed — read-only' },
  { id: 'CO-6', docId: 16, docName: 'Motion to Compel — Brief',             lockedBy: 'System',      since: '2026-04-08 00:00', notes: 'Filed — read-only' },
];

// ── APPROVALS / SIGNOFFS ──
const DOC_APPROVALS = [
  { id: 'AP-1', docId: 1,  doc: 'Opposition to MSJ — Draft v3',           stage: 'Partner Review',  requester: 'M. Kirkland', approver: 'S. Chen',     status: 'Pending',  due: '2026-04-22' },
  { id: 'AP-2', docId: 17, doc: 'Interrogatory Responses — Set 3 (Draft)', stage: 'Partner Review',  requester: 'L. Torres',   approver: 'M. Kirkland', status: 'Pending',  due: '2026-04-21' },
  { id: 'AP-3', docId: 19, doc: 'Source Code Protection Brief (Draft)',   stage: 'Peer Review',     requester: 'J. Park',     approver: 'M. Kirkland', status: 'Pending',  due: '2026-04-23' },
  { id: 'AP-4', docId: 20, doc: 'Mediation Statement (Draft)',            stage: 'Partner Review',  requester: 'A. Petrov',   approver: 'M. Kirkland', status: 'Pending',  due: '2026-04-24' },
  { id: 'AP-5', docId: 10, doc: 'FCPA Compliance Memo — Sterling',        stage: 'Compliance',      requester: 'S. Chen',     approver: 'S. Chen',     status: 'Approved', due: '2026-04-19' },
  { id: 'AP-6', docId: 8,  doc: 'Patent Claim Chart — Blackwell v. Orion', stage: 'Peer Review',    requester: 'J. Park',     approver: 'M. Kirkland', status: 'Changes', due: '2026-04-20' },
];

// ── WORKFLOWS / AUTOMATION ──
const DOC_WORKFLOWS = [
  { id: 'WF-1', name: 'New filing → eSign → Serve',        trigger: 'Status: Filed',          runs: 34, lastRun: '2026-04-14', status: 'Active', steps: ['Generate cover sheet','Send for eSign','Email service list','Log to PACER'] },
  { id: 'WF-2', name: 'Draft → Redline → Partner Review',  trigger: 'Comment: @review',       runs: 128, lastRun: '2026-04-20', status: 'Active', steps: ['Generate redline','Assign reviewer','Send Slack nudge'] },
  { id: 'WF-3', name: 'Discovery production OCR pipeline', trigger: 'Folder: /discovery/',    runs: 52, lastRun: '2026-04-19', status: 'Active', steps: ['OCR scan','Bates stamp','Privilege screen','Produce to vendor'] },
  { id: 'WF-4', name: 'Expert report → Daubert checklist', trigger: 'Type: Expert Report',    runs: 18, lastRun: '2026-04-02', status: 'Active', steps: ['Check CV','Validate methodology','Cross-reference exhibits'] },
  { id: 'WF-5', name: 'Closed matter → Archive + RP-1',    trigger: 'Matter closed',          runs: 7,  lastRun: '2026-03-31', status: 'Active', steps: ['Apply retention','Snapshot','Move to WS-ARCH','Notify billing'] },
  { id: 'WF-6', name: 'Contract renewal → Alert',          trigger: '30d before expiry',      runs: 23, lastRun: '2026-04-12', status: 'Active', steps: ['Check contract DB','Create task','Notify owner'] },
  { id: 'WF-7', name: 'DLP: credit-card detection',        trigger: 'Upload',                 runs: 912, lastRun: '2026-04-21', status: 'Active', steps: ['Scan for PCI patterns','Block if found','Notify DLP admin'] },
];

// ── OCR PIPELINES ──
const DOC_OCR_PIPELINES = [
  { id: 'OC-1', name: 'Production — Native PDF',     queue: 12, avgTimeSec: 4.2,  accuracy: 99.1, lastRun: '2026-04-21 10:14' },
  { id: 'OC-2', name: 'Production — Scanned TIFF',   queue: 48, avgTimeSec: 11.6, accuracy: 96.8, lastRun: '2026-04-21 09:42' },
  { id: 'OC-3', name: 'Handwritten exhibit OCR',     queue: 3,  avgTimeSec: 28.4, accuracy: 88.3, lastRun: '2026-04-20 16:10' },
  { id: 'OC-4', name: 'Foreign-language (zh-Hant)',  queue: 1,  avgTimeSec: 18.1, accuracy: 92.4, lastRun: '2026-04-19 14:08' },
];

// ── PERMISSIONS / ACCESS MATRIX ──
const DOC_ACCESS_REVIEWS = [
  { id: 'AR-1', folder: 'Redstone v. Meridian',     users: 14, lastReview: '2026-03-01', status: 'Current',   nextDue: '2026-09-01' },
  { id: 'AR-2', folder: 'Sterling Pharma',          users: 11, lastReview: '2026-01-15', status: 'Due soon',  nextDue: '2026-04-30' },
  { id: 'AR-3', folder: 'Pacific Shipping',         users: 9,  lastReview: '2025-12-10', status: 'Overdue',   nextDue: '2026-03-10' },
  { id: 'AR-4', folder: 'Firm Templates',           users: 52, lastReview: '2026-02-18', status: 'Current',   nextDue: '2026-08-18' },
  { id: 'AR-5', folder: 'Blackwell IP',             users: 6,  lastReview: '2026-03-22', status: 'Current',   nextDue: '2026-09-22' },
  { id: 'AR-6', folder: 'Archive 2024',             users: 42, lastReview: '2025-11-30', status: 'Overdue',   nextDue: '2026-02-28' },
];

// ── ACTIVE SHARES (external & internal links) ──
const DOC_SHARES = [
  { id: 'SH-1', doc: 'Shipping Route Analysis 2019–2024', recipient: 'co-counsel@rossandpartners.com', scope: 'View',     expires: '2026-05-10', createdBy: 'S. Chen',     status: 'Active' },
  { id: 'SH-2', doc: 'Eminent Domain Valuation Report',    recipient: 'Harbor District board',          scope: 'View',     expires: '2026-04-30', createdBy: 'R. Vasquez',  status: 'Active' },
  { id: 'SH-3', doc: 'Merger Agreement — NovaTech/Apex',   recipient: 'apex-counsel@stroock.com',       scope: 'Comment',  expires: '2026-04-25', createdBy: 'A. Petrov',   status: 'Active' },
  { id: 'SH-4', doc: 'Expert Witness CV — Dr. Patel',      recipient: 'Thornton Estate family',         scope: 'View',     expires: null,         createdBy: 'R. Vasquez',  status: 'Active' },
  { id: 'SH-5', doc: 'Class Certification Motion',         recipient: 'Public PACER',                   scope: 'Public',   expires: null,         createdBy: 'M. Kirkland', status: 'Active' },
  { id: 'SH-6', doc: 'Settlement Offer — Atlas Financial', recipient: 'opposing@atlaslaw.com',          scope: 'View',     expires: '2026-04-22', createdBy: 'A. Petrov',   status: 'Expiring' },
];

// ── DLP POLICIES ──
const DOC_DLP_POLICIES = [
  { id: 'DLP-1', name: 'SSN pattern (###-##-####)',          action: 'Block upload',   hits30d: 7,  lastHit: '2026-04-19', status: 'Active' },
  { id: 'DLP-2', name: 'Credit card (PCI)',                  action: 'Block upload',   hits30d: 3,  lastHit: '2026-04-17', status: 'Active' },
  { id: 'DLP-3', name: 'Highly Confidential — external share', action: 'Require MFA', hits30d: 18, lastHit: '2026-04-21', status: 'Active' },
  { id: 'DLP-4', name: 'Privileged label — AEO-only',        action: 'Redact on export', hits30d: 42, lastHit: '2026-04-20', status: 'Active' },
  { id: 'DLP-5', name: 'Source code extension (.c/.cpp)',    action: 'Flag + review',  hits30d: 2,  lastHit: '2026-04-10', status: 'Active' },
];

// ── TOP CONTRIBUTORS ──
const DOC_CONTRIBUTORS = [
  { user: 'M. Kirkland',  docs: 87, edits: 342, comments: 118 },
  { user: 'S. Chen',       docs: 62, edits: 291, comments:  94 },
  { user: 'L. Torres',     docs: 54, edits: 208, comments:  76 },
  { user: 'J. Park',       docs: 41, edits: 162, comments:  58 },
  { user: 'A. Petrov',     docs: 34, edits: 129, comments:  42 },
  { user: 'R. Vasquez',    docs: 28, edits: 104, comments:  31 },
];

// ── DASHBOARD KPIs ──
const DOC_KPIS = {
  totalDocs: 2841,
  activeHolds: 5,
  pendingApprovals: 4,
  checkedOut: DOC_CHECKOUTS.length,
  expiringShares: 1,
  auditEventsToday: 8,
  dlpIncidents30d: 72,
  storageGB: 28.7,
  storageCapGB: 500,
  lastBackup: '2026-04-21 04:00',
};

window.DOC_FOLDERS = DOC_FOLDERS;
window.DOC_ITEMS = DOC_ITEMS;
window.DOC_TEMPLATES = DOC_TEMPLATES;
window.DOC_SAVED_SEARCHES = DOC_SAVED_SEARCHES;
window.DOC_ANALYTICS = DOC_ANALYTICS;
window.DOC_WORKSPACES = DOC_WORKSPACES;
window.DOC_LEGAL_HOLDS = DOC_LEGAL_HOLDS;
window.DOC_RETENTION_POLICIES = DOC_RETENTION_POLICIES;
window.DOC_AUDIT_TRAIL = DOC_AUDIT_TRAIL;
window.DOC_CHECKOUTS = DOC_CHECKOUTS;
window.DOC_APPROVALS = DOC_APPROVALS;
window.DOC_WORKFLOWS = DOC_WORKFLOWS;
window.DOC_OCR_PIPELINES = DOC_OCR_PIPELINES;
window.DOC_ACCESS_REVIEWS = DOC_ACCESS_REVIEWS;
window.DOC_SHARES = DOC_SHARES;
window.DOC_DLP_POLICIES = DOC_DLP_POLICIES;
window.DOC_CONTRIBUTORS = DOC_CONTRIBUTORS;
window.DOC_KPIS = DOC_KPIS;
window.ALL_DOCS_REF = DOC_ITEMS;
