:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f9fbff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #d3dbe8;
  --primary: #2563eb;
  --primary-soft: #eaf1ff;
  --danger-soft: #fef2f2;
  --radius-lg: 12px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: 'DM Sans', 'Segoe UI', sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.35;
}

h1,
h2,
h3,
strong {
  font-family: 'Manrope', 'DM Sans', sans-serif;
  letter-spacing: -0.01em;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.hidden {
  display: none !important;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.eyebrow {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}

.lead {
  color: var(--muted);
  font-size: 11px;
}

.brand-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-line h1 {
  font-size: clamp(15px, 2.2vw, 18px);
  font-weight: 800;
}

.brand-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.auth-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 14px;
}

.auth-card {
  width: min(100%, 520px);
  padding: 14px;
  display: grid;
  gap: 10px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.auth-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  border-radius: 6px;
  padding: 7px 8px;
  cursor: pointer;
}

.auth-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

label {
  display: grid;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #334155;
}

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

input,
select {
  width: 100%;
  min-height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: #fff;
  padding: 6px 9px;
  color: var(--text);
}

input::placeholder {
  color: #94a3b8;
}

input:focus,
select:focus,
button:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.14);
}

button {
  border: 0;
  border-radius: var(--radius-sm);
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-secondary {
  background: #0f172a;
  color: #fff;
}

.btn-ghost {
  background: #fff;
  color: #334155;
  border: 1px solid var(--line-strong);
}

.btn-danger {
  background: var(--danger-soft);
  color: #991b1b;
  border: 1px solid #fecaca;
}

.auth-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.auth-debug {
  border: 1px solid #fecaca;
  background: #fef2f2;
  border-radius: var(--radius-sm);
  color: #7f1d1d;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  font-size: 11px;
  line-height: 1.45;
  padding: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

.app-shell {
  width: min(1280px, calc(100% - 16px));
  margin: 0 auto;
  padding: 8px 0 56px;
  display: grid;
  gap: 8px;
}

.topbar {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.topbar-main {
  display: grid;
  gap: 4px;
}

.topbar-side {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.hero-badges span {
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: #334155;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
}

.hero-actions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

main .panel {
  padding: 10px;
  display: grid;
  gap: 8px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.section-head h2 {
  font-size: 13px;
  font-weight: 800;
}

.chip {
  border-radius: 999px;
  border: 1px solid #d6e5ff;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
}

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

.stat-card {
  min-height: 74px;
  padding: 8px 10px;
  display: grid;
  align-content: space-between;
  border-radius: var(--radius-md);
}

.stat-card p {
  font-size: 10px;
  color: var(--muted);
}

.stat-card h3 {
  font-size: clamp(16px, 3vw, 21px);
  line-height: 1.1;
}

.profile-actions,
.order-tools,
.payout-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.order-tools select,
.payout-tools select {
  min-width: 156px;
}

.reward-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  align-items: end;
}

.focus-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.spotlight-wrap {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: center;
}

.progress-ring {
  --progress: 0;
  width: 116px;
  height: 116px;
  margin-inline: auto;
  border-radius: 50%;
  background: conic-gradient(var(--primary) calc(var(--progress) * 1%), #e6ecf6 0);
  display: grid;
  place-items: center;
}

.progress-ring > div {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 4px;
}

.progress-ring p {
  color: var(--muted);
  font-size: 10px;
}

.progress-ring strong {
  font-size: 16px;
}

.spotlight-info {
  display: grid;
  gap: 3px;
}

.spotlight-info h3 {
  font-size: 13px;
}

.spotlight-info p {
  color: #475569;
  font-size: 11px;
}

.quest-board,
.leaderboard,
.payout-list,
.analytics-list,
.analytics-bars {
  display: grid;
  gap: 6px;
}

.quest-item,
.rank-item,
.payout-item,
.partner-item,
.month-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.quest-item {
  padding: 7px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
}

.quest-item p {
  font-size: 11px;
  color: #334155;
}

.quest-status {
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: #334155;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  white-space: nowrap;
}

.quest-status.done {
  border-color: #86efac;
  background: #f0fdf4;
  color: #166534;
}

.booster-text {
  color: #475569;
  font-size: 11px;
}

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

table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  background: #fff;
}

thead th {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #fbfdff;
  text-align: left;
}

tbody td {
  padding: 8px;
  border-bottom: 1px solid #ecf1f7;
  font-size: 11px;
  color: #1e293b;
  vertical-align: top;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.action-delete {
  background: #fff;
  color: #b42318;
  border: 1px solid #fecdca;
  border-radius: 7px;
  min-height: 0;
  padding: 3px 7px;
  font-size: 10px;
}

.empty-state {
  border: 1px dashed #d4dbe7;
  border-radius: var(--radius-md);
  background: #fbfdff;
  text-align: center;
  color: #64748b;
  font-size: 11px;
  padding: 8px;
}

.rank-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
}

.rank-pill {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-soft);
  border: 1px solid #d6e5ff;
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.rank-meta strong {
  font-size: 12px;
}

.rank-meta p,
.rank-points p {
  color: #64748b;
  font-size: 10px;
}

.rank-points {
  text-align: right;
}

.rank-points strong {
  display: block;
  font-size: 11px;
}

.payout-item {
  padding: 8px 9px;
  display: grid;
  gap: 6px;
}

.payout-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.payout-head strong {
  font-size: 12px;
}

.payout-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.payout-meta span {
  font-size: 10px;
  color: #64748b;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 6px;
  background: #fff;
}

.payout-status {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 2px 7px;
  border: 1px solid transparent;
}

.payout-status.pending {
  color: #854d0e;
  background: #fff7ed;
  border-color: #fed7aa;
}

.payout-status.approved {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.payout-status.paid {
  color: #166534;
  background: #ecfdf3;
  border-color: #bbf7d0;
}

.payout-status.rejected {
  color: #991b1b;
  background: #fef2f2;
  border-color: #fecaca;
}

.payout-note {
  color: #475569;
  font-size: 11px;
}

.payout-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.payout-actions button {
  min-height: 30px;
  font-size: 10px;
  padding: 3px 8px;
}

.analytics-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.analytics-grid article {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  padding: 8px;
  display: grid;
  gap: 6px;
}

.analytics-grid h3 {
  font-size: 12px;
}

.partner-item,
.month-item {
  padding: 7px;
  gap: 4px;
}

.partner-item strong,
.month-item strong {
  font-size: 11px;
}

.partner-item p,
.month-item p {
  color: #64748b;
  font-size: 10px;
}

.partner-bar,
.month-bar {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: #e3eaf7;
  overflow: hidden;
}

.partner-bar span,
.month-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #4f8cff);
}

.ad-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #f7faff;
  padding: 9px;
  display: grid;
  gap: 4px;
  min-height: 110px;
}

.ad-kicker {
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ad-card h3 {
  font-size: 13px;
}

.ad-card p {
  color: #475569;
  font-size: 11px;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%) translateY(16px);
  background: #0f172a;
  color: #fff;
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 11px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 90;
  max-width: calc(100vw - 20px);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (min-width: 760px) {
  body {
    font-size: 13px;
  }

  .app-shell {
    width: min(1380px, calc(100% - 22px));
    padding-top: 10px;
    gap: 9px;
  }

  .topbar {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .topbar-side {
    justify-content: flex-end;
    align-items: flex-end;
    flex-direction: column;
  }

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

  .spotlight-wrap {
    grid-template-columns: auto 1fr;
  }

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

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

  .form-grid label {
    grid-column: span 2;
  }

  .form-grid > button,
  .form-grid > .profile-actions {
    grid-column: span 2;
    align-self: end;
  }

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

@media (min-width: 1120px) {
  .app-shell {
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }

  .topbar,
  .stats-grid,
  .panel {
    grid-column: span 12;
  }

  section[aria-labelledby='order-form-title'] {
    grid-column: span 8;
  }

  section[aria-labelledby='spotlight-title'] {
    grid-column: span 4;
  }

  section[aria-labelledby='payout-title'],
  section[aria-labelledby='orders-title'] {
    grid-column: span 8;
  }

  section[aria-labelledby='leaderboard-title'],
  section[aria-labelledby='analytics-title'],
  section[aria-labelledby='ads-title'],
  section[aria-labelledby='profile-title'] {
    grid-column: span 4;
  }

  section[aria-labelledby='member-form-title'],
  section[aria-labelledby='reward-title'],
  section[aria-labelledby='simulation-title'] {
    grid-column: span 4;
  }
}
