<!DOCTYPE html>
<html>
<head>
<style>
  body { font-family: sans-serif; font-size: 12px; color: #1A1625; }
  h1 { font-size: 18px; margin-bottom: 0; }
  p.sub { color: #6b6470; margin-top: 4px; }
  table { width: 100%; border-collapse: collapse; margin-top: 16px; }
  th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #eee6d8; font-size: 11px; }
  th { background: #FFF9F0; color: #a19a8f; }
  .right { text-align: right; }
</style>
</head>
<body>
  <h1>{{ $shopName }} — {{ ucfirst($tab) }} Report</h1>
  <p class="sub">{{ $from }} to {{ $to }}</p>

  @if($tab === 'sales')
    <table>
      <thead><tr><th>Order</th><th>Customer</th><th>Date</th><th class="right">Total</th></tr></thead>
      <tbody>
        @foreach($data['orders'] as $o)
          <tr><td>#{{ $o->id }}</td><td>{{ $o->customer->name ?? '—' }}</td><td>{{ $o->created_at->format('d M Y') }}</td><td class="right">₹{{ number_format($o->total_amount, 0) }}</td></tr>
        @endforeach
      </tbody>
    </table>
  @endif

  @if($tab === 'pipeline')
    <table>
      <thead><tr><th>Stage</th><th class="right">Count</th></tr></thead>
      <tbody>
        @foreach($data['counts'] as $stage => $count)
          <tr><td>{{ ucfirst($stage) }}</td><td class="right">{{ $count }}</td></tr>
        @endforeach
      </tbody>
    </table>
  @endif

  @if($tab === 'balances')
    <table>
      <thead><tr><th>Order</th><th>Customer</th><th class="right">Balance</th></tr></thead>
      <tbody>
        @foreach($data['orders'] as $o)
          <tr><td>#{{ $o->id }}</td><td>{{ $o->customer->name ?? '—' }}</td><td class="right">₹{{ number_format($o->balance_amount, 0) }}</td></tr>
        @endforeach
      </tbody>
    </table>
  @endif

  @if($tab === 'salary')
    <table>
      <thead><tr><th>Staff</th><th>Date</th><th>Notes</th><th class="right">Amount</th></tr></thead>
      <tbody>
        @foreach($data['payments'] as $p)
          <tr><td>{{ $p->staff->name ?? '—' }}</td><td>{{ $p->paid_on->format('d M Y') }}</td><td>{{ $p->notes ?? '—' }}</td><td class="right">₹{{ number_format($p->amount, 0) }}</td></tr>
        @endforeach
      </tbody>
    </table>
  @endif
</body>
</html>
