<?php $r=$report??[];$h=static fn($v):string=>htmlspecialchars((string)$v,ENT_QUOTES,'UTF-8');$inc=$r['inc']??[];$det=$r['det']??[];$comp=$r['comp']??[];$health=$r['health']??[];$zt=$r['zt']??[]; ?>
<style>
.esc{display:grid;gap:16px}.esc-card{background:#fff;border:1px solid #dce4ef;border-radius:18px;padding:18px}.esc-hero{background:linear-gradient(135deg,#102a43,#244f76);color:#fff;display:flex;justify-content:space-between;gap:20px;align-items:center}.esc-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px}.esc-value{font-size:30px;font-weight:850}.esc-actions{display:flex;gap:8px;flex-wrap:wrap}.esc-btn{display:inline-block;padding:10px 14px;border-radius:10px;background:#1d5f9f;color:#fff;text-decoration:none;font-weight:750;border:0}.esc-table{width:100%;border-collapse:collapse;min-width:720px}.esc-table th,.esc-table td{padding:10px;border-bottom:1px solid #e7edf4;text-align:left}.esc-scroll{overflow:auto}.esc-risk{font-size:52px;font-weight:900}.esc-list{display:grid;gap:10px}.esc-item{padding:12px;border-left:4px solid #9fb7cf;background:#f8fafc;border-radius:8px}.esc-item.critique{border-color:#b91c1c}.esc-item.élevée{border-color:#c2410c}.esc-item.moyenne{border-color:#ca8a04}.esc-item.faible{border-color:#2563eb}.esc-bar{height:10px;background:#e8eef5;border-radius:20px;overflow:hidden}.esc-fill{height:100%;background:#315f86}@media(max-width:760px){.esc-hero{flex-direction:column;align-items:flex-start}.esc-table{min-width:650px}}
</style>
<div class="esc">
<div class="esc-actions"><a class="esc-btn" href="/public/administration/securite/soc">← SOC</a><a class="esc-btn" href="/public/administration/securite/audit">Audit & conformité</a><a class="esc-btn" href="/public/administration/securite/executive/export.csv?days=<?= (int)($r['days']??30) ?>">Exporter CSV</a><a class="esc-btn" target="_blank" href="/public/administration/securite/executive/rapport?days=<?= (int)($r['days']??30) ?>">Rapport imprimable</a></div>
<section class="esc-card esc-hero"><div><small>ENTERPRISE-008.10 · AXIOM 9.9.6</small><h1>Executive Security Center</h1><p>Synthèse Direction de la sécurité, de la conformité et de la continuité d’activité.</p></div><div><div class="esc-risk"><?= (int)($r['securityScore']??0) ?>/100</div><strong>Score global de sécurité</strong><br><small>Actualisé <?= $h($r['generatedAt']??'') ?></small></div></section>
<section class="esc-card"><form method="get"><label>Période <select name="days"><?php foreach([7,30,90] as $d):?><option value="<?=$d?>" <?= (int)($r['days']??30)===$d?'selected':'' ?>><?=$d?> jours</option><?php endforeach?></select></label> <button class="esc-btn">Actualiser</button></form></section>
<div class="esc-grid"><article class="esc-card"><small>Conformité</small><div class="esc-value"><?= (int)($comp['score']??0) ?>/100</div><span><?= $h($comp['status']??'non évalué') ?></span></article><article class="esc-card"><small>Incidents actifs</small><div class="esc-value"><?= (int)($inc['active']??0) ?></div><span><?= (int)($inc['critical']??0) ?> critique(s)</span></article><article class="esc-card"><small>Incidents en retard</small><div class="esc-value"><?= (int)($inc['overdue']??0) ?></div></article><article class="esc-card"><small>Détections ouvertes</small><div class="esc-value"><?= (int)($det['open_count']??0) ?></div><span><?= (int)($det['critical']??0) ?> critique(s)</span></article><article class="esc-card"><small>Alertes santé</small><div class="esc-value"><?= (int)($health['active_alerts']??0) ?></div><span><?= (int)($health['critical_alerts']??0) ?> critique(s)</span></article><article class="esc-card"><small>Zero Trust appliqué</small><div class="esc-value"><?= (int)($zt['enforced']??0) ?></div><span><?= (int)($zt['active']??0) ?> active(s)</span></article></div>
<section class="esc-card"><h2>Continuité et exploitation</h2><div class="esc-grid"><div><small>Dernière sauvegarde</small><h3><?= $h($r['backup']['statut']??'inconnue') ?></h3><p><?= $h($r['backup']['finished_at']??$r['backup']['created_at']??'') ?></p></div><div><small>Dernière mise à jour</small><h3><?= $h($r['update']['version_cible']??'inconnue') ?></h3><p><?= $h($r['update']['statut']??'') ?> · <?= $h($r['update']['installation_fin']??'') ?></p></div><div><small>Risque maximal actif</small><h3><?= (int)($inc['max_risk']??0) ?>/100</h3></div></div></section>
<section class="esc-card"><h2>Actions prioritaires recommandées</h2><div class="esc-list"><?php foreach(($r['actions']??[]) as $a):?><div class="esc-item <?= $h($a['priority']) ?>"><strong><?= $h(strtoupper($a['priority'])) ?> · <?= $h($a['title']) ?></strong><br><?= $h($a['detail']) ?></div><?php endforeach?></div></section>
<section class="esc-card esc-scroll"><h2>Modules les plus exposés</h2><table class="esc-table"><thead><tr><th>Module</th><th>Incidents</th><th>Actifs</th><th>Risque maximal</th></tr></thead><tbody><?php foreach(($r['modules']??[]) as $m):?><tr><td><?= $h($m['module']) ?></td><td><?= (int)$m['incidents'] ?></td><td><?= (int)$m['active'] ?></td><td><strong><?= (int)$m['max_risk'] ?>/100</strong><div class="esc-bar"><div class="esc-fill" style="width:<?= min(100,(int)$m['max_risk']) ?>%"></div></div></td></tr><?php endforeach?><?php if(empty($r['modules'])):?><tr><td colspan="4">Aucune donnée sur la période.</td></tr><?php endif?></tbody></table></section>
<section class="esc-card esc-scroll"><h2>Évolution du risque</h2><table class="esc-table"><thead><tr><th>Jour</th><th>Incidents</th><th>Risque moyen</th><th>Risque maximal</th></tr></thead><tbody><?php foreach(($r['trend']??[]) as $t):?><tr><td><?= $h($t['day']) ?></td><td><?= (int)$t['incidents'] ?></td><td><?= $h($t['avg_risk']) ?></td><td><?= (int)$t['max_risk'] ?></td></tr><?php endforeach?><?php if(empty($r['trend'])):?><tr><td colspan="4">Aucune tendance disponible.</td></tr><?php endif?></tbody></table></section>
</div>
