:root {
  --bg: #0b1220;
  --bg-soft: #121a2b;
  --panel: #ffffff;
  --panel-soft: #f6f8fc;
  --border: #d8e0f0;
  --text: #101828;
  --text-soft: #667085;
  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --secondary: #475467;
  --success: #0f9d58;
  --warning: #f59e0b;
  --danger: #dc2626;
  --purple: #7c3aed;
  --shadow: 0 20px 40px rgba(15, 23, 42, 0.12);
  --radius: 18px;
  --radius-sm: 12px;
  --sidebar-width: 280px;
  --transition: 0.2s ease;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Tahoma", "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #eef3ff 0%, #f7f9fc 55%, #edf2ff 100%);
  color: var(--text);
}

body {
  overflow-x: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.2), transparent 20%),
    radial-gradient(circle at bottom left, rgba(124, 58, 237, 0.15), transparent 25%),
    linear-gradient(180deg, #eef3ff 0%, #f7f9fc 100%);
}

.login-card {
  width: min(100%, 560px);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}

.brand-mark {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: white;
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 1.4rem;
  box-shadow: 0 16px 30px rgba(37, 99, 235, 0.28);
}

.brand-small {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  font-size: 1rem;
}

.login-brand h1,
.sidebar-brand-text strong,
.topbar h1,
.card h2,
.login-card h3,
.modal-head h3 {
  margin: 0;
}

.login-brand p,
.sidebar-brand-text span,
.current-admin span,
.status-pill,
.card-head p,
.field span,
.quick-action strong,
.user-list small,
.hint-box,
.admin-accounts-list small,
.stat-card small,
.stat-label {
  color: var(--text-soft);
}

.mode-banner,
.hint-box,
.info-note {
  background: linear-gradient(135deg, #eff6ff, #eef2ff);
  border: 1px solid #dbeafe;
  border-radius: 18px;
  padding: 14px 16px;
}

.badge,
.status-pill,
.tag,
.role-badge,
.status-badge,
.type-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.badge,
.status-pill {
  background: #eff6ff;
  color: var(--primary);
  font-weight: 700;
}

.form-stack,
.form-grid {
  display: grid;
  gap: 16px;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid .full-row {
  grid-column: 1 / -1;
}

.field,
.switch-field {
  display: grid;
  gap: 8px;
}

.field span,
.switch-field span {
  font-weight: 600;
  font-size: 0.95rem;
}

.field input,
.field textarea,
.field select,
.global-search input {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.global-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.switch-field {
  grid-template-columns: auto 1fr;
  align-items: center;
  background: #f8fafc;
  border-radius: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
}

.switch-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.btn,
.icon-btn,
.quick-action,
.nav-link {
  transition: transform var(--transition), opacity var(--transition), background-color var(--transition), border-color var(--transition);
}

.btn {
  border: none;
  border-radius: 14px;
  padding: 12px 18px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover,
.icon-btn:hover,
.quick-action:hover,
.nav-link:hover {
  transform: translateY(-1px);
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #1d4ed8);
  color: white;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.2);
}

.btn-secondary {
  background: #eff4ff;
  color: var(--primary);
  border: 1px solid #dbeafe;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, var(--danger));
  color: white;
}

.demo-credentials {
  margin-top: 24px;
  background: #fbfdff;
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 18px;
}

.cred-grid {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.cred-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #09101b 0%, #0f172a 50%, #111827 100%);
  color: white;
  padding: 20px 18px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: 24px 0 40px rgba(2, 6, 23, 0.2);
}

.sidebar-head,
.current-admin-card,
.current-admin,
.topbar-left,
.topbar-right,
.inline-actions,
.card-head,
.login-brand,
.toolbar,
.stats-grid,
.dashboard-grid,
.quick-actions,
.admin-account-item,
.details-grid,
.details-list li {
  display: flex;
  gap: 14px;
}

.sidebar-head,
.current-admin-card,
.current-admin,
.topbar-left,
.topbar-right,
.inline-actions,
.card-head,
.toolbar,
.admin-account-item {
  align-items: center;
}

.sidebar-nav {
  display: grid;
  gap: 8px;
  align-content: start;
}

.nav-link {
  background: transparent;
  color: rgba(255, 255, 255, 0.82);
  border: 1px solid transparent;
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: right;
}

.nav-link.active {
  background: rgba(37, 99, 235, 0.18);
  border-color: rgba(191, 219, 254, 0.16);
  color: white;
}

.nav-icon {
  width: 22px;
  text-align: center;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 18px;
}

.current-admin-card {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 18px;
  padding: 14px;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: white;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.25);
}

.app-main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 18px 24px;
  backdrop-filter: blur(16px);
  background: rgba(245, 248, 255, 0.82);
  border-bottom: 1px solid rgba(152, 162, 179, 0.16);
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.topbar-right {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.global-search {
  display: grid;
  gap: 6px;
  min-width: 220px;
}

.content {
  padding: 24px;
  display: grid;
  gap: 24px;
}

.view {
  display: none;
  gap: 24px;
}

.view.active {
  display: grid;
}

.card {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(208, 217, 236, 0.75);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 22px;
  min-width: 0;
}

.card-head {
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.card-head h2 {
  font-size: 1.08rem;
}

.stats-grid {
  flex-wrap: wrap;
}

.stats-grid,
.dashboard-grid,
.settings-grid {
  display: grid;
  gap: 18px;
}

.stats-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.stat-card {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(208, 217, 236, 0.8);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 20px;
  display: grid;
  gap: 8px;
}

.stat-value {
  font-size: 1.9rem;
  font-weight: 800;
}

.dashboard-grid {
  grid-template-columns: 1.25fr 1fr;
}

.dashboard-grid.secondary {
  grid-template-columns: 1.2fr 0.8fr;
}

.settings-grid {
  grid-template-columns: 1.2fr 0.8fr;
}

.chart-wrap {
  position: relative;
  min-height: 280px;
}

.chart-wrap canvas {
  width: 100%;
  height: 280px;
  display: block;
}

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

.quick-action {
  background: #f8faff;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px 14px;
  display: grid;
  gap: 10px;
  text-align: center;
}

.quick-action span {
  font-size: 1.6rem;
}

.user-list {
  display: grid;
  gap: 12px;
}

.user-list-item,
.reward-card,
.admin-account-item,
.details-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  background: #fbfdff;
}

.user-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.user-list-meta {
  display: grid;
  gap: 6px;
}

.toolbar {
  flex-wrap: wrap;
  margin-bottom: 18px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
}

.field.compact {
  min-width: 180px;
  flex: 1 1 200px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 18px;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  background: white;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: var(--secondary);
  font-weight: 700;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid #edf2f7;
  text-align: right;
  vertical-align: top;
}

tbody tr:hover {
  background: #f9fbff;
}

.actions-cell {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.table-action {
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 0.85rem;
}

.table-action:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.table-action.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.pagination {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.pagination button {
  min-width: 40px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 12px;
  padding: 8px 12px;
}

.pagination button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.empty-state {
  text-align: center;
  color: var(--text-soft);
  padding: 28px;
}

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

.reward-card {
  display: grid;
  gap: 14px;
}

.reward-image {
  width: 100%;
  height: 170px;
  border-radius: 16px;
  object-fit: cover;
  background: linear-gradient(135deg, #eff6ff, #ede9fe);
  border: 1px solid var(--border);
}

.reward-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.reward-description {
  color: var(--text-soft);
  line-height: 1.8;
  min-height: 56px;
}

.reward-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-accounts-list,
.details-body,
.details-grid {
  display: grid;
  gap: 14px;
}

.admin-account-item {
  justify-content: space-between;
  background: #f8fafc;
}

.role-badge.super_admin {
  background: #ede9fe;
  color: var(--purple);
}

.role-badge.manager {
  background: #ecfdf3;
  color: var(--success);
}

.role-badge.viewer {
  background: #f3f4f6;
  color: #475467;
}

.status-badge.active,
.type-badge.earn,
.type-badge.reward,
.tag.success {
  background: #ecfdf3;
  color: var(--success);
}

.status-badge.inactive,
.type-badge.spend,
.tag.danger {
  background: #fef2f2;
  color: var(--danger);
}

.type-badge.salaf,
.tag.warning {
  background: #fffbeb;
  color: var(--warning);
}

.type-badge.commission,
.type-badge.debt_repay,
.tag.info {
  background: #eff6ff;
  color: var(--primary);
}

.status-badge.unread {
  background: #eff6ff;
  color: var(--primary);
}

.status-badge.read {
  background: #f3f4f6;
  color: var(--secondary);
}

.notification-preview {
  max-width: 320px;
  color: var(--text-soft);
  line-height: 1.7;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(15, 23, 42, 0.55);
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-dialog {
  width: min(100%, 820px);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: white;
  border-radius: 24px;
  box-shadow: 0 26px 60px rgba(15, 23, 42, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.modal-dialog.small {
  width: min(100%, 520px);
}

.modal-dialog.large {
  width: min(100%, 1100px);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid #eef2f7;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}

.modal form,
.confirm-body,
.details-body {
  padding: 24px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: white;
  display: grid;
  place-items: center;
  color: var(--text);
}

.details-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.details-card h4,
.details-card h5 {
  margin: 0 0 10px;
}

.details-list {
  margin: 0;
  padding-right: 18px;
  display: grid;
  gap: 8px;
}

.details-list li {
  align-items: flex-start;
  line-height: 1.8;
}

.toast-container {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 50;
  display: grid;
  gap: 10px;
  width: min(100%, 360px);
}

.toast {
  background: white;
  border: 1px solid var(--border);
  border-right-width: 5px;
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: grid;
  gap: 6px;
}

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

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

.toast.info {
  border-right-color: var(--primary);
}

.toast strong {
  display: block;
}

.muted {
  color: var(--text-soft);
}

.text-danger {
  color: var(--danger);
}

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

.text-warning {
  color: var(--warning);
}

.permission-hidden {
  display: none !important;
}

@media (max-width: 1440px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .quick-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .dashboard-grid,
  .dashboard-grid.secondary,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .rewards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .topbar-right {
    justify-content: space-between;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(100%);
    width: min(100%, 320px);
    z-index: 20;
    transition: transform var(--transition);
  }

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

  .stats-grid,
  .quick-actions,
  .rewards-grid,
  .form-grid,
  .details-grid {
    grid-template-columns: 1fr;
  }

  .content,
  .topbar {
    padding: 18px;
  }
}

@media (max-width: 640px) {
  .login-card,
  .card,
  .modal form,
  .confirm-body,
  .details-body {
    padding: 18px;
  }

  .toolbar,
  .card-head,
  .topbar-left,
  .topbar-right,
  .inline-actions,
  .user-list-item {
    align-items: stretch;
    flex-direction: column;
  }

  .global-search {
    min-width: auto;
  }

  .stat-value {
    font-size: 1.6rem;
  }

  .modal {
    padding: 12px;
  }

  .modal-dialog {
    border-radius: 20px;
  }
}
