:root {
  --bg: #0b0d14;
  --surface: #12141d;
  --surface2: #181b26;
  --border: #252836;
  --text: #eef0f6;
  --muted: #8b92a8;
  --purple: #7c3aed;
  --purple2: #a855f7;
  --pink: #ec4899;
  --cyan: #06b6d4;
  --green: #10b981;
  --orange: #f59e0b;
  --red: #ef4444;
  --radius: 14px;
  --sidebar-w: 260px;
  --header-h: 64px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] {
  --bg: #f3f4f8;
  --surface: #ffffff;
  --surface2: #f8f9fc;
  --border: #e2e5ef;
  --text: #111827;
  --muted: #6b7280;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; text-decoration: none; }

.hidden { display: none !important; }

/* Login */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(124, 58, 237, 0.15), transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(236, 72, 153, 0.12), transparent 50%),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.login-brand .logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  display: grid;
  place-items: center;
  font-size: 1.2rem;
}

.login-brand h1 {
  margin: 0;
  font-size: 1.1rem;
}

.login-brand p {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.form-group { margin-bottom: 14px; }

.form-group label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.92rem;
}

.form-control:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(135deg, var(--purple), var(--pink));
  color: #fff;
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-success {
  background: linear-gradient(135deg, var(--purple), var(--purple2));
  color: #fff;
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.btn-block { width: 100%; }

.btn-sm { padding: 6px 12px; font-size: 0.78rem; }

.alert {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  margin-top: 12px;
}

.alert-error {
  background: rgba(239, 68, 68, 0.12);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

/* App shell */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 90;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  padding: 20px 18px 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand .logo {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.sidebar-brand h2 {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.3;
}

.sidebar-brand small {
  color: var(--muted);
  font-size: 0.72rem;
}

.nav-section {
  padding: 14px 12px 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 2px 10px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  cursor: pointer;
  border: none;
  background: transparent;
  width: calc(100% - 20px);
  text-align: left;
}

.nav-item:hover {
  background: var(--surface2);
  color: var(--text);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.35), rgba(168, 85, 247, 0.2));
  color: #fff;
  box-shadow: inset 3px 0 0 var(--purple2);
}

.nav-item svg,
.nav-item i,
.logo i,
.btn i,
.icon-btn i,
.balance-pill i {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.9;
}

.logo i {
  width: 22px;
  height: 22px;
  color: #fff;
}

.ico-stat {
  width: 22px;
  height: 22px;
  opacity: 0.88;
}

.role-badge {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(124, 58, 237, 0.2);
  color: var(--purple2);
}

.search-bar {
  margin-bottom: 14px;
}

.search-bar .form-control {
  max-width: 360px;
}

.actions-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sidebar-report {
  margin: auto 12px 16px;
  padding: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.sidebar-report h4 {
  margin: 0 0 4px;
  font-size: 0.85rem;
}

.sidebar-report p {
  margin: 0 0 10px;
  font-size: 0.75rem;
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  background: rgba(124, 58, 237, 0.2);
  color: var(--purple2);
}

.main-wrap {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(18, 20, 29, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 50;
}

[data-theme="light"] .topbar {
  background: rgba(255, 255, 255, 0.9);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  cursor: pointer;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.notif-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.balance-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.25), rgba(168, 85, 247, 0.15));
  border: 1px solid rgba(124, 58, 237, 0.35);
  font-weight: 600;
  font-size: 0.85rem;
}

.profile-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
}

.content {
  padding: 24px 20px 48px;
  flex: 1;
}

.page-head {
  margin-bottom: 22px;
}

.page-head h1 {
  margin: 0 0 6px;
  font-size: clamp(1.35rem, 3vw, 1.75rem);
}

.page-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

/* Cards & grid */
.grid-stats {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  border-radius: var(--radius);
  padding: 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  min-height: 110px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat-card.gradient-pink {
  background: linear-gradient(135deg, #ec4899, #7c3aed);
  border: none;
  color: #fff;
}

.stat-card.gradient-cyan {
  background: linear-gradient(135deg, #06b6d4, #3b82f6);
  border: none;
  color: #fff;
}

.stat-card .label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-card.gradient-pink .label,
.stat-card.gradient-cyan .label {
  color: rgba(255, 255, 255, 0.85);
}

.stat-card .value {
  font-size: clamp(1.4rem, 2.5vw, 1.9rem);
  font-weight: 700;
  line-height: 1.1;
}

.stat-card .sub {
  font-size: 0.72rem;
  color: var(--muted);
}

.stat-card .icon-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.panel-head h3 {
  margin: 0;
  font-size: 0.95rem;
}

.link-muted {
  font-size: 0.78rem;
  color: var(--purple2);
  cursor: pointer;
}

.game-bar {
  margin-bottom: 14px;
}

.game-bar-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  margin-bottom: 6px;
}

.progress {
  height: 8px;
  background: var(--surface2);
  border-radius: 999px;
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--pink), var(--purple));
}

.activity-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.activity-item:last-child { border-bottom: none; }

.activity-item .time {
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

/* Stats page */
.range-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.82rem;
}

.pill.active {
  background: linear-gradient(135deg, var(--purple), var(--purple2));
  color: #fff;
  border-color: transparent;
}

.grid-stats-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 18px 0;
}

.chart-box {
  height: 220px;
  position: relative;
  margin-top: 10px;
}

.chart-box canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

table.data-table th,
table.data-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

table.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
}

.mono {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.78rem;
  word-break: break-all;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
}

.status-pending { background: rgba(245, 158, 11, 0.15); color: var(--orange); }
.status-approved { background: rgba(16, 185, 129, 0.15); color: var(--green); }
.status-rejected { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.status-active { background: rgba(16, 185, 129, 0.15); color: var(--green); }
.status-revoked { background: rgba(239, 68, 68, 0.15); color: var(--red); }

/* Topup */
.topup-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  align-items: start;
}

.topup-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface);
}

.topup-card.pending-highlight {
  border-color: rgba(245, 158, 11, 0.5);
}

.topup-request {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  background: var(--surface);
}

.info-box {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.55;
  padding: 12px;
  background: var(--surface2);
  border-radius: 10px;
  margin: 12px 0;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal {
  width: min(520px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  padding: 22px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h3 {
  margin: 0 0 16px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.footer-note {
  text-align: center;
  color: var(--muted);
  font-size: 0.72rem;
  padding: 16px;
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
  font-size: 0.88rem;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 300;
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  animation: slideIn 0.25s ease;
}

@keyframes slideIn {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Responsive */
@media (max-width: 1200px) {
  .grid-stats { grid-template-columns: repeat(3, 1fr); }
  .grid-stats-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.show {
    display: block;
  }

  .main-wrap {
    margin-left: 0;
  }

  .menu-toggle {
    display: grid;
    place-items: center;
  }

  .grid-2,
  .topup-layout,
  .form-row {
    grid-template-columns: 1fr;
  }

  .grid-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .profile-chip span.name {
    display: none;
  }

  .content {
    padding: 16px 14px 40px;
  }
}

@media (max-width: 520px) {
  .grid-stats,
  .grid-stats-4 {
    grid-template-columns: 1fr;
  }

  .balance-pill {
    font-size: 0.78rem;
    padding: 6px 10px;
  }

  .topbar {
    padding: 0 12px;
  }
}
