/* ===========================================================================
   MaxMarket — modern minimal UI (Linear-style restraint, one accent, motion)
   =========================================================================== */
:root {
  --bg: #0a0a0f;
  --bg-2: #0e0e15;
  --surface: #15151d;
  --surface-2: #1c1c27;
  --surface-3: #23232f;
  --line: rgba(255,255,255,.07);
  --line-2: rgba(255,255,255,.12);

  --text: #f3f4f8;
  --text-2: #abb1c4;
  --muted: #6b7188;

  --accent: #5b7cff;
  --accent-2: #4a67e0;
  --accent-soft: rgba(91,124,255,.14);

  --green: #2fd08a;
  --red: #ff5d6c;
  --amber: #ffc24b;

  --r: 16px; --r-lg: 22px; --pill: 999px;
  --nav-h: 62px;
  --ease: cubic-bezier(.22,.61,.36,1);
  --spring: cubic-bezier(.34,1.4,.5,1);
  --maxw: 600px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); }
body {
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.45; letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
  font-variant-numeric: tabular-nums;
}
button { font-family: inherit; cursor: pointer; color: inherit; border: 0; background: none; }
svg { display: block; }
.icon { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; } .icon.lg { width: 26px; height: 26px; }

/* subtle single top glow — no busy decoration */
.bg-ambient { position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(90% 60% at 50% -20%, rgba(91,124,255,.16), transparent 60%),
    var(--bg); }

#app { min-height: 100vh; padding-bottom: calc(var(--nav-h) + 26px + env(safe-area-inset-bottom)); }

/* ── topbar ─────────────────────────────────────────────────────────── */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 18px; padding-top: calc(14px + env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(10,10,15,.92), rgba(10,10,15,.55) 70%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.03em; transition: transform .12s var(--ease); }
.brand:active { transform: scale(.96); }
.brand .logo { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px;
  background: linear-gradient(140deg, #7d93ff, #5b7cff); color: #fff; box-shadow: 0 4px 14px rgba(91,124,255,.4); }
.brand .logo .icon { width: 17px; height: 17px; stroke-width: 2.1; }
.brand .name { background: linear-gradient(90deg, #9db0ff, #5b7cff 70%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.balance-pill { display: inline-flex; align-items: center; gap: 7px; background: var(--surface-2); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: var(--pill); font-weight: 650; font-size: 14px; transition: transform .15s var(--ease);
  flex: none; white-space: nowrap; }
.balance-pill:active { transform: scale(.96); }
.balance-pill .icon { color: var(--accent); flex: none; }
.balance-pill span { white-space: nowrap; }
.brand { min-width: 0; }
.brand .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── view + transitions ─────────────────────────────────────────────── */
.view { padding: 12px 16px 12px; max-width: var(--maxw); margin: 0 auto; }
.view-anim { animation: viewIn .3s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes itemIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.loader { text-align: center; color: var(--muted); padding: 40px 0; }
.center-spin { display: grid; place-items: center; padding: 46px 0; }

/* ── filters ────────────────────────────────────────────────────────── */
.filters { position: sticky; top: 60px; z-index: 20; margin: 0 -16px 10px; padding: 6px 0 10px;
  background: linear-gradient(180deg, var(--bg) 72%, transparent); }
.filters .row { display: flex; align-items: center; gap: 8px; overflow-x: auto; padding: 5px 16px; scrollbar-width: none; }
.filters .row::-webkit-scrollbar { display: none; }
.filters .count { padding: 4px 16px 4px; color: var(--text-2); font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.filters .count b { color: var(--text); font-weight: 700; }

.seg { display: inline-flex; flex: none; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--pill); }
.seg button { padding: 8px 14px; border-radius: var(--pill); font-size: 13px; font-weight: 600; white-space: nowrap; color: var(--text-2);
  display: inline-flex; align-items: center; gap: 6px; transition: color .2s var(--ease), background .2s var(--ease); }
.seg button .icon { width: 15px; height: 15px; }
.seg button.active { background: var(--accent); color: #fff; }

.chip { flex: none; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); padding: 8px 14px; border-radius: var(--pill); font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: background .2s var(--ease), border-color .2s var(--ease), transform .12s var(--ease); }
.chip:active { transform: scale(.95); }
.chip .code { font-weight: 700; }
.chip .cnt { color: var(--muted); font-weight: 700; font-size: 11px; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.active .cnt { color: rgba(255,255,255,.85); }

/* ── list / cards ───────────────────────────────────────────────────── */
.list { display: flex; flex-direction: column; gap: 9px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 13px 14px;
  display: flex; align-items: center; gap: 13px; animation: itemIn .34s var(--ease) both;
  transition: border-color .2s var(--ease), transform .12s var(--ease), background .2s var(--ease); }
.card.tap:active { transform: scale(.985); border-color: var(--line-2); }
.cc-badge { flex: none; width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center;
  background: var(--accent-soft); border: 1px solid rgba(91,124,255,.2); color: #9db0ff; font-weight: 800; font-size: 14px; letter-spacing: -.02em; }
.cc-badge .icon { color: var(--text-2); }
.card .body { flex: 1; min-width: 0; }
.card .ttl { font-weight: 700; font-size: 16px; letter-spacing: -.02em; }
.card .sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.card .sub .meta { display: inline-flex; align-items: center; gap: 4px; }
.card .sub .meta .icon { width: 13px; height: 13px; }
.card .right { flex: none; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.price { font-weight: 750; font-size: 16px; letter-spacing: -.02em; }
.price .cur { color: var(--text-2); font-weight: 600; font-size: 12px; }
.price-old { font-size: 11px; color: var(--muted); text-decoration: line-through; margin-top: -3px; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 7px; }
.badge .icon { width: 12px; height: 12px; }
.badge.fa { background: rgba(47,208,138,.13); color: var(--green); }
.badge.nofa { background: rgba(107,113,136,.16); color: var(--muted); }
.badge.disc { background: var(--accent-soft); color: var(--accent); }

/* ── buttons ────────────────────────────────────────────────────────── */
.btn { border-radius: 11px; padding: 9px 15px; font-weight: 650; font-size: 14px; display: inline-flex; align-items: center;
  justify-content: center; gap: 7px; background: var(--accent); color: #fff; transition: transform .12s var(--ease), filter .2s var(--ease); }
.btn .icon { width: 16px; height: 16px; }
.btn:active { transform: scale(.96); filter: brightness(.95); }
.btn:disabled { opacity: .5; }
.btn.block { width: 100%; padding: 14px; border-radius: 14px; font-size: 15px; }
.btn.ghost { background: var(--surface-2); border: 1px solid var(--line); color: var(--text); }
.btn.green { background: var(--green); color: #042418; }
.btn.sm { padding: 8px 13px; font-size: 13px; border-radius: 10px; }

/* ── empty / sections ───────────────────────────────────────────────── */
.empty { text-align: center; color: var(--muted); padding: 56px 18px; animation: viewIn .3s var(--ease) both; }
.empty .eico { width: 58px; height: 58px; margin: 0 auto 16px; display: grid; place-items: center; border-radius: 18px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text-2); }
.empty .eico .icon { width: 26px; height: 26px; }
.section-title { font-weight: 600; font-size: 12px; color: var(--muted); letter-spacing: .02em; margin: 22px 3px 10px; text-transform: uppercase; }

/* ── balance / stats ────────────────────────────────────────────────── */
.balance-card { position: relative; overflow: hidden; border-radius: var(--r-lg); padding: 24px 22px; text-align: center; margin-bottom: 14px;
  background: var(--surface); border: 1px solid var(--line); }
.balance-card .lbl { color: var(--text-2); font-size: 13px; }
.balance-card .big { font-size: 38px; font-weight: 750; margin: 6px 0 16px; letter-spacing: -.03em; }
.balance-card .big .cur { font-size: 17px; color: var(--text-2); font-weight: 600; }
.balance-card .hint { color: var(--text-2); font-size: 12.5px; margin-top: 4px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 4px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 15px; animation: itemIn .3s var(--ease) both; }
.stat .v { font-size: 21px; font-weight: 750; letter-spacing: -.02em; display: flex; align-items: center; gap: 7px; }
.stat .v .icon { color: var(--accent); width: 18px; height: 18px; }
.stat .k { color: var(--muted); font-size: 12px; margin-top: 3px; }

/* ── referral / info ────────────────────────────────────────────────── */
.ref-link { display: flex; gap: 9px; align-items: center; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.ref-link code { flex: 1; font-size: 12px; color: var(--text-2); word-break: break-all; font-family: ui-monospace, Menlo, monospace; }

.hero { text-align: center; padding: 14px 6px 20px; animation: viewIn .35s var(--ease) both; }
.hero .badge-pill { display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: var(--pill);
  background: var(--accent-soft); border: 1px solid transparent; color: var(--accent); font-size: 12px; font-weight: 700; margin-bottom: 14px; }
.hero h2 { margin: 0 0 8px; font-size: 24px; font-weight: 750; letter-spacing: -.03em; }
.hero p { margin: 0 auto; max-width: 440px; color: var(--text-2); font-size: 14px; }
.feature { display: flex; gap: 13px; align-items: flex-start; padding: 15px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); margin-bottom: 9px; animation: itemIn .3s var(--ease) both; }
.feature .fic { flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.feature .fic .icon { width: 21px; height: 21px; }
.feature h4 { margin: 1px 0 4px; font-size: 15px; font-weight: 650; }
.feature p { margin: 0; color: var(--text-2); font-size: 13px; }
.step { display: flex; gap: 12px; align-items: flex-start; padding: 4px 2px 16px; }
.step .n { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: var(--accent); color: #fff; }
.step h4 { margin: 2px 0 3px; font-size: 14px; } .step p { margin: 0; color: var(--text-2); font-size: 13px; }

/* ── payload / qr ───────────────────────────────────────────────────── */
.payload-box { background: #06060a; border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-family: ui-monospace, Menlo, monospace;
  font-size: 12.5px; white-space: pre-wrap; word-break: break-all; color: #cdd5e8; margin-top: 8px; }
.qr-wrap { display: grid; place-items: center; padding: 16px; background: #fff; border-radius: var(--r); margin: 6px 0 12px; }
.qr-wrap img { width: 210px; height: 210px; }

/* ── modal / sheet ──────────────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  z-index: 100; display: flex; align-items: flex-end; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.sheet { width: 100%; max-width: var(--maxw); margin: 0 auto; border-radius: 24px 24px 0 0; padding: 18px 18px calc(20px + env(safe-area-inset-bottom));
  background: var(--bg-2); border-top: 1px solid var(--line-2); box-shadow: 0 -20px 50px rgba(0,0,0,.5);
  animation: rise .34s var(--spring); max-height: 90vh; overflow-y: auto; }
@keyframes rise { from { transform: translateY(70px); opacity: .6 } to { transform: none; opacity: 1 } }
.sheet .grab { width: 38px; height: 4px; border-radius: 4px; background: var(--line-2); margin: 0 auto 16px; }
.sheet h3 { margin: 0 0 4px; font-size: 19px; font-weight: 700; letter-spacing: -.02em; display: flex; align-items: center; gap: 9px; }
.sheet .muted { color: var(--text-2); font-size: 13px; margin-bottom: 14px; }
.field { width: 100%; background: var(--surface); border: 1px solid var(--line); color: var(--text); border-radius: 13px; padding: 14px; font-size: 17px; margin-bottom: 12px; outline: none; transition: border-color .2s var(--ease), box-shadow .2s var(--ease); }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.amount-quick { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.amount-quick button { flex: 1; min-width: 56px; background: var(--surface); border: 1px solid var(--line); color: var(--text); border-radius: 11px; padding: 11px; font-weight: 700; transition: background .15s var(--ease); }
.amount-quick button:active { background: var(--accent); border-color: var(--accent); }
.provider-row { display: flex; gap: 10px; margin-top: 6px; } .provider-row .btn { flex: 1; }
.row2 { display: flex; gap: 10px; } .row2 .btn { flex: 1; }
.spacer { height: 9px; }

/* ── tabbar (clean, sliding indicator) ──────────────────────────────── */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); display: flex; background: rgba(12,12,18,.86);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-top: 1px solid var(--line); }
.tab-indicator { position: absolute; top: 8px; height: calc(var(--nav-h) - 16px); width: 20%; padding: 0 10px;
  transition: transform .34s var(--spring); pointer-events: none; }
.tab-indicator::after { content: ""; display: block; width: 100%; height: 100%; border-radius: 14px; background: var(--accent-soft); }
.tab { flex: 1; position: relative; z-index: 1; display: grid; place-items: center; color: var(--muted); transition: color .25s var(--ease); }
.tab .ic { display: grid; place-items: center; transition: transform .3s var(--spring); }
.tab .ic .icon { width: 25px; height: 25px; }
.tab.active { color: var(--accent); }
.tab.active .ic { transform: scale(1.08); }

/* ── toast ──────────────────────────────────────────────────────────── */
#toastRoot { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + 24px); z-index: 200; display: flex; flex-direction: column;
  align-items: center; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 8px; padding: 11px 16px; border-radius: 13px; font-size: 14px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--line-2); box-shadow: 0 12px 30px rgba(0,0,0,.45); animation: toastIn .3s var(--spring); max-width: 88%; }
@keyframes toastIn { from { transform: translateY(16px) scale(.96); opacity: 0 } to { transform: none; opacity: 1 } }
.toast .icon { width: 17px; height: 17px; } .toast.ok .icon { color: var(--green); } .toast.err .icon { color: var(--red); }

/* ── spinner + skeleton ─────────────────────────────────────────────── */
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.25); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }
.sk { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 13px 14px; display: flex; align-items: center; gap: 13px; margin-bottom: 9px; }
.sk-b { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 8px; }
@keyframes shimmer { from { background-position: 100% 0 } to { background-position: -100% 0 } }
.sk .a { width: 44px; height: 44px; border-radius: 13px; flex: none; } .sk .l { flex: 1; } .sk .l span { display: block; height: 11px; border-radius: 6px; }

/* ── market header / actions ────────────────────────────────────────── */
.mkt-toolbar { display: flex; align-items: center; gap: 8px; position: sticky; top: 60px; z-index: 20;
  background: linear-gradient(180deg, var(--bg) 75%, transparent); padding: 6px 0 8px; }
.mkt-sub { color: var(--muted); font-size: 13px; font-weight: 600; padding: 0 2px 10px; }
.mkt-sub b { color: var(--text); font-weight: 750; }
.pill-btn { display: inline-flex; align-items: center; gap: 7px; background: var(--surface); border: 1px solid var(--line); color: var(--text);
  padding: 10px 15px; border-radius: var(--pill); font-size: 14px; font-weight: 650; position: relative; white-space: nowrap; transition: transform .12s var(--ease), background .2s var(--ease); }
.pill-btn:active { transform: scale(.94); }
.pill-btn .icon { width: 16px; height: 16px; }
.pill-btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill-btn.icon-only { padding: 9px; }
.pill-btn .fbadge { position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 10px; font-weight: 800; display: grid; place-items: center; }

.applied { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 0 10px; }
.applied .a { display: inline-flex; align-items: center; gap: 5px; background: var(--accent-soft); color: var(--accent);
  border-radius: var(--pill); padding: 5px 10px 5px 11px; font-size: 12px; font-weight: 650; }
.applied .a .icon { width: 13px; height: 13px; }

/* ── sheet form bits ────────────────────────────────────────────────── */
.sheet-label { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .02em; text-transform: uppercase; margin: 16px 2px 9px; }
.range { display: flex; align-items: center; gap: 10px; } .range .field { margin-bottom: 0; } .range span { color: var(--muted); }
.chips-wrap { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── persistent cart bar ────────────────────────────────────────────── */
.cart-bar { position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom)); z-index: 45; max-width: var(--maxw); margin: 0 auto; }
.cart-bar .inner { display: flex; align-items: center; gap: 12px; background: var(--accent); color: #fff; border-radius: 16px; padding: 12px 12px 12px 16px;
  box-shadow: 0 14px 34px rgba(91,124,255,.42); animation: toastIn .3s var(--spring); }
.cart-bar .ic2 { display: grid; place-items: center; }
.cart-bar .ct { flex: 1; min-width: 0; } .cart-bar .ct b { font-size: 15px; font-weight: 750; } .cart-bar .ct span { display: block; font-size: 12px; opacity: .85; }
.cart-bar .go { background: #fff; color: var(--accent-2); border-radius: 12px; padding: 10px 16px; font-weight: 750; font-size: 14px; }
.cart-bar .clr { opacity: .85; padding: 6px; }

/* ── bulk/mass result rows ──────────────────────────────────────────── */
.res { display: flex; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.res:last-child { border: 0; } .res .ri { flex: none; } .res .rt { flex: 1; } .res .rs { font-size: 12px; font-weight: 700; color: var(--muted); }
.res.ok .ri { color: var(--green); } .res.bad .ri { color: var(--red); }

/* ── selectable card checkbox ───────────────────────────────────────── */
.selbox { flex: none; width: 26px; height: 26px; border-radius: 8px; border: 1.5px solid var(--line-2); display: grid; place-items: center; color: transparent; transition: all .15s var(--ease); }
.card.sel .selbox { background: var(--accent); border-color: var(--accent); color: #fff; }
.card.sel { border-color: var(--accent); }

/* ── insufficient-funds (compact) ───────────────────────────────────── */
.short { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 6px 0 4px; }
.short .ring { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 12px; }
.short .ring .icon { width: 30px; height: 30px; }
.short .amt { font-size: 30px; font-weight: 800; letter-spacing: -.03em; margin: 2px 0 2px; }
.short .amt .cur { font-size: 15px; color: var(--text-2); font-weight: 600; }
.short .sub { color: var(--text-2); font-size: 13px; margin-bottom: 16px; }

/* убрать уродливые стрелки у number-инпутов */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }

/* группа выбора (чипы) в шитах — без переноса «таблеткой» */
.opt-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { border: 1px solid var(--line); background: var(--surface); color: var(--text-2); border-radius: 12px;
  padding: 11px 14px; font-size: 14px; font-weight: 650; transition: all .15s var(--ease); }
.opt:active { transform: scale(.96); }
.opt.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* флаг-аватар вместо «+7» */
.cc-badge.flag { background: var(--surface-2); border-color: var(--line); color: var(--text);
  font-size: 26px; line-height: 1; font-weight: 400; }
.opt .fl, .chip .fl { margin-right: 5px; }
