#page-audit .audit-panel {
  container-type: inline-size;
  min-width: 0;
  overflow: hidden;
  padding: 0;
}

.audit-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
  padding: 16px 20px;
}

.audit-panel-head h3,
.audit-panel-head p {
  margin: 0;
}

.audit-panel-head p {
  margin-top: 4px;
  color: #526681;
  font-size: 13px;
}

.audit-filters {
  display: grid;
  grid-template-columns: minmax(170px, 1.65fr) minmax(105px, 1fr) repeat(2, minmax(115px, 1fr)) minmax(278px, 2.2fr);
  gap: 10px;
  align-items: end;
  margin: 0;
  padding: 13px 20px;
  border-block: 1px solid #e0e7f1;
  background: #f6f8fc;
}

.audit-filters label {
  display: grid;
  min-width: 0;
  gap: 4px;
  margin: 0;
  color: #445a78;
  font-size: 12px;
}

.audit-filters label > :is(input, select) {
  width: 100%;
  min-width: 0;
  margin: 0;
  background: #fff;
}

.audit-date-range {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.audit-filter-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  grid-column: 1 / -1;
}

.audit-error {
  margin: 12px 20px 0;
  padding: 8px 12px;
  border: 1px solid #f0d0d7;
  border-radius: 8px;
  background: #fff4f5;
  color: #98233b;
}

.audit-results[aria-busy="true"] {
  opacity: .72;
}

.audit-table-wrap {
  max-height: 420px;
  overflow: auto;
  scrollbar-color: #b9c2d1 transparent;
}

.audit-table {
  width: 100%;
  table-layout: fixed;
  border-spacing: 0;
}

.audit-col-time { width: 112px; }
.audit-col-user { width: 110px; }
.audit-col-action { width: 112px; }
.audit-col-business { width: 168px; }
.audit-col-detail { width: 100px; }

.audit-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 40px;
  padding: 6px 11px;
  background: #edf2fa;
  color: #435a78;
  font-size: 12px;
}

.audit-table .audit-sort {
  display: flex;
  width: 100%;
  min-height: 27px;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  text-align: start;
  font: inherit;
  font-weight: 700;
}

.audit-sort span { color: #647c9a; }
.audit-table th[aria-sort] .audit-sort,
.audit-table th[aria-sort] .audit-sort span {
  color: #244a85;
}

.audit-sort:focus-visible {
  outline: 2px solid #557fc2;
  outline-offset: 2px;
}

.audit-table tbody td {
  height: 54px;
  padding: 8px 11px;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.audit-table tbody tr:hover { background: #f2f6fc; }

.audit-time-cell time,
.audit-business-cell {
  font-variant-numeric: tabular-nums;
}

.audit-time-cell time > *,
.audit-business-cell > * {
  display: block;
}

.audit-time-cell time > * {
  white-space: nowrap;
}

.audit-time-cell span,
.audit-business-cell small {
  color: #546984;
  font-size: 11px;
}

.audit-business-cell small {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audit-action {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 6px;
  background: #eaf0fa;
  color: #345785;
  font-size: 11px;
  font-weight: 700;
}

.audit-action.is-positive { background: #e7f5ee; color: #14634c; }
.audit-action.is-warning { background: #fbecef; color: #9c263c; }

.audit-summary {
  display: -webkit-box;
  overflow: hidden;
  color: #384b65;
  white-space: pre-line;
  line-height: 1.65;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.audit-pager .pager-controls,
.audit-page-jump {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
}

.audit-pager .pager-controls button { white-space: nowrap; }
.audit-pager .page-jump { white-space: nowrap; }

.audit-empty {
  margin: 0;
  padding: 38px 14px;
  color: #526681;
  text-align: center;
}

.audit-detail-dialog dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin: 0 0 14px;
  padding: 4px;
  border: 1px solid #e0e7f1;
  border-radius: 12px;
  background: #f6f8fc;
}

.audit-detail-dialog dl div { padding: 8px 10px; }
.audit-detail-dialog dt { color: #526681; font-size: 12px; }
.audit-detail-dialog dd { margin: 3px 0 0; font-weight: 650; overflow-wrap: anywhere; }
.audit-detail-dialog h4 { margin: 0 0 6px; }

.audit-detail-dialog pre {
  max-height: 44dvh;
  overflow: auto;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid #e0e7f1;
  border-radius: 9px;
  background: #fbfcff;
  color: #263953;
  font: inherit;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.audit-detail-dialog pre.is-error { color: #98233b; }

@container (max-width: 1040px) {
  .audit-filters { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .audit-date-range { grid-column: span 2; }
  .audit-filter-actions { grid-column: span 2; }
}

@container (max-width: 720px) {
  .audit-panel-head, .audit-filters { padding: 12px; }
  .audit-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .audit-keyword { grid-column: 1 / -1; }
  .audit-filters > label:nth-of-type(2) { grid-column: 1 / -1; }
  .audit-date-range { grid-column: 1 / -1; }
  .audit-table-wrap { max-height: none; }
  .audit-table, .audit-table tbody { display: block; }
  .audit-table colgroup { display: none; }
  .audit-table thead {
    display: block;
    padding: 5px 8px;
    background: #edf2fa;
  }
  .audit-table thead tr { display: flex; gap: 6px; }
  .audit-table thead th {
    position: static;
    flex: 1;
    min-width: 0;
    height: auto;
    padding: 2px 3px;
    border: 0;
    white-space: normal;
  }
  .audit-table thead th:nth-child(n+5) { display: none; }
  .audit-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 6px 9px;
    padding: 10px 12px;
    border-bottom: 1px solid #e1e8f2;
  }
  .audit-table tbody td {
    display: block;
    height: auto;
    padding: 0;
    border: 0;
    background: transparent;
  }
  .audit-table .audit-time-cell { grid-area: 1 / 1; }
  .audit-table .audit-user-cell { grid-area: 2 / 1; }
  .audit-table .audit-action-cell { grid-area: 1 / 3; justify-self: end; }
  .audit-table .audit-business-cell { grid-area: 1 / 2; }
  .audit-table .audit-summary-cell { grid-area: 2 / 2 / 3 / 4; }
  .audit-table .audit-detail-cell { grid-area: 3 / 3; justify-self: end; }
}

@media (max-width: 600px) {
  .audit-detail-dialog dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
