// ============================================================================
// Document fragments — the "mess in" half of the visual.
//
// Each fragment is a slice of an actual BorderLens product screen, recreated
// in CSS so it scales crisply at any size. All data is fictional:
//   merchant       Northbank Ltd
//   EORI           GB744920183000
//   order numbers  fresh #10xxx range, never the original IDs
//   AWB / MRN      fresh, same character shape
//   £ amounts      same digit-count as originals
//
// Five fragments, mapped to the five uploaded screens:
//   ExecutiveSummary  — KPI tiles + sidebar
//   OrderExplorer     — order rows with expanded carrier-charge panel
//   Returns           — returns table with expanded inbound/outbound charges
//   ClaimPack         — light-canvas modal listing TCA reclaims
//   DestinationMarkets— light-canvas grid of country cards
// ============================================================================

// ── Common chrome ───────────────────────────────────────────────────────────
function WindowChrome({ active, width }) {
  return (
    <div style={{
      padding: '9px 14px',
      display: 'flex', alignItems: 'center', gap: 10,
      borderBottom: '1px solid #1e293b',
      background: '#0b1322',
      width,
    }}>
      <div style={{ display: 'flex', gap: 6 }}>
        <span style={{ width: 9, height: 9, borderRadius: '50%', background: '#e85b5b' }}/>
        <span style={{ width: 9, height: 9, borderRadius: '50%', background: '#f0b748' }}/>
        <span style={{ width: 9, height: 9, borderRadius: '50%', background: '#5cc463' }}/>
      </div>
      <div style={{ marginLeft: 8, fontSize: 9.5, color: '#64748b', fontFamily: 'var(--bl-font-mono)' }}>
        localhost:5173
      </div>
      <div style={{
        marginLeft: 'auto',
        fontSize: 9, color: '#475569',
        textTransform: 'uppercase', letterSpacing: '0.1em', fontWeight: 600,
      }}>{active}</div>
    </div>
  );
}

// Small reusable sidebar (compact) for fragments that need it
function MiniSidebar({ active }) {
  const items = [
    'Executive Summary', 'Order Explorer', 'Suppliers', 'Duty & Tax',
    'Carrier & Rate Card', 'Uploads', 'Returns', 'Findings',
  ];
  return (
    <div style={{
      width: 132, flexShrink: 0,
      background: '#0b1322',
      borderRight: '1px solid #1e293b',
      padding: '14px 10px',
      fontSize: 9.5,
      color: '#cbd5e1',
    }}>
      <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 4 }}>
        <span style={{ width: 5, height: 5, borderRadius: '50%', background: 'var(--bl-brand)' }}/>
        <span style={{ fontSize: 9, fontWeight: 700, letterSpacing: '0.16em', color: '#fff' }}>BORDERLENS</span>
      </div>
      <div style={{ fontSize: 8, color: '#64748b', marginBottom: 2, paddingLeft: 11 }}>Northbank</div>
      <div style={{ fontSize: 7.5, color: '#475569', marginBottom: 14, paddingLeft: 11 }}>Historical · validated</div>
      <div style={{ display: 'flex', flexDirection: 'column', gap: 1 }}>
        {items.map((label) => {
          const isActive = label === active;
          return (
            <div key={label} style={{
              padding: '5px 8px',
              borderRadius: 4,
              fontSize: 9,
              color: isActive ? '#fff' : '#94a3b8',
              background: isActive ? '#1e293b' : 'transparent',
              fontWeight: isActive ? 500 : 400,
            }}>{label}</div>
          );
        })}
      </div>
    </div>
  );
}

// ── 1. Executive Summary fragment ───────────────────────────────────────────
// KPI tiles top-row (Customs Findings, Data Quality) + Operation Overview tile.
function ExecutiveSummary() {
  return (
    <div style={{
      width: 460,
      background: '#0f172a',
      borderRadius: 8,
      boxShadow: '0 22px 50px -16px rgba(0,0,0,0.55), 0 6px 12px rgba(0,0,0,0.30), inset 0 0 0 1px rgba(148,163,184,0.10)',
      overflow: 'hidden',
      fontFamily: 'var(--bl-font)',
      color: '#e2e8f0',
    }}>
      <WindowChrome active="EXECUTIVE SUMMARY" width={460}/>
      <div style={{ display: 'flex' }}>
        <MiniSidebar active="Executive Summary"/>
        <div style={{ flex: 1, padding: '14px 14px 16px', display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 8 }}>
          {/* Customs Findings card */}
          <div style={{
            padding: 12, borderRadius: 6,
            background: '#1e293b',
            borderLeft: '3px solid var(--bl-brand)',
            gridColumn: 'span 2',
          }}>
            <div style={{ fontSize: 8, fontWeight: 600, color: '#64748b', textTransform: 'uppercase', letterSpacing: '0.12em' }}>Customs Findings</div>
            <div style={{ display: 'flex', alignItems: 'baseline', gap: 6, marginTop: 6 }}>
              <span style={{ fontSize: 22, fontWeight: 600, color: '#fff', fontVariantNumeric: 'tabular-nums' }}>17</span>
              <span style={{ fontSize: 9.5, color: '#cbd5e1' }}>high confidence</span>
            </div>
            <div style={{ fontSize: 9, color: '#94a3b8', marginTop: 4 }}>
              94 total open — TCA, RGR, classification, valuation
            </div>
            <div style={{ fontSize: 9, color: 'var(--bl-brand-hi)', marginTop: 8, fontWeight: 500 }}>Review findings →</div>
          </div>

          {/* Operation overview (truncated) */}
          <div style={{
            padding: 12, borderRadius: 6,
            background: '#1e293b',
            borderLeft: '3px solid var(--bl-brand)',
            gridColumn: 'span 2',
          }}>
            <div style={{ fontSize: 8, fontWeight: 600, color: '#64748b', textTransform: 'uppercase', letterSpacing: '0.12em' }}>Operation Overview — 90 days</div>
            <table style={{ width: '100%', marginTop: 8, borderCollapse: 'collapse', fontSize: 9.5 }}>
              <tbody>
                {[
                  ['Customer orders', '843',  'CDS declared'],
                  ['Customer returns','62',   'Unmatched'],
                  ['Stock inbound',   '418',  'Unmatched'],
                  ['Trade outbound',  '291',  'Unmatched'],
                ].map(([k, n, tag]) => (
                  <tr key={k}>
                    <td style={{ padding: '3px 0', color: '#cbd5e1' }}>{k}</td>
                    <td style={{ padding: '3px 0', textAlign: 'right', color: '#fff', fontWeight: 600, fontVariantNumeric: 'tabular-nums' }}>{n}</td>
                    <td style={{ padding: '3px 0 3px 10px', color: '#64748b', fontSize: 8.5 }}>
                      <span style={{ display: 'inline-flex', alignItems: 'center', gap: 4 }}>
                        <span style={{ width: 4, height: 4, borderRadius: '50%', background: tag === 'CDS declared' ? 'var(--bl-brand)' : '#64748b' }}/>
                        {tag}
                      </span>
                    </td>
                  </tr>
                ))}
              </tbody>
            </table>
            <div style={{
              marginTop: 8, paddingTop: 6,
              borderTop: '1px solid #334155',
              display: 'flex', justifyContent: 'space-between', fontSize: 8.5,
            }}>
              <span style={{ color: '#f87171' }}>Overdue (&gt;21d, no invoice)</span>
              <span style={{ color: '#f87171', fontWeight: 600 }}>2 ⚠</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  );
}

// ── 2. Order Explorer fragment ──────────────────────────────────────────────
// Order rows + expanded carrier-charge panel — the most data-dense view.
function OrderExplorer() {
  const rows = [
    { id: '#13472', date: '03/05/26', dest: 'US·CT', val: '£1,318',  est: '£94',   inv: '£94',   v: '−£1',   vc: 'pos',  margin: '74.2%' },
    { id: '#13468', date: '02/05/26', dest: 'AU',    val: '£1,047',  est: '£244',  inv: '£202',  v: '−£42',  vc: 'pos',  margin: '65.8%' },
    { id: '#13463', date: '02/05/26', dest: 'US·CA', val: '£687',    est: '£57',   inv: '£57',   v: '+£0',   vc: 'risk', margin: '70.3%' },
    { id: '#13458', date: '02/05/26', dest: 'US·AL', val: '£1,604',  est: '—',     inv: '—',     v: '—',     vc: 'pos',  margin: '78.4%', pending: true },
    { id: '#13451', date: '01/05/26', dest: 'US·NJ', val: '£742',    est: '£62',   inv: '£62',   v: '+£0',   vc: 'risk', margin: '69.7%' },
    { id: '#13444', date: '30/04/26', dest: 'US·PA', val: '£2,418',  est: '£169',  inv: '£190',  v: '+£21',  vc: 'risk', margin: '72.4%' },
    { id: '#13438', date: '29/04/26', dest: 'US·CA', val: '£1,074',  est: '£93',   inv: '£93',   v: '−£0',   vc: 'pos',  margin: '72.8%' },
    { id: '#13433', date: '29/04/26', dest: 'US·NY', val: '£3,148',  est: '£420',  inv: '£618',  v: '+£198', vc: 'risk', margin: '70.1%', risk: true },
    { id: '#13427', date: '28/04/26', dest: 'US·MA', val: '£546',    est: '£36',   inv: '—',     v: '—',     vc: 'pos',  margin: '72.6%' },
    { id: '#13422', date: '28/04/26', dest: 'US·GA', val: '£2,461',  est: '£166',  inv: '£341',  v: '+£175', vc: 'risk', margin: '73.0%', risk: true },
  ];

  const visible = rows.slice(0, 7);

  const expanded = rows[2]; // visually shows expansion under #13463

  return (
    <div style={{
      width: 540,
      background: '#0f172a',
      borderRadius: 8,
      boxShadow: '0 22px 50px -16px rgba(0,0,0,0.55), 0 6px 12px rgba(0,0,0,0.30), inset 0 0 0 1px rgba(148,163,184,0.10)',
      overflow: 'hidden',
      fontFamily: 'var(--bl-font)',
      color: '#e2e8f0',
    }}>
      <WindowChrome active="ORDER EXPLORER" width={540}/>
      <div style={{ display: 'flex' }}>
        <MiniSidebar active="Order Explorer"/>
        <div style={{ flex: 1, padding: 0, minWidth: 0 }}>
          <table style={{ width: '100%', borderCollapse: 'collapse', fontSize: 9 }}>
            <thead>
              <tr style={{ background: '#0b1322' }}>
                {['Order','Date','Dest','Value','Est. D&T','Carrier','Δ','Margin'].map((h, i) => (
                  <th key={i} style={{
                    padding: '7px 8px',
                    textAlign: i >= 3 ? 'right' : 'left',
                    fontSize: 7.5, fontWeight: 600, color: '#64748b',
                    textTransform: 'uppercase', letterSpacing: '0.08em',
                    borderBottom: '1px solid #1e293b',
                  }}>{h}</th>
                ))}
              </tr>
            </thead>
            <tbody>
              {visible.map((r, i) => {
                const isExpanded = i === 2;
                return (
                  <React.Fragment key={r.id}>
                    <tr style={{ borderBottom: '1px solid #131c2e' }}>
                      <td style={{ padding: '6px 8px', fontFamily: 'var(--bl-font-mono)', fontSize: 9, color: 'var(--bl-brand-hi)', fontWeight: 500 }}>{r.id}</td>
                      <td style={{ padding: '6px 8px', color: '#94a3b8', fontFamily: 'var(--bl-font-mono)', fontSize: 8.5 }}>{r.date}</td>
                      <td style={{ padding: '6px 8px' }}>
                        <span style={{
                          fontSize: 8, fontFamily: 'var(--bl-font-mono)', fontWeight: 500,
                          padding: '1px 5px', borderRadius: 2, background: '#1e293b', color: '#cbd5e1',
                        }}>{r.dest}</span>
                      </td>
                      <td style={{ padding: '6px 8px', textAlign: 'right', fontVariantNumeric: 'tabular-nums', color: '#fff' }}>{r.val}</td>
                      <td style={{ padding: '6px 8px', textAlign: 'right', fontVariantNumeric: 'tabular-nums', color: r.est === '—' ? '#475569' : (r.risk ? '#fbbf24' : '#f87171') }}>{r.est}</td>
                      <td style={{ padding: '6px 8px', textAlign: 'right', fontVariantNumeric: 'tabular-nums', color: r.inv === '—' ? '#475569' : '#cbd5e1' }}>{r.inv}</td>
                      <td style={{ padding: '6px 8px', textAlign: 'right', fontVariantNumeric: 'tabular-nums', color: r.v === '—' ? '#475569' : (r.vc === 'pos' ? 'var(--bl-brand)' : '#f87171'), fontWeight: 500 }}>{r.v}</td>
                      <td style={{ padding: '6px 8px', textAlign: 'right', fontVariantNumeric: 'tabular-nums', color: 'var(--bl-brand)' }}>{r.margin}</td>
                    </tr>
                    {isExpanded && (
                      <tr>
                        <td colSpan="8" style={{ padding: '8px 12px 12px', background: '#0a111e', borderBottom: '1px solid #131c2e' }}>
                          <div style={{ fontSize: 7.5, color: '#64748b', textTransform: 'uppercase', letterSpacing: '0.1em', fontWeight: 600, marginBottom: 6 }}>
                            Carrier Invoice Charges
                          </div>
                          <div style={{ display: 'flex', gap: 14, fontSize: 8.5, color: '#94a3b8', marginBottom: 6, fontFamily: 'var(--bl-font-mono)' }}>
                            <span>AWB: 4910827314</span>
                            <span style={{
                              padding: '1px 6px', background: '#1e293b', borderRadius: 2,
                              color: '#a5b4fc', fontSize: 8,
                            }}>Direct</span>
                            <span>Customs: £142</span>
                            <span style={{ marginLeft: 'auto', color: 'var(--bl-brand-hi)' }}>Reclassify</span>
                          </div>
                          <table style={{ width: '100%', borderCollapse: 'collapse', fontSize: 8.5 }}>
                            <tbody>
                              {[
                                ['Shipping',     'Standard shipping charge', '£18'],
                                ['Customs Duty', 'Import Export Duties',     '£57'],
                                ['VAT',          'IMPORT EXPORT TAXES',      '£85'],
                                ['Surcharge',    'Fuel Surcharge',           '£4'],
                                ['Brokerage',    'Duty Tax Paid',            '£8'],
                              ].map((c) => (
                                <tr key={c[0]} style={{ borderTop: '1px solid #131c2e' }}>
                                  <td style={{ padding: '3px 0', color: '#cbd5e1', width: 80 }}>{c[0]}</td>
                                  <td style={{ padding: '3px 0', color: '#64748b', fontSize: 8 }}>{c[1]}</td>
                                  <td style={{ padding: '3px 0', textAlign: 'right', color: '#fff', fontVariantNumeric: 'tabular-nums', fontWeight: 500 }}>{c[2]}</td>
                                </tr>
                              ))}
                            </tbody>
                          </table>
                        </td>
                      </tr>
                    )}
                  </React.Fragment>
                );
              })}
            </tbody>
          </table>
        </div>
      </div>
    </div>
  );
}

// ── 3. Returns fragment ─────────────────────────────────────────────────────
function ReturnsFragment() {
  const rows = [
    { id: '#13218', date: '12 Apr 26', country: 'IE', rev: '£1,742.40', ref: '£1,720.10', net: '−£618.20',  customs: '31.1%', sunk: '£648.30', evidence: 'Actual · both legs', awb: '4810239185', status: 'Returned' },
    { id: '#12844',  date: '08 Mar 26', country: 'US', rev: '£1,082.55', ref: '£1,060.40', net: '−£198.40',  customs: '13.4%', sunk: '£221.85', evidence: 'Actual · both legs', awb: '6210478921', status: 'Returned' },
    { id: '#11612',  date: '22 Feb 26', country: 'US', rev: '£884.20',   ref: '£883.40',   net: '−£202.10',  customs: '15.2%', sunk: '£204.70', evidence: 'Actual · both legs', awb: '1948302174', status: 'Returned' },
    { id: '#11501',  date: '14 Feb 26', country: 'US', rev: '£2,488.10', ref: '£612.30',   net: '+£1,820.40',customs: '0.0%',  sunk: '£74.60',  evidence: 'Partial · inbound',  awb: '7401189264', status: 'Returned', partial: true },
  ];

  return (
    <div style={{
      width: 580,
      background: '#0f172a',
      borderRadius: 8,
      boxShadow: '0 22px 50px -16px rgba(0,0,0,0.55), 0 6px 12px rgba(0,0,0,0.30), inset 0 0 0 1px rgba(148,163,184,0.10)',
      overflow: 'hidden',
      fontFamily: 'var(--bl-font)',
      color: '#e2e8f0',
    }}>
      <WindowChrome active="RETURNS" width={580}/>
      <div style={{ padding: '12px 14px 8px', display: 'flex', alignItems: 'center', gap: 8, borderBottom: '1px solid #1e293b' }}>
        <span style={{ fontSize: 9, fontWeight: 600, color: '#64748b', textTransform: 'uppercase', letterSpacing: '0.1em' }}>Status</span>
        {['All','Open','Returned','Closed','Needs matching'].map((t, i) => (
          <span key={t} style={{
            padding: '3px 9px',
            fontSize: 9, fontWeight: 500,
            borderRadius: 4,
            background: t === 'Returned' ? 'var(--bl-brand-bg)' : 'transparent',
            color: t === 'Returned' ? 'var(--bl-brand)' : '#94a3b8',
            border: t === 'Returned' ? '1px solid var(--bl-brand-border)' : '1px solid #1e293b',
          }}>{t}</span>
        ))}
        <span style={{ marginLeft: 'auto', fontSize: 8.5, color: '#64748b', fontFamily: 'var(--bl-font-mono)' }}>62 returns</span>
      </div>
      <table style={{ width: '100%', borderCollapse: 'collapse', fontSize: 9 }}>
        <thead>
          <tr style={{ background: '#0b1322' }}>
            {['Order','Date','Revenue','Refunded','Net','Customs','Sunk','Evidence','Status'].map((h, i) => (
              <th key={i} style={{
                padding: '7px 8px',
                textAlign: i >= 2 && i <= 6 ? 'right' : 'left',
                fontSize: 7.5, fontWeight: 600, color: '#64748b',
                textTransform: 'uppercase', letterSpacing: '0.08em',
                borderBottom: '1px solid #1e293b',
              }}>{h}</th>
            ))}
          </tr>
        </thead>
        <tbody>
          {rows.map((r, i) => (
            <tr key={r.id} style={{ borderBottom: '1px solid #131c2e', background: i === 3 ? '#0c1628' : 'transparent' }}>
              <td style={{ padding: '6px 8px', fontFamily: 'var(--bl-font-mono)', fontSize: 9, color: 'var(--bl-brand-hi)', fontWeight: 500 }}>{r.id}</td>
              <td style={{ padding: '6px 8px', fontSize: 8.5 }}>
                <div style={{ color: '#cbd5e1' }}>{r.date}</div>
                <div style={{ color: '#475569', fontSize: 7.5 }}>{r.country}</div>
              </td>
              <td style={{ padding: '6px 8px', textAlign: 'right', fontVariantNumeric: 'tabular-nums', color: '#fff' }}>{r.rev}</td>
              <td style={{ padding: '6px 8px', textAlign: 'right', fontVariantNumeric: 'tabular-nums', color: '#cbd5e1' }}>{r.ref}</td>
              <td style={{ padding: '6px 8px', textAlign: 'right', fontVariantNumeric: 'tabular-nums', color: r.net.startsWith('+') ? '#fbbf24' : '#cbd5e1' }}>{r.net}</td>
              <td style={{ padding: '6px 8px', textAlign: 'right', fontVariantNumeric: 'tabular-nums', color: '#cbd5e1' }}>{r.customs}</td>
              <td style={{ padding: '6px 8px', textAlign: 'right', fontVariantNumeric: 'tabular-nums', color: 'var(--bl-brand)' }}>{r.sunk}</td>
              <td style={{ padding: '6px 8px', fontSize: 8.5, color: r.partial ? '#fbbf24' : 'var(--bl-brand)' }}>
                <div>{r.evidence}</div>
                <div style={{ color: '#475569', fontFamily: 'var(--bl-font-mono)', fontSize: 7.5 }}>{r.awb}</div>
              </td>
              <td style={{ padding: '6px 8px', fontSize: 8.5, color: '#94a3b8' }}>{r.status}</td>
            </tr>
          ))}
          {/* Expanded inbound/outbound for last row */}
          <tr>
            <td colSpan="9" style={{ padding: '10px 12px', background: '#0a111e' }}>
              <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 14, fontSize: 8.5 }}>
                <div>
                  <div style={{ fontSize: 7.5, color: '#64748b', textTransform: 'uppercase', letterSpacing: '0.1em', fontWeight: 600, marginBottom: 6 }}>
                    Inbound Charges <span style={{ color: '#475569', marginLeft: 6 }}>AWB 7401189264</span>
                  </div>
                  {[
                    ['Shipping',  'Standard shipping charge', '£21.40'],
                    ['Surcharge', 'Fuel Surcharge',           '£6.85'],
                    ['Surcharge', 'Emergency Situation',      '£0.62'],
                  ].map((c, j) => (
                    <div key={j} style={{ display: 'flex', justifyContent: 'space-between', padding: '2px 0', color: '#cbd5e1' }}>
                      <span>{c[0]} <span style={{ color: '#64748b', marginLeft: 6, fontSize: 8 }}>{c[1]}</span></span>
                      <span style={{ color: '#fff', fontVariantNumeric: 'tabular-nums' }}>{c[2]}</span>
                    </div>
                  ))}
                </div>
                <div style={{
                  background: '#0f172a', borderRadius: 4, padding: 8,
                }}>
                  <div style={{ fontSize: 7.5, color: '#64748b', textTransform: 'uppercase', letterSpacing: '0.1em', fontWeight: 600, marginBottom: 6 }}>Inbound Summary</div>
                  {[
                    ['Shipping','£21'],
                    ['Duty','£0.00'],
                    ['Surcharges','£7.47'],
                    ['Billed weight','3.20 kg'],
                  ].map((c, j) => (
                    <div key={j} style={{ display: 'flex', justifyContent: 'space-between', padding: '2px 0', color: '#94a3b8', fontSize: 8.5 }}>
                      <span>{c[0]}</span>
                      <span style={{ color: '#fff', fontVariantNumeric: 'tabular-nums', fontWeight: 500 }}>{c[1]}</span>
                    </div>
                  ))}
                </div>
              </div>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  );
}

// ── 4. Claim Pack — light canvas modal ──────────────────────────────────────
function ClaimPack() {
  const claims = [
    { name: 'MILANO TESSILE SRL',   hs: '610910', mrn: '26GB471BCA8', date: '2024-09-12', value: '£1,184.00', duty: '£108.00', reclaim: '£108.00', deadline: '2027-09-12' },
    { name: 'PIETRO SARTI LDA',     hs: '620640', mrn: '26GBE2D518C', date: '2024-11-04', value: '£612.00',   duty: '£56.00',  reclaim: '£56.00',  deadline: '2027-11-04' },
    { name: 'NORMANDIE TEXTILE SAS',hs: '611780', mrn: '26GBE91FA37', date: '2025-01-22', value: '£927.00',   duty: '£84.00',  reclaim: '£84.00',  deadline: '2028-01-22' },
  ];
  return (
    <div style={{
      width: 420,
      background: '#fbfbfb',
      borderRadius: 10,
      boxShadow: '0 28px 60px -18px rgba(0,0,0,0.55), 0 8px 16px rgba(0,0,0,0.30)',
      overflow: 'hidden',
      fontFamily: 'var(--bl-font)',
      color: '#0f172a',
    }}>
      <div style={{
        padding: '14px 18px',
        display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between',
        borderBottom: '1px solid #e2e8f0',
      }}>
        <div>
          <div style={{ fontSize: 14, fontWeight: 600 }}>Claim Pack</div>
          <div style={{ fontSize: 9.5, color: '#64748b', marginTop: 2, fontVariantNumeric: 'tabular-nums' }}>
            07 May 2026 · 3 claims · £248.00
          </div>
        </div>
        <div style={{
          fontSize: 9, color: '#475569', padding: '4px 8px',
          border: '1px solid #cbd5e1', borderRadius: 4, fontWeight: 500,
        }}>Download CSV</div>
      </div>
      <div style={{ padding: 14 }}>
        <div style={{
          padding: '10px 12px',
          background: '#f1f4f8',
          borderRadius: 6,
          fontSize: 9.5,
          marginBottom: 12,
        }}>
          <div style={{ fontSize: 7.5, color: '#64748b', textTransform: 'uppercase', letterSpacing: '0.1em', fontWeight: 600 }}>Merchant</div>
          <div style={{ color: '#0f172a', marginTop: 3 }}>Northbank Ltd</div>
          <div style={{ color: '#64748b', fontSize: 9, fontFamily: 'var(--bl-font-mono)' }}>EORI: GB744920183000</div>
        </div>
        {claims.map((c, i) => (
          <div key={i} style={{ marginBottom: i === claims.length - 1 ? 0 : 10 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 5 }}>
              <span style={{
                width: 16, height: 16, borderRadius: '50%',
                background: 'rgba(13,158,140,0.1)',
                color: 'var(--bl-brand)',
                display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
                fontSize: 9, fontWeight: 600,
              }}>{i + 1}</span>
              <span style={{ fontSize: 10, fontWeight: 600 }}>{c.name}</span>
              <span style={{ fontSize: 9, color: '#64748b' }}>· HS {c.hs} · TCA</span>
            </div>
            <div style={{
              background: '#f1f4f8', borderRadius: 6,
              padding: '8px 12px', display: 'grid', gridTemplateColumns: '90px 1fr',
              rowGap: 3, columnGap: 8, fontSize: 9, color: '#64748b',
            }}>
              <span>MRN</span><span style={{ color: '#0f172a', fontFamily: 'var(--bl-font-mono)', fontSize: 8.5 }}>{c.mrn}</span>
              <span>Declared value</span><span style={{ color: '#0f172a' }}>{c.value}</span>
              <span>Duty paid</span><span style={{ color: '#0f172a' }}>{c.duty}</span>
              <span>Reclaim amount</span>
              <span>
                <span style={{ color: 'var(--bl-brand)', fontWeight: 600 }}>{c.reclaim}</span>
                <span style={{
                  marginLeft: 6,
                  fontSize: 7.5, padding: '1px 5px',
                  background: 'rgba(13,158,140,0.12)', color: 'var(--bl-brand)',
                  borderRadius: 3, fontWeight: 600,
                }}>Ready</span>
              </span>
              <span>Deadline</span><span style={{ color: '#0f172a' }}>{c.deadline}</span>
            </div>
          </div>
        ))}
      </div>
    </div>
  );
}

// ── 5. Destination Markets — light canvas grid ──────────────────────────────
function DestinationMarkets() {
  const cards = [
    { code: 'US', name: 'United States', rev: '£382,750', pct: '0.4%',  margin: '73.9%', sub1: ['Customs %', '11.3% actual / 12.0% duty rate'], ioss: true },
    { code: 'DK', name: 'Denmark',    rev: '£3,514', pct: '0.3%',  margin: '69.0%', sub1: ['Customs %', '40.1% actual / 12.0% duty rate'], ioss: true },
    { code: 'HK', name: 'Hong Kong',  rev: '£8,348', pct: '0.8%',  margin: '70.3%', sub1: ['Promo mix', '5.2% discount'], ioss: false },
    { code: 'AT', name: 'Austria',    rev: '£5,442', pct: '0.5%',  margin: '69.1%', sub1: ['Customs %', '35.6% actual / 12.0% duty rate'], ioss: true },
  ];
  return (
    <div style={{
      width: 480,
      background: '#fbfbfb',
      borderRadius: 10,
      boxShadow: '0 28px 60px -18px rgba(0,0,0,0.55), 0 8px 16px rgba(0,0,0,0.30)',
      overflow: 'hidden',
      fontFamily: 'var(--bl-font)',
      color: '#0f172a',
      padding: 14,
    }}>
      <div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 10 }}>
        <span style={{ fontSize: 10, color: '#64748b' }}>HS Code Analysis</span>
        <span style={{
          fontSize: 10, padding: '4px 10px',
          background: 'var(--bl-brand)', color: '#fff',
          borderRadius: 4, fontWeight: 500,
        }}>Destination Markets</span>
      </div>
      <div style={{ fontSize: 9.5, color: '#475569', marginBottom: 12, fontVariantNumeric: 'tabular-nums' }}>
        <span style={{ color: '#0f172a', fontWeight: 600 }}>22 destinations</span>
        <span style={{ color: '#cbd5e1', margin: '0 8px' }}>·</span>
        <span><span style={{ color: '#0f172a', fontWeight: 600 }}>£998,142</span> total international revenue</span>
        <span style={{ color: '#cbd5e1', margin: '0 8px' }}>·</span>
        <span>all time</span>
      </div>
      <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 8 }}>
        {cards.map((c) => (
          <div key={c.code} style={{
            background: '#fff',
            border: '1px solid #e2e8f0',
            borderRadius: 8,
            padding: 12,
            position: 'relative',
          }}>
            {c.ioss && (
              <div style={{
                position: 'absolute', top: 10, right: 10,
                fontSize: 7, fontWeight: 700, padding: '2px 6px',
                background: '#fef3c7', color: '#92400e',
                borderRadius: 3, letterSpacing: '0.04em',
              }}>! IOSS</div>
            )}
            <div style={{ fontSize: 16, fontWeight: 600 }}>{c.code}</div>
            <div style={{ fontSize: 8.5, color: '#94a3b8', marginBottom: 8 }}>{c.name}</div>
            <div style={{ display: 'grid', gridTemplateColumns: '1fr auto', rowGap: 3, fontSize: 8.5 }}>
              <span style={{ color: '#64748b' }}>Revenue</span>
              <span style={{ color: '#0f172a', fontWeight: 600, fontVariantNumeric: 'tabular-nums' }}>
                {c.rev} <span style={{ color: '#94a3b8', fontWeight: 400 }}>({c.pct})</span>
              </span>
              <span style={{ color: '#64748b' }}>True margin</span>
              <span style={{ color: '#0f172a', fontWeight: 600, fontVariantNumeric: 'tabular-nums' }}>
                {c.margin}
                <span style={{ color: 'var(--bl-brand)', marginLeft: 4, fontSize: 7.5 }}>● Live</span>
              </span>
              <span style={{ color: '#64748b' }}>{c.sub1[0]}</span>
              <span style={{ color: '#0f172a', fontVariantNumeric: 'tabular-nums', fontSize: 8 }}>{c.sub1[1]}</span>
            </div>
          </div>
        ))}
      </div>
    </div>
  );
}

// Public component map — exported under the legacy names so hero.jsx keeps working.
window.CarrierInvoice  = OrderExplorer;        // dense invoice → order explorer
window.CdsDeclaration  = ClaimPack;            // CDS doc → claim pack (light)
window.ShopifyExport   = ReturnsFragment;      // shopify CSV → returns
window.Spreadsheet     = ExecutiveSummary;     // spreadsheet → exec summary
window.EmailFragment   = DestinationMarkets;   // email pdf → destination markets

// Also export under their real names
window.ExecutiveSummary    = ExecutiveSummary;
window.OrderExplorer       = OrderExplorer;
window.ReturnsFragment     = ReturnsFragment;
window.ClaimPack           = ClaimPack;
window.DestinationMarkets  = DestinationMarkets;
