:root {
  --bg-main: #0e0f12;
  --bg-alt: #14171d;
  --bg-card: #16181d;
  --bg-card-soft: #1b1f27;
  --text-main: #f5f5f5;
  --text-muted: #b9b9b9;
  --line: #2e3038;
  --line-soft: #2a2d35;
  --gold: #d4af37;
  --gold-dark: #b8962e;
  --gold-soft: rgba(212, 175, 55, 0.2);
  --danger: #e74c3c;
  --ok: #2ecc71;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text-main);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background:
    radial-gradient(1000px 520px at 92% -14%, rgba(212, 175, 55, 0.14) 0%, rgba(212, 175, 55, 0) 62%),
    linear-gradient(180deg, var(--bg-alt) 0%, var(--bg-main) 34%, #0b0c10 100%);
}

.affiliate-page {
  width: min(1050px, 94vw);
  margin: 24px auto 52px;
  display: grid;
  gap: 18px;
}

.hero {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 22px 20px;
  background: linear-gradient(135deg, #1a1d24 0%, #16181d 46%, #111319 100%);
  box-shadow: var(--shadow);
}

.hero::after {
  content: "";
  position: absolute;
  width: 210px;
  height: 210px;
  right: -70px;
  top: -70px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212, 175, 55, 0.22) 0%, rgba(212, 175, 55, 0) 68%);
  pointer-events: none;
}

.hero h1 {
  margin: 8px 0 8px;
  font-size: clamp(1.3rem, 2vw, 1.8rem);
  line-height: 1.15;
  letter-spacing: 0.01em;
}

.hero p {
  margin: 0;
  color: var(--text-muted);
  max-width: 720px;
  line-height: 1.45;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--gold);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
}

.back-link:hover {
  text-decoration: underline;
}

.card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  background: linear-gradient(150deg, var(--bg-card) 0%, var(--bg-card-soft) 100%);
  display: grid;
  gap: 12px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.35);
}

.affiliate-guest {
  border-color: rgba(245, 196, 0, 0.35);
  background:
    linear-gradient(180deg, rgba(212, 175, 55, 0.08) 0%, rgba(212, 175, 55, 0.02) 100%),
    linear-gradient(150deg, var(--bg-card) 0%, var(--bg-card-soft) 100%);
}

.affiliate-guest-eyebrow {
  margin: 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #d4af37;
}

.affiliate-guest h2 {
  margin: 2px 0 0;
  font-size: clamp(1.2rem, 2vw, 1.55rem);
}

.affiliate-guest-lead {
  margin: 0;
  color: #d2d2d2;
  line-height: 1.52;
}

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

.affiliate-guest-card {
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 12px;
  background: rgba(18, 21, 27, 0.72);
  padding: 12px;
  display: grid;
  gap: 8px;
}

.affiliate-guest-card--wide {
  margin-top: 2px;
}

.affiliate-guest-card h3 {
  margin: 0;
  font-size: 0.95rem;
  color: #d4af37;
}

.affiliate-guest-card ul,
.affiliate-guest-steps {
  margin: 0;
  padding-left: 18px;
  color: #d4d4d4;
  line-height: 1.42;
}

.affiliate-guest-steps li + li {
  margin-top: 4px;
}

.affiliate-guest-cta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.affiliate-guest-note {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.card h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text-muted);
  line-height: 1.45;
}

.card ul li + li {
  margin-top: 6px;
}

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

label {
  display: grid;
  gap: 7px;
  font-size: 0.9rem;
  color: #e3e3e3;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-card-soft);
  color: var(--text-main);
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

input[readonly] {
  background: #14171d;
  color: #efefef;
}

input::placeholder {
  color: #9ca3af;
}

input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
  background: #20242d;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-card-soft);
  color: var(--text-main);
  padding: 10px 12px;
  outline: none;
  resize: vertical;
  min-height: 120px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

textarea::placeholder {
  color: #9ca3af;
}

textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
  background: #20242d;
}

.btn {
  border-radius: 11px;
  padding: 10px 14px;
  border: 0;
  font-weight: 700;
  cursor: pointer;
  width: fit-content;
  text-decoration: none;
  transition: transform 0.15s ease, filter 0.15s ease, opacity 0.2s ease;
}

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

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: #0e0f12;
  box-shadow: 0 8px 22px rgba(212, 175, 55, 0.24);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-main);
  border: 1px solid var(--line);
}

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

.stat {
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: linear-gradient(150deg, #191d25 0%, #151820 100%);
  padding: 10px;
  min-height: 76px;
  display: grid;
  align-content: center;
  gap: 4px;
}

.label {
  display: block;
  color: var(--text-muted);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.stat strong {
  font-size: 1rem;
}

.row-actions {
  margin-top: 4px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.partner-tier-box {
  border: 1px solid var(--gold-soft);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(212, 175, 55, 0.1) 0%, rgba(212, 175, 55, 0.03) 100%),
    #171b24;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.partner-tier-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.partner-tier-right {
  text-align: right;
}

.partner-tier-progress {
  width: 100%;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.partner-tier-progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold) 0%, var(--gold-dark) 100%);
  transition: width 0.25s ease;
}

.status {
  min-height: 20px;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.status.ok {
  color: var(--ok);
}

.status.err {
  color: var(--danger);
}

.request-state-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 700;
}

.request-state-pill.pending {
  color: #fef08a;
  border-color: rgba(250, 204, 21, 0.45);
  background: rgba(133, 77, 14, 0.24);
}

.request-state-pill.approved {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(21, 128, 61, 0.22);
}

.request-state-pill.rejected {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(127, 29, 29, 0.22);
}

.affiliate-page #affiliateRedeemStatus,
.affiliate-page #affiliateBoundInfo {
  margin: 0;
  min-height: 0;
}

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

.affiliate-info-box {
  border: 1px solid var(--gold-soft);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(212, 175, 55, 0.08) 0%, rgba(212, 175, 55, 0.02) 100%),
    #171b24;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.affiliate-info-box h3 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--gold);
}

.affiliate-info-box p {
  margin: 0;
  color: #dddddd;
  line-height: 1.45;
}

.partner-private-area.hidden {
  display: none;
}

.partner-private-area {
  display: grid;
  gap: 16px;
}

.affiliate-trader-counters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.affiliate-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
}

.affiliate-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  background: rgba(20, 23, 30, 0.7);
}

.affiliate-table th,
.affiliate-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  font-size: 0.9rem;
}

.affiliate-table th {
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.affiliate-table tbody tr:hover {
  background: rgba(212, 175, 55, 0.08);
}

.partner-manifesto p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.52;
}

.text-link-btn {
  border: 0;
  background: transparent;
  color: var(--gold);
  font-weight: 700;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-decoration: none;
  text-underline-offset: 2px;
}

.text-link-btn:hover {
  filter: brightness(1.08);
}

.partner-access-btn {
  display: flex;
  width: 100%;
  min-height: 52px;
  text-align: center;
  align-items: center;
  justify-content: center;
  font-size: 1.03rem;
  letter-spacing: 0.01em;
  box-shadow: 0 12px 28px rgba(212, 175, 55, 0.3);
}

@media (max-width: 860px) {
  .affiliate-page {
    width: min(100%, 95vw);
    margin-top: 16px;
    gap: 14px;
  }

  .hero {
    padding: 18px 16px;
  }

  .card {
    padding: 14px;
  }

  .grid,
  .stats,
  .affiliate-trader-counters,
  .affiliate-guest-grid {
    grid-template-columns: 1fr;
  }

  .btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  .row-actions {
    display: grid;
    gap: 8px;
  }

  .affiliate-table {
    min-width: 100%;
  }

  .affiliate-guest-cta {
    display: grid;
    gap: 8px;
  }
}

@media (max-width: 520px) {
  .hero h1 {
    font-size: 1.16rem;
  }

  .hero p,
  .card ul,
  .partner-manifesto p {
    font-size: 0.92rem;
  }

  .card {
    border-radius: 14px;
    padding: 12px;
    gap: 10px;
  }

  .stat {
    min-height: 68px;
  }

  input {
    font-size: 16px;
  }
}
