:root {
  --bg-main: #0b0e14;
  --bg-deep: #0b0e14;
  --bg-panel: #121722;
  --bg-card: #171d29;
  --bg-soft: #1d2431;
  --bg-input: #0f141d;
  --bg-hover: rgba(255, 255, 255, 0.04);
  --text-main: #eef2f7;
  --text-muted: #a7b0c0;
  --text-faint: #6d7890;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.11);
  --accent: #858DF1;
  --accent-2: #a1a8ff;
  --accent-cyan: #4de2ff;
  --accent-purple: #9d50bb;
  --accent-soft: rgba(133, 141, 241, 0.16);
  --accent-glow: rgba(77, 226, 255, 0.45);
  --accent-gradient: linear-gradient(135deg, #959cf7, #858DF1);
  --success: #27d17c;
  --warning: #f1b847;
  --error: #ef5d6c;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --sidebar-w: 260px;
  --topbar-h: 72px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(35, 208, 255, 0.08), transparent 24%),
    radial-gradient(circle at bottom left, rgba(111, 124, 255, 0.12), transparent 22%),
    var(--bg-main);
  color: var(--text-main);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.08) 0.6px, transparent 0.6px);
  background-size: 18px 18px;
  opacity: 0.08;
  pointer-events: none;
  z-index: -2;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  border: 0;
  outline: 0;
}

img {
  max-width: 100%;
  display: block;
}

::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-track {
  background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

.layout {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: rgba(16, 21, 31, 0.95);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  backdrop-filter: blur(18px);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 18px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #b7bcff, var(--accent));
  display: grid;
  place-items: center;
  font-weight: 900;
  color: #fff;
  box-shadow: 0 0 24px rgba(35, 208, 255, 0.15);
  overflow: hidden;
}

.sidebar-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-letter {
  display: none;
}

.logo-fallback .logo-letter {
  display: block;
}

.logo-fallback img {
  display: none;
}

.sidebar-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
}

.nav-label {
  padding: 12px 10px 8px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 11px 14px;
  margin-bottom: 6px;
  border-radius: 12px;
  color: var(--text-muted);
  border: 1px solid transparent;
  transition: 0.18s ease;
}

.nav-item i {
  width: 18px;
  text-align: center;
  color: var(--accent);
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(133, 141, 241, 0.22), rgba(133, 141, 241, 0.08));
  border-color: rgba(133, 141, 241, 0.2);
  color: #fff;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  flex: 0 0 auto;
}

.user-info {
  min-width: 0;
  flex: 1;
}

.user-name {
  font-size: 13px;
  font-weight: 700;
}

.user-role {
  font-size: 11px;
  color: var(--text-muted);
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 900;
  height: var(--topbar-h);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(11, 14, 20, 0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.server-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.pulse-dot.online {
  background: var(--success);
  box-shadow: 0 0 12px var(--success);
}

.pulse-dot.offline {
  background: var(--error);
  box-shadow: 0 0 12px var(--error);
}

#menuToggle {
  display: none;
  cursor: pointer;
  font-size: 18px;
}

.content {
  padding: 24px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.page-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.page-subtitle {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 13px;
}

.glass,
.card-stat,
.table-container,
.card,
.modal {
  background: linear-gradient(180deg, rgba(24, 28, 40, 0.98), rgba(18, 22, 33, 0.98));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-stat,
.card {
  padding: 20px;
}

.grid-stats,
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

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

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  background: rgba(133, 141, 241, 0.12);
  color: var(--accent);
}

.stat-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-value {
  margin-top: 8px;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.stat-trend {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 12px;
}

.table-container,
.table-card {
  overflow: hidden;
}

.table-header,
.card-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
}

.table-responsive {
  overflow-x: auto;
}

.data-table,
table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
table th {
  text-align: left;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.data-table td,
table td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tr:hover td,
table tr:hover td {
  background: rgba(255, 255, 255, 0.015);
}

.input,
input,
select,
textarea {
  width: 100%;
  background: #0f141d;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 13px;
  color: var(--text-main);
  transition: 0.18s ease;
}

textarea {
  resize: vertical;
  min-height: 100px;
}

.input:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: rgba(133, 141, 241, 0.45);
  box-shadow: 0 0 0 3px rgba(133, 141, 241, 0.14);
}

.form-group {
  margin-bottom: 16px;
}

.label,
label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.18s ease;
  white-space: nowrap;
  border: 1px solid transparent;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, #9097f7, var(--accent));
  color: #fff;
  box-shadow: 0 8px 24px rgba(133, 141, 241, 0.22);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border);
  color: var(--text-main);
}

.btn-danger {
  background: rgba(239, 93, 108, 0.12);
  border-color: rgba(239, 93, 108, 0.22);
  color: var(--error);
}

.btn-xs,
.btn-sm {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 9px;
  font-size: 12px;
}

.btn-copy {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.badge-active {
  background: rgba(39, 209, 124, 0.12);
  color: var(--success);
}

.badge-banned {
  background: rgba(239, 93, 108, 0.12);
  color: var(--error);
}

.badge-unused {
  background: rgba(255,255,255,0.07);
  color: var(--text-muted);
}

.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 12px;
  margin-bottom: 18px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
}

.alert-success {
  background: rgba(39, 209, 124, 0.12);
  color: var(--success);
  border-color: rgba(39, 209, 124, 0.2);
}

.alert-error {
  background: rgba(239, 93, 108, 0.12);
  color: var(--error);
  border-color: rgba(239, 93, 108, 0.2);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
  z-index: 1200;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  width: min(100%, 560px);
  overflow: hidden;
}

.modal-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body,
.modal-content {
  padding: 20px;
}

.switch {
  position: relative;
  display: inline-flex;
  width: 46px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #2b3342;
  transition: 0.18s ease;
  cursor: pointer;
}

.slider::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: 0.18s ease;
}

.switch input:checked + .slider {
  background: var(--accent);
}

.switch input:checked + .slider::before {
  transform: translateX(22px);
}

.mono {
  font-family: "JetBrains Mono", "Consolas", monospace;
}

.user-avatar img,
.profile-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.profile-upload-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.profile-upload-preview {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: linear-gradient(135deg, #9097f7, var(--accent));
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-size: 24px;
  font-weight: 800;
}

.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1300;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(23, 29, 41, 0.98);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.toast-success {
  color: var(--success);
}

.toast-error {
  color: var(--error);
}

.layout-overlay {
  display: none;
}

.fade-in,
.stagger-in > * {
  opacity: 1;
}

@media (max-width: 980px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .main {
    margin-left: 0;
  }

  .layout-overlay {
    position: fixed;
    inset: 0;
    display: none;
    background: rgba(0, 0, 0, 0.55);
    z-index: 990;
  }

  .layout-overlay.active {
    display: block;
  }

  #menuToggle {
    display: inline-block;
    margin-right: 12px;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .content {
    padding: 16px;
  }

  .topbar {
    height: auto;
    min-height: var(--topbar-h);
    padding: 14px 16px;
    flex-wrap: wrap;
  }

  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td,
  table,
  table tbody,
  table tr,
  table td {
    display: block;
    width: 100%;
  }

  .data-table thead,
  table thead {
    display: none;
  }

  .data-table tr,
  table tr {
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
  }

  .data-table td,
  table td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    text-align: right !important;
    padding: 12px 14px;
  }

  .data-table td::before {
    content: attr(data-label);
    text-align: left;
    color: var(--text-faint);
    font-size: 11px;
    font-weight: 700;
  }
}

@media (max-width: 560px) {
  :root {
    --sidebar-w: 100vw;
  }

  .sidebar {
    width: min(100vw, 320px);
  }

  .sidebar-header,
  .sidebar-footer,
  .sidebar-nav {
    padding-left: 14px;
    padding-right: 14px;
  }

  .topbar {
    gap: 10px;
  }

  .topbar-title {
    font-size: 16px;
  }

  .page-title {
    font-size: 22px;
  }

  .page-subtitle {
    font-size: 12px;
  }

  .table-header,
  .card-header,
  .modal-head,
  .modal-body,
  .modal-content,
  .card-stat,
  .card {
    padding-left: 14px;
    padding-right: 14px;
  }

  .server-pill {
    width: 100%;
    justify-content: center;
  }

  .profile-upload-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .page-header .btn,
  .table-header .btn,
  .table-header .search-wrap {
    width: 100%;
  }
}
