<div class="container-fluid">

<h2 class="fw-bold mb-4">
Enterprise Governance Control Center
</h2>

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

<?php

$cards = [

'Roles'
    => $stats['roles'],

'Menu Items'
    => $stats['menu_items'],

'Permissions'
    => $stats['permissions'],

'Track Assignments'
    => $stats['track_assignments'],

'Orphan Menus'
    => $stats['orphan_menu_items'],

'Unused Roles'
    => $stats['unused_roles']

];

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

?>

<div class="col-md-2">

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

<div class="card-body text-center">

<div class="text-muted">
<?= htmlspecialchars($label) ?>
</div>

<h3>
<?= (int)$value ?>
</h3>

</div>

</div>

</div>

<?php endforeach; ?>

</div>

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

<div class="card-body text-center">

<h6>Governance Score</h6>

<h1 class="text-success">
<?= (int)$stats['governance_score'] ?>%
</h1>

</div>

</div>

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

<div class="card-header fw-bold">
Role Permission Coverage
</div>

<div class="table-responsive">

<table class="table table-striped">

<thead>

<tr>
<th>Role</th>
<th>Code</th>
<th>Permissions</th>
</tr>

</thead>

<tbody>

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

<tr>

<td>
<?= htmlspecialchars($r['name']) ?>
</td>

<td>
<?= htmlspecialchars($r['code']) ?>
</td>

<td>
<?= (int)$r['permission_count'] ?>
</td>

</tr>

<?php endforeach; ?>

</tbody>

</table>

</div>

</div>

</div>
