/* Primitivas → semánticos → componentes. La fuente refleja la estética Apple solicitada. */
:root {
  --green-500: oklch(72% .15 158);
  --green-600: oklch(58% .14 158);
  --green-700: oklch(42% .11 158);
  --neutral-0: oklch(99% .006 155);
  --neutral-50: oklch(97% .008 155);
  --neutral-100: oklch(94% .01 155);
  --neutral-500: oklch(55% .015 155);
  --neutral-700: oklch(34% .015 155);
  --neutral-900: oklch(20% .018 155);
  --danger: oklch(55% .19 27);

  --bg: var(--neutral-50);
  --surface: var(--neutral-0);
  --surface-soft: var(--neutral-100);
  --text: var(--neutral-900);
  --text-secondary: var(--neutral-500);
  --accent: var(--green-600);
  --accent-strong: var(--green-700);
  --accent-contrast: var(--neutral-0);
  --border: oklch(90% .012 155);
  --shadow: 0 12px 32px oklch(25% .02 155 / .07);
  --radius-lg: 26px;
  --radius-md: 18px;
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  --bg: oklch(17% .014 155);
  --surface: oklch(22% .014 155);
  --surface-soft: oklch(27% .015 155);
  --text: oklch(96% .008 155);
  --text-secondary: oklch(72% .014 155);
  --accent: var(--green-500);
  --accent-strong: oklch(80% .13 158);
  --accent-contrast: oklch(18% .02 155);
  --border: oklch(32% .015 155);
  --shadow: 0 14px 36px oklch(8% .01 155 / .28);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-width: 280px;
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { cursor: pointer; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible {
  outline: 3px solid var(--green-500);
  outline-offset: 3px;
}
button:disabled { cursor: not-allowed; opacity: .55; }
[hidden] { display: none !important; }
.svg-definitions { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { width: 100%; max-width: 760px; min-height: 100dvh; margin: 0 auto; padding: 0 20px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding-top: env(safe-area-inset-top);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 750; letter-spacing: -.4px; }
.brand img { border-radius: 50%; box-shadow: 0 5px 14px oklch(40% .1 158 / .2); }
.language-button {
  min-width: 48px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 750;
  transition: transform 160ms ease-out, background 160ms ease-out;
}
.language-button:hover { background: var(--surface-soft); }
.language-button:active { transform: scale(.95); }

main { padding: 16px 0 124px; }
.state-view { min-height: 58dvh; display: grid; place-content: center; justify-items: center; gap: 16px; text-align: center; }
.state-view p { max-width: 34ch; margin: 0; color: var(--text-secondary); }
.state-view h1 { margin: 0; font-size: 28px; letter-spacing: -.8px; }
.state-icon { width: 48px; height: 48px; color: var(--accent); }
.loader { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: loading-spin .8s linear infinite; }
@keyframes loading-spin { to { transform: rotate(360deg); } }

.welcome-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; }
.welcome-row h1 { margin: 2px 0 0; font-size: clamp(30px, 7vw, 42px); line-height: 1.1; letter-spacing: -1.4px; }
.greeting { margin: 0; font-size: 14px; }
.muted { color: var(--text-secondary); }
.network-pill, .soft-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 11px;
  border-radius: 999px;
  background: oklch(72% .15 158 / .13);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.balance-hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 176px;
  padding: 28px;
  border-radius: var(--radius-lg);
  background: oklch(29% .06 158);
  color: oklch(97% .015 155);
  box-shadow: 0 18px 40px oklch(30% .07 158 / .18);
}
.balance-hero > span { font-size: 14px; color: oklch(88% .03 155); }
.balance-hero strong { position: relative; z-index: 1; display: block; margin-top: 14px; font-size: clamp(38px, 10vw, 54px); line-height: 1; letter-spacing: -2px; }
.balance-hero small, .balance-detail small { font-size: 16px; letter-spacing: 0; }
.hero-decoration { position: absolute; z-index: -1; right: -44px; top: -72px; width: 220px; height: 220px; border: 42px solid oklch(75% .15 158 / .12); border-radius: 50%; }

.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 28px 0 14px; }
.section-heading h2 { margin: 0; font-size: 20px; letter-spacing: -.45px; }
.task-card, .withdraw-card, .goal-card, .admin-table-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  margin-bottom: 16px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.task-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: oklch(72% .15 158 / .13);
  color: var(--accent-strong);
}
.task-copy h3, .goal-card h3 { margin: 0 0 4px; font-size: 17px; letter-spacing: -.25px; }
.task-copy p, .goal-card p { margin: 0; color: var(--text-secondary); font-size: 14px; line-height: 1.5; }
.progress-label { grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 4px; }
.progress-label strong { font-size: 15px; }
.progress-label span { color: var(--text-secondary); font-size: 12px; }
.progress-track { grid-column: 1 / -1; height: 9px; overflow: hidden; border-radius: 99px; background: var(--surface-soft); }
.progress-track > span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width 260ms ease-out; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 50px;
  padding: 12px 18px;
  border: 0;
  border-radius: 16px;
  font-weight: 720;
  transition: transform 160ms ease-out, filter 160ms ease-out, background 160ms ease-out;
}
.button:hover { filter: brightness(1.04); }
.button:active { transform: scale(.98); }
.button svg { width: 20px; height: 20px; }
.button-primary { background: var(--accent); color: var(--accent-contrast); }
.button-secondary { border: 1px solid var(--border); background: var(--surface-soft); color: var(--text); }
.task-card > .button { grid-column: 1 / -1; width: 100%; }
.task-footnote { grid-column: 1 / -1; margin: -4px 0 0; text-align: center; color: var(--text-secondary); font-size: 12px; }
.task-footnote strong { color: var(--accent-strong); }
.referral-link { grid-column: 1 / -1; display: block; overflow: hidden; padding: 12px 14px; border-radius: 12px; background: var(--surface-soft); color: var(--text-secondary); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.balance-detail { padding: 32px 24px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.balance-detail > span { color: var(--text-secondary); font-size: 14px; }
.balance-detail > strong { display: block; margin: 12px 0; font-size: clamp(42px, 12vw, 60px); line-height: 1; letter-spacing: -2px; }
.balance-detail p { margin: 0; color: var(--text-secondary); font-size: 14px; }
.earnings-list { display: grid; gap: 12px; margin-top: 24px; }
.earnings-list article { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 14px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.earnings-list h3 { margin: 0; font-size: 15px; }
.earnings-list p { margin: 3px 0 0; color: var(--text-secondary); font-size: 12px; }
.earnings-list article > strong { grid-column: 2; font-size: 18px; }

.withdraw-card { display: block; margin-top: 4px; }
.withdraw-card .section-heading { margin-top: 0; }
fieldset { min-width: 0; margin: 0 0 22px; padding: 0; border: 0; }
legend, .field-label { display: block; margin-bottom: 10px; font-size: 14px; font-weight: 700; }
.network-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.network-options label { position: relative; cursor: pointer; }
.network-options input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.network-options label > span { display: grid; place-content: center; min-height: 72px; padding: 8px 4px; border: 1px solid var(--border); border-radius: 15px; background: var(--surface-soft); text-align: center; font-size: 13px; font-weight: 700; transition: border 160ms ease-out, background 160ms ease-out, transform 160ms ease-out; }
.network-options small { color: var(--text-secondary); font-size: 10px; font-weight: 600; }
.network-options input:checked + span { border-color: var(--accent); background: oklch(72% .15 158 / .13); color: var(--accent-strong); }
.network-options input:focus-visible + span { outline: 3px solid var(--green-500); outline-offset: 3px; }
.network-options label:active > span { transform: scale(.97); }
#wallet-address { width: 100%; min-height: 52px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-soft); color: var(--text); font-size: 16px; }
#wallet-address::placeholder { color: var(--text-secondary); }
#withdraw-form > .button { width: 100%; margin-top: 18px; }
.field-error { margin: 8px 0 0; color: var(--danger); font-size: 13px; }
.goal-card { display: block; animation: enter 220ms ease-out; }
.goal-card .task-icon { margin-bottom: 14px; }
.goal-card .progress-label { margin-top: 20px; }
.goal-card .goal-track { margin-top: 8px; }
.goal-card .clause { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--text); font-size: 13px; }
@keyframes enter { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }

.icon-button { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); transition: transform 160ms ease-out, background 160ms ease-out; }
.icon-button:hover { background: var(--surface-soft); }
.icon-button:active { transform: scale(.94); }
.metrics-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.metrics-grid article { padding: 18px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.metrics-grid span { display: block; min-height: 40px; color: var(--text-secondary); font-size: 13px; }
.metrics-grid strong { display: block; margin-top: 6px; font-size: 28px; letter-spacing: -1px; }
.admin-table-card { display: block; padding: 18px; }
.admin-table-card .section-heading { margin-top: 0; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px 8px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { color: var(--text-secondary); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
td small { display: block; color: var(--text-secondary); }
tbody tr:last-child td { border-bottom: 0; }

.bottom-nav {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  display: flex;
  width: calc(100% - 32px);
  max-width: 560px;
  min-height: 72px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 14px 40px oklch(20% .02 155 / .16);
  transform: translateX(-50%);
}
.nav-item { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0; min-height: 56px; border: 0; border-radius: 17px; background: transparent; color: var(--text-secondary); font-size: 10px; font-weight: 700; transition: color 160ms ease-out, background 160ms ease-out, transform 160ms ease-out; }
.nav-item svg { width: 22px; height: 22px; }
.nav-item:hover { background: var(--surface-soft); }
.nav-item:active { transform: scale(.95); }
.nav-item.active { background: oklch(72% .15 158 / .13); color: var(--accent-strong); }

.reward-modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 24px; }
.reward-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: oklch(12% .02 155 / .55); backdrop-filter: blur(8px); cursor: default; }
.reward-card { position: relative; width: 100%; max-width: 360px; padding: 32px 24px 24px; border: 1px solid var(--border); border-radius: 30px; background: var(--surface); box-shadow: 0 24px 80px oklch(10% .02 155 / .3); text-align: center; animation: reward-enter 240ms ease-out; }
@keyframes reward-enter { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }
.close-button { position: absolute; top: 12px; right: 12px; border: 0; }
.reward-coin { display: block; margin: 4px auto 18px; filter: drop-shadow(0 14px 16px oklch(40% .1 158 / .22)); }
.reward-card p { margin: 0; color: var(--text-secondary); font-size: 14px; }
.reward-card h2 { margin: 6px 0 10px; color: var(--accent-strong); font-size: 42px; letter-spacing: -1.5px; }
.reward-card > span { display: block; margin-bottom: 24px; color: var(--text-secondary); font-size: 14px; }
.reward-card > .button { width: 100%; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 104px; width: max-content; max-width: calc(100% - 40px); padding: 12px 18px; border-radius: 14px; background: var(--neutral-900); color: var(--neutral-0); box-shadow: var(--shadow); font-size: 14px; text-align: center; transform: translateX(-50%); animation: enter 180ms ease-out; }

@media (min-width: 700px) {
  .app-shell { padding: 0 28px; }
  main { padding-top: 28px; }
  .page { padding-bottom: 12px; }
  #page-tasks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  #page-tasks .balance-hero, #page-tasks .section-heading { grid-column: 1 / -1; }
  #page-tasks .task-card { margin-bottom: 0; }
  .balance-hero { min-height: 190px; }
}

@media (max-width: 360px) {
  .app-shell { padding: 0 14px; }
  .task-card, .withdraw-card, .goal-card { padding: 16px; }
  .network-options label > span { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

.provider-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-top: 10px;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2px;
}

.language-card {
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
}

.language-card h2 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 25px;
  letter-spacing: -.6px;
}

.language-card > p {
  margin-bottom: 20px;
  line-height: 1.5;
}

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

.language-option {
  min-width: 0;
  min-height: 48px;
  padding: 10px 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  overflow-wrap: anywhere;
  transition: transform 160ms ease-out, border-color 160ms ease-out, background 160ms ease-out;
}

.language-option:hover { border-color: var(--accent); }
.language-option:active { transform: scale(.97); }
.language-option.selected {
  border-color: var(--accent);
  background: oklch(72% .15 158 / .13);
  color: var(--accent-strong);
}

.progress-label strong { direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] th, [dir="rtl"] td { text-align: right; }
[dir="rtl"] .close-button { right: auto; left: 12px; }
[dir="rtl"] .hero-decoration { right: auto; left: -44px; }

@media (max-width: 340px) {
  .language-options { grid-template-columns: 1fr; }
}
