:root {
  --aff-bg: #eef2fb;
  --aff-text: #0f172a;
  --aff-muted: #64748b;
  --aff-border: #d8dfef;
  --aff-card: #ffffff;
  --aff-accent: #0f3ea8;
  --aff-accent-2: #1d4ed8;
}

* {
  box-sizing: border-box;
}

.aff-body {
  margin: 0;
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--aff-text);
  background:
    radial-gradient(circle at 16% 10%, rgba(59, 130, 246, 0.16), transparent 38%),
    radial-gradient(circle at 86% 88%, rgba(37, 99, 235, 0.12), transparent 44%),
    linear-gradient(180deg, #eef3ff 0%, #f6f8fe 100%);
  min-height: 100vh;
}

.aff-auth-main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 20px 14px 34px;
}

.aff-auth-shell {
  min-height: calc(100vh - 80px);
  display: grid;
  place-items: center;
}

.aff-auth-card {
  width: min(460px, 100%);
  border: 1px solid var(--aff-border);
  border-radius: 16px;
  padding: 20px;
  background: var(--aff-card);
  box-shadow: 0 20px 44px rgba(15, 23, 42, 0.12);
}

.aff-auth-head h1 {
  margin: 0;
  font-size: 30px;
}

.aff-auth-head p {
  margin: 6px 0 14px;
  font-size: 13px;
  color: var(--aff-muted);
}

.aff-auth-form {
  display: grid;
  gap: 6px;
}

.aff-auth-form label {
  margin-top: 6px;
  font-size: 12px;
  color: #334155;
  font-weight: 700;
}

.aff-auth-form input {
  width: 100%;
  border: 1px solid var(--aff-border);
  border-radius: 10px;
  padding: 10px 11px;
  font-size: 13px;
  color: #1f2937;
  outline: none;
}

.aff-auth-form input:focus {
  border-color: #96ace7;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.aff-btn {
  margin-top: 12px;
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--aff-accent), var(--aff-accent-2));
  cursor: pointer;
}

.aff-auth-foot {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--aff-muted);
}

.aff-auth-foot a {
  color: var(--aff-accent-2);
  font-weight: 700;
  text-decoration: none;
}

.aff-app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.aff-sidebar {
  background: linear-gradient(180deg, #0b2f86, #0e3fae);
  color: #fff;
  border-right: 1px solid rgba(255, 255, 255, 0.18);
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.aff-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 800;
  padding: 6px 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.22);
}

.aff-logo-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #60a5fa;
}

.aff-nav {
  margin-top: 14px;
  display: grid;
  gap: 5px;
}

.aff-nav a,
.aff-nav-group-toggle {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  border-radius: 10px;
  padding: 10px 10px;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  width: 100%;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.aff-nav a:hover,
.aff-nav a.active,
.aff-nav-group-toggle:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.aff-nav-group-toggle {
  justify-content: space-between;
}

.aff-nav-group-toggle span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.aff-nav-group-toggle > i {
  transition: transform 0.2s ease;
}

.aff-nav-group.open .aff-nav-group-toggle > i {
  transform: rotate(180deg);
}

.aff-subnav {
  display: none;
  padding-left: 12px;
  margin-top: 4px;
  border-left: 1px dashed rgba(255, 255, 255, 0.35);
}

.aff-nav-group.open .aff-subnav {
  display: grid;
  gap: 5px;
}

.aff-subnav a {
  font-size: 12px;
  padding: 8px 9px;
}

.aff-content-wrap {
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
}

.aff-topbar {
  height: 64px;
  border-bottom: 1px solid #d9e1f1;
  background: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.aff-menu-btn {
  border: 1px solid #dbe4f5;
  border-radius: 10px;
  width: 38px;
  height: 38px;
  background: #fff;
  color: #1d4ed8;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.aff-topbar-title h1 {
  margin: 0;
  font-size: 20px;
  color: #0f172a;
}

.aff-topbar-title p {
  margin: 2px 0 0;
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
}

.aff-main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 16px 14px calc(64px + env(safe-area-inset-bottom, 0px));
}

.aff-page-head h2 {
  margin: 0;
  font-size: 24px;
  color: #0f172a;
}

.aff-page-head p {
  margin: 6px 0 0;
  font-size: 13px;
  color: #64748b;
}

.aff-alert {
  margin: 12px 0 0;
  border: 1px solid #c8dbff;
  background: #eff6ff;
  color: #1e3a8a;
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 700;
}

.aff-alert-danger {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

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

.aff-stat-card {
  border: 1px solid #dce5f6;
  border-radius: 12px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 6px;
}

.aff-stat-card span {
  font-size: 12px;
  color: #475569;
  font-weight: 700;
}

.aff-stat-card strong {
  font-size: 22px;
  color: #0f172a;
}

.aff-link-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.aff-link-card {
  border: 1px solid #dce5f6;
  border-radius: 12px;
  background: #fff;
  padding: 12px;
}

.aff-link-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.aff-copy-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.aff-copy-row input {
  border: 1px solid var(--aff-border);
  border-radius: 10px;
  padding: 10px;
  font-size: 12px;
}

.aff-btn-mini {
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  color: #fff;
  background: var(--aff-accent-2);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.aff-filter-form {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
}

.aff-filter-form label {
  display: grid;
  gap: 6px;
  min-width: 160px;
}

.aff-filter-form span {
  font-size: 12px;
  color: #475569;
  font-weight: 700;
}

.aff-filter-form select,
.aff-filter-form input {
  border: 1px solid var(--aff-border);
  border-radius: 10px;
  padding: 10px;
  min-height: 38px;
  font-size: 12px;
  color: #0f172a;
  background: #fff;
}

.aff-btn-wide {
  width: 100%;
}

.aff-qr-box {
  display: grid;
  place-items: center;
  background: #fff;
  border: 1px solid #dce5f6;
  border-radius: 10px;
  padding: 8px;
}

.aff-qr-box img {
  width: 150px;
  height: 150px;
  object-fit: cover;
}

.aff-dual-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
}

.aff-dual-grid > * {
  min-width: 0;
}

.aff-table-card {
  margin-top: 12px;
  border: 1px solid #dce5f6;
  border-radius: 12px;
  background: #fff;
  padding: 12px;
  min-width: 0;
}

.aff-table-head h2 {
  margin: 0;
  font-size: 18px;
}

.aff-table-wrap {
  margin-top: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  border: 1px solid #edf2fb;
  border-radius: 10px;
}

.aff-table {
  width: max-content;
  min-width: 680px;
  border-collapse: collapse;
}

.aff-table th,
.aff-table td {
  border-bottom: 1px solid #eef2fa;
  padding: 9px 8px;
  font-size: 12px;
  text-align: left;
  vertical-align: middle;
}

.aff-table td strong {
  display: block;
}

.aff-table td small {
  display: block;
  margin-top: 2px;
  color: #6b7280;
}

.aff-table th {
  background: #f8faff;
  color: #334155;
  font-weight: 800;
  text-transform: uppercase;
}

.aff-empty {
  text-align: center !important;
  color: #94a3b8;
  font-weight: 700;
}

.aff-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
}

.aff-status-pill.is-active {
  color: #166534;
  background: #dcfce7;
  border: 1px solid #86efac;
}

.aff-status-pill.is-inactive {
  color: #991b1b;
  background: #fee2e2;
  border: 1px solid #fca5a5;
}

.aff-status-pill.is-neutral {
  color: #334155;
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
}

.aff-link-btn {
  border: 1px solid #c9d7f5;
  color: #1e3a8a;
  background: #eef4ff;
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.aff-pagination {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.aff-page-btn {
  text-decoration: none;
  border: 1px solid #d6def0;
  color: #1f2937;
  background: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

.aff-page-btn.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.aff-page-text {
  font-size: 12px;
  color: #64748b;
  font-weight: 700;
}

.aff-search-card {
  margin-top: 12px;
  border: 1px solid #dce5f6;
  border-radius: 12px;
  background: #fff;
  padding: 10px;
}

.aff-search-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.aff-search-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--aff-border);
  border-radius: 10px;
  padding: 10px 11px;
  font-size: 13px;
  outline: none;
}

.aff-search-form input:focus {
  border-color: #96ace7;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.aff-info-grid {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.aff-info-item {
  border: 1px solid #e6edf8;
  border-radius: 10px;
  background: #fafcff;
  padding: 10px;
  display: grid;
  gap: 4px;
}

.aff-info-item span {
  font-size: 11px;
  color: #64748b;
  font-weight: 700;
}

.aff-info-item strong {
  font-size: 13px;
  color: #0f172a;
}

.aff-lock-overview {
  margin-top: 12px;
}

.aff-user-actions {
  margin-top: 12px;
}

.aff-form-grid {
  margin-top: 8px;
  display: grid;
  gap: 10px;
  max-width: 620px;
}

.aff-form-field {
  display: grid;
  gap: 6px;
}

.aff-form-field label {
  font-size: 12px;
  color: #475569;
  font-weight: 700;
}

.aff-form-field input {
  width: 100%;
  border: 1px solid var(--aff-border);
  border-radius: 10px;
  padding: 10px 11px;
  font-size: 13px;
  color: #1f2937;
  outline: none;
}

.aff-form-field input:focus {
  border-color: #96ace7;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.aff-select {
  width: 100%;
  border: 1px solid var(--aff-border);
  border-radius: 10px;
  padding: 10px 11px;
  font-size: 13px;
  color: #1f2937;
  background: #fff;
  outline: none;
}

.aff-select:focus {
  border-color: #96ace7;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.aff-help-note {
  margin: 2px 0 0;
  font-size: 11px;
  color: #64748b;
  font-weight: 700;
}

.aff-2fa-setup {
  margin-top: 10px;
  border: 1px dashed #d4def2;
  border-radius: 12px;
  background: #f8fbff;
  padding: 10px;
  display: grid;
  gap: 8px;
  max-width: 620px;
}

.aff-2fa-qr {
  width: 180px;
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid #d8e2f5;
  background: #fff;
  padding: 5px;
}

.aff-quick-amounts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.aff-quick-btn {
  border: 1px solid #c9d7f5;
  color: #1e3a8a;
  background: #eef4ff;
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.aff-quick-btn:hover {
  background: #dbeafe;
}

.aff-form-sep {
  border: 0;
  border-top: 1px dashed #d7dfef;
  width: 100%;
}

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

  .aff-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 60;
  }

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

  .aff-menu-btn {
    display: inline-flex;
  }

  .aff-content-wrap {
    width: 100%;
  }

  .aff-main {
    padding: 14px 12px calc(86px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 980px) {
  .aff-stats-grid,
  .aff-link-grid,
  .aff-dual-grid,
  .aff-info-grid {
    grid-template-columns: 1fr;
  }

  .aff-search-form {
    flex-direction: column;
    align-items: stretch;
  }

  .aff-search-form .aff-btn-mini {
    width: 100%;
  }

  .aff-table {
    min-width: 640px;
  }

  .aff-table th,
  .aff-table td {
    white-space: nowrap;
  }

  .aff-pagination {
    justify-content: center;
    flex-wrap: wrap;
  }
}
