body, html {
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
  background: #fafbfc;
  margin: 0;
  padding: 0;
  color: #18181b;
}

.roles-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: #fff;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  align-items: center;
  padding: 0 32px;
  z-index: 100;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.5px;
}

.roles-root {
  display: flex;
  min-height: 100vh;
  background: #fafbfc;
}

.roles-sidebar {
  width: 220px;
  background: #fff;
  border-right: 1px solid #f0f0f0;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin-top: 56px;
  position: relative;
}

.roles-sidebar-title {
  font-weight: 600;
  font-size: 20px;
  padding: 24px 0 16px 32px;
  letter-spacing: -0.5px;
}

.roles-sidebar-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.roles-sidebar-item {
  padding: 8px 0 8px 32px;
  font-size: 16px;
  color: #444;
  border-radius: 20px 0 0 20px;
  margin-right: 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.roles-sidebar-item.active, .roles-sidebar-item:hover {
  background: #f4f4f5;
  color: #18181b;
  font-weight: 500;
}

.roles-logout-btn {
  margin: 32px 24px 24px 32px;
  padding: 10px 0;
  width: calc(100% - 56px);
  background: #fff0f0;
  color: #dc2626;
  border: 1px solid #ffe4e6;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border 0.15s;
  box-shadow: 0 1px 2px rgba(220,38,38,0.04);
  position: absolute;
  bottom: 0;
  left: 0;
}

.roles-logout-btn:hover, .roles-logout-btn:focus {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  outline: none;
}

.roles-main {
  flex: 1;
  padding: 72px 32px 32px 32px;
  background: #fafbfc;
  min-width: 0;
}

.roles-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.roles-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
  color: #18181b;
}

.roles-controls {
  display: flex;
  margin-bottom: 24px;
}

.roles-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.roles-search-input {
  padding: 8px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 15px;
  width: 260px;
  background: #fff;
  color: #18181b;
  transition: border 0.2s;
  height: 38px;
  box-sizing: border-box;
}

.roles-search-input:focus {
  outline: none;
  border: 1.5px solid #18181b;
}

.roles-search-btn, .roles-add-btn {
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #18181b;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border 0.15s;
  white-space: nowrap;
}

.roles-search-btn:hover, .roles-add-btn:hover {
  background: #18181b;
  color: #fff;
  border: 1px solid #18181b;
}

.roles-add-btn {
  margin-left: 4px;
}

.roles-sort-group {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.roles-sort-btn {
  background: #fff;
  border: 1px solid #e5e7eb;
  color: #888;
  border-radius: 8px;
  padding: 6px 18px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border 0.15s;
  white-space: nowrap;
}

.roles-sort-btn.active, .roles-sort-btn:hover {
  background: #18181b;
  color: #fff;
  border: 1px solid #18181b;
}

.roles-table-panel {
  margin-top: 0;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(16,30,54,0.04);
  padding: 20px 20px 16px 20px;
}

.roles-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0;
}

.roles-table th, .roles-table td {
  padding: 10px 8px;
  text-align: left;
  font-size: 15px;
}

.roles-table th {
  color: #888;
  font-weight: 500;
  border-bottom: 1px solid #f0f0f0;
}

.roles-table td {
  color: #222;
  border-bottom: 1px solid #f6f6f6;
}

.roles-table tr:last-child td {
  border-bottom: none;
}

.theme-mode-icon-roles {
  position: absolute;
  right: 32px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  width: 24px;
  height: 24px;
  z-index: 101;
  transition: opacity 0.3s;
  display: flex;
  align-items: center;
}

.theme-mode-icon-roles {
  background-image: url('/images/dark-mode-icon.png');
}

.theme-mode-icon-roles:hover {
  opacity: 0.8;
}

.error-container {
  margin-bottom: 24px;
}

.error-message {
  padding: 1rem;
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.refresh-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  color: #18181b;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border 0.15s;
}

.refresh-button:hover {
  background: #18181b;
  color: #fff;
  border: 1px solid #18181b;
}

.refresh-icon {
  font-size: 18px;
  line-height: 1;
}

.roles-permissions-badge {
  background: #fef3c7;
  color: #92400e;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid #fde68a;
  display: inline-block;
}

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: #71717a;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #f4f4f5;
  border-top-color: #18181b;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Add Role Form Styles */
.add-role-form {
  max-width: 800px;
}

.form-section {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(16,30,54,0.04);
  padding: 32px;
  margin-bottom: 24px;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 20px 0;
  color: #18181b;
  padding-bottom: 8px;
  border-bottom: 1px solid #f0f0f0;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  font-size: 14px;
  font-weight: 500;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  color: #18181b;
  background: #fff;
  transition: border 0.2s;
  width: 100%;
  box-sizing: border-box;
}

.form-input:focus {
  outline: none;
  border: 1.5px solid #18181b;
}

.form-input::placeholder {
  color: #9ca3af;
}

textarea.form-input {
  resize: vertical;
  min-height: 80px;
}

.permissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.permission-item {
  display: flex;
  align-items: center;
}

.permission-label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 12px;
  border-radius: 8px;
  transition: background 0.15s;
  width: 100%;
}

.permission-label:hover {
  background: #f9fafb;
}

.permission-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #166534;
  cursor: pointer;
}

.permission-text {
  font-size: 15px;
  font-weight: 500;
  color: #18181b;
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid #f0f0f0;
}

.save-button {
  padding: 10px 20px;
  background: #166534;
  color: #fff;
  border: 1px solid #166534;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border 0.15s;
}

.save-button:hover:not(:disabled) {
  background: #15803d;
  border: 1px solid #15803d;
}

.save-button:disabled {
  background: #9ca3af;
  border: 1px solid #9ca3af;
  cursor: not-allowed;
}

.cancel-button {
  padding: 10px 20px;
  background: #fff;
  color: #6b7280;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border 0.15s;
}

.cancel-button:hover:not(:disabled) {
  background: #f4f4f5;
  border: 1px solid #d1d5db;
  color: #18181b;
}

.cancel-button:disabled {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  color: #9ca3af;
  cursor: not-allowed;
}

.back-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  color: #18181b;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border 0.15s;
  text-decoration: none;
}

.back-button:hover {
  background: #f4f4f5;
  border: 1px solid #d1d5db;
}

.back-arrow {
  font-size: 18px;
  font-weight: 600;
}

/* Detail Page Styles */
.roles-header {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 32px;
}

.roles-detail-content {
  max-width: 800px;
}

.roles-detail-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(16,30,54,0.04);
  padding: 32px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-label {
  font-size: 14px;
  font-weight: 500;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-value {
  font-size: 16px;
  font-weight: 500;
  color: #18181b;
}

.permissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.permission-item {
  display: flex;
  align-items: center;
}

.permission-label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 12px;
  border-radius: 8px;
  transition: background 0.15s;
  width: 100%;
}

.permission-label:hover {
  background: #f9fafb;
}

.permission-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #166534;
  cursor: pointer;
}

.permission-text {
  font-size: 15px;
  font-weight: 500;
  color: #18181b;
}

.permission-display {
  width: 100%;
}

.permission-badge.enabled {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.permission-badge.disabled {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.permissions-summary {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #f0f0f0;
}

.edit-button {
  padding: 8px 16px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  color: #18181b;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border 0.15s;
}

.edit-button:hover {
  background: #f4f4f5;
  border: 1px solid #d1d5db;
}

.edit-actions {
  display: flex;
  gap: 12px;
}

.save-button {
  padding: 8px 16px;
  background: #166534;
  color: #fff;
  border: 1px solid #166534;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border 0.15s;
}

.save-button:hover:not(:disabled) {
  background: #15803d;
  border: 1px solid #15803d;
}

.save-button:disabled {
  background: #9ca3af;
  border: 1px solid #9ca3af;
  cursor: not-allowed;
}

.cancel-button {
  padding: 8px 16px;
  background: #fff;
  color: #6b7280;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border 0.15s;
}

.cancel-button:hover:not(:disabled) {
  background: #f4f4f5;
  border: 1px solid #d1d5db;
  color: #18181b;
}

.cancel-button:disabled {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  color: #9ca3af;
  cursor: not-allowed;
}

.delete-button {
  padding: 8px 16px;
  background: #fff;
  color: #dc2626;
  border: 1px solid #fecaca;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border 0.15s;
}

.delete-button:hover:not(:disabled) {
  background: #fef2f2;
  border: 1px solid #fca5a5;
}

.delete-button:disabled {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  color: #9ca3af;
  cursor: not-allowed;
}

.edit-input {
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  color: #18181b;
  background: #fff;
  transition: border 0.2s;
  width: 100%;
  box-sizing: border-box;
}

.edit-input:focus {
  outline: none;
  border: 1.5px solid #18181b;
}

textarea.edit-input {
  resize: vertical;
  min-height: 80px;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 20px 0;
  color: #18181b;
  padding-bottom: 8px;
  border-bottom: 1px solid #f0f0f0;
}

.roles-detail-section {
  margin-bottom: 32px;
}

.roles-detail-section:last-child {
  margin-bottom: 0;
}

.back-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  color: #18181b;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border 0.15s;
  text-decoration: none;
}

.back-button:hover {
  background: #f4f4f5;
  border: 1px solid #d1d5db;
}

.back-arrow {
  font-size: 18px;
  font-weight: 600;
}

.roles-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
  color: #18181b;
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow: hidden;
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 24px 16px 24px;
  border-bottom: 1px solid #f0f0f0;
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #18181b;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #6b7280;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: #f4f4f5;
  color: #18181b;
}

.modal-body {
  padding: 24px;
}

.modal-message {
  font-size: 16px;
  color: #374151;
  margin: 0 0 16px 0;
  line-height: 1.5;
}

.modal-warning {
  font-size: 14px;
  color: #6b7280;
  margin: 0 0 20px 0;
  line-height: 1.5;
}

.modal-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  color: #18181b;
  background: #fff;
  transition: border 0.2s;
  box-sizing: border-box;
}

.modal-input:focus {
  outline: none;
  border: 2px solid #ef4444;
}

.modal-input::placeholder {
  color: #9ca3af;
}

.modal-footer {
  display: flex;
  gap: 12px;
  padding: 16px 24px 24px 24px;
  justify-content: flex-end;
}

.modal-cancel-button {
  padding: 10px 20px;
  background: #fff;
  color: #6b7280;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.modal-cancel-button:hover:not(:disabled) {
  background: #f4f4f5;
  border: 1px solid #d1d5db;
  color: #18181b;
}

.modal-cancel-button:disabled {
  background: #f9fafb;
  color: #d1d5db;
  cursor: not-allowed;
}

.modal-delete-button {
  padding: 10px 20px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.modal-delete-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

.modal-delete-button:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(239, 68, 68, 0.3);
}

.modal-delete-button:disabled {
  background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
  box-shadow: 0 2px 8px rgba(156, 163, 175, 0.2);
  cursor: not-allowed;
  transform: none;
}