/* Position dialog at the top instead of center */
.custom-popup .MuiDialog-container {
    align-items: flex-start !important;
}

.custom-popup .MuiPaper-root {
    margin-top: 40px; /* pushes popup from very top */
    border-radius: 14px;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.18);
    animation: popupSlideDown 0.25s ease-out;
    background: #ffffff;
    overflow: hidden;
}

/* Title section */
.popup-title {
    background-color: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.title-text {
    font-size: 1.3rem;
    font-weight: 600;
    color: #1f2937;
}

/* Close button */
.close-button {
    color: #6b7280;
    transition: all 0.2s ease;
}

.close-button:hover {
    background-color: #edf2f7;
    color: #374151;
}

/* Content */
.popup-content {
    padding: 24px 28px;
    color: #4b5563;
}

/* Divider */
.popup-divider {
    height: 1px;
    background-color: #e5e7eb;
    width: 100%;
}

/* Actions */
.popup-actions {
    padding: 16px 24px;
    gap: 12px;
    display: flex;
    justify-content: flex-end;
}

.action-button {
    border-radius: 8px;
    padding: 8px 18px;
    font-weight: 500;
    text-transform: none;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

/* Contained button */
.action-button.MuiButton-contained {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.action-button.MuiButton-contained:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Outlined */
.action-button.MuiButton-outlined {
    border-color: #d1d5db;
}

.action-button.MuiButton-outlined:hover {
    background-color: #f9fafb;
}

/* Animation: slide from top */
@keyframes popupSlideDown {
    from {
        opacity: 0;
        transform: translateY(-16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile adjustments */
@media (max-width: 600px) {
    .custom-popup .MuiPaper-root {
        margin-top: 16px;
    }

    .popup-title {
        padding: 16px 20px;
    }

    .popup-content {
        padding: 20px;
    }

    .popup-actions {
        padding: 14px 20px;
        flex-direction: column;
    }

    .action-button {
        width: 100%;
    }
}


/* ==========================
   Role Management Styles
========================== */

/* Role Management Page Container */
.rm-container {
  padding: 30px;
  background-color: white;
  min-height: 100vh;
}

.rm-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 30px;
  gap: 20px;
}

.rm-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rm-header-text {
  flex: 1;
}

.rm-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--dark);
  margin: 0;
  margin-bottom: 5px;
}

.rm-subtitle {
  font-size: 14px;
  color: var(--grey-4);
  margin: 0;
}

.rm-create-button {
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rm-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

@media (max-width: 1024px) {
  .rm-grid {
    grid-template-columns: 1fr;
  }
}

.rm-card {
  background-color: white;
  border: 1px solid var(--grey-3);
  border-radius: 10px;
  padding: 20px;
  transition: all 0.2s ease;
}

.rm-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.rm-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.rm-role-info {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.rm-role-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.rm-role-info-text {
  flex: 1;
  min-width: 0;
}

.rm-role-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--dark);
  margin: 0;
  margin-bottom: 2px;
}

.rm-role-desc {
  font-size: 12px;
  color: var(--grey-4);
  margin: 0;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rm-permission-count {
  font-size: 12px;
  color: var(--grey-4);
  margin: 0;
}

.rm-actions {
  display: flex;
  gap: 8px;
}

.rm-action-button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--grey-3);
  background-color: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
}

.rm-action-button:hover {
  background-color: var(--grey-1);
  border-color: var(--grey-4);
}

.rm-action-edit:hover {
  background-color: rgba(0, 123, 255, 0.06) !important;
  border-color: var(--primary) !important;
}

.rm-action-delete:hover {
  background-color: #fff3f3 !important;
  border-color: var(--error) !important;
}

.rm-delete-confirm {
  background-color: #fff3f3;
  border-color: var(--error);
}

.rm-delete-confirm:hover {
  background-color: #ffe6e6;
  border-color: var(--error);
}

.rm-permission-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rm-tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  background-color: var(--grey-1);
  border: 1px solid var(--grey-3);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--dark);
}

.rm-more-tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  background-color: white;
  border: 1px solid var(--grey-3);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--grey-4);
}

/* Role Modal Styles */
.rm-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.rm-modal {
  background-color: white;
  border-radius: 12px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  position: relative;
  z-index: 10000;
}

.rm-modal-header {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--grey-3);
}

.rm-modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--dark);
  margin: 0;
}

.rm-modal-close-button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.rm-modal-close-button:hover {
  background-color: var(--grey-1);
}

.rm-modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.rm-modal-input-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 24px;
}

.rm-modal-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 8px;
}

.rm-modal-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--grey-3);
  border-radius: 10px;
  font-size: 14px;
  color: var(--dark);
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.rm-modal-input:focus {
  border-color: var(--primary);
}

.rm-modal-input::placeholder {
  color: var(--grey-4);
}

.rm-modal-permissions-section {
  margin-top: 20px;
}

.rm-modal-description {
  font-size: 13px;
  color: var(--grey-4);
  margin: 4px 0 20px 0;
}

.rm-modal-permission-category {
  margin-bottom: 24px;
}

.rm-modal-category-header {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.rm-modal-category-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--dark);
  margin: 0;
}

.rm-modal-collapse-button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 14px;
  color: var(--dark);
  transition: all 0.3s ease;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rm-modal-collapse-button:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.rm-modal-collapse-button svg {
  transition: transform 0.3s ease;
}

.rm-modal-collapse-button.expanded svg {
  transform: rotate(0deg);
}

.rm-modal-collapse-button.collapsed svg {
  transform: rotate(180deg);
}

.rm-modal-permission-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  overflow: hidden;
  transition: all 0.3s ease-in-out;
}

.rm-modal-permission-grid-wrapper {
  overflow: hidden;
  transition: max-height 0.4s ease-in-out, opacity 0.3s ease-in-out;
}

.rm-modal-permission-grid-wrapper.collapsed {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
}

.rm-modal-permission-grid-wrapper.expanded {
  max-height: 2000px;
  opacity: 1;
  overflow: visible;
}

@media (max-width: 640px) {
  .rm-modal-permission-grid {
    grid-template-columns: 1fr;
  }
}

.rm-modal-permission-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--grey-3);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  background-color: white;
}

.rm-modal-permission-item:hover {
  background-color: var(--grey-1);
  border-color: var(--grey-4);
}

.rm-modal-checkbox {
  margin-top: 2px;
  cursor: pointer;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.rm-modal-permission-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.rm-modal-permission-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--dark);
  word-break: break-word;
}

.rm-modal-permission-description {
  font-size: 12px;
  color: var(--grey-4);
}

/* Module Select Dropdown */
.rm-modal-select-wrapper {
  margin-bottom: 20px;
  position: relative;
  overflow: visible !important;
}

.rm-modal-select {
  width: 100%;
  padding: 12px 40px 12px 16px;
  border: 2px solid var(--grey-3);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--dark);
  background-color: white;
  background-image: linear-gradient(to bottom, #ffffff, #f8f9fa);
  cursor: pointer;
  transition: all 0.3s ease;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  position: relative;
  z-index: 99999 !important;
}

.rm-modal-select:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(0, 123, 255, 0.15);
  background-image: linear-gradient(to bottom, #ffffff, #ffffff);
}

.rm-modal-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.1), 0 2px 8px rgba(0, 123, 255, 0.2);
  background-image: linear-gradient(to bottom, #ffffff, #ffffff);
}

.rm-modal-select option {
  padding: 10px;
  font-size: 14px;
}

/* Module List Styles */
.rm-modal-modules-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rm-modal-module-item {
  border: 2px solid var(--grey-3);
  border-radius: 12px;
  padding: 16px;
  background-color: white;
  background-image: linear-gradient(to bottom, #ffffff, #fafbfc);
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.rm-modal-module-item:hover {
  background-image: linear-gradient(to bottom, #ffffff, #f8f9fa);
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(0, 123, 255, 0.1);
  transform: translateY(-2px);
}

.rm-modal-module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--grey-2);
}

.rm-modal-module-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  flex: 1;
}

.rm-modal-module-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--dark);
}

.rm-modal-remove-button {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--grey-4);
  cursor: pointer;
  padding: 0 8px;
  line-height: 1;
  transition: all 0.2s;
  border-radius: 4px;
}

.rm-modal-remove-button:hover {
  background-color: rgba(255, 0, 0, 0.1);
  color: #dc3545;
}

/* CRUD Permissions */
.rm-modal-crud-permissions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

@media (max-width: 640px) {
  .rm-modal-crud-permissions {
    grid-template-columns: 1fr;
  }
}

.rm-modal-crud-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--dark);
  padding: 10px 14px;
  border: 2px solid var(--grey-3);
  border-radius: 8px;
  background-color: white;
  transition: all 0.2s ease;
}

.rm-modal-crud-label:hover {
  border-color: var(--primary);
  background-color: rgba(0, 123, 255, 0.05);
}

.rm-modal-crud-label:has(input:checked) {
  border-color: var(--primary);
  background-color: rgba(0, 123, 255, 0.1);
  color: var(--primary);
}

.rm-modal-crud-label .MuiCheckbox-root {
  padding: 6px;
  transform: scale(1.3);
}

.rm-modal-crud-label .MuiCheckbox-root svg {
  width: 28px;
  height: 28px;
}

.rm-modal-crud-label .MuiFormControlLabel-root {
  margin-left: 0;
  margin-right: 0;
}

.rm-modal-crud-label .MuiFormControlLabel-label {
  font-size: 14px;
  font-weight: 500;
  margin-left: 8px;
}

.rm-modal-crud-checkbox {
  cursor: pointer;
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

/* All Permissions List */
.rm-modal-perm-list {
  list-style: disc;
  padding-left: 20px;
  margin: 0;
  max-height: 250px;
  overflow-y: auto;
}

.rm-modal-perm-list-item {
  margin-bottom: 8px;
}

.rm-modal-perm-list-module-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--dark);
}

.rm-modal-perm-list-sub {
  list-style: circle;
  padding-left: 20px;
  margin: 4px 0 0 0;
}

.rm-modal-perm-list-sub li {
  font-size: 13px;
  color: var(--grey-4);
  padding: 2px 0;
}

.rm-modal-footer {
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--grey-3);
}

/* Loading State */
.rm-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 60px 0;
}

/* Empty State */
.rm-empty {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 60px 0;
}

.rm-empty-text {
  font-size: 15px;
  color: var(--grey-4);
  margin: 0;
}

/* =============================================
   Module Permissions Tree View
============================================= */

.rm-tree-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  flex-wrap: wrap;
  gap: 8px;
}

.rm-tree-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Global "Select All Modules & Submodules" button */
.rm-tree-global-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rm-select-all-btn {
  padding: 5px 12px;
  border: 1.5px solid var(--primary);
  border-radius: 8px;
  background: white;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.rm-select-all-btn:hover {
  background: rgba(0, 123, 255, 0.06);
}

.rm-select-all-btn--active {
  background: rgba(0, 123, 255, 0.08);
  border-color: var(--primary);
}

/* Per-module "Select All Submodules" button */
.rm-select-module-btn {
  padding: 3px 10px;
  border: 1.5px solid var(--grey-3);
  border-radius: 6px;
  background: white;
  color: var(--grey-4);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.rm-select-module-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(0, 123, 255, 0.04);
}

.rm-select-module-btn--active {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(0, 123, 255, 0.06);
}

.rm-tree-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: rgba(0, 123, 255, 0.08);
  padding: 3px 10px;
  border-radius: 20px;
}

/* Outer tree container */
.rm-tree {
  border: 1px solid var(--grey-3);
  border-radius: 10px;
  overflow: hidden;
  background: white;
  max-height: 420px;
  overflow-y: auto;
}

/* One group = one main menu + its sub menus */
.rm-tree-group {
  border-bottom: 1px solid var(--grey-2);
}
.rm-tree-group:last-child {
  border-bottom: none;
}

/* ── Main Menu Row ── */
.rm-tree-main-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--grey-1);
  gap: 10px;
  cursor: default;
  transition: background 0.15s ease;
}
.rm-tree-main-row--enabled {
  background: rgba(0, 123, 255, 0.05);
}

.rm-tree-main-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

/* Expand/collapse arrow button */
.rm-tree-expander {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--grey-4);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.rm-tree-expander:hover {
  color: var(--dark);
  background: var(--grey-2);
}
.rm-tree-expander-placeholder {
  width: 22px;
  flex-shrink: 0;
}

/* Checkbox label wrapper */
.rm-tree-check-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
}
.rm-tree-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* Icon badge (first-letter avatar) */
.rm-tree-icon-badge {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.rm-tree-icon-badge--main {
  background: var(--primary);
  color: white;
}
.rm-tree-icon-badge--sub {
  background: var(--grey-2);
  color: var(--grey-4);
}

/* Module label text */
.rm-tree-label {
  font-size: 14px;
  color: var(--dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rm-tree-label--main {
  font-weight: 600;
}
.rm-tree-label--active {
  color: var(--primary);
  font-weight: 500;
}

/* Enabled sub-page counter badge */
.rm-tree-sub-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  background: rgba(0, 123, 255, 0.1);
  padding: 1px 7px;
  border-radius: 10px;
  flex-shrink: 0;
}

/* Permission chip strip */
.rm-tree-perms {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* Individual Read / Create / Update / Delete chip */
.rm-perm-chip {
  min-width: 60px;
  height: 26px;
  border-radius: 6px;
  border: 1.5px solid var(--grey-3);
  background: white;
  color: var(--grey-4);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  flex-shrink: 0;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.rm-perm-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(0, 123, 255, 0.05);
}
.rm-perm-chip--active {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}
.rm-perm-chip--active:hover {
  background: #0056b3;
  border-color: #0056b3;
  color: white;
}

/* ── Sub Menu List ── */
.rm-tree-submenu-list {
  background: white;
}

/* Each sub menu row */
.rm-tree-sub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px 8px 0;
  gap: 8px;
  border-top: 1px solid var(--grey-2);
  transition: background 0.15s ease;
}
.rm-tree-sub-row:hover {
  background: #f8faff;
}
.rm-tree-sub-row--enabled {
  background: rgba(0, 123, 255, 0.02);
  flex-direction: column;
  align-items: stretch;
  padding-bottom: 10px;
}

/* Full-width top line (branch + checkbox + icon + label) */
.rm-tree-sub-top {
  display: flex;
  align-items: center;
  width: 100%;
}

/* Second row: wrappable permission chips */
.rm-tree-perms-section {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  /* indent to align with label (branch 34 + gap 8 + checkbox 16 + gap 8 + icon 26 + gap 8) */
  padding-left: 100px;
  padding-top: 8px;
  padding-bottom: 4px;
  width: 100%;
  box-sizing: border-box;
}

/* A cluster of chips (CRUD group or extra group) */
.rm-tree-perms-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* Vertical divider between CRUD and extra chips */
.rm-tree-perms-sep {
  width: 1px;
  height: 20px;
  background: var(--grey-3);
  flex-shrink: 0;
  align-self: center;
}

.rm-tree-sub-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

/* Tree branch connector line */
.rm-tree-branch {
  width: 34px;
  flex-shrink: 0;
  position: relative;
  align-self: stretch;
  display: flex;
  align-items: center;
}
.rm-tree-branch::before {
  content: '';
  position: absolute;
  left: 22px;
  top: -8px;
  bottom: 50%;
  width: 10px;
  border-left: 1.5px solid var(--grey-3);
  border-bottom: 1.5px solid var(--grey-3);
  border-bottom-left-radius: 3px;
}
.rm-tree-branch--last::after {
  display: none;
}

/* Additional permission chip (locked, module-level) */
.rm-perm-chip--global {
  width: auto;
  padding: 0 8px;
  height: 26px;
  border-radius: 6px;
  border: 1.5px solid #0ea5e9;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 10px;
  font-weight: 600;
  cursor: default;
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Additional permission chip (interactive — per role / per user) */
.rm-perm-chip--extra {
  width: auto;
  padding: 0 8px;
  height: 26px;
  border-radius: 6px;
  border: 1.5px solid #a855f7;
  background: white;
  color: #7c3aed;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.rm-perm-chip--extra:hover {
  background: rgba(168, 85, 247, 0.08);
  border-color: #7c3aed;
}
.rm-perm-chip--extra-active {
  background: #7c3aed;
  color: white;
  border-color: #7c3aed;
}
.rm-perm-chip--extra-active:hover {
  background: #6d28d9;
  border-color: #6d28d9;
  color: white;
}

/* =============================================
   Module Permissions Modal (mpm-*)
============================================= */

.mpm-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 4px;
}

.mpm-module-row {
  border: 1px solid var(--grey-3);
  border-radius: 10px;
  padding: 14px 16px;
  background: white;
}

.mpm-module-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.mpm-module-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--dark);
}

.mpm-perms-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-left: 4px;
}

.mpm-no-perms {
  font-size: 12px;
  color: var(--grey-4);
  font-style: italic;
}

.mpm-perm-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mpm-perm-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex: 1;
  font-size: 13px;
  color: var(--dark);
}

.mpm-perm-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.mpm-perm-key {
  font-family: monospace;
  font-size: 12px;
  background: var(--grey-1);
  padding: 2px 6px;
  border-radius: 4px;
  color: #0369a1;
}

.mpm-perm-delete {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--grey-4);
  padding: 3px 6px;
  border-radius: 4px;
  transition: all 0.15s;
  line-height: 1;
  flex-shrink: 0;
}

.mpm-perm-delete:hover {
  background: #fee2e2;
  color: #dc2626;
}

.mpm-add-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.mpm-add-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--grey-3);
  border-radius: 8px;
  font-size: 12px;
  font-family: monospace;
  color: var(--dark);
  outline: none;
  transition: border-color 0.15s;
}

.mpm-add-input:focus {
  border-color: var(--primary);
}

.mpm-add-input::placeholder {
  color: var(--grey-4);
  font-family: monospace;
}

.mpm-add-btn {
  padding: 6px 12px;
  border: 1.5px solid var(--primary);
  border-radius: 8px;
  background: white;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.mpm-add-btn:hover:not(:disabled) {
  background: var(--primary);
  color: white;
}

.mpm-add-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}