<div class="d-flex justify-content-between mb-4">
    <h4 class="mb-0">Job Runs: <?= e($job['job_name']) ?></h4>
    <a href="/admin/jobs" class="btn btn-secondary">Back</a>
</div>
<div class="card"><div class="card-body"><div class="table-responsive">
    <table class="table table-sm table-striped">
        <thead><tr><th>Started</th><th>Completed</th><th>Duration</th><th>Status</th><th>Triggered</th><th>Records</th><th>Error</th></tr></thead>
        <tbody>
        <?php foreach ($runs as $r): ?>
        <tr>
            <td><?= format_datetime($r['started_at']) ?></td>
            <td><?= $r['completed_at'] ? format_datetime($r['completed_at']) : '-' ?></td>
            <td><?= $r['duration_ms'] ? $r['duration_ms'] . 'ms' : '-' ?></td>
            <td><?= status_badge($r['status']) ?></td>
            <td><?= e($r['triggered_by']) ?></td>
            <td><?= $r['records_processed'] !== null ? $r['records_processed'] : '-' ?></td>
            <td><?= $r['error_message'] ? '<span class="text-danger" title="' . e($r['error_message']) . '"><i class="fas fa-exclamation-circle"></i></span>' : '-' ?></td>
        </tr>
        <?php endforeach; ?>
        </tbody>
    </table>
</div></div></div>