<?php $r=$report??[];$h=static fn($v):string=>htmlspecialchars((string)$v,ENT_QUOTES,'UTF-8');$latest=$r['latest']??[];$checks=$r['checks']??[];$trail=$r['trail']??[]; ?>
<style>.ac{display:grid;gap:16px}.ac-card{background:#fff;border:1px solid #dce4ef;border-radius:16px;padding:18px}.ac-hero{background:linear-gradient(135deg,#102a43,#315f86);color:#fff}.ac-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:12px}.ac-value{font-size:32px;font-weight:850}.ac table{width:100%;border-collapse:collapse;min-width:760px}.ac th,.ac td{padding:10px;border-bottom:1px solid #e7edf4;text-align:left}.ac-scroll{overflow:auto}.ac-btn{display:inline-block;padding:10px 14px;border:0;border-radius:9px;background:#1d5f9f;color:#fff;text-decoration:none;font-weight:750;cursor:pointer}.pass{color:#166534;font-weight:800}.fail{color:#991b1b;font-weight:800}</style>
<div class="ac"><div><a class="ac-btn" href="/public/administration/securite/soc">← SOC</a> <a class="ac-btn" href="/public/administration/securite/audit/export.csv">Exporter CSV</a></div><section class="ac-card ac-hero"><small>ENTERPRISE-008.9 · AXIOM 9.9.5</small><h1>Audit & Compliance Center</h1><p>Contrôles RGPD, ISO 27001, NIS2 et Zero Trust avec piste d’audit chaînée.</p></section><div class="ac-grid"><article class="ac-card"><small>Score global</small><div class="ac-value"><?= (int)($latest['score']??0) ?>/100</div></article><article class="ac-card"><small>État</small><div class="ac-value" style="font-size:22px"><?= $h($latest['status']??'never') ?></div></article><article class="ac-card"><small>Dernier audit</small><div><?= $h($latest['created_at']??'Jamais') ?></div></article></div><section class="ac-card"><form method="post" action="/public/administration/securite/audit/executer"><?php if(class_exists('App\Core\Csrf')) echo App\Core\Csrf::field(); ?><button class="ac-btn">Lancer l’audit de conformité</button></form><p><?= $h($latest['summary']??'') ?></p></section><section class="ac-card ac-scroll"><h2>Contrôles</h2><table><thead><tr><th>Référentiel</th><th>Contrôle</th><th>État</th><th>Gravité</th><th>Détails</th><th>Date</th></tr></thead><tbody><?php foreach($checks as $c):?><tr><td><?= $h($c['framework']) ?></td><td><strong><?= $h($c['control_code']) ?></strong><br><?= $h($c['title']) ?></td><td class="<?= $c['status']==='pass'?'pass':'fail' ?>"><?= $h(strtoupper($c['status'])) ?></td><td><?= $h($c['severity']) ?></td><td><?= $h($c['details']) ?></td><td><?= $h($c['checked_at']) ?></td></tr><?php endforeach?><?php if(!$checks):?><tr><td colspan="6">Aucun contrôle exécuté.</td></tr><?php endif?></tbody></table></section><section class="ac-card ac-scroll"><h2>Piste d’audit immuable</h2><table><thead><tr><th>Date</th><th>Événement</th><th>Objet</th><th>Acteur</th><th>Détails</th></tr></thead><tbody><?php foreach($trail as $a):?><tr><td><?= $h($a['created_at']) ?></td><td><?= $h($a['event_type']) ?></td><td><?= $h($a['subject_type'].' · '.$a['subject_ref']) ?></td><td><?= $h($a['actor_id']??'système') ?></td><td><?= $h($a['details']) ?></td></tr><?php endforeach?><?php if(!$trail):?><tr><td colspan="5">Aucune entrée.</td></tr><?php endif?></tbody></table></section></div>
