:root {
  --bg: #060a12;
  --card: #111827;
  --border: #1e293b;
  --text: #f8fafc;
  --muted: #94a3b8;
  --purple: #a855f7;
  --purple-dark: #7c3aed;
  --gold: #f59e0b;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'IBM Plex Sans Arabic', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.65;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 70% 50% at 50% -10%, rgba(168, 85, 247, 0.15), transparent);
  pointer-events: none;
}

a { color: inherit; text-decoration: none; }

.hidden { display: none !important; }

.mk-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(6, 10, 18, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.mk-header-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mk-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mk-brand img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 2px solid var(--purple);
}

.mk-brand strong {
  display: block;
  color: var(--purple);
  font-size: 1rem;
}

.mk-brand span {
  font-size: 0.75rem;
  color: var(--muted);
}

.mk-main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  position: relative;
  z-index: 1;
}

#loginSection,
#registerSection {
  max-width: 520px;
  margin-inline: auto;
}

.mk-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  margin-bottom: 16px;
  scroll-margin-top: 92px;
}

.mk-card h2 {
  font-size: 1.25rem;
  margin-bottom: 6px;
}

.mk-card .lead {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.field-box { margin-bottom: 14px; }

.field-box label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.field-box input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}

.field-box input:focus {
  outline: none;
  border-color: var(--purple);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 18px;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(135deg, var(--purple), var(--purple-dark));
  color: #fff;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  width: auto;
}

.btn-sm { padding: 8px 14px; font-size: 0.85rem; width: auto; }

.link-btn {
  background: none;
  border: none;
  color: var(--purple);
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.error-msg { color: var(--danger); font-size: 0.85rem; min-height: 1.2em; margin: 8px 0; }

.switch-tab {
  text-align: center;
  margin-top: 16px;
  font-size: 0.9rem;
  color: var(--muted);
}

.status-banner {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.status-banner.pending {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: var(--gold);
}

.status-banner.active {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: var(--success);
}

.mk-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.mk-stat {
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}

.mk-stat .val {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--purple);
}

.mk-stat .lbl {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

.ref-box {
  background: #0b1220;
  border: 1px dashed rgba(168, 85, 247, 0.45);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.ref-box label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.ref-url {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.ref-url input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 0.82rem;
  direction: ltr;
  text-align: left;
}

.code-badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(168, 85, 247, 0.15);
  color: var(--purple);
  font-family: ui-monospace, monospace;
  font-weight: 700;
  margin-bottom: 12px;
}

.commission-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.commission-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #0b1220;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 0.88rem;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--card);
  border: 1px solid var(--border);
  padding: 12px 20px;
  border-radius: 10px;
  opacity: 0;
  transition: 0.3s;
  z-index: 200;
}

.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

.splash {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.splash img { width: 72px; border-radius: 16px; margin-bottom: 12px; }

.splash-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-top: 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Points & rewards ─── */
.points-summary {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.points-big {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.points-val {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--gold);
  line-height: 1;
}

.points-lbl {
  font-size: 0.95rem;
  color: var(--muted);
}

.points-meta {
  font-size: 0.9rem;
  line-height: 1.7;
}

.progress-block {
  margin-bottom: 20px;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.88rem;
}

.progress-head span:last-child {
  color: var(--purple);
  font-weight: 700;
}

.progress-track {
  height: 12px;
  background: #0b1220;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple), var(--gold));
  border-radius: 999px;
  transition: width 0.5s ease;
  min-width: 0;
}

.progress-hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 8px;
}

.rewards-progress-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.reward-progress-item {
  padding: 14px;
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.reward-progress-item.achieved {
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.06);
}

.reward-progress-item.claimed {
  border-color: rgba(168, 85, 247, 0.45);
}

.reward-progress-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.reward-progress-head .icon {
  font-size: 1.4rem;
}

.reward-progress-head strong {
  flex: 1;
  font-size: 0.95rem;
}

.reward-badge {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 600;
}

.reward-badge.locked { background: rgba(148, 163, 184, 0.15); color: var(--muted); }
.reward-badge.achieved { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.reward-badge.claimed { background: rgba(168, 85, 247, 0.15); color: var(--purple); }

.reward-progress-item .progress-track {
  height: 8px;
}

.reward-progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 6px;
}

.ref-url {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ref-url input {
  flex: 1 1 200px;
  min-width: 0;
}

.referrals-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.referral-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.referral-date {
  font-size: 0.8rem;
  white-space: nowrap;
}

.points-tier-banner {
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.25);
  color: #fcd34d;
  font-size: 0.9rem;
  font-weight: 600;
}

.commission-tiers-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.tier-row {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.tier-row.achieved {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.06);
}

.tier-row-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.tier-row-head strong {
  flex: 1;
}

.product-points-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.product-points-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.product-points-main strong {
  display: block;
  margin-bottom: 4px;
}

.product-points-meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.product-points-side {
  min-width: 112px;
  text-align: left;
}

.product-points-side strong {
  display: block;
  color: var(--gold);
  font-size: 1rem;
}

.product-points-side span {
  color: var(--muted);
  font-size: 0.75rem;
}

.payout-form {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid rgba(168, 85, 247, 0.14);
  border-radius: 12px;
  background: rgba(11, 18, 32, 0.8);
}

.wallet-subsection h3 {
  font-size: 1rem;
  margin: 12px 0 10px;
}

#dashboardSection {
  display: flex;
  flex-direction: column;
}

.dashboard-hero-card {
  order: 1;
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.98), rgba(11, 18, 32, 0.98));
  border-color: rgba(168, 85, 247, 0.18);
}

.overview-stats-wrap { order: 2; }
.points-section { order: 3; }
.referrals-section { order: 4; }
.team-section { order: 5; }
#statsGrid { order: 6; }
.products-section { order: 7; }
.wallet-section { order: 8; }
.commissions-section { order: 9; }
.profile-section { order: 10; }

.card-head-inline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-head-inline .lead,
.card-head-inline h2 {
  margin-bottom: 0;
}

.shortcut-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.shortcut-btn {
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.84rem;
  cursor: pointer;
  transition: 0.2s ease;
}

.shortcut-btn:hover {
  border-color: rgba(168, 85, 247, 0.38);
  background: rgba(168, 85, 247, 0.08);
}

.overview-stats-wrap {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.overview-stats-wrap .mk-stat {
  text-align: right;
  background: rgba(11, 18, 32, 0.95);
}

.overview-stats-wrap .mk-stat .val {
  font-size: 1.15rem;
}

.referral-row,
.product-points-row,
.commission-row {
  transition: 0.18s ease;
}

.referral-row:hover,
.product-points-row:hover,
.commission-row:hover {
  border-color: rgba(168, 85, 247, 0.18);
  background: rgba(255, 255, 255, 0.045);
}

@media (max-width: 900px) {
  .overview-stats-wrap {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .mk-main {
    padding: 20px 14px 42px;
  }

  .mk-card {
    padding: 20px 16px;
  }

  .card-head-inline,
  .product-points-row,
  .referral-row {
    flex-direction: column;
  }

  .overview-stats-wrap {
    grid-template-columns: 1fr 1fr;
  }

  .product-points-side {
    min-width: 0;
    text-align: right;
  }
}
