// CRIMINAL JUSTICE — INVESTIGATORS sub-platform (5 tabs: Dashboard · Team · Leads · Budget · Reports)
const { useState: useCjInvState } = React;
const Tcip = window.ArbiterTokens;

// ── Dashboard ────────────────────────────────────────────────────────────
function CjInvestigatorsDashboard({ data }) {
  const cj = window.__cj;
  const invs = data.investigators;
  const leads = data.investigatorLeads || [];
  const reports = data.investigatorReports || [];
  const totalHours = invs.reduce((s, i) => s + i.hoursMTD, 0);
  const totalBudget = invs.reduce((s, i) => s + i.budgetRemain, 0);
  const openLeads = leads.filter(l => l.status !== 'Completed').length;
  const critLeads = leads.filter(l => l.priority === 'critical' && l.status !== 'Completed').length;

  // By type
  const byType = {};
  invs.forEach(i => { byType[i.type] = (byType[i.type] || 0) + 1; });
  const typeData = Object.entries(byType).sort((a, b) => b[1] - a[1]);
  const maxType = Math.max(...typeData.map(r => r[1]), 1);

  // Firms ranked by hours
  const byFirm = {};
  invs.forEach(i => {
    if (!byFirm[i.firm]) byFirm[i.firm] = { hours: 0, engagements: 0, budgetRemain: 0 };
    byFirm[i.firm].hours += i.hoursMTD;
    byFirm[i.firm].engagements += 1;
    byFirm[i.firm].budgetRemain += i.budgetRemain;
  });
  const firmData = Object.entries(byFirm).sort((a, b) => b[1].hours - a[1].hours);
  const maxHours = Math.max(...firmData.map(f => f[1].hours), 1);

  return (
    <div>
      <div style={{ display: 'grid', gridTemplateColumns: 'repeat(6, 1fr)', gap: '12px', marginBottom: '16px' }}>
        <div style={cj.stat}><span style={cj.statLabel}>Active engagements</span><span style={cj.statValue}>{invs.length}</span></div>
        <div style={cj.stat}><span style={cj.statLabel}>Hours MTD</span><span style={{ ...cj.statValue, color: cj.cobalt }}>{totalHours.toLocaleString()}</span></div>
        <div style={cj.stat}><span style={cj.statLabel}>Budget remaining</span><span style={{ ...cj.statValue, color: cj.emerald }}>${(totalBudget / 1000).toFixed(0)}k</span></div>
        <div style={cj.stat}><span style={cj.statLabel}>Open leads</span><span style={cj.statValue}>{openLeads}</span><span style={{ ...cj.statDelta, color: Tcip.color.text.tertiary }}>{leads.length} total</span></div>
        <div style={cj.stat}><span style={cj.statLabel}>Critical leads</span><span style={{ ...cj.statValue, color: critLeads > 0 ? cj.burgundy : Tcip.color.text.primary }}>{critLeads}</span></div>
        <div style={cj.stat}><span style={cj.statLabel}>Reports delivered</span><span style={cj.statValue}>{reports.length}</span></div>
      </div>

      <div style={{ display: 'grid', gridTemplateColumns: '1fr 1.4fr', gap: '14px', marginBottom: '14px' }}>
        <div style={cj.card}>
          <div style={cj.cardH}>By investigation type</div>
          <div style={{ padding: '14px 16px' }}>
            {typeData.map(([t, n]) => (
              <div key={t} style={{ marginBottom: '10px' }}>
                <div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: '4px' }}>
                  <span style={{ fontSize: '11px', fontWeight: 600, color: Tcip.color.text.primary }}>{t}</span>
                  <span style={{ fontSize: '11px', fontFamily: Tcip.font.mono, fontWeight: 700, color: cj.cobalt }}>{n}</span>
                </div>
                <div style={{ height: '6px', background: Tcip.color.border.light, borderRadius: '3px', overflow: 'hidden' }}>
                  <div style={{ width: `${(n / maxType) * 100}%`, height: '100%', background: cj.cobalt }} />
                </div>
              </div>
            ))}
          </div>
        </div>

        <div style={cj.card}>
          <div style={cj.cardH}>Firm engagement — hours MTD</div>
          <table style={{ width: '100%', borderCollapse: 'collapse' }}>
            <thead>
              <tr>
                <th style={cj.th}>Firm</th>
                <th style={{ ...cj.th, textAlign: 'right' }}>Engagements</th>
                <th style={{ ...cj.th, textAlign: 'right' }}>Hours MTD</th>
                <th style={cj.th}>Load</th>
                <th style={{ ...cj.th, textAlign: 'right' }}>Budget left</th>
              </tr>
            </thead>
            <tbody>
              {firmData.map(([firm, d]) => (
                <tr key={firm}>
                  <td style={{ ...cj.td, fontWeight: 600 }}>{firm}</td>
                  <td style={{ ...cj.td, textAlign: 'right', fontFamily: Tcip.font.mono }}>{d.engagements}</td>
                  <td style={{ ...cj.td, textAlign: 'right', fontFamily: Tcip.font.mono, fontWeight: 700, color: cj.cobalt }}>{d.hours}</td>
                  <td style={cj.td}>
                    <div style={{ width: '90px', height: '5px', background: Tcip.color.border.light, borderRadius: '3px', overflow: 'hidden' }}>
                      <div style={{ width: `${(d.hours / maxHours) * 100}%`, height: '100%', background: cj.cobalt }} />
                    </div>
                  </td>
                  <td style={{ ...cj.td, textAlign: 'right', fontFamily: Tcip.font.mono, color: cj.emerald, fontWeight: 700 }}>${(d.budgetRemain / 1000).toFixed(0)}k</td>
                </tr>
              ))}
            </tbody>
          </table>
        </div>
      </div>

      <div style={cj.card}>
        <div style={{ ...cj.cardH, color: cj.burgundy }}>! Critical & high-priority leads</div>
        <table style={{ width: '100%', borderCollapse: 'collapse' }}>
          <thead>
            <tr>
              <th style={cj.th}>ID</th>
              <th style={cj.th}>Matter</th>
              <th style={cj.th}>Title</th>
              <th style={cj.th}>Assigned</th>
              <th style={cj.th}>Priority</th>
              <th style={cj.th}>Status</th>
              <th style={cj.th}>Expected</th>
            </tr>
          </thead>
          <tbody>
            {leads.filter(l => (l.priority === 'critical' || l.priority === 'high') && l.status !== 'Completed').map(l => {
              const pc = l.priority === 'critical' ? { bg: cj.burgundyBg, color: cj.burgundy }
                : { bg: cj.orangeBg, color: cj.orange };
              return (
                <tr key={l.id}>
                  <td style={{ ...cj.td, fontFamily: Tcip.font.mono, color: cj.burgundy, fontWeight: 700 }}>{l.id}</td>
                  <td style={{ ...cj.td, fontSize: '11px', color: Tcip.color.text.secondary }}>{l.matter}</td>
                  <td style={{ ...cj.td, fontWeight: 600, maxWidth: '320px' }}>{l.title}</td>
                  <td style={{ ...cj.td, fontSize: '11px' }}>{l.assigned}</td>
                  <td style={cj.td}><span style={{ ...cj.tag, background: pc.bg, color: pc.color, textTransform: 'uppercase' }}>{l.priority}</span></td>
                  <td style={{ ...cj.td, fontSize: '11px' }}>{l.status}</td>
                  <td style={{ ...cj.td, fontFamily: Tcip.font.mono, fontSize: '11px', color: cj.amber }}>{l.expected}</td>
                </tr>
              );
            })}
          </tbody>
        </table>
      </div>
    </div>
  );
}

// ── Team (full engagement list) ─────────────────────────────────────────
function CjInvestigatorsTeam({ data }) {
  const cj = window.__cj;
  return (
    <div style={cj.card}>
      <div style={cj.cardH}>
        <span>Investigator engagements — {data.investigators.length}</span>
        <button style={cj.btnPrimary}>+ Add engagement</button>
      </div>
      <table style={{ width: '100%', borderCollapse: 'collapse' }}>
        <thead>
          <tr>
            <th style={cj.th}>ID</th>
            <th style={cj.th}>Firm</th>
            <th style={cj.th}>Type</th>
            <th style={cj.th}>Matter</th>
            <th style={cj.th}>Lead</th>
            <th style={{ ...cj.th, textAlign: 'right' }}>Hours MTD</th>
            <th style={{ ...cj.th, textAlign: 'right' }}>Budget left</th>
            <th style={cj.th}>Focus</th>
          </tr>
        </thead>
        <tbody>
          {data.investigators.map(i => {
            const typeTag = i.type.toLowerCase().includes('forensic') ? { bg: cj.cobaltBg, color: cj.cobalt }
              : i.type.toLowerCase().includes('digital') || i.type.toLowerCase().includes('mobile') ? { bg: cj.violetBg, color: cj.violet }
              : i.type.toLowerCase().includes('medical') ? { bg: cj.emeraldBg, color: cj.emerald }
              : i.type.toLowerCase().includes('jury') ? { bg: cj.amberBg, color: cj.amber }
              : i.type.toLowerCase().includes('polygraph') ? { bg: cj.violetBg, color: cj.violet }
              : i.type.toLowerCase().includes('ballistic') ? { bg: cj.burgundyBg, color: cj.burgundy }
              : i.type.toLowerCase().includes('background') ? { bg: cj.orangeBg, color: cj.orange }
              : { bg: Tcip.color.bg.secondary, color: Tcip.color.text.secondary };
            return (
              <tr key={i.id}>
                <td style={{ ...cj.td, fontFamily: Tcip.font.mono, color: cj.burgundy, fontWeight: 700 }}>{i.id}</td>
                <td style={{ ...cj.td, fontWeight: 600 }}>{i.firm}</td>
                <td style={cj.td}><span style={{ ...cj.tag, background: typeTag.bg, color: typeTag.color }}>{i.type}</span></td>
                <td style={{ ...cj.td, fontSize: '11px', color: Tcip.color.text.secondary }}>{i.matter}</td>
                <td style={{ ...cj.td, fontSize: '11px' }}>{i.lead}</td>
                <td style={{ ...cj.td, textAlign: 'right', fontFamily: Tcip.font.mono, fontWeight: 700, color: cj.cobalt }}>{i.hoursMTD}</td>
                <td style={{ ...cj.td, textAlign: 'right', fontFamily: Tcip.font.mono, color: cj.emerald, fontWeight: 700 }}>${(i.budgetRemain / 1000).toFixed(0)}k</td>
                <td style={{ ...cj.td, fontSize: '11px', color: Tcip.color.text.primary, maxWidth: '360px' }}>{i.focus}</td>
              </tr>
            );
          })}
        </tbody>
      </table>
    </div>
  );
}

// ── Leads ───────────────────────────────────────────────────────────────
function CjInvestigatorsLeads({ data }) {
  const cj = window.__cj;
  const [statusFilter, setStatusFilter] = useCjInvState('All');
  const [priorityFilter, setPriorityFilter] = useCjInvState('All');

  const leads = data.investigatorLeads || [];
  const filtered = leads.filter(l =>
    (statusFilter === 'All' || l.status === statusFilter) &&
    (priorityFilter === 'All' || l.priority === priorityFilter)
  );

  const statuses = ['All', ...new Set(leads.map(l => l.status))];
  const priorities = ['All', 'critical', 'high', 'medium', 'low'];

  return (
    <div>
      <div style={{ display: 'grid', gridTemplateColumns: 'repeat(5, 1fr)', gap: '12px', marginBottom: '16px' }}>
        <div style={cj.stat}><span style={cj.statLabel}>Leads</span><span style={cj.statValue}>{leads.length}</span></div>
        <div style={cj.stat}><span style={cj.statLabel}>In progress</span><span style={{ ...cj.statValue, color: cj.cobalt }}>{leads.filter(l => l.status === 'In progress').length}</span></div>
        <div style={cj.stat}><span style={cj.statLabel}>Completed</span><span style={{ ...cj.statValue, color: cj.emerald }}>{leads.filter(l => l.status === 'Completed').length}</span></div>
        <div style={cj.stat}><span style={cj.statLabel}>Awaiting / pending</span><span style={{ ...cj.statValue, color: cj.amber }}>{leads.filter(l => l.status === 'Awaiting' || l.status === 'Pending').length}</span></div>
        <div style={cj.stat}><span style={cj.statLabel}>Critical priority</span><span style={{ ...cj.statValue, color: cj.burgundy }}>{leads.filter(l => l.priority === 'critical').length}</span></div>
      </div>

      <div style={cj.card}>
        <div style={cj.cardH}>
          <span>Investigation leads — {filtered.length}</span>
          <div style={{ display: 'flex', gap: '6px' }}>
            <select value={statusFilter} onChange={e => setStatusFilter(e.target.value)} style={{ padding: '3px 8px', fontSize: '11px', border: `1px solid ${Tcip.color.border.light}`, borderRadius: '5px', background: Tcip.color.bg.card, color: Tcip.color.text.secondary }}>
              {statuses.map(s => <option key={s} value={s}>Status: {s}</option>)}
            </select>
            <select value={priorityFilter} onChange={e => setPriorityFilter(e.target.value)} style={{ padding: '3px 8px', fontSize: '11px', border: `1px solid ${Tcip.color.border.light}`, borderRadius: '5px', background: Tcip.color.bg.card, color: Tcip.color.text.secondary }}>
              {priorities.map(p => <option key={p} value={p}>Priority: {p}</option>)}
            </select>
            <button style={cj.btnPrimary}>+ New lead</button>
          </div>
        </div>
        <table style={{ width: '100%', borderCollapse: 'collapse' }}>
          <thead>
            <tr>
              <th style={cj.th}>ID</th>
              <th style={cj.th}>Opened</th>
              <th style={cj.th}>Matter</th>
              <th style={cj.th}>Title</th>
              <th style={cj.th}>Assigned</th>
              <th style={cj.th}>Priority</th>
              <th style={cj.th}>Status</th>
              <th style={cj.th}>Expected</th>
              <th style={cj.th}>Notes</th>
            </tr>
          </thead>
          <tbody>
            {filtered.map(l => {
              const pc = l.priority === 'critical' ? { bg: cj.burgundyBg, color: cj.burgundy }
                : l.priority === 'high' ? { bg: cj.orangeBg, color: cj.orange }
                : l.priority === 'medium' ? { bg: cj.amberBg, color: cj.amber }
                : { bg: Tcip.color.bg.secondary, color: Tcip.color.text.tertiary };
              const sc = l.status === 'Completed' ? { bg: cj.emeraldBg, color: cj.emerald }
                : l.status === 'In progress' ? { bg: cj.cobaltBg, color: cj.cobalt }
                : l.status === 'Awaiting' || l.status === 'Pending' ? { bg: cj.amberBg, color: cj.amber }
                : { bg: cj.violetBg, color: cj.violet };
              return (
                <tr key={l.id}>
                  <td style={{ ...cj.td, fontFamily: Tcip.font.mono, color: cj.burgundy, fontWeight: 700 }}>{l.id}</td>
                  <td style={{ ...cj.td, fontFamily: Tcip.font.mono, fontSize: '11px', color: Tcip.color.text.tertiary }}>{l.opened}</td>
                  <td style={{ ...cj.td, fontSize: '11px', color: Tcip.color.text.secondary }}>{l.matter}</td>
                  <td style={{ ...cj.td, fontWeight: 600, maxWidth: '320px' }}>{l.title}</td>
                  <td style={{ ...cj.td, fontSize: '11px' }}>{l.assigned}</td>
                  <td style={cj.td}><span style={{ ...cj.tag, background: pc.bg, color: pc.color, textTransform: 'uppercase' }}>{l.priority}</span></td>
                  <td style={cj.td}><span style={{ ...cj.tag, background: sc.bg, color: sc.color }}>{l.status}</span></td>
                  <td style={{ ...cj.td, fontFamily: Tcip.font.mono, fontSize: '11px', color: cj.amber }}>{l.expected}</td>
                  <td style={{ ...cj.td, fontSize: '10px', color: Tcip.color.text.tertiary, fontStyle: 'italic', maxWidth: '240px' }}>{l.notes}</td>
                </tr>
              );
            })}
          </tbody>
        </table>
      </div>
    </div>
  );
}

// ── Budget ──────────────────────────────────────────────────────────────
function CjInvestigatorsBudget({ data }) {
  const cj = window.__cj;
  const invs = data.investigators;
  // Assume each engagement started with budgetRemain + hoursMTD * rate ~ approx budget
  const rate = 250; // heuristic hourly rate for display
  const enriched = invs.map(i => {
    const spent = i.hoursMTD * rate;
    const total = spent + i.budgetRemain;
    const pctUsed = total > 0 ? Math.round((spent / total) * 100) : 0;
    return { ...i, spent, total, pctUsed };
  });

  const totalSpent = enriched.reduce((s, x) => s + x.spent, 0);
  const totalBudget = enriched.reduce((s, x) => s + x.total, 0);
  const totalRemain = enriched.reduce((s, x) => s + x.budgetRemain, 0);
  const overallPct = totalBudget > 0 ? Math.round((totalSpent / totalBudget) * 100) : 0;

  return (
    <div>
      <div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: '12px', marginBottom: '16px' }}>
        <div style={cj.stat}><span style={cj.statLabel}>Total budget</span><span style={cj.statValue}>${(totalBudget / 1000).toFixed(0)}k</span></div>
        <div style={cj.stat}><span style={cj.statLabel}>Spent MTD</span><span style={{ ...cj.statValue, color: cj.cobalt }}>${(totalSpent / 1000).toFixed(0)}k</span></div>
        <div style={cj.stat}><span style={cj.statLabel}>Remaining</span><span style={{ ...cj.statValue, color: cj.emerald }}>${(totalRemain / 1000).toFixed(0)}k</span></div>
        <div style={cj.stat}><span style={cj.statLabel}>Burn rate</span><span style={{ ...cj.statValue, color: overallPct > 75 ? cj.burgundy : overallPct > 50 ? cj.amber : cj.emerald }}>{overallPct}%</span></div>
      </div>

      <div style={cj.card}>
        <div style={cj.cardH}>Budget utilization by engagement</div>
        <table style={{ width: '100%', borderCollapse: 'collapse' }}>
          <thead>
            <tr>
              <th style={cj.th}>Engagement</th>
              <th style={cj.th}>Firm</th>
              <th style={cj.th}>Matter</th>
              <th style={{ ...cj.th, textAlign: 'right' }}>Hours MTD</th>
              <th style={{ ...cj.th, textAlign: 'right' }}>Spent</th>
              <th style={{ ...cj.th, textAlign: 'right' }}>Remaining</th>
              <th style={cj.th}>Utilization</th>
            </tr>
          </thead>
          <tbody>
            {enriched.sort((a, b) => b.pctUsed - a.pctUsed).map(i => {
              const uColor = i.pctUsed > 80 ? cj.burgundy : i.pctUsed > 60 ? cj.amber : cj.emerald;
              return (
                <tr key={i.id}>
                  <td style={{ ...cj.td, fontFamily: Tcip.font.mono, color: cj.burgundy, fontWeight: 700 }}>{i.id}</td>
                  <td style={{ ...cj.td, fontWeight: 600 }}>{i.firm}</td>
                  <td style={{ ...cj.td, fontSize: '11px', color: Tcip.color.text.secondary }}>{i.matter}</td>
                  <td style={{ ...cj.td, textAlign: 'right', fontFamily: Tcip.font.mono }}>{i.hoursMTD}</td>
                  <td style={{ ...cj.td, textAlign: 'right', fontFamily: Tcip.font.mono, fontWeight: 700, color: cj.cobalt }}>${(i.spent / 1000).toFixed(0)}k</td>
                  <td style={{ ...cj.td, textAlign: 'right', fontFamily: Tcip.font.mono, fontWeight: 700, color: cj.emerald }}>${(i.budgetRemain / 1000).toFixed(0)}k</td>
                  <td style={cj.td}>
                    <div style={{ display: 'flex', alignItems: 'center', gap: '6px' }}>
                      <div style={{ width: '90px', height: '6px', background: Tcip.color.border.light, borderRadius: '3px', overflow: 'hidden' }}>
                        <div style={{ width: `${Math.min(i.pctUsed, 100)}%`, height: '100%', background: uColor }} />
                      </div>
                      <span style={{ fontFamily: Tcip.font.mono, fontSize: '11px', fontWeight: 700, color: uColor }}>{i.pctUsed}%</span>
                    </div>
                  </td>
                </tr>
              );
            })}
          </tbody>
        </table>
      </div>
    </div>
  );
}

// ── Reports ─────────────────────────────────────────────────────────────
function CjInvestigatorsReports({ data }) {
  const cj = window.__cj;
  const reports = data.investigatorReports || [];
  return (
    <div>
      <div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: '12px', marginBottom: '16px' }}>
        <div style={cj.stat}><span style={cj.statLabel}>Reports delivered</span><span style={cj.statValue}>{reports.length}</span></div>
        <div style={cj.stat}><span style={cj.statLabel}>Total pages</span><span style={cj.statValue}>{reports.reduce((s, r) => s + r.pages, 0).toLocaleString()}</span></div>
        <div style={cj.stat}><span style={cj.statLabel}>Matters covered</span><span style={cj.statValue}>{new Set(reports.map(r => r.matter)).size}</span></div>
        <div style={cj.stat}><span style={cj.statLabel}>Avg length</span><span style={cj.statValue}>{Math.round(reports.reduce((s, r) => s + r.pages, 0) / (reports.length || 1))} <span style={{ fontSize: '12px', color: Tcip.color.text.tertiary, fontWeight: 500 }}>pp</span></span></div>
      </div>

      <div style={cj.card}>
        <div style={cj.cardH}>
          <span>Investigator reports — {reports.length}</span>
          <button style={cj.btnSecondary}>⇩ Export CSV</button>
        </div>
        <table style={{ width: '100%', borderCollapse: 'collapse' }}>
          <thead>
            <tr>
              <th style={cj.th}>Report ID</th>
              <th style={cj.th}>Dated</th>
              <th style={cj.th}>Matter</th>
              <th style={cj.th}>Title</th>
              <th style={{ ...cj.th, textAlign: 'right' }}>Pages</th>
              <th style={cj.th}>Conclusion</th>
            </tr>
          </thead>
          <tbody>
            {reports.map(r => (
              <tr key={r.id}>
                <td style={{ ...cj.td, fontFamily: Tcip.font.mono, color: cj.burgundy, fontWeight: 700 }}>{r.id}</td>
                <td style={{ ...cj.td, fontFamily: Tcip.font.mono, fontSize: '11px' }}>{r.dated}</td>
                <td style={{ ...cj.td, fontSize: '11px', color: Tcip.color.text.secondary }}>{r.matter}</td>
                <td style={{ ...cj.td, fontWeight: 600, maxWidth: '320px' }}>{r.title}</td>
                <td style={{ ...cj.td, textAlign: 'right', fontFamily: Tcip.font.mono, fontWeight: 700 }}>{r.pages}</td>
                <td style={{ ...cj.td, fontSize: '11px', color: Tcip.color.text.primary, maxWidth: '460px' }}>{r.conclusion}</td>
              </tr>
            ))}
          </tbody>
        </table>
      </div>
    </div>
  );
}

// ── Platform entry ──────────────────────────────────────────────────────
function CriminalInvestigatorsPlatform({ data }) {
  const [subTab, setSubTab] = useCjInvState('dashboard');
  const cj = window.__cj;

  const subTabs = [
    { id: 'dashboard', label: 'Dashboard' },
    { id: 'team',      label: 'Team' },
    { id: 'leads',     label: 'Leads' },
    { id: 'budget',    label: 'Budget' },
    { id: 'reports',   label: 'Reports' },
  ];

  const renderSub = () => {
    switch (subTab) {
      case 'dashboard': return <CjInvestigatorsDashboard data={data} />;
      case 'team':      return <CjInvestigatorsTeam      data={data} />;
      case 'leads':     return <CjInvestigatorsLeads     data={data} />;
      case 'budget':    return <CjInvestigatorsBudget    data={data} />;
      case 'reports':   return <CjInvestigatorsReports   data={data} />;
      default:          return <CjInvestigatorsDashboard data={data} />;
    }
  };

  return (
    <div>
      <div style={{ display: 'flex', gap: '0', borderBottom: `1px solid ${Tcip.color.border.light}`, marginBottom: '16px' }}>
        {subTabs.map(t => {
          const active = subTab === t.id;
          return (
            <button key={t.id} onClick={() => setSubTab(t.id)}
              style={{
                padding: '8px 14px', fontSize: '11px', fontWeight: active ? 600 : 500,
                color: active ? cj.burgundy : Tcip.color.text.tertiary,
                background: 'none',
                borderTop: 'none', borderLeft: 'none', borderRight: 'none',
                borderBottom: `2px solid ${active ? cj.burgundy : 'transparent'}`,
                cursor: 'pointer', fontFamily: Tcip.font.family,
                marginBottom: '-1px', transition: 'color 0.15s',
              }}>
              {t.label}
            </button>
          );
        })}
      </div>
      {renderSub()}
    </div>
  );
}

window.CriminalInvestigatorsPlatform = CriminalInvestigatorsPlatform;
