#systemManagement {
  min-width: 0;
  color: var(--theme-text);
}

.system-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: max-content;
  max-width: 100%;
  margin: 0 0 18px;
  padding: 4px;
  border: 1px solid var(--theme-border);
  border-radius: 10px;
  background: var(--theme-raised);
}

.system-tabs button {
  padding: 9px 16px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--theme-muted);
  font-size: 13px;
}

.system-tabs button[aria-selected="true"] {
  background: var(--theme-panel);
  color: var(--theme-action);
  font-weight: 650;
  box-shadow: 0 1px 4px #183b6518;
}

#systemManagement :is(button, input, select):focus-visible {
  outline: 2px solid var(--theme-focus);
  outline-offset: 2px;
}

.system-card {
  min-width: 0;
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid var(--theme-border);
  border-radius: 8px;
  background: var(--theme-panel);
}

.system-member-tools,
.system-audit-tools {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--theme-border);
}

.system-member-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) minmax(145px, 1fr) minmax(120px, .8fr);
  flex: 1;
  gap: 12px;
}

.system-audit-filters {
  display: grid;
  grid-template-columns: minmax(240px, 1.8fr) minmax(170px, 1fr);
  flex: 1;
  gap: 12px;
}

.system-member-filters label,
.system-audit-filters label {
  display: grid;
  min-width: 0;
  gap: 7px;
  color: var(--theme-muted);
  font-size: 12px;
}

.system-member-filters :is(input, select),
.system-audit-filters :is(input, select) {
  width: 100%;
  min-width: 0;
  min-height: 37px;
  padding: 8px 10px;
  border: 1px solid var(--theme-border);
  border-radius: 7px;
  background: var(--theme-panel);
  color: var(--theme-text);
  font-size: 13px;
}

.system-member-filters input::placeholder,
.system-audit-filters input::placeholder {
  color: var(--theme-muted);
}

.system-member-actions {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

#systemManagement .system-member-actions button {
  min-height: 37px;
  padding: 8px 13px;
  border: 1px solid var(--theme-border);
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
}

#systemManagement .system-member-actions .primary {
  border-color: var(--theme-action);
}

#systemManagement .system-member-actions .secondary {
  color: var(--theme-secondary);
}

.system-table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

.system-table-wrap:focus-visible {
  outline: 2px solid var(--theme-focus);
  outline-offset: -2px;
}

.system-table-wrap > .system-table {
  width: 100%;
  min-width: 580px;
  border-collapse: collapse;
  color: var(--theme-text);
  font-size: 12px;
}

.system-table th {
  padding: 14px 16px;
  background: var(--theme-raised);
  color: var(--theme-muted);
  font-size: 11px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.system-table td {
  padding: 15px 16px;
  border-top: 1px solid var(--theme-border);
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.system-table tr:hover td {
  background: var(--theme-hover);
}

.system-table td:first-child {
  font-variant-numeric: tabular-nums;
}

.system-table td:last-child {
  min-width: 120px;
}

.system-member-source {
  display: block;
  margin-top: 4px;
  color: var(--theme-muted);
  font-size: 10px;
  line-height: 1.5;
}

.system-member-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  white-space: nowrap;
}

.system-member-status::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.system-member-status.is-active {
  color: var(--theme-green);
}

.system-member-status.is-inactive,
.system-muted {
  color: var(--theme-muted);
}

.system-row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.system-table .link-btn {
  border-radius: 3px;
  color: var(--theme-link);
  white-space: nowrap;
}

.system-table .link-btn:hover:not(:disabled) {
  text-decoration: underline;
}

.system-member-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--theme-border);
  color: var(--theme-muted);
  font-size: 11px;
}

.system-page-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.system-page-buttons button {
  padding: 5px 10px;
  border: 1px solid var(--theme-border);
  border-radius: 5px;
  background: transparent;
  color: var(--theme-text);
}

.system-page-buttons button:hover:not(:disabled) {
  background: var(--theme-hover);
}

.system-page-buttons button:disabled {
  cursor: default;
}

.system-caption {
  margin: 0 0 14px;
  color: var(--theme-muted);
  font-size: 12px;
  line-height: 1.8;
}

.system-notice {
  margin-bottom: 18px;
  padding: 12px 16px;
  border: 1px solid var(--theme-border);
  border-radius: 8px;
  background: var(--theme-raised);
}

.form-grid > .system-caption {
  margin: 0;
}

.system-identity-fields {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-width: 0;
  gap: 14px;
  margin: 0;
  padding: 0;
  border: 0;
}

.system-table td.system-empty {
  padding: 48px 16px;
  background: var(--theme-panel);
  color: var(--theme-muted);
  text-align: center;
}

.system-audit-table td {
  padding: 14px 16px;
  vertical-align: top;
}

.audit-time-cell {
  width: 162px;
  color: var(--theme-secondary);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.audit-actor-cell {
  width: 112px;
  color: var(--theme-text);
  font-weight: 500;
  white-space: nowrap;
}

.audit-action-cell {
  width: 140px;
  white-space: nowrap;
}

.audit-content-cell {
  min-width: 360px;
}

.audit-action-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.audit-action-badge.is-create {
  background: var(--theme-green-bg);
  color: var(--theme-green);
}

.audit-action-badge.is-edit {
  background: var(--theme-selected);
  color: var(--theme-blue);
}

.audit-action-badge.is-danger {
  background: var(--theme-red-bg);
  color: var(--theme-red);
}

.audit-action-badge.is-neutral {
  background: var(--theme-raised);
  color: var(--theme-secondary);
}

.audit-detail {
  display: grid;
  gap: 8px;
  min-width: 0;
  line-height: 1.6;
}

.audit-headline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}

.audit-record-title {
  color: var(--theme-text);
  font-size: 13px;
  font-weight: 600;
}

.audit-record-context {
  color: var(--theme-secondary);
  font-size: 12px;
}

.audit-count-tag {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--theme-raised);
  color: var(--theme-muted);
  font-size: 11px;
  white-space: nowrap;
}

.audit-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.audit-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  max-width: 100%;
  padding: 3px 8px;
  border: 1px solid var(--theme-border);
  border-radius: 6px;
  background: var(--theme-page);
  font-size: 12px;
}

.audit-field-name {
  flex: none;
  color: var(--theme-muted);
  font-size: 11px;
}

.audit-field-val {
  color: var(--theme-text);
  font-weight: 500;
  overflow-wrap: anywhere;
}

.audit-diff-list {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.audit-diff-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  font-size: 12px;
}

.audit-diff-values {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.audit-old {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--theme-raised);
  color: var(--theme-muted);
  text-decoration: line-through;
  overflow-wrap: anywhere;
}

.audit-old.is-empty {
  text-decoration: none;
}

.audit-arrow {
  color: var(--theme-muted);
  font-size: 11px;
}

.audit-new {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--theme-selected);
  color: var(--theme-text);
  font-weight: 500;
  overflow-wrap: anywhere;
}

.audit-new.is-empty {
  background: var(--theme-raised);
  color: var(--theme-muted);
  font-weight: 400;
}

.audit-more {
  margin-top: 2px;
}

.audit-more summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--theme-link);
  font-size: 12px;
  user-select: none;
  list-style: none;
}

.audit-more summary::-webkit-details-marker {
  display: none;
}

.audit-more summary::after {
  content: "▾";
  font-size: 11px;
  transition: transform .15s;
}

.audit-more[open] > summary::after {
  transform: rotate(180deg);
}

.audit-more summary:hover {
  text-decoration: underline;
}

.audit-more[open] > :not(summary) {
  margin-top: 6px;
}

.audit-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.audit-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border: 1px solid var(--theme-border);
  border-radius: 6px;
  background: var(--theme-page);
  color: var(--theme-text);
  font-size: 12px;
}

.audit-plain-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--theme-text);
  font-size: 12px;
}

.audit-text {
  color: var(--theme-text);
  font-size: 12px;
}

@container workspace (max-width: 900px) {
  .system-member-tools,
  .system-audit-tools {
    flex-direction: column;
    align-items: stretch;
  }

  .system-member-actions {
    justify-content: flex-end;
  }
}

@container workspace (max-width: 760px) {
  .system-member-tools,
  .system-audit-tools {
    padding: 15px;
  }

  .system-member-filters,
  .system-audit-filters {
    grid-template-columns: minmax(0, 1fr);
  }

  .system-table :is(th, td) {
    padding-inline: 12px;
  }

  .system-member-pagination {
    padding-inline: 12px;
  }
}

@media (max-width: 760px) {
  .system-identity-fields {
    grid-template-columns: minmax(0, 1fr);
  }
}
