.system-admin-panel {
  display: grid;
  gap: 18px;
}

.filter-section {
  padding-bottom: 20px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 18px 20px 0;
}

.filter-grid label {
  display: grid;
  gap: 7px;
}

.filter-grid span {
  color: var(--th-color-slate-500);
  font-size: 12px;
  font-weight: 700;
}

.filter-grid input,
.filter-grid select,
.form-grid input,
.form-grid select,
.stacked-form input,
.stacked-form select {
  min-height: 38px;
  min-width: 0;
  border: 1px solid var(--th-color-slate-200);
  border-radius: var(--th-radius-sm);
  background: var(--th-color-white);
  color: var(--th-color-slate-900);
  padding: 8px 10px;
}

.filter-grid select[multiple],
.form-grid select[multiple],
.stacked-form select[multiple] {
  min-height: 96px;
}

.action-section {
  padding-bottom: 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 18px 20px 0;
}

.form-grid label,
.stacked-form label {
  display: grid;
  gap: 7px;
}

.form-grid span,
.stacked-form span {
  color: var(--th-color-slate-500);
  font-size: 12px;
  font-weight: 800;
}

.stacked-form {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--th-color-slate-200);
  padding-top: 14px;
}

.form-message {
  margin: 0;
  color: var(--th-color-slate-500);
  font-size: 12px;
  font-weight: 700;
}

.system-admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
}

.system-admin-menu-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(360px, 1.05fr);
  gap: 18px;
  align-items: start;
}

.section-actions,
.form-actions,
.menu-tree-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-actions,
.form-actions {
  justify-content: flex-end;
}

.filter-grid .checkbox-field {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 9px;
  align-self: end;
  border: 1px solid var(--th-color-slate-200);
  border-radius: var(--th-radius-sm);
  background: var(--th-color-white);
  padding: 8px 10px;
}

.filter-grid .checkbox-field input {
  min-height: 0;
  width: 16px;
  height: 16px;
  padding: 0;
}

.menu-warning-panel {
  display: grid;
  gap: 12px;
  border-color: rgba(245, 158, 11, 0.35);
  background: #fffbeb;
}

.menu-warning-panel ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0 0 0 18px;
  color: #92400e;
  font-size: 13px;
  font-weight: 700;
}

.menu-operation-panel {
  display: grid;
  gap: 8px;
  border-color: rgba(245, 158, 11, 0.28);
  background: var(--th-color-white);
}

.menu-tree-section,
.menu-detail-panel {
  align-self: start;
  overflow: hidden;
}

.menu-tree {
  display: grid;
  gap: 8px;
  padding: 14px 20px 20px;
}

.menu-tree-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto auto;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  border: 1px solid var(--th-color-slate-200);
  border-radius: var(--th-radius-sm);
  background: var(--th-color-white);
  padding: 8px 10px;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.menu-tree-row:hover {
  border-color: rgba(37, 99, 235, 0.36);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.07);
  transform: translateY(-1px);
}

.menu-tree-row--selected {
  border-color: var(--th-color-blue-600);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.18);
}

.menu-tree-row--muted {
  background: var(--th-color-slate-50);
}

.menu-tree-row--warning {
  border-color: rgba(245, 158, 11, 0.45);
}

.menu-tree-main {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, max-content) minmax(80px, 1fr);
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.menu-tree-branch {
  width: 9px;
  height: 9px;
  border: 2px solid var(--th-color-blue-600);
  border-radius: 50%;
  background: var(--th-color-blue-50);
}

.menu-tree-name {
  overflow: hidden;
  color: var(--th-color-slate-900);
  font-size: 13px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-tree-meta {
  color: var(--th-color-slate-500);
  font-size: 12px;
  font-weight: 800;
}

.status-pill--active {
  background: #dcfce7;
  color: #15803d;
}

.code-chip--warning {
  background: #ffedd5;
  color: #c2410c;
}

.icon-button {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--th-color-slate-200);
  border-radius: var(--th-radius-sm);
  background: var(--th-color-white);
  color: var(--th-color-slate-700);
  cursor: pointer;
}

.icon-button:hover:not(:disabled) {
  border-color: var(--th-color-blue-600);
  color: var(--th-color-blue-600);
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.menu-config-form {
  padding: 16px 20px 20px;
}

.form-message--warning {
  color: #b45309;
}

.form-message--error {
  color: var(--th-color-danger);
}

.text-button,
.row-action {
  border: 0;
  background: transparent;
  color: var(--th-color-blue-600);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  padding: 0;
  text-decoration: none;
}

.text-button:disabled,
.row-action:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.empty-state {
  min-height: 220px;
  display: grid;
  place-items: center;
  color: var(--th-color-slate-500);
  font-size: 13px;
  padding: 24px;
  text-align: center;
}

.empty-state--compact {
  min-height: 160px;
}

.empty-state--error {
  color: var(--th-color-danger);
}

.table-section {
  overflow: hidden;
}

.table-wrap {
  overflow-x: auto;
  padding: 14px 20px 20px;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--th-color-slate-200);
  padding: 14px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--th-color-slate-500);
  font-size: 12px;
  font-weight: 800;
}

td {
  color: var(--th-color-slate-900);
  font-size: 13px;
}

td strong,
td small {
  display: block;
}

td small {
  margin-top: 4px;
  color: var(--th-color-slate-500);
  font-size: 12px;
}

.status-pill,
.code-chip {
  display: inline-flex;
  max-width: 100%;
  min-height: 24px;
  align-items: center;
  border-radius: var(--th-radius-sm);
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
}

.status-pill {
  background: var(--th-color-slate-100);
  color: var(--th-color-slate-700);
}

.code-chip {
  overflow-wrap: anywhere;
  background: var(--th-color-blue-50);
  color: var(--th-color-blue-700);
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid var(--th-color-slate-200);
  padding: 14px 20px 18px;
}

.page-size-control,
.pagination-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-size-control span,
.pagination-actions span {
  color: var(--th-color-slate-500);
  font-size: 12px;
  font-weight: 800;
}

.page-size-control select {
  min-height: 34px;
  border: 1px solid var(--th-color-slate-200);
  border-radius: var(--th-radius-sm);
  background: var(--th-color-white);
  color: var(--th-color-slate-900);
  padding: 6px 8px;
}

.primary-button,
.secondary-button {
  min-height: 34px;
  border: 1px solid var(--th-color-slate-200);
  border-radius: var(--th-radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  padding: 6px 12px;
}

.primary-button {
  align-self: end;
  background: var(--th-color-blue-600);
  border-color: var(--th-color-blue-600);
  color: var(--th-color-white);
}

.secondary-button {
  background: var(--th-color-white);
  color: var(--th-color-slate-700);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.detail-panel {
  align-self: start;
  overflow: hidden;
}

.detail-list {
  display: grid;
  gap: 14px;
  padding: 16px 20px 20px;
}

.detail-list div {
  display: grid;
  gap: 5px;
}

.detail-list span {
  color: var(--th-color-slate-500);
  font-size: 12px;
  font-weight: 800;
}

.detail-list strong {
  color: var(--th-color-slate-900);
  font-size: 13px;
}

.detail-list small {
  color: var(--th-color-slate-500);
  font-size: 12px;
}

.permission-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

@media (max-width: 980px) {
  .system-admin-grid,
  .system-admin-menu-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .filter-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .pagination-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-actions,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .menu-tree-row {
    grid-template-columns: 1fr;
  }

  .menu-tree-actions {
    justify-content: flex-start;
  }
}
