<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>{{ $title }}</title>
    <style>
        body { font-family: 'Helvetica', 'Arial', sans-serif; font-size: 10px; color: #111827; }
        h1 { font-size: 15px; margin: 0 0 2px; }
        .meta { color: #6b7280; margin: 0 0 12px; font-size: 9px; }
        table { width: 100%; border-collapse: collapse; }
        th, td { border: 1px solid #e5e7eb; padding: 4px 6px; text-align: left; vertical-align: top; }
        th { background: #f9fafb; font-weight: bold; }
        tr:nth-child(even) td { background: #fafafa; }
        .summary { margin: 0 0 12px; padding: 8px 10px; border: 1px solid #e5e7eb; background: #f9fafb; }
        .summary strong { display: inline-block; margin-right: 18px; font-size: 10px; }
    </style>
</head>
<body>
    <h1>{{ $title }}</h1>
    <p class="meta">Generated {{ $generatedAt }} · Period: {{ $period }} · {{ count($rows) }} {{ str('row')->plural(count($rows)) }}</p>

    @if (count($summary))
        <div class="summary">
            @foreach ($summary as $label => $value)
                <strong>{{ $label }}: {{ $value }}</strong>
            @endforeach
        </div>
    @endif

    <table>
        <thead>
            <tr>
                @foreach ($headings as $heading)
                    <th>{{ $heading }}</th>
                @endforeach
            </tr>
        </thead>
        <tbody>
            @forelse ($rows as $row)
                <tr>
                    @foreach ($row as $cell)
                        <td>{{ $cell }}</td>
                    @endforeach
                </tr>
            @empty
                <tr>
                    <td colspan="{{ count($headings) }}">No records.</td>
                </tr>
            @endforelse
        </tbody>
    </table>
</body>
</html>
