:root {
  --bg: #06010d;
  --bg-2: #0b0414;
  --panel: rgba(10, 4, 22, 0.86);
  --panel-soft: rgba(255,255,255,0.03);
  --panel-border: rgba(143, 74, 255, 0.25);
  --panel-border-strong: rgba(165, 93, 255, 0.42);
  --white: #f5efff;
  --muted: rgba(232, 221, 255, 0.7);
  --purple: #a855f7;
  --purple-2: #7c3aed;
  --danger: #ef4444;
  --danger-soft: rgba(239,68,68,0.12);
  --success: #10b981;
  --shadow: 0 24px 70px rgba(0,0,0,0.42);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, Segoe UI, Tahoma, sans-serif;
  color: var(--white);
  background:
    radial-gradient(circle at 20% 15%, rgba(168,85,247,0.16), transparent 28%),
    radial-gradient(circle at 80% 0%, rgba(124,58,237,0.14), transparent 26%),
    linear-gradient(180deg, #030108 0%, #07010f 55%, #05010a 100%);
  overflow-x: hidden;
}
button, input, select { font: inherit; }
button {
  border: 1px solid transparent;
  background: rgba(255,255,255,0.04);
  color: var(--white);
  cursor: pointer;
}
img { display: block; }
.hidden { display: none !important; }

.surface-panel,
.surface-bar,
.modal-card,
.confirm-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.surface-panel,
.modal-card,
.confirm-card { border-radius: var(--radius-xl); }
.surface-bar { border-radius: 24px; }

.ghost-btn,
.submit-btn,
.inline-btn,
.custom-select-trigger,
.custom-select-option,
.nav-group-btn,
.subnav-item,
.password-toggle {
  transition: background .22s ease, border-color .22s ease, transform .22s ease, box-shadow .22s ease, color .22s ease, opacity .22s ease;
}

.ghost-btn,
.submit-btn {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  font-weight: 700;
}
.ghost-btn {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.08);
}
.ghost-btn:hover { background: rgba(255,255,255,0.08); }
.submit-btn {
  background: linear-gradient(90deg, var(--purple), #c061ff);
  box-shadow: 0 16px 36px rgba(168,85,247,0.25);
}
.submit-btn:hover { transform: translateY(-1px); }
.danger-fill {
  background: linear-gradient(90deg, #ff6a7a, #ff8562);
  box-shadow: 0 16px 36px rgba(255,90,109,0.2);
}

.panel-body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: center/34vw auto no-repeat url('/assets/img/server-logo.gif');
  opacity: .035;
  pointer-events: none;
  filter: blur(1px);
}

.topbar-shell { padding: 18px 0 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 18px;
}
.brand-fixed,
.brand-portal { display: flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: .18em; font-size: .92rem; }
.brand-mini-logo,
.sidebar-logo { width: 42px; height: 42px; border-radius: 14px; object-fit: cover; box-shadow: 0 0 18px rgba(168,85,247,0.28); }
.panel-app { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar {
  margin: 0;
  border-radius: 0;
  border-right: 1px solid rgba(255,255,255,0.07);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.sidebar-brand { display:flex; align-items:center; gap:12px; padding: 4px 8px 18px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.sidebar-eyebrow { margin: 0 0 6px; color: rgba(255,255,255,0.55); text-transform: uppercase; letter-spacing: .22em; font-size: .68rem; }
.sidebar-brand h1 { margin: 0; font-size: 1.18rem; }
.sidebar-nav { display:grid; gap: 14px; }
.nav-group-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  padding: 16px 16px;
  border-radius: 22px;
  border-color: rgba(168,85,247,0.2);
}
.nav-group-btn:hover,
.nav-group-btn.open,
.nav-group-btn.active {
  background: rgba(168,85,247,0.12);
  border-color: rgba(168,85,247,0.38);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
}
.nav-group-copy { display:flex; align-items:center; gap: 12px; min-width: 0; }
.nav-group-icon {
  width: 40px; height: 40px; border-radius: 14px;
  display:grid; place-items:center;
  background: linear-gradient(180deg, rgba(168,85,247,0.2), rgba(124,58,237,0.06));
  border: 1px solid rgba(168,85,247,0.2);
  color: #d9bcff;
  flex: 0 0 auto;
}
.nav-group-icon svg { width: 18px; height: 18px; }
.nav-label { display:block; font-weight:800; }
.nav-sub { display:none; }
.nav-chevron {
  width: 14px;
  height: 14px;
  position: relative;
  flex: 0 0 14px;
}
.nav-chevron::before,
.nav-chevron::after {
  content: '';
  position: absolute;
  top: 6px;
  width: 8px;
  height: 2px;
  background: linear-gradient(90deg, #d0a0ff, #8b5cf6);
  border-radius: 999px;
  box-shadow: 0 0 10px rgba(168,85,247,0.4);
  transition: transform .22s ease;
}
.nav-chevron::before { left: 0; transform: rotate(45deg); }
.nav-chevron::after { right: 0; transform: rotate(-45deg); }
.nav-group-btn.open .nav-chevron::before { transform: rotate(-45deg); }
.nav-group-btn.open .nav-chevron::after { transform: rotate(45deg); }

.subnav-list {
  display: grid;
  gap: 8px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  padding-left: 18px;
  transition: max-height .26s ease, opacity .2s ease, padding-top .2s ease;
}
.subnav-list.open { max-height: 420px; opacity: 1; padding-top: 6px; }
.subnav-item {
  min-height: 44px;
  text-align: left;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.03);
  padding: 0 14px;
  color: rgba(255,255,255,0.82);
  background: transparent;
}
.subnav-item:hover,
.subnav-item.active {
  background: rgba(168,85,247,0.14);
  border-color: rgba(168,85,247,0.28);
}

.panel-content { padding: 0 18px 24px; }
.panel-top-actions { display:flex; align-items:center; gap:12px; }
.session-chip {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--chip-color, #8b5cf6) 55%, rgba(255,255,255,0.08));
  background: color-mix(in srgb, var(--chip-color, #8b5cf6) 14%, rgba(255,255,255,0.04));
}
.panel-main { padding-top: 18px; display:grid; gap:18px; }
.page-header,
.table-panel,
.form-panel { padding: 26px; }
.page-header h2,
.panel-section-head h3 { margin: 0 0 10px; }
.page-header h2 { font-size: 2rem; }
.panel-section-head h3 { font-size: 1.42rem; }
.panel-section-head,
.table-head { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; }
.panel-note { margin:0; color: var(--muted); line-height: 1.7; }
.view-panel { display:none; }
.view-panel.active { display:block; }

.user-form { display:grid; gap: 16px; }
.form-grid { display:grid; gap: 14px; }
.form-grid.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.align-end { align-items: end; }
.user-form label { display:grid; gap: 8px; color: var(--muted); font-size: .94rem; }
.user-form input,
.login-form input,
.native-hidden,
.fake-input {
  width:100%;
  min-height: 50px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.035);
  color: var(--white);
  border-radius: 16px;
  padding: 0 16px;
  outline: none;
}
.user-form input:focus,
.login-form input:focus { border-color: rgba(168,85,247,0.4); box-shadow: 0 0 0 4px rgba(168,85,247,0.12); }
.switch-row {
  display:flex !important;
  align-items:center;
  justify-content:space-between;
  min-height: 50px;
  padding: 0 16px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.035);
}
.switch-row input { width: 18px; height: 18px; accent-color: var(--purple); }
.form-actions-row { display:flex; gap: 12px; flex-wrap: wrap; }
.form-message { min-height: 22px; margin: 0; color: var(--muted); }

.password-field { position: relative; }
.password-field input { padding-right: 56px; }
.password-toggle {
  position:absolute; right: 10px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border-radius: 12px;
  border-color: rgba(255,255,255,0.08);
}
.password-toggle svg { width: 18px; height: 18px; }
.password-toggle .eye-off { display:none; }
.password-toggle.is-open .eye-open { display:none; }
.password-toggle.is-open .eye-off { display:block; }
.password-toggle.is-open { background: rgba(168,85,247,0.16); border-color: rgba(168,85,247,0.28); }

.color-field { display:grid; grid-template-columns: 78px 1fr; gap: 12px; }
.color-field input[type="color"] { padding: 6px; min-height: 50px; }

.custom-select { position: relative; }
.custom-select select.native-hidden {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.custom-select-trigger {
  width: 100%;
  min-height: 50px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 16px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.035);
  padding: 0 16px;
  text-align: left;
}
.custom-select-trigger:hover,
.custom-select.open .custom-select-trigger {
  border-color: rgba(168,85,247,0.34);
  box-shadow: 0 0 0 4px rgba(168,85,247,0.08);
}
.custom-select-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.custom-select-arrow {
  width: 12px; height: 12px; position: relative; flex: 0 0 12px;
}
.custom-select-arrow::before,
.custom-select-arrow::after {
  content: '';
  position: absolute;
  top: 5px;
  width: 7px;
  height: 2px;
  background: linear-gradient(90deg, #d7b8ff, #9f67ff);
  border-radius: 999px;
  box-shadow: 0 0 8px rgba(168,85,247,0.36);
  transition: transform .2s ease;
}
.custom-select-arrow::before { left: 0; transform: rotate(45deg); }
.custom-select-arrow::after { right: 0; transform: rotate(-45deg); }
.custom-select.open .custom-select-arrow::before { transform: rotate(-45deg); }
.custom-select.open .custom-select-arrow::after { transform: rotate(45deg); }
.custom-select-menu {
  position:absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 24;
  display:grid;
  gap: 6px;
  padding: 10px;
  border-radius: 20px;
  background: rgba(12, 5, 23, 0.98);
  border: 1px solid rgba(168,85,247,0.28);
  box-shadow: 0 22px 40px rgba(0,0,0,0.38);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
}
.custom-select.open .custom-select-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.custom-select-option {
  width:100%;
  min-height: 42px;
  border-radius: 14px;
  text-align:left;
  padding: 0 14px;
  background: transparent;
  border-color: transparent;
  color: rgba(255,255,255,0.84);
}
.custom-select-option:hover,
.custom-select-option.is-selected {
  background: rgba(168,85,247,0.14);
  border-color: rgba(168,85,247,0.22);
}

.table-wrap { overflow:auto; margin-top: 16px; }
.users-table { width:100%; min-width: 1020px; border-collapse: collapse; }
.users-table th,
.users-table td { padding: 16px 12px; text-align:left; border-bottom: 1px solid rgba(255,255,255,0.06); }
.users-table th { color: rgba(255,255,255,0.58); font-weight: 700; }
.empty-state-cell,
.empty-mini { color: var(--muted); text-align:center; }
.row-actions { display:flex; gap: 8px; flex-wrap: wrap; }
.inline-btn {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border-color: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.88);
}
.inline-btn:hover { background: rgba(255,255,255,0.08); }
.inline-btn.danger { color: #ffb8c3; border-color: rgba(255,89,109,0.2); background: rgba(255,89,109,0.08); }
.inline-btn.danger:hover { background: rgba(255,89,109,0.14); }

.role-badge,
.status-badge,
.perm-count {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: .88rem;
}
.role-badge {
  background: color-mix(in srgb, var(--role-color, #8b5cf6) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--role-color, #8b5cf6) 48%, rgba(255,255,255,0.08));
}
.role-badge.large { min-height: 40px; padding: 0 16px; }
.role-dot { display:inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--role-color, #8b5cf6); box-shadow: 0 0 14px color-mix(in srgb, var(--role-color, #8b5cf6) 60%, transparent); margin-right: 8px; }
.status-badge.is-active { background: rgba(16,185,129,0.14); border: 1px solid rgba(16,185,129,0.22); color: #8df0c3; }
.status-badge.is-inactive { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08); color: rgba(255,255,255,0.72); }
.perm-count { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08); }
.perm-count.is-empty { color: rgba(255,255,255,0.58); }

.roles-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-top: 16px; }
.role-card {
  padding: 18px;
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,0.07);
  background: rgba(255,255,255,0.03);
}
.role-card-top { display:flex; justify-content:space-between; align-items:flex-start; gap: 12px; margin-bottom: 16px; }
.role-meta-row { display:flex; justify-content:space-between; align-items:center; gap: 12px; padding-top: 12px; margin-top: 12px; border-top: 1px solid rgba(255,255,255,0.05); color: var(--muted); }
.role-meta-row strong { color: var(--white); }

.permissions-box { display:grid; gap: 14px; }
.permission-category {
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,0.07);
  background: rgba(255,255,255,0.03);
  padding: 18px;
}
.permission-category-head { display:flex; align-items:center; gap: 12px; margin-bottom: 14px; }
.permission-category-head h4 { margin: 0; font-size: 1.02rem; }
.permission-category-head p { margin: 4px 0 0; color: var(--muted); font-size: .88rem; }
.permission-category-icon {
  width: 40px; height: 40px; border-radius: 14px;
  display:grid; place-items:center;
  background: rgba(168,85,247,0.14);
  border: 1px solid rgba(168,85,247,0.24);
  color: #d8bcff;
}
.permission-category-icon svg { width: 18px; height: 18px; }
.permission-category-grid { display:grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.permission-item {
  display:flex !important;
  align-items:flex-start;
  gap: 10px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.025);
}
.permission-item input { width: 18px; height: 18px; accent-color: var(--purple); margin-top: 3px; }
.permission-item small { display:block; color: rgba(255,255,255,0.5); margin-top: 4px; }

.action-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 18px; }
.action-card {
  padding: 22px;
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,0.07);
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  display:grid;
  gap: 14px;
}
.action-card:hover { transform: translateY(-2px); border-color: rgba(168,85,247,0.28); }
.action-icon-box {
  width: 56px; height: 56px; border-radius: 18px;
  display:grid; place-items:center;
  background: linear-gradient(180deg, rgba(168,85,247,0.18), rgba(124,58,237,0.08));
  border: 1px solid rgba(168,85,247,0.24);
  color: #e7d2ff;
}
.action-icon-box svg { width: 24px; height: 24px; }
.action-card strong { font-size: 1.08rem; }
.action-card small { color: var(--muted); }
.action-card p { margin: 0; color: rgba(255,255,255,0.48); font-size: .88rem; }

.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(1, 0, 5, 0.68);
  backdrop-filter: blur(8px);
}
.confirm-card {
  width: min(470px, calc(100vw - 28px));
  padding: 22px;
}
.confirm-card-top { display:flex; align-items:center; justify-content:space-between; gap: 14px; }
.confirm-close {
  width: 40px; height: 40px; border-radius: 14px; background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.08); position: relative;
}
.confirm-close span {
  position:absolute; left: 50%; top: 50%; width: 16px; height: 2px; border-radius: 999px; background: rgba(255,255,255,0.72);
}
.confirm-close span:first-child { transform: translate(-50%, -50%) rotate(45deg); }
.confirm-close span:last-child { transform: translate(-50%, -50%) rotate(-45deg); }
.confirm-icon-wrap {
  width: 48px; height: 48px; border-radius: 16px; display:grid; place-items:center;
  background: rgba(255,114,94,0.12); border: 1px solid rgba(255,114,94,0.28);
}
.confirm-icon {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid #ff9f8f; position: relative;
}
.confirm-icon::after {
  content: '!'; position: absolute; inset: 0; display:grid; place-items:center; font-size: .8rem; color: #ffb5aa; font-weight: 800;
}
.confirm-tag { margin: 16px 0 8px; color: #d8bcff; text-transform: uppercase; letter-spacing: .18em; font-size: .74rem; }
.confirm-card h3 { margin: 0 0 10px; font-size: 1.5rem; }
.confirm-text { margin: 0; color: var(--muted); line-height: 1.7; }
.confirm-actions { display:flex; justify-content:flex-end; gap: 10px; margin-top: 22px; }

.loader-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display:grid;
  place-items:center;
  background: rgba(2,1,8,0.82);
  backdrop-filter: blur(10px);
}
.loader-backdrop-logo {
  position:absolute;
  inset:0;
  background: center/min(380px, 40vw) no-repeat url('/assets/img/server-logo.gif');
  opacity: .08;
  filter: blur(1px);
}
.loader-card { display:grid; justify-items:center; gap: 18px; }
.loader-card p { margin: 0; color: rgba(255,255,255,0.78); letter-spacing: .08em; text-transform: uppercase; font-size: .78rem; }
.loader-pulse {
  width: 78px; height: 78px; border-radius: 50%;
  border: 2px solid rgba(168,85,247,0.12);
  background: radial-gradient(circle, rgba(168,85,247,0.6), rgba(124,58,237,0.18));
  box-shadow: 0 0 0 0 rgba(168,85,247,0.46), 0 0 36px rgba(168,85,247,0.32);
  animation: pulseLoad 1.15s ease-in-out infinite;
}
@keyframes pulseLoad {
  0% { transform: scale(.9); box-shadow: 0 0 0 0 rgba(168,85,247,0.42), 0 0 22px rgba(168,85,247,0.24); }
  70% { transform: scale(1.08); box-shadow: 0 0 0 22px rgba(168,85,247,0), 0 0 42px rgba(168,85,247,0.36); }
  100% { transform: scale(.94); box-shadow: 0 0 0 0 rgba(168,85,247,0), 0 0 24px rgba(168,85,247,0.28); }
}

@media (max-width: 980px) {
  .panel-app { grid-template-columns: 1fr; }
  .sidebar { border-radius: 0 0 26px 26px; border-right: 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
  .panel-content { padding: 0 12px 20px; }
}
@media (max-width: 720px) {
  .form-grid.two-col { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
  .roles-grid,
  .action-grid,
  .permission-category-grid { grid-template-columns: 1fr; }
}


.panel-note:empty { display:none; }

.edit-modal-card { width: min(640px, calc(100vw - 28px)); }
.modal-form { margin-top: 12px; }
.confirm-icon-wrap.neutral { background: rgba(168,85,247,0.12); border-color: rgba(168,85,247,0.28); }
.confirm-icon.pencil { width: 20px; height: 20px; border: 0; border-radius: 0; }
.confirm-icon.pencil::after { content: ''; position: absolute; width: 12px; height: 3px; background: #d8bcff; border-radius: 999px; top: 8px; left: 3px; transform: rotate(-35deg); box-shadow: 8px 5px 0 -1px rgba(216,188,255,0.7); }
