/* User management */
.permission-caution { display: block; margin-top: 5px; color: #aa6b14; font-size: 11px; }
.permission-group[hidden],.permission-group label[hidden] { display: none !important; }
#usersDialog .users-workspace { padding: 0; gap: 0; height: 100%; overflow: hidden; background: #f5f7fc; }
#usersDialog .users-page-heading { margin: 0; padding: 24px 30px; background: white; border-bottom: 1px solid #e5eaf3; }
.users-settings-shell { display: grid; grid-template-columns: 260px minmax(0,1fr); flex: 1; min-height: 0; }
.users-settings-nav { padding: 26px 16px; background: white; border-right: 1px solid #e5eaf3; display: flex; flex-direction: column; gap: 12px; }
.users-settings-nav small { padding: 0 12px 16px; color: #8390a7; font-size: 11px; letter-spacing: .07em; }
.users-settings-nav button { text-align: left; display: grid; gap: 7px; background: transparent; color: #4f607c; padding: 16px; border: 1px solid transparent; border-radius: 12px; white-space: normal; }
.users-settings-nav button span { font-size: 12px; font-weight: normal; color: #8190aa; }
.users-settings-nav button[aria-current="page"] { background: #edf1ff; color: #315dec; border-color: #8a9fff; }
.users-nav-tip { padding: 18px 12px; font-size: 12px; color: #8390a7; line-height: 1.6; }
.users-settings-content { min-width: 0; overflow: auto; padding: 26px; }
.users-settings-content > [hidden] { display: none !important; }
.users-summary { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin-bottom: 22px; }
.users-summary > div { display: grid; gap: 10px; border: 1px solid #e3e9f3; border-radius: 14px; padding: 18px; background: white; }
.users-summary span { font-size: 12px; color: #7d8ba3; }
.users-summary strong { font-size: 26px; color: #27344c; }
#usersDialog .users-toolbar { grid-template-columns: minmax(160px,1fr) minmax(120px,160px) minmax(120px,160px) max-content; margin-bottom: 18px; }
@media(max-width:1000px) { .users-settings-shell { grid-template-columns: 210px minmax(0,1fr); } #usersDialog .users-toolbar { grid-template-columns: 1fr 1fr; } .users-summary { grid-template-columns: 1fr 1fr; } }
.users-dialog {
  width: 100vw;
  max-width: none;
}

.users-workspace {
  min-height: 0;
  gap: 14px;
  overflow-x: hidden;
  overflow-y: auto;
}

.users-toolbar {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) 180px 180px max-content;
  gap: 10px;
  align-items: center;
}

.users-layout {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  min-height: 0;
  width: 100%;
  max-height: none;
  gap: 14px;
}

.role-management-section {
  display: grid;
  flex: 0 0 auto;
  gap: 12px;
  min-height: auto;
  padding: 16px;
  border: 1px solid #dbe3ef;
  border-radius: 16px;
  background: #fff;
  width: 100%;
}

.role-management-section > .dialog-title { align-items: end; }
.role-management-section > .dialog-title h3,
.role-management-section > .dialog-title p { margin: 0; }
.role-management-section > .dialog-title p { margin-top: 5px; color: #687487; }
.role-selector-actions { display: flex; align-items: end; gap: 10px; }
.role-selector { display: grid; grid-template-columns: auto 220px; align-items: center; gap: 10px; }
.role-selector span { font-weight: 700; color: #58677c; }
.role-permission-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.role-permission-toolbar > span { color: #58677c; }
.role-management-section .permission-groups {
  max-height: none;
  overflow: visible;
}
.role-management-section > .dialog-actions { justify-content: space-between; align-items: center; }
.role-management-section > .dialog-actions .message { margin: 0; flex: 1; }

.role-create-dialog .auth-form { width: min(520px, calc(100vw - 32px)); }
.role-create-dialog label { display: grid; gap: 7px; }
.role-create-dialog label > span { color: #58677c; font-weight: 700; }

.users-list-wrap {
  flex: 0 0 auto !important;
  width: 100%;
  min-width: 0;
  max-height: 360px;
  overflow: auto;
  border: 1px solid #dbe3ef;
  border-radius: 14px;
  background: #fff;
}

.users-list-wrap table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.users-list-wrap th,
.users-list-wrap td {
  padding: 11px 10px;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.users-list-wrap th:nth-child(1) { width: 15%; }
.users-list-wrap th:nth-child(2) { width: 20%; }
.users-list-wrap th:nth-child(3) { width: 14%; }
.users-list-wrap th:nth-child(4) { width: 18%; }
.users-list-wrap th:nth-child(5) { width: 17%; }
.users-list-wrap th:nth-child(6) { width: 16%; }

.users-list-wrap tr[data-user-id] {
  cursor: pointer;
}

.users-list-wrap tr[data-user-id]:hover,
.users-list-wrap tr.selected {
  background: #eef5ff;
}

.users-list-wrap td:last-child {
  text-align: right;
}

.users-list-wrap td:last-child button {
  max-width: 100%;
  padding-inline: 8px;
}

.user-editor {
  width: 100%;
  min-width: 0;
  min-height: 0;
  max-height: none;
  overflow: visible;
  border: 1px solid #dbe3ef;
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #fff;
}

.user-editor > .dialog-title {
  min-height: 46px;
}

.user-editor > .dialog-title h3,
.user-editor > .dialog-title p {
  margin: 0;
}

.user-editor > .dialog-title p {
  margin-top: 5px;
  color: #687487;
  font-size: 14px;
}

.user-main-fields {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(190px, 260px) minmax(210px, 300px);
  gap: 12px;
  align-items: end;
}

.user-main-fields label {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.user-main-fields label > span {
  color: #58677c;
  font-weight: 700;
}

.user-active-field {
  display: flex !important;
  align-items: center;
  justify-content: flex-start;
  min-height: 44px;
  padding: 0 4px;
  white-space: nowrap;
}

.user-active-field input {
  width: auto;
  margin: 0 9px 0 0;
}

.user-comment-field {
  grid-column: 3;
}

.user-password-field {
  grid-column: 1 / 3;
}

.user-permissions-section {
  display: grid;
  min-height: 0;
  gap: 12px;
  border-top: 1px solid #e4e9f1;
  padding-top: 14px;
}

.permission-groups {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 12px;
  max-height: 380px;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 4px;
}

.permission-group {
  min-width: 0;
  border: 1px solid #dbe3ef;
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 9px;
  align-content: start;
  background: #fbfcfe;
}

.permission-group h4 {
  margin: 0 0 3px;
}

.permission-group label {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.permission-group input {
  width: auto;
  margin: 2px 0 0;
}

.permission-groups.is-admin {
  opacity: .58;
  pointer-events: none;
}

.user-editor > .message {
  grid-column: auto;
  margin: 0;
}

.user-editor-actions {
  position: sticky;
  bottom: -18px;
  z-index: 2;
  justify-content: flex-end;
  margin: 0 -18px -18px;
  padding: 12px 18px 18px;
  border-top: 1px solid #e4e9f1;
  background: #fff;
}

.user-editor-actions .danger-button {
  margin-right: auto;
}

@media (max-width: 1600px) {
  .user-main-fields {
    grid-template-columns: minmax(200px, 1fr) minmax(180px, 230px);
  }

  .user-active-field {
    grid-column: 1 / -1;
    min-height: 30px;
  }

  .user-comment-field {
    grid-column: 2;
  }

  .user-password-field {
    grid-column: 1;
  }

  .permission-groups {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
}

@media (max-width: 760px) {
  .role-management-section > .dialog-title,
  .role-selector-actions { align-items: stretch; }
  .role-selector-actions { flex-direction: column; }
  .role-selector { grid-template-columns: 1fr; }
}
