/* Earnings counter — mobile-first, RTL, dark by default. */
:root {
  --bg: #120f24;
  --bg2: #1d1740;
  --card: #231d4a;
  --card2: #2c2560;
  --text: #f7f5ff;
  --muted: #aaa3d6;
  --line: rgba(255, 255, 255, .09);
  --accent: #ffd166;
  --good: #2ee59d;
  --bad: #ff5c7a;
  --b1: #ff6b6b;
  --b2: #ffa62b;
  --nav-h: 72px;
  --radius: 22px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f1ff;
  --bg2: #e9e3ff;
  --card: #ffffff;
  --card2: #f1edff;
  --text: #1d1838;
  --muted: #6b6590;
  --line: rgba(0, 0, 0, .08);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100dvh;
  background: radial-gradient(1200px 600px at 50% -200px, var(--bg2), var(--bg)) fixed, var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Rubik", "Assistant", Arial, sans-serif;
  font-size: 18px;
  line-height: 1.45;
  overflow-x: hidden;
}
button, input, select, a.btn, label.btn { font: inherit; color: inherit; touch-action: manipulation; }
button { cursor: pointer; }
h1 { font-size: 28px; margin: 4px 0; }
h2 { font-size: 20px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 15px; }
[hidden] { display: none !important; }

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right))
           calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
}
.page-login { padding-bottom: 24px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin: 14px 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
}
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 4px; }

/* ---------- buttons & fields ---------- */
.btn, .chip-btn, .link-btn, .step-btn {
  min-height: 56px;
  border: none;
  border-radius: 16px;
  font-weight: 700;
  -webkit-user-select: none; user-select: none;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 22px;
  background: var(--accent);
  color: #1a1433;
  text-decoration: none;
  margin: 6px 0;
}
.btn.big { width: 100%; font-size: 22px; min-height: 64px; }
.btn.ghost { background: var(--card2); color: var(--text); border: 1px solid var(--line); }
.btn.danger-btn { background: var(--bad); color: #fff; }
.btn:active, .chip-btn:active, .link-btn:active, .step-btn:active { transform: scale(.97); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-row .btn { flex: 1 1 140px; }
.btn-col { display: flex; flex-direction: column; gap: 4px; }
.btn-col .btn { width: 100%; }
.chip-btn { background: var(--card2); border: 1px solid var(--line); padding: 0 18px; color: var(--text); }
.link-btn { background: transparent; color: var(--muted); padding: 0 14px; font-weight: 600; }

.field { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; font-weight: 600; color: var(--muted); }
input, select {
  min-height: 56px;
  width: 100%;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card2);
  color: var(--text);
  font-size: 18px;
}
input[type="color"] { padding: 6px; }
input[type="checkbox"] { width: 30px; height: 30px; min-height: 30px; accent-color: var(--accent); flex: none; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; font-weight: 600; }
.range-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.range-row label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 15px; font-weight: 600; min-width: 0; }

/* ---------- home ---------- */
.first-screen {
  display: flex; flex-direction: column;
  min-height: calc(100dvh - var(--nav-h) - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}
.today-card { text-align: center; padding: 8px 0 4px; position: relative; }
.today-card .label { color: var(--muted); font-weight: 700; letter-spacing: .5px; }
.big-ils {
  font-size: clamp(48px, 15vw, 72px);
  font-weight: 900;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #fff, var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
:root[data-theme="light"] .big-ils { background: linear-gradient(180deg, #2b2257, #7a5cff); -webkit-background-clip: text; background-clip: text; }
.big-usd {
  font-size: clamp(48px, 15vw, 72px);
  font-weight: 900;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #fff, var(--good));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
:root[data-theme="light"] .big-usd { background: linear-gradient(180deg, #0b5e3c, #1fae6f); -webkit-background-clip: text; background-clip: text; }
.taps { font-size: 16px; color: var(--muted); }
.rate-chip { position: absolute; top: 4px; inset-inline-start: 0; font-size: 13px; color: var(--muted); }
.big-ils.bump { animation: bump .35s ease; }
@keyframes bump { 40% { transform: scale(1.08); } }

.goal { margin: 10px 0 0; }
.goal-bar { height: 22px; border-radius: 999px; background: var(--card2); overflow: hidden; border: 1px solid var(--line); }
.goal-fill {
  height: 100%; width: 0; border-radius: 999px;
  transition: width .6s cubic-bezier(.2, .9, .3, 1.2), background-color .6s;
  background-image: linear-gradient(90deg, rgba(255,255,255,.25), rgba(255,255,255,0) 60%);
}
.goal-text { text-align: center; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.goal-text.small { font-size: 15px; color: var(--muted); font-weight: 600; margin-top: 2px; }

.thumb-zone { margin-top: auto; padding-top: 14px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.page-home .thumb-zone { min-height: 330px; justify-content: flex-end; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 14px; }
.step-btn {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--card2); border: 1px solid var(--line); color: var(--text);
  font-size: 34px; line-height: 1;
}
.qty {
  width: 96px; height: 64px; text-align: center;
  font-size: 32px; font-weight: 800; border-radius: 18px;
  -moz-appearance: textfield;
}
.qty::-webkit-outer-spin-button, .qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.tap-btn {
  width: min(86vw, 380px);
  min-width: 60%;
  height: 176px;
  border: none;
  border-radius: 48px;
  background: linear-gradient(135deg, var(--b1), var(--b2));
  color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  box-shadow: 0 14px 0 rgba(0, 0, 0, .25), 0 18px 40px rgba(0, 0, 0, .35), inset 0 2px 0 rgba(255, 255, 255, .35);
  text-shadow: 0 2px 6px rgba(0, 0, 0, .3);
  -webkit-user-select: none; user-select: none;
  transition: transform .08s, box-shadow .08s;
  position: relative;
}
.tap-btn:active, .tap-btn.pressed { transform: translateY(8px) scale(.98); box-shadow: 0 6px 0 rgba(0,0,0,.25), 0 8px 20px rgba(0,0,0,.3), inset 0 2px 0 rgba(255,255,255,.35); }
.tap-top { font-size: 20px; font-weight: 700; opacity: .95; }
.tap-amount { font-size: 54px; font-weight: 900; line-height: 1.05; }
.tap-btn.small { height: 120px; width: min(70vw, 280px); }
.tap-btn.small .tap-amount { font-size: 40px; }
.row-links { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }

.coin-float {
  position: fixed; z-index: 50; pointer-events: none;
  font-size: 34px; font-weight: 900; color: var(--accent);
  text-shadow: 0 2px 10px rgba(0,0,0,.5);
  animation: floatUp 1s ease-out forwards;
  transform: translateX(-50%);
}
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(.7); }
  15% { opacity: 1; transform: translate(-50%, -10px) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -140px) scale(1); }
}

/* ---------- entries ---------- */
.entry-list { list-style: none; margin: 0; padding: 0; }
.entry {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.entry:last-child { border-bottom: none; }
.e-body { flex: 1; min-width: 0; }
.e-main { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.e-amt { font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; }
.e-usd { font-size: 21px; font-weight: 800; color: var(--good); font-variant-numeric: tabular-nums; }
.e-meta { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.e-acts { display: flex; gap: 6px; flex: none; }
.icon-btn {
  width: 56px; height: 56px; border-radius: 16px; border: 1px solid var(--line);
  background: var(--card2); font-size: 20px; color: var(--text);
}
.pending-tag { font-size: 12px; background: var(--accent); color: #1a1433; border-radius: 999px; padding: 2px 8px; font-weight: 800; }
.empty { color: var(--muted); text-align: center; padding: 10px 0; }

.day-group { margin: 14px 0; }
.day-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap;
  padding: 10px 14px; border-radius: 14px; background: var(--card2); font-weight: 800;
}
.day-head .sub { font-variant-numeric: tabular-nums; }
.day-head .sub .usd { color: var(--good); font-weight: 800; margin-inline-start: 8px; }
.day-group .entry-list { background: var(--card); border-radius: 16px; padding: 0 14px; margin-top: 6px; border: 1px solid var(--line); }

/* ---------- summary ---------- */
.cards { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 12px; }
@media (min-width: 600px) { .cards { grid-template-columns: 1fr 1fr; } }
.scard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.scard .t { display: flex; justify-content: space-between; color: var(--muted); font-weight: 700; }
.scard .v { font-size: 36px; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1.15; }
.scard .v2 { font-size: 36px; font-weight: 900; line-height: 1.15; color: var(--good); font-variant-numeric: tabular-nums; }
.scard .meta { display: flex; justify-content: space-between; margin-top: 6px; font-size: 15px; }
.chg.up { color: var(--good); font-weight: 800; }
.chg.down { color: var(--bad); font-weight: 800; }
.chg.flat { color: var(--muted); }

.bars {
  position: relative; display: flex; align-items: flex-end; gap: 4px;
  height: 190px; padding-top: 22px; direction: ltr;
}
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; background: none; border: none; padding: 0; }
.bar {
  width: 100%; border-radius: 8px 8px 3px 3px; min-height: 3px;
  background: linear-gradient(180deg, var(--b2), var(--b1));
  opacity: .75; transition: height .5s;
}
.bar-col.today .bar, .bar-col.sel .bar { opacity: 1; box-shadow: 0 0 0 2px var(--accent); }
.bar-val { font-size: 10px; color: var(--muted); white-space: nowrap; margin-bottom: 2px; }
.bar-lbl { font-size: 11px; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.bar-col.today .bar-lbl { color: var(--accent); font-weight: 800; }
.goal-line { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--good); pointer-events: none; }
.goal-line span { position: absolute; top: -18px; left: 0; font-size: 11px; color: var(--good); font-weight: 700; }

.res-total { font-size: 30px; font-weight: 900; margin: 10px 0 2px; font-variant-numeric: tabular-nums; }
.day-rows { list-style: none; padding: 0; margin: 8px 0 0; }
.day-rows li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.day-rows li .usd { color: var(--good); font-weight: 700; margin-inline-start: 8px; }

/* ---------- admin ---------- */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 10px; }
.swatch { height: 56px; border-radius: 16px; border: 3px solid transparent; }
.swatch.sel { border-color: var(--text); }
.swatch.custom { background: var(--card2); border: 2px dashed var(--muted); font-size: 14px; color: var(--text); }
.preview { display: flex; justify-content: center; margin-bottom: 8px; }
.rate-now { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.override { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; margin: 12px 0; }
.override label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 15px; font-weight: 600; min-width: 0; }
.override .btn { grid-column: 1 / -1; }
.table-wrap { overflow-x: auto; }
table.rates { width: 100%; border-collapse: collapse; font-size: 15px; }
table.rates th, table.rates td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: start; }
table.rates input { min-height: 44px; width: 92px; padding: 0 8px; font-size: 16px; }
table.rates .icon-btn { width: 48px; height: 48px; }
.danger { margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--bad); }
.tag-est { color: var(--bad); font-weight: 700; }

/* ---------- login ---------- */
.login-wrap { min-height: 90dvh; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.login-wrap .logo { font-size: 84px; filter: drop-shadow(0 10px 20px rgba(0,0,0,.4)); }
.login-wrap form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.login-wrap input { text-align: center; font-size: 22px; }
.err { color: var(--bad); font-weight: 700; min-height: 28px; }

/* ---------- nav, toast, sheet, badge ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
}
.bottom-nav a {
  flex: 1; min-height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 700; gap: 2px;
}
.bottom-nav a .ni { font-size: 26px; line-height: 1; filter: grayscale(.6); }
.bottom-nav a.active { color: var(--accent); }
.bottom-nav a.active .ni { filter: none; transform: scale(1.1); }

#toasts {
  position: fixed; left: 0; right: 0; z-index: 60;
  bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px;
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px;
  background: #2f2870; color: #fff; border-radius: 18px; padding: 6px 8px 6px 18px; padding-inline-start: 18px;
  min-height: 56px; font-weight: 700; box-shadow: 0 10px 30px rgba(0,0,0,.4);
  opacity: 0; transform: translateY(20px); transition: opacity .2s, transform .2s; max-width: 100%;
}
.toast.show { opacity: 1; transform: none; }
.toast.err { background: #8a1f3a; }
.toast-act { min-height: 48px; min-width: 72px; border-radius: 12px; border: none; background: var(--accent); color: #1a1433; font-weight: 900; padding: 0 14px; }

.sheet-bd {
  position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .5);
  display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .2s;
}
.sheet-bd.open { opacity: 1; }
.sheet {
  width: 100%; max-width: 560px; background: var(--card); color: var(--text);
  border-radius: 26px 26px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .25s; max-height: 92dvh; overflow-y: auto;
}
.sheet-bd.open .sheet { transform: none; }
.sheet::before { content: ""; display: block; width: 48px; height: 5px; border-radius: 9px; background: var(--muted); opacity: .5; margin: -6px auto 12px; }

.sync-badge {
  position: fixed; top: calc(8px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 40;
  background: var(--accent); color: #1a1433; font-weight: 800; font-size: 14px;
  border-radius: 999px; padding: 6px 14px; box-shadow: 0 6px 20px rgba(0,0,0,.35);
}
canvas.confetti { position: fixed; inset: 0; z-index: 80; pointer-events: none; }

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