/* Tela de auditoria: diálogo largo, filtros, lista de registros expansíveis. */
dialog.dialog-wide {
  width: min(1120px, calc(100% - 32px));
}

.audit-integrity {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 16px 24px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--surface-2);
  font-size: 13px;
}
.audit-integrity p {
  color: var(--muted);
}
.audit-integrity.ok {
  border-color: color-mix(in srgb, var(--ok) 35%, transparent);
  background: var(--ok-soft);
}
.audit-integrity.ok p {
  color: var(--ok);
  font-weight: 550;
}
.audit-integrity.broken {
  border-color: var(--overdue);
  background: var(--overdue-soft);
}
.audit-integrity.broken p {
  color: var(--overdue);
  font-weight: 650;
}

.audit-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 0.9fr)) repeat(3, minmax(0, 1fr)) auto;
  align-items: start;
  gap: 10px;
  padding: 16px 24px 4px;
}
/* Os campos encolhem com a coluna (a data não invade o campo ao lado). */
.audit-filters .field,
.audit-filters input {
  min-width: 0;
}
.audit-filters input[type="date"] {
  padding-inline: 10px;
}
/* O botão fica na linha dos campos, com a mesma altura. */
.audit-filters > .button {
  align-self: end;
  min-height: 46px;
}
/* Telas médias: três filtros por linha (o botão fecha a segunda). */
@media (max-width: 1180px) {
  .audit-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.audit-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 24px;
}
.audit-count {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.audit-export {
  display: flex;
  gap: 8px;
}

/* Mesma grade no cabeçalho e no resumo de cada registro. */
.audit-header,
.audit-entry > summary {
  display: grid;
  grid-template-columns: 150px minmax(0, 1.2fr) minmax(0, 1.4fr) minmax(0, 1.4fr) 120px;
  gap: 12px;
  align-items: baseline;
}
.audit-header {
  margin: 0 24px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.audit-list {
  margin: 0 24px;
}
.audit-entry {
  border-bottom: 1px solid var(--line);
}
.audit-entry > summary {
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
  list-style: none;
}
.audit-entry > summary::-webkit-details-marker {
  display: none;
}
.audit-entry > summary:hover,
.audit-entry[open] > summary {
  background: var(--surface-2);
}
.audit-entry > summary > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.audit-time,
.audit-ip {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
/* A ação é o que se lê primeiro: quebra a linha em vez de ser cortada. */
.audit-entry > summary > span.audit-action {
  font-weight: 600;
  white-space: normal;
  overflow-wrap: anywhere;
}
.audit-event {
  margin-right: 8px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.audit-body {
  display: grid;
  gap: 10px;
  padding: 4px 12px 16px;
  font-size: 13px;
}
.audit-facts,
.audit-changes {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4px 16px;
}
.audit-facts dt,
.audit-changes dt {
  color: var(--muted);
}
.audit-facts dd,
.audit-changes dd {
  overflow-wrap: anywhere;
}
.audit-section {
  margin-top: 4px;
  font-weight: 650;
}
.audit-before {
  color: var(--overdue);
  text-decoration: line-through;
}
.audit-arrow {
  color: var(--muted);
}
.audit-after {
  color: var(--ok);
}
.audit-raw summary {
  color: var(--brand);
  cursor: pointer;
  font-weight: 550;
}
.audit-json {
  max-height: 260px;
  overflow: auto;
  margin-top: 6px;
  padding: 10px;
  border-radius: var(--radius-small);
  background: var(--surface-2);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.audit-hash {
  display: grid;
  gap: 2px;
  color: var(--faint);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 11px;
  overflow-wrap: anywhere;
}
.audit-empty {
  padding: 32px 12px;
  color: var(--muted);
  text-align: center;
}
.audit-more {
  display: flex;
  justify-content: center;
  padding: 16px 24px 24px;
}

/* Histórico do documento: painel do arquivo e resultado da conferência. */
.history-file {
  display: grid;
  gap: 10px;
  margin: 16px 24px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  font-size: 13px;
}
.history-file-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.history-file-head h3 {
  font-size: 15px;
}
.history-note {
  color: var(--muted);
}
.history-result {
  padding: 10px 12px;
  border-radius: var(--radius-small);
  background: var(--surface-2);
  font-weight: 550;
  overflow-wrap: anywhere;
}
.history-result.ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.history-result.broken {
  background: var(--overdue-soft);
  color: var(--overdue);
  font-weight: 650;
}
.history-list {
  margin-bottom: 24px;
}

@media (max-width: 900px) {
  .audit-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .audit-header {
    display: none;
  }
  .audit-entry > summary {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 12px;
  }
  .audit-action,
  .audit-record {
    grid-column: 1 / -1;
  }
}
@media (max-width: 720px) {
  .history-file {
    margin-inline: 18px;
  }
  .audit-integrity,
  .audit-toolbar {
    flex-direction: column;
    align-items: stretch;
    margin-inline: 18px;
  }
  .audit-toolbar {
    margin-inline: 0;
    padding-inline: 18px;
  }
  .audit-export {
    flex-direction: column;
  }
  .audit-filters {
    grid-template-columns: minmax(0, 1fr);
    padding-inline: 18px;
  }
  .audit-list {
    margin-inline: 18px;
  }
  .audit-facts,
  .audit-changes {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Histórico: um item por arquivo, com o resultado da conferência. */
.history-files {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.history-file-item {
  display: grid;
  gap: 3px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.history-file-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}
.history-file-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.history-file-title strong {
  overflow-wrap: anywhere;
}
.history-file-kind {
  padding: 0 7px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11px;
  font-weight: 650;
}
.history-file-meta {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.history-file-hash {
  color: var(--faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  overflow-wrap: anywhere;
}
.history-file-status {
  font-size: 12px;
  font-weight: 550;
  overflow-wrap: anywhere;
}
.history-file-status.ok {
  color: var(--ok);
}
.history-file-status.broken {
  color: var(--overdue);
  font-weight: 700;
}
.history-file-status.unknown {
  color: var(--muted);
}

