<div class="container-fluid">

<h2 class="fw-bold mb-4">
Enterprise Reviewer Sustainability Center
</h2>

<div class="row g-3 mb-4">

<?php

$cards = [
    'Reviewers' => $stats['reviewers'],
    'Active Reviewers 365d' => $stats['active_reviewers_365'],
    'Completed Reviews' => $stats['completed_reviews'],
    'Open Reviews' => $stats['open_reviews'],
    'Overdue Reviews' => $stats['overdue_reviews'],
    'Sustainability Score' => $stats['sustainability_score'] . '%',
];

foreach ($cards as $label => $value):

?>

<div class="col-md-2">
<div class="card border-0 shadow-sm">
<div class="card-body text-center">
<div class="text-muted">
<?= htmlspecialchars($label) ?>
</div>
<h3>
<?= htmlspecialchars((string)$value) ?>
</h3>
</div>
</div>
</div>

<?php endforeach; ?>

</div>

<div class="card border-0 shadow-sm mb-4">

<div class="card-header fw-bold">
Reviewer Sustainability Findings
</div>

<div class="card-body">

<?php foreach ($findings as $f): ?>

<div class="alert alert-<?= htmlspecialchars($f['severity']) ?>">
<strong><?= htmlspecialchars($f['title']) ?></strong>
<br>
<?= htmlspecialchars($f['message']) ?>
</div>

<?php endforeach; ?>

<?php if (empty($findings)): ?>

<div class="alert alert-success">
Reviewer sustainability indicators are healthy.
</div>

<?php endif; ?>

</div>

</div>

<div class="card border-0 shadow-sm">

<div class="card-header fw-bold">
Reviewer Sustainability Matrix
</div>

<div class="table-responsive">

<table class="table table-striped align-middle">

<thead>
<tr>
<th>ID</th>
<th>Reviewer</th>
<th>Total</th>
<th>Completed</th>
<th>Open</th>
<th>Overdue</th>
<th>Last Completed</th>
</tr>
</thead>

<tbody>

<?php foreach ($rows as $r): ?>

<tr>
<td><?= (int)$r['id'] ?></td>
<td><?= htmlspecialchars($r['reviewer_name']) ?></td>
<td><?= (int)$r['total_reviews'] ?></td>
<td><?= (int)$r['completed_reviews'] ?></td>
<td><?= (int)$r['open_reviews'] ?></td>
<td><?= (int)$r['overdue_reviews'] ?></td>
<td><?= htmlspecialchars($r['last_completed_at'] ?? '') ?></td>
</tr>

<?php endforeach; ?>

</tbody>

</table>

</div>

</div>

</div>
