/* Member linked system user */
.system-user-link-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  margin: 4px 0 14px;
  border: 1px solid rgba(15,127,85,.16);
  border-radius: 24px;
  background: linear-gradient(135deg, #ecfdf3, #fff);
}
.system-user-link-card > div:first-child {
  display: grid;
  gap: 3px;
}
.system-user-link-card strong {
  font-weight: 1000;
}
.system-role-pill {
  width: max-content;
  margin: 5px 0 2px;
  background: #eef2ff;
  color: #3730a3;
}
#email[readonly],
#password:disabled {
  background: #f8fafc;
  color: #64748b;
}


.system-user-link-card select:not(:disabled) {
  cursor: pointer;
  background-color: #fff;
}

.system-user-link-card select:disabled {
  cursor: not-allowed;
  background-color: #f8fafc;
}


/* Searchable system user selector */
.system-user-search-select {
  position: relative;
  width: 100%;
}

.system-user-search-btn {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid rgba(148,163,184,.35);
  border-radius: 18px;
  background: #fff;
  color: #0f172a;
  font-weight: 950;
  text-align: left;
  cursor: pointer;
}

.system-user-search-btn:disabled {
  cursor: not-allowed;
  background: #f8fafc;
  color: #64748b;
}

.system-user-search-menu {
  position: absolute;
  z-index: 80;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  padding: 10px;
  border: 1px solid rgba(15,23,42,.12);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 24px 55px rgba(15,23,42,.16);
}

.system-user-search-menu input {
  width: 100%;
  margin-bottom: 10px;
}

.system-user-search-options {
  display: grid;
  gap: 8px;
  max-height: 290px;
  overflow: auto;
}

.system-user-option {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px;
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 16px;
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.system-user-option strong,
.system-user-option small {
  display: block;
}

.system-user-option small {
  margin-top: 2px;
  color: #64748b;
  font-weight: 750;
}

.system-user-option.is-selected {
  border-color: rgba(15,127,85,.35);
  background: #ecfdf3;
}

.system-user-option.is-disabled {
  opacity: .52;
  cursor: not-allowed;
}

.system-user-option-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: #ecfdf3;
  color: #0f7f55;
  font-weight: 1000;
}

.system-user-no-results {
  padding: 10px;
}


/* Compact Members table: no horizontal scroll needed for actions */
.members-compact-wrap {
  overflow-x: visible;
}

.members-compact-table {
  table-layout: fixed;
  width: 100%;
  min-width: 0;
}

.members-compact-table th,
.members-compact-table td {
  padding: 12px 10px;
  vertical-align: middle;
}

.members-compact-table th:nth-child(1),
.members-compact-table td:nth-child(1) { width: 31%; }

.members-compact-table th:nth-child(2),
.members-compact-table td:nth-child(2) { width: 24%; }

.members-compact-table th:nth-child(3),
.members-compact-table td:nth-child(3) { width: 18%; }

.members-compact-table th:nth-child(4),
.members-compact-table td:nth-child(4) { width: 10%; }

.members-compact-table th:nth-child(5),
.members-compact-table td:nth-child(5) { width: 17%; }

.compact-identity {
  gap: 10px;
}

.compact-identity .avatar,
.compact-identity .avatar-img,
.avatar-sm {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 14px;
  font-size: .95rem;
}

.members-compact-table strong,
.members-compact-table small {
  max-width: 100%;
}

.members-compact-table small {
  display: block;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.members-compact-table td {
  overflow: hidden;
}

.members-table-actions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}

.members-table-actions .btn-small {
  padding: 6px 9px;
  min-height: 30px;
  border-radius: 10px;
  font-size: .76rem;
  line-height: 1;
}

.members-actions-head {
  text-align: right;
}

.member-status-cell .pill {
  width: max-content;
  max-width: 100%;
}

.member-main-cell,
.member-contact-cell,
.member-activity-cell,
.member-status-cell {
  min-width: 0;
}

.member-contact-cell strong,
.member-activity-cell strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-extra {
  display: none !important;
}

@media (max-width: 1050px) {
  .members-compact-table th:nth-child(3),
  .members-compact-table td:nth-child(3) {
    display: none;
  }

  .members-compact-table th:nth-child(1),
  .members-compact-table td:nth-child(1) { width: 38%; }

  .members-compact-table th:nth-child(2),
  .members-compact-table td:nth-child(2) { width: 28%; }

  .members-compact-table th:nth-child(4),
  .members-compact-table td:nth-child(4) { width: 14%; }

  .members-compact-table th:nth-child(5),
  .members-compact-table td:nth-child(5) { width: 20%; }
}

@media (max-width: 820px) {
  .members-compact-wrap {
    overflow-x: visible;
  }

  .members-compact-table thead {
    display: none;
  }

  .members-compact-table,
  .members-compact-table tbody,
  .members-compact-table tr,
  .members-compact-table td {
    display: block;
    width: 100% !important;
  }

  .members-compact-table tr {
    padding: 12px;
    margin-bottom: 12px;
    border: 1px solid rgba(15,23,42,.08);
    border-radius: 18px;
    background: #fff;
  }

  .members-compact-table td {
    padding: 6px 0;
  }

  .member-status-cell {
    display: inline-flex !important;
    gap: 8px;
    align-items: center;
  }

  .members-table-actions {
    justify-content: flex-start;
    padding-top: 10px !important;
  }

  .members-table-actions .btn-small {
    flex: 0 0 auto;
  }

  .desktop-muted {
    display: none !important;
  }

  .mobile-extra {
    display: block !important;
  }
}


/* Member -> User privileges */
.member-system-privileges-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  margin: 4px 0 14px;
  border: 1px solid rgba(37, 99, 235, .16);
  border-radius: 24px;
  background: linear-gradient(135deg, #eff6ff, #fff);
}

.privilege-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.privilege-head strong {
  display: block;
  font-weight: 1000;
}

.privilege-head span {
  display: block;
  color: #64748b;
  font-size: .88rem;
}

.privilege-switch {
  display: inline-grid !important;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
  margin: 0;
  font-weight: 950;
}

.member-permission-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.member-permissions-list {
  display: grid;
  gap: 12px;
  max-height: 360px;
  overflow: auto;
  padding-right: 3px;
}

.member-permission-group {
  padding: 12px;
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 18px;
  background: #fff;
}

.member-permission-group-title {
  font-weight: 1000;
  margin-bottom: 8px;
}

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

.member-permission-item {
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  margin: 0;
  padding: 9px;
  border: 1px solid rgba(15,23,42,.06);
  border-radius: 14px;
  background: #f8fafc;
}

.member-permission-item strong,
.member-permission-item small {
  display: block;
  line-height: 1.25;
}

.member-permission-item small {
  color: #64748b;
  font-size: .74rem;
}

@media (max-width: 760px) {
  .privilege-head {
    display: grid;
  }

  .member-permission-grid {
    grid-template-columns: 1fr;
  }
}
