#modal:has(#role-editor-form) {
  width: min(1060px, 96vw);
  max-width: 96vw;
}

#role-editor-form .info-strip {
  margin: 0 0 18px;
  line-height: 1.6;
}

.roles-select {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 390px;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-soft);
}

.roles-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 20px 0 14px;
  padding: 14px 16px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.roles-summary h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.roles-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.roles-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.roles-groups fieldset {
  margin: 0;
  min-width: 0;
  padding: 12px 14px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcfd;
}

.roles-groups legend {
  padding: 2px 8px;
  font-weight: 700;
  color: var(--teal-dark);
  font-size: 12.5px;
  background: #ffffff;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
}

.roles-permission {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 8px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
  cursor: pointer;
  transition: background-color 0.12s var(--ease);
}

.roles-permission:not(.is-fixed):hover {
  background: #eef6f4;
}

.roles-permission input {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  margin: 2px 0 0;
  accent-color: var(--teal);
}

.roles-permission span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.roles-permission small {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.roles-permission.is-fixed {
  color: var(--muted);
  cursor: default;
}

.roles-permission.is-fixed input {
  opacity: 0.55;
}

.roles-save-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.roles-save-row p {
  flex: 1 1 300px;
  margin: 0;
}

.roles-save-row button {
  white-space: nowrap;
}

.roles-feedback:not(:empty) {
  margin: 16px 0;
  padding: 12px 14px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 10px;
  color: #065f46;
  font-size: 13px;
  line-height: 1.5;
}

.roles-feedback.is-error:not(:empty) {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.roles-reload {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
  color: var(--muted);
  font-size: 12.5px;
}

@media (max-width: 700px) {
  .roles-groups {
    grid-template-columns: 1fr;
  }
  .roles-summary {
    align-items: flex-start;
  }
  .roles-summary .pill {
    white-space: nowrap;
  }
  .roles-save-row button {
    width: 100%;
  }
  .roles-select {
    max-width: none;
  }
  #modal:has(#role-editor-form) {
    width: calc(100vw - 20px);
  }
}
