/* Activity log (Audit module). Classes are prefixed audit- because every module stylesheet loads on every page. */
.audit-summary { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.audit-table td { font-size: 14px; }
.audit-time { white-space: nowrap; }
.audit-strong { display: block; font-weight: 600; }
.audit-sub { display: block; font-size: 12px; color: var(--muted); overflow-wrap: break-word; }
.audit-person, .audit-record { min-width: 8em; }
.audit-reason { min-width: 8em; overflow-wrap: break-word; }
.audit-changes summary { cursor: pointer; color: var(--accent); font-weight: 600; white-space: nowrap; }
.audit-changes[open] summary { margin-bottom: 6px; }
.audit-pager { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.audit-pager .is-disabled { opacity: .45; pointer-events: none; }
.audit-table .pill { margin-bottom: 4px; }

/* Pictures on top of the log */
.audit-kpis { margin-bottom: 20px; }
.audit-viz .grid-2 + .grid-2 { margin-top: 20px; }
.audit-viz-stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.audit-note { margin: 6px 0 0; }
.audit-code { display: block; font-size: 12px; font-weight: 600; color: var(--accent); text-decoration: none; }
.audit-code:hover { text-decoration: underline; }

/* Before → after: old value struck out in red, new value in green, number difference with an arrow */
.audit-dlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; min-width: 14em; }
.audit-d { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; padding: 5px 8px; border-radius: 8px; background: var(--sunk); border-left: 3px solid var(--line-strong); font-size: 13px; }
.audit-d-added { border-left-color: var(--ok); }
.audit-d-removed { border-left-color: var(--bad); }
.audit-d-changed { border-left-color: var(--info); }
.audit-d-field { font-family: var(--mono); font-size: 12px; color: var(--muted); min-width: 6em; overflow-wrap: anywhere; }
.audit-d-vals { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; min-width: 0; }
.audit-d-old, .audit-d-new { padding: 1px 6px; border-radius: 5px; overflow-wrap: anywhere; max-width: 22em; }
.audit-d-old { background: var(--bad-bg); color: var(--bad); text-decoration: line-through; text-decoration-thickness: 1px; }
.audit-d-new { background: var(--ok-bg); color: var(--ok); font-weight: 600; text-decoration: none; }
.audit-d-empty { color: var(--muted); font-style: italic; font-size: 12px; }
.audit-d-arrow { color: var(--muted); font-weight: 700; }
.audit-d-delta { font-size: 12px; font-weight: 700; padding: 1px 6px; border-radius: 999px; white-space: nowrap; }
.audit-d-up { background: var(--info-bg); color: var(--info); }
.audit-d-down { background: var(--warn-bg); color: var(--warn); }
.audit-changes { margin-top: 5px; }
.audit-dlist-wide .audit-d { font-size: 15px; padding: 8px 12px; }
.audit-dlist-wide .audit-d-field { font-size: 13px; min-width: 12em; }
.audit-dlist-wide .audit-d-old, .audit-dlist-wide .audit-d-new { max-width: none; }

/* One entry: who → what → which record, with its barcode */
.audit-entry-who { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.audit-entry-fact { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; border-radius: 12px; background: var(--sunk); min-width: 10em; flex: 1 1 10em; }
.audit-entry-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.audit-entry-label .icon { width: 16px; height: 16px; }
.audit-entry-value { font-size: 18px; font-weight: 700; overflow-wrap: anywhere; }
.audit-entry-arrow { font-size: 22px; color: var(--muted); font-weight: 700; }
.audit-entry-code { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 10px; background: #fff; color: #000; border-radius: 10px; }
.audit-entry-code svg { max-width: 220px; height: auto; }
.audit-entry-h { margin: 22px 0 8px; font-size: 18px; }
.audit-entry-legend { display: flex; gap: 8px; align-items: baseline; font-size: 12px; margin-bottom: 8px; }
.audit-kind-failed .audit-entry-fact:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.audit-entry-more { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 20px; margin: 18px 0 0; }
.audit-entry-more dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.audit-entry-more dd { margin: 2px 0 0; overflow-wrap: anywhere; }

/* The record's other entries as a step line, kind shown by the dot colour */
.audit-history { list-style: none; margin: 0; padding: 0 0 0 6px; }
.audit-history-step { position: relative; display: flex; gap: 12px; padding: 0 0 12px 0; }
.audit-history-step::before { content: ""; position: absolute; left: 6px; top: 16px; bottom: 0; width: 2px; background: var(--line); }
.audit-history-step:last-child::before { display: none; }
.audit-history-dot { flex: none; width: 14px; height: 14px; margin-top: 4px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--bg); position: relative; }
.audit-kind-added .audit-history-dot { background: var(--ok); }
.audit-kind-retired .audit-history-dot { background: var(--warn); }
.audit-kind-failed .audit-history-dot { background: var(--bad); }
.audit-kind-signin .audit-history-dot, .audit-kind-download .audit-history-dot { background: var(--info); }
.audit-history-body { color: inherit; text-decoration: none; min-width: 0; }
.audit-history-body:hover .audit-strong { text-decoration: underline; }
.audit-history-step.is-current .audit-history-dot { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--accent); }
.audit-history-step.is-current .audit-strong { color: var(--accent); }

@media (max-width: 600px) {
  .audit-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .audit-kpis .kpi { min-height: 0; padding: 14px; }
  .audit-kpis .kpi-value { font-size: 30px; }
  .audit-kpis .kpi-sub { font-size: 12px; }
  .audit-entry-arrow { transform: rotate(90deg); align-self: center; margin: 0 auto; }
  .audit-entry-fact { flex-basis: 100%; }
  .audit-dlist-wide .audit-d-field { min-width: 0; flex-basis: 100%; }
  /* Phone: each log row becomes a card, so the drawn changes are on screen instead of off to the side. */
  .audit-table thead { display: none; }
  .audit-table, .audit-table tbody, .audit-table tr, .audit-table td { display: block; width: 100%; }
  .audit-table tr { padding: 10px 2px; border-bottom: 1px solid var(--line); }
  .audit-table td { border: 0; padding: 3px 6px; min-width: 0; }
  .audit-table td::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
  .audit-table .audit-time::before { display: none; }
  .audit-table .audit-time { white-space: normal; }
  .audit-dlist { min-width: 0; }
  .audit-d-old, .audit-d-new { max-width: 100%; }
}
@media print {
  .audit-d-old, .audit-d-new { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .audit-entry-code { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
