<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <style>
        body { font-family: DejaVu Sans, sans-serif; font-size: 11px; color: #222; }
        h1 { font-size: 18px; }
        table { width: 100%; border-collapse: collapse; margin-top: 15px; }
        th, td { padding: 6px 8px; border-bottom: 1px solid #ddd; text-align: left; }
        th { background: #f4f4f4; text-transform: capitalize; }
        tr:nth-child(even) { background: #fafafa; }
    </style>
</head>
<body>
    <h1><?= esc($title) ?></h1>
    <p style="color:#777;">Generated <?= date('Y-m-d H:i') ?></p>

    <table>
        <thead>
            <tr><?php foreach ($headers as $h): ?><th><?= esc(str_replace('_', ' ', (string) $h)) ?></th><?php endforeach; ?></tr>
        </thead>
        <tbody>
            <?php foreach ($rows as $row): ?>
                <tr><?php foreach ($row as $cell): ?><td><?= esc((string) $cell) ?></td><?php endforeach; ?></tr>
            <?php endforeach; ?>
        </tbody>
    </table>
</body>
</html>
