<div class="card">
    <div class="card-body">
        <h3 class="card-title"><?= h(t('history.title')) ?></h3>

        <?php if (empty($history)): ?>
        <div class="text-muted"><?= h(t('history.none')) ?></div>
        <?php else: ?>
        <table class="table table-sm">
            <thead>
                <tr>
                    <th><?= h(t('common.date')) ?></th>
                    <th><?= h(t('history.event')) ?></th>
                    <th><?= h(t('history.detail')) ?></th>
                    <th><?= h(t('history.user')) ?></th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($history as $h): ?>
                <tr>
                    <td class="text-muted"><?= htmlspecialchars($h['created_at'], ENT_QUOTES) ?></td>
                    <td>
                        <span class="badge bg-secondary-lt">
                            <?= htmlspecialchars($h['label'], ENT_QUOTES) ?>
                        </span>
                    </td>
                    <td>
                        <?= !empty($h['details']) ? nl2br(htmlspecialchars($h['details'], ENT_QUOTES)) : '—' ?>
                    </td>
                    <td><?= htmlspecialchars($h['actor_name'] ?? '—', ENT_QUOTES) ?></td>
                </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
        <?php endif; ?>
    </div>
</div>
