<%- include('../partials/shell-open') %>
<div class="topbar">
  <div><div class="eyebrow">Append-only record</div><h1>Activity</h1></div>
</div>
<div class="content">
  <div class="card">
    <table>
      <thead><tr><th>When</th><th>Who</th><th>Action</th><th class="hide-sm">Detail</th><th class="hide-sm">IP</th></tr></thead>
      <tbody>
      <% rows.forEach(function(r){ var d = r.detail ? (typeof r.detail === 'string' ? JSON.parse(r.detail) : r.detail) : null; %>
        <tr>
          <td class="mono" style="font-size:12px;white-space:nowrap"><%= new Date(r.created_at).toISOString().slice(0,16).replace('T',' ') %></td>
          <td style="font-size:13px"><%= r.user_name || '—' %></td>
          <td><span class="pill type"><%= r.action %></span>
              <% if (r.entity_id) { %> <span class="code-ref"><%= r.entity_id %></span><% } %></td>
          <td class="hide-sm mono" style="font-size:12px;color:var(--muted);max-width:340px;word-break:break-all">
            <% if (d && d.from !== undefined) { %><%= d.from || '—' %> → <%= d.to || '—' %>
            <% } else if (d) { %><%= JSON.stringify(d) %><% } %>
          </td>
          <td class="hide-sm mono" style="font-size:12px;color:var(--muted)"><%= r.ip || '' %></td>
        </tr>
      <% }); %>
      </tbody>
    </table>
  </div>
</div>
<%- include('../partials/shell-close') %>
