/* MPay Mini App — "ink & pearl": a dark silk video behind glass cards, pearl type, jade accents.
   The palette is taken from the background video (#05090c ink, #29393a–#455455 silk) and the folded-paper M logo. */
:root {
  --bg: #05090c;
  --surface: rgba(255, 255, 255, 0.055);
  --surface-2: rgba(255, 255, 255, 0.085);
  --surface-3: rgba(255, 255, 255, 0.14);
  --surface-solid: #0b1115;
  --glass-blur: blur(18px) saturate(140%);
  --text: #eef3f1;
  --muted: #8b9c9a;
  --faint: #56686a;
  --line: rgba(255, 255, 255, 0.085);
  --line-strong: rgba(255, 255, 255, 0.16);
  --accent: #8fdcc9;
  --accent-soft: rgba(143, 220, 201, 0.13);
  --good: #4fe0a0;
  --good-soft: rgba(79, 224, 160, 0.13);
  --bad: #ff6f6f;
  --bad-soft: rgba(255, 111, 111, 0.13);
  --warn: #f2c46d;
  --warn-soft: rgba(242, 196, 109, 0.13);
  /* pearl: the primary surface (buttons, highlights) — white with a jade fold, like the logo */
  --grad: linear-gradient(135deg, #ffffff 0%, #e6efec 46%, #b9ddd3 100%);
  --on-grad: #061012;
  --grad-glow: 0 10px 28px rgba(185, 221, 211, 0.16);
  --grad-check: linear-gradient(145deg, #0e2624 0%, #1d4842 48%, #5ea597 100%);
  --grad-invoice: linear-gradient(145deg, #0e1a24 0%, #23404f 52%, #7ea3b6 100%);
  --hero: linear-gradient(160deg, rgba(255, 255, 255, 0.11) 0%, rgba(255, 255, 255, 0.035) 55%, rgba(143, 220, 201, 0.06) 100%);
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.45);
  --tabbar-bg: rgba(5, 9, 12, 0.62);
  --sheet-bg: rgba(10, 15, 19, 0.9);
  --veil: linear-gradient(180deg, rgba(5, 9, 12, 0.2) 0%, rgba(5, 9, 12, 0.42) 45%, rgba(5, 9, 12, 0.7) 100%);
  --video-filter: none;
  --radius: 22px;
  color-scheme: dark;
}

/* light: the same silk, inverted into pearl; ink becomes the primary surface */
:root[data-theme="light"] {
  --bg: #eef2f1;
  --surface: rgba(255, 255, 255, 0.6);
  --surface-2: rgba(10, 30, 32, 0.055);
  --surface-3: rgba(10, 30, 32, 0.1);
  --surface-solid: #f7f9f8;
  --text: #0a1315;
  --muted: #56686a;
  --faint: #93a3a2;
  --line: rgba(10, 30, 32, 0.08);
  --line-strong: rgba(10, 30, 32, 0.14);
  --accent: #217a69;
  --accent-soft: rgba(33, 122, 105, 0.1);
  /* darker status colours: the dark-theme ones are unreadable on white (all >= 4.5:1 here) */
  --good: #0a7038;
  --good-soft: rgba(10, 112, 56, 0.1);
  --bad: #c0222e;
  --bad-soft: rgba(192, 34, 46, 0.08);
  --warn: #8a5100;
  --warn-soft: rgba(138, 81, 0, 0.12);
  --grad: linear-gradient(135deg, #0b1416 0%, #18272a 55%, #2c4744 100%);
  --on-grad: #f2f7f5;
  --grad-glow: 0 10px 26px rgba(11, 20, 22, 0.22);
  --hero: linear-gradient(160deg, rgba(255, 255, 255, 0.78) 0%, rgba(255, 255, 255, 0.55) 60%, rgba(33, 122, 105, 0.08) 100%);
  --shadow: 0 12px 30px rgba(20, 40, 44, 0.12);
  --tabbar-bg: rgba(238, 242, 241, 0.7);
  --sheet-bg: rgba(246, 248, 247, 0.93);
  --veil: linear-gradient(180deg, rgba(238, 242, 241, 0.25) 0%, rgba(238, 242, 241, 0.45) 50%, rgba(238, 242, 241, 0.7) 100%);
  --video-filter: invert(1) hue-rotate(180deg) saturate(0.7) brightness(1.03);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; }
a { color: var(--accent); text-decoration: none; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.hidden { display: none !important; }

/* ---------- silk video background ---------- */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: var(--bg) url("../img/bg.jpg") center / cover no-repeat; }
.bg video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: var(--video-filter); pointer-events: none; }
/* iOS draws a big ▶ of its own over a video it will not start (Low Power Mode): never any controls here, and the still
   frame (the poster, in the theme's colours) lies over the video until it really plays ("live": index.html). One rule
   for each control: a browser that does not know one of them drops the whole rule it stands in. */
.bg video::-webkit-media-controls { display: none !important; -webkit-appearance: none; }
.bg video::-webkit-media-controls-panel { display: none !important; -webkit-appearance: none; }
.bg video::-webkit-media-controls-play-button { display: none !important; -webkit-appearance: none; }
.bg video::-webkit-media-controls-overlay-play-button { display: none !important; -webkit-appearance: none; }
.bg video::-webkit-media-controls-start-playback-button { display: none !important; -webkit-appearance: none; }
.bg::before { content: ""; position: absolute; inset: 0; z-index: 1; background: url("../img/bg.jpg") center / cover no-repeat; filter: var(--video-filter); transition: opacity 0.6s; pointer-events: none; }
.bg.live::before { opacity: 0; }
.bg::after { content: ""; position: absolute; inset: 0; z-index: 1; background: var(--veil); pointer-events: none; }
:root[data-theme="light"] .bg { background-image: none; }
@media (prefers-reduced-motion: reduce) { .bg video { display: none; } .bg.live::before { opacity: 1; } }

#app { max-width: 560px; margin: 0 auto; padding: 14px 16px calc(96px + env(safe-area-inset-bottom)); }
#app.no-tabbar { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }

/* ---------- screen transitions (motion.js): the screens move, their cards fade one by one ----------
   Never opacity, a filter or a view-transition-name on a screen: that would cut its glass off from the video. */
/* flow-root keeps the first block's margin inside the screen, so one lifted out (fixed) stays exactly where it was */
.screen { position: relative; z-index: 1; display: flow-root; }
.leaving { position: fixed !important; z-index: 0 !important; margin: 0 !important; pointer-events: none; }

/* while a screen arrives its list rows follow one after another */
.screen.entering .list > *, .screen.entering .tiles > *, .screen.entering .mini-ticket { animation: row-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) both; }
.screen.entering .list > :nth-child(2), .screen.entering .tiles > :nth-child(2) { animation-delay: 35ms; }
.screen.entering .list > :nth-child(3) { animation-delay: 70ms; }
.screen.entering .list > :nth-child(4) { animation-delay: 105ms; }
.screen.entering .list > :nth-child(5) { animation-delay: 140ms; }
.screen.entering .list > :nth-child(6) { animation-delay: 175ms; }
.screen.entering .list > :nth-child(7) { animation-delay: 210ms; }
.screen.entering .list > :nth-child(n + 8) { animation-delay: 245ms; }
@keyframes row-in { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) {
  .screen.entering .list > *, .screen.entering .tiles > *, .screen.entering .mini-ticket { animation: none; }
}
/* a list being replaced (Active / Archive) dims until the new one comes; each card on its own: glass stays glass */
#items > * { transition: opacity 0.2s, transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1); }
#items.loading > * { opacity: 0.45; }

/* glass: every card floats over the video */
.list, .tile, .field, .select, .summary, .qr-card, .note, .toggle-row, .price-card, .chip, .icon-btn, .hero,
.segmented, .mini-ticket.closed, .tip-card {
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; margin: 2px 2px 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; letter-spacing: 0.01em; }
.brand .logo { width: 34px; height: 34px; border-radius: 11px; overflow: hidden; display: grid; place-items: center; box-shadow: 0 0 0 1px var(--line-strong), 0 8px 20px rgba(0, 0, 0, 0.35); }
.logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-size: 13.5px; font-weight: 650; transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1); }
.chip:active, .icon-btn:active { transform: scale(0.94); }
.chip svg { width: 16px; height: 16px; }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1); }
.icon-btn svg { width: 19px; height: 19px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.top-actions .icon-btn { width: 34px; height: 34px; }
.top-actions .icon-btn svg { width: 18px; height: 18px; }
.title { font-size: 27px; font-weight: 800; letter-spacing: -0.02em; margin: 4px 2px 16px; }
.subtitle { color: var(--muted); margin: -10px 2px 16px; }
.section-title { display: flex; justify-content: space-between; align-items: center; font-weight: 750; font-size: 17px; margin: 24px 4px 10px; }
.section-title a, .section-title button { font-size: 14px; font-weight: 650; color: var(--accent); background: none; border: 0; }

/* ---------- hero: a pane of frosted glass with a silk sheen ---------- */
.hero { position: relative; overflow: hidden; border-radius: 28px; padding: 20px 18px 18px; color: var(--text); background: var(--hero); border: 1px solid var(--line-strong); box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.08); isolation: isolate; }
.hero::before { content: ""; position: absolute; z-index: -1; width: 280px; height: 280px; right: -90px; top: -150px; border-radius: 50%; background: radial-gradient(circle, rgba(185, 221, 211, 0.22), transparent 64%); }
.hero::after { content: ""; position: absolute; z-index: -1; inset: 0; background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.06) 45%, transparent 60%); }
.hero .label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 650; color: var(--muted); letter-spacing: 0.01em; }
.hero .label button { background: none; border: 0; padding: 0; display: grid; color: var(--muted); }
.hero .label svg { width: 17px; height: 17px; }
.hero .total { font-size: 42px; font-weight: 800; letter-spacing: -0.03em; margin: 4px 0 0; line-height: 1.12; font-variant-numeric: tabular-nums; }
.hero .rates-note { font-size: 12px; color: var(--muted); margin-top: 2px; }
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 20px; }
.action { display: flex; flex-direction: column; align-items: center; gap: 7px; background: none; border: 0; color: var(--text); font-size: 12.5px; font-weight: 650; padding: 0; }
.action .ic { width: 52px; height: 52px; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; transition: transform 0.15s, background 0.15s; }
.actions .action:first-child .ic { background: var(--grad); color: var(--on-grad); border-color: transparent; box-shadow: var(--grad-glow); }
.action:active .ic { transform: scale(0.92); }
.action svg { width: 22px; height: 22px; }

/* ---------- tiles ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.tile { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); text-align: left; transition: transform 0.15s; }
.tile:active { transform: scale(0.98); }
.tile .ic { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; color: #eef3f1; flex: none; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18); }
.tile .ic svg { width: 21px; height: 21px; }
.tile b { display: block; font-size: 15.5px; }
.tile span { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.3; margin-top: 1px; }

/* ---------- lists ---------- */
.list { background: var(--surface); border-radius: var(--radius); padding: 6px; border: 1px solid var(--line); }
.list + .list { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px; border-radius: 16px; background: none; border: 0; text-align: left; transition: background 0.15s, transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1); }
.row:active { background: var(--surface-2); transform: scale(0.985); }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 650; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { color: var(--muted); font-size: 13px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .end { text-align: right; flex: none; }
.row .end .t { font-variant-numeric: tabular-nums; }
.row .chev { color: var(--faint); width: 18px; height: 18px; flex: none; }
.row > .good { display: grid; place-items: center; width: 24px; height: 24px; flex: none; }
.row > .good svg { width: 22px; height: 22px; }
.row .row-ic { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--text); }
.row .row-ic svg { width: 21px; height: 21px; }
.row.static:active { background: none; }
/* a choice that can't be taken now (a swap target with no free coins, a balance withdrawn in the bot): it says why */
.row.off { opacity: 0.55; }
.warn-t { color: var(--warn); }
/* the balance an invoice is paid from: one of several, the picked one filled */
.row .pick {
  width: 24px; height: 24px; flex: none; display: grid; place-items: center; border-radius: 50%;
  border: 2px solid var(--line-strong); color: transparent; transition: background 0.15s, border-color 0.15s;
}
.row .pick svg { width: 15px; height: 15px; stroke-width: 3; }
.row .pick.on { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.divider { height: 1px; background: var(--line); margin: 2px 10px; }

.coin { position: relative; width: 42px; height: 42px; flex: none; }
.coin > svg { width: 100%; height: 100%; display: block; border-radius: 50%; box-shadow: 0 0 0 1px var(--line-strong); }
.coin .badge { position: absolute; right: -3px; bottom: -3px; width: 19px; height: 19px; border-radius: 50%; box-shadow: 0 0 0 2.5px var(--surface-solid); }
.coin .badge svg { width: 100%; height: 100%; display: block; }
.coin.lg { width: 64px; height: 64px; }
.coin.lg .badge { width: 26px; height: 26px; }
.coin.sm { width: 28px; height: 28px; }

.empty { text-align: center; color: var(--muted); padding: 34px 16px; }
.empty .em-ic { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 22px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.empty .em-ic svg { width: 30px; height: 30px; }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

/* ---------- segmented ---------- */
.segmented { position: relative; display: flex; padding: 4px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); margin-bottom: 14px; }
.segmented button { position: relative; z-index: 1; flex: 1; height: 36px; border-radius: 11px; border: 0; background: none; font-weight: 650; color: var(--muted); font-size: 14px; transition: color 0.3s; }
.segmented button.active { color: var(--on-grad); }
/* the pill under the active half slides across (--i: 0 or 1) */
.seg-ind { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 11px; background: var(--grad); box-shadow: var(--grad-glow); transform: translateX(calc(var(--i, 0) * 100%)); transition: transform 0.42s cubic-bezier(0.3, 1.25, 0.5, 1); }
@media (prefers-reduced-motion: reduce) { .seg-ind { transition: none; } }

/* ---------- forms ---------- */
.field { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 11px 14px 10px; margin-bottom: 10px; transition: border-color 0.15s, box-shadow 0.15s; }
.field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.field.error { border-color: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }
.field > label, .field .lbl { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 650; color: var(--muted); }
.field .in { display: flex; align-items: center; gap: 8px; }
.field input, .field textarea { flex: 1; min-width: 0; width: 100%; border: 0; outline: 0; background: none; color: var(--text); font-size: 16.5px; padding: 6px 0 2px; resize: none; }
.field input::placeholder, .field textarea::placeholder { color: var(--faint); }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.field .hint.bad { color: var(--bad); }
.field .hint.good { color: var(--good); }
.field .mini { height: 30px; padding: 0 10px; border-radius: 10px; border: 0; background: var(--accent-soft); color: var(--accent); font-weight: 750; font-size: 13px; flex: none; }
.amount-field input { font-size: 32px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.amount-field .cur { font-size: 20px; font-weight: 800; color: var(--muted); }
.unit-switch { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface-2); flex: none; }
.unit-switch button { min-width: 44px; height: 30px; padding: 0 10px; border: 0; border-radius: 9px; background: none; color: var(--muted); font-weight: 800; font-size: 14px; }
.unit-switch button.active { background: var(--grad); color: var(--on-grad); }

.tip-card { display: flex; gap: 12px; align-items: flex-start; margin-top: 14px; padding: 14px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line-strong); }
.tip-card .tip-ic { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; flex: none; background: var(--grad); color: var(--on-grad); }
.tip-card .tip-ic svg { width: 20px; height: 20px; }
.tip-card .main { flex: 1; min-width: 0; }
.tip-card b { display: block; font-size: 15px; margin-bottom: 3px; }
.tip-card .s { color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.tip-card code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; padding: 1px 6px; border-radius: 7px; background: var(--surface-2); color: var(--text); white-space: nowrap; }
.tip-card .btn { height: 42px; font-size: 14.5px; margin-top: 10px; }
.select { display: flex; align-items: center; gap: 12px; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px; margin-bottom: 10px; text-align: left; }
.select .main { flex: 1; min-width: 0; }
.select .lbl { font-size: 12.5px; font-weight: 650; color: var(--muted); }
.select .val { font-weight: 700; font-size: 16px; }
.select .chev { width: 18px; height: 18px; color: var(--faint); }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 13px 14px; margin-bottom: 10px; }
.toggle-row .t { font-weight: 650; }
.toggle-row .s { font-size: 12.5px; color: var(--muted); }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 30px; background: var(--surface-3); transition: 0.2s; }
.switch span::after { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); transition: 0.2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }

.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 36px; height: 36px; border-radius: 12px; border: 0; background: var(--surface-2); font-size: 20px; font-weight: 700; }
.stepper input { width: 72px; text-align: center; font-weight: 800; font-size: 18px; }

.summary { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 6px 14px; margin: 4px 0 14px; }
.summary .line { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; font-size: 14.5px; }
.summary .line + .line { border-top: 1px solid var(--line); }
.summary .line span:first-child { color: var(--muted); }
.summary .line span:last-child { font-weight: 650; text-align: right; word-break: break-all; font-variant-numeric: tabular-nums; }
.summary .line.total span:last-child { font-size: 16px; font-weight: 800; }

/* buttons: pearl primary (ink in the light theme), glass secondary */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 54px; border: 0; border-radius: 17px; background: var(--grad); color: var(--on-grad); font-weight: 750; font-size: 16.5px; letter-spacing: 0.01em; box-shadow: var(--grad-glow); transition: transform 0.15s, opacity 0.15s; }
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.4; box-shadow: none; }
.btn svg { width: 20px; height: 20px; }
.btn.secondary { background: var(--surface-2); color: var(--text); box-shadow: none; border: 1px solid var(--line); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); }
.btn.ghost { background: none; color: var(--accent); box-shadow: none; height: 46px; }
.btn.danger { background: var(--bad-soft); color: var(--bad); box-shadow: none; }
.btn.light { background: rgba(255, 255, 255, 0.95); color: #061012; box-shadow: none; }
.btn + .btn { margin-top: 10px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-row .btn + .btn { margin-top: 0; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid currentColor; border-top-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- asset screen ---------- */
.asset-head { text-align: center; padding: 8px 0 4px; }
.asset-head .coin { margin: 0 auto 12px; }
.asset-head .amt { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.asset-head .fiat { color: var(--muted); font-size: 15px; margin-top: 2px; }
.round-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 18px 0 6px; }
.round-actions .action { color: var(--text); }
.round-actions .action .ic { background: var(--surface); border: 1px solid var(--line); color: var(--accent); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); }
.price-card { display: flex; justify-content: space-between; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px; margin-top: 12px; }

/* ---------- coin screen: the price chart ---------- */
.coin-title { display: flex; align-items: center; gap: 12px; margin: 2px 2px 14px; }
.coin-title .t { font-weight: 750; font-size: 17px; line-height: 1.2; }
.coin-title .s { color: var(--muted); font-size: 13px; font-weight: 650; }
.chart-card { position: relative; overflow: hidden; padding: 18px 0 12px; border-radius: 26px; background: var(--hero); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); }
.chart-price { padding: 0 18px; font-size: 34px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.chart-sub { display: flex; align-items: center; gap: 8px; min-height: 28px; padding: 6px 18px 0; font-size: 13.5px; }
.chg { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chg.good { background: var(--good-soft); color: var(--good); }
.chg.bad { background: var(--bad-soft); color: var(--bad); }
.chg.flat { background: var(--surface-2); color: var(--muted); }
.chart { position: relative; height: 210px; margin-top: 4px; touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: crosshair; }
.chart-ghost { position: absolute; left: 0; right: 16px; top: 34px; bottom: 34px; width: calc(100% - 16px); height: calc(100% - 68px); overflow: visible; }
.chart-ghost path { fill: none; stroke: var(--surface-3); stroke-width: 2.5; stroke-linecap: round; vector-effect: non-scaling-stroke; animation: ghost 1.6s ease-in-out infinite; }
@keyframes ghost { 50% { opacity: 0.35; } }
.chart.loading .chart-svg { opacity: 0.35; transition: opacity 0.2s; }
.chart-empty { width: 100%; height: 100%; display: grid; place-items: center; padding: 0; border: 0; background: none; color: var(--muted); font-size: 14px; }
.chart-svg { display: block; overflow: visible; }
.chart-svg.up { --c: var(--good); }
.chart-svg.down { --c: var(--bad); }
.chart-svg.flat { --c: var(--accent); }
/* a period switch: the old chart fades out over the new one, which is revealed left to right */
.chart-svg.chart-old { position: absolute; left: 0; top: 0; pointer-events: none; animation: chart-out 0.3s ease both; }
.chart-svg.reveal { animation: chart-reveal 0.85s cubic-bezier(0.22, 1, 0.36, 1) backwards; }
.chart-svg.reveal .chart-hl, .chart-svg.reveal .chart-halo { animation: chart-fade 0.45s 0.6s both; }
.chart-svg.reveal .chart-pulse { animation-delay: 0.85s; }
/* a chart still drawing itself in when another period replaces it: it keeps drawing and fades out all the same */
.chart-svg.reveal.chart-old { animation: chart-reveal 0.85s cubic-bezier(0.22, 1, 0.36, 1) backwards, chart-out 0.3s ease both; }
@keyframes chart-out { to { opacity: 0; } }
@keyframes chart-reveal { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes chart-fade { from { opacity: 0; } }
.area-a { stop-color: var(--c); stop-opacity: 0.32; }
.area-m { stop-color: var(--c); stop-opacity: 0.1; }
.area-b { stop-color: var(--c); stop-opacity: 0; }
.line-a { stop-color: var(--c); stop-opacity: 0.5; }
.line-b { stop-color: var(--c); stop-opacity: 1; }
.cur-a { stop-color: var(--text); stop-opacity: 0; }
.cur-b { stop-color: var(--text); stop-opacity: 0.4; }
.chart-base { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 2 5; stroke-linecap: round; }
.chart-line { fill: none; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.chart-glow { fill: none; stroke: var(--c); stroke-width: 9; stroke-linejoin: round; opacity: 0.1; }
:root[data-theme="light"] .chart-glow { opacity: 0.05; }
.chart-hl text { fill: var(--muted); font-size: 11px; font-weight: 650; font-variant-numeric: tabular-nums; }
.chart-cursor { stroke-width: 1.2; opacity: 0; transition: opacity 0.15s; }
.chart-dot { fill: var(--c); stroke: var(--surface-solid); stroke-width: 2.5; opacity: 0; }
.chart-halo { fill: var(--c); opacity: 0.16; }
.chart-end { fill: var(--c); }
.chart-pulse { fill: var(--c); transform-box: fill-box; transform-origin: center; animation: chart-pulse 1.8s ease-out infinite; }
.chart-svg.scrub .chart-cursor, .chart-svg.scrub .chart-dot { opacity: 1; }
.chart-svg.scrub .chart-end, .chart-svg.scrub .chart-hl, .chart-svg.scrub .chart-halo { opacity: 0; }
.chart-svg.scrub .chart-pulse { animation: none; opacity: 0; }
@keyframes chart-pulse { from { transform: scale(1); opacity: 0.5; } to { transform: scale(3.4); opacity: 0; } }
.periods { position: relative; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; margin: 6px 12px 0; padding: 3px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.periods .period-ind { position: absolute; left: 0; top: 3px; bottom: 3px; width: 0; border-radius: 10px; background: var(--grad); box-shadow: var(--grad-glow); opacity: 0; transition: transform 0.42s cubic-bezier(0.3, 1.25, 0.5, 1), width 0.42s cubic-bezier(0.3, 1.25, 0.5, 1), opacity 0.2s; }
.periods .period-ind.on { opacity: 1; }
.periods button { position: relative; z-index: 1; height: 32px; padding: 0; border: 0; border-radius: 10px; background: none; color: var(--muted); font-weight: 700; font-size: 13px; transition: color 0.3s; }
.periods button.active { color: var(--on-grad); }
.hold { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; padding: 12px 16px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); }
.hold .end { text-align: right; }
.hold .t { font-weight: 750; }
.hold .s { color: var(--muted); font-size: 13px; }
@media (prefers-reduced-motion: reduce) {
  .chart-pulse, .chart-ghost path { animation: none; }
  .chart-pulse { opacity: 0; }
  .chart-svg.reveal, .chart-svg.reveal .chart-hl, .chart-svg.reveal .chart-halo { animation: none; }
  .periods .period-ind { transition: none; }
}

/* ---------- deposit ---------- */
.qr-card { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 26px; padding: 20px; text-align: center; }
.qr-box { width: 208px; height: 208px; margin: 0 auto; padding: 14px; border-radius: 22px; background: #fff; position: relative; box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35); }
.qr-box svg { width: 100%; height: 100%; display: block; }
.qr-box .qr-logo { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; transform: translate(-50%, -50%); border-radius: 50%; background: #fff; padding: 4px; }
.qr-box .qr-logo svg { width: 100%; height: 100%; }
.addr { margin-top: 16px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 14.5px; word-break: break-all; line-height: 1.5; }
.addr b { color: var(--accent); font-weight: 700; }
.copy-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.copy-row .btn { height: 46px; font-size: 15px; border-radius: 14px; }
.copy-row .btn + .btn { margin-top: 0; }
.memo-copy { height: 34px; padding: 0 14px; border-radius: 11px; border: 0; background: var(--warn-soft); color: var(--warn); font-weight: 700; font-size: 13.5px; font-family: inherit; }
.memo-card { background: var(--warn-soft); border-radius: 20px; padding: 14px; margin-top: 12px; }
.memo-card .lbl { color: var(--warn); font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.memo-card .lbl svg { width: 16px; height: 16px; }
.memo-card .val { display: flex; justify-content: space-between; align-items: center; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 22px; font-weight: 700; margin-top: 6px; }
.notes { margin-top: 12px; display: grid; gap: 8px; }
.note { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 11px 12px; }
.note svg { width: 18px; height: 18px; flex: none; margin-top: 1px; color: var(--accent); }
.note.warn svg { color: var(--warn); }

/* ---------- check ticket: jade silk (invoice: steel silk) ---------- */
.ticket { position: relative; overflow: hidden; border-radius: 28px; color: #eef3f1; background: var(--grad-check); padding: 22px 22px 20px; border: 1px solid rgba(255, 255, 255, 0.14); box-shadow: 0 20px 44px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.12); isolation: isolate; }
.ticket.invoice { background: var(--grad-invoice); }
.ticket.muted-ticket { filter: grayscale(0.85); opacity: 0.8; }
.ticket::before { content: ""; position: absolute; z-index: -1; width: 300px; height: 300px; right: -110px; top: -150px; border-radius: 50%; background: radial-gradient(circle, rgba(220, 244, 237, 0.3), transparent 62%); }
.ticket::after { content: ""; position: absolute; z-index: -1; inset: 0; background: linear-gradient(120deg, transparent 35%, rgba(255, 255, 255, 0.07) 48%, transparent 62%); }
.ticket .notch { position: absolute; top: 64%; width: 26px; height: 26px; border-radius: 50%; background: var(--bg); transform: translateY(-50%); }
.ticket .notch.l { left: -13px; }
.ticket .notch.r { right: -13px; }
.ticket .t-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 14px; opacity: 0.92; }
.ticket .t-head .brandmark { display: flex; align-items: center; gap: 7px; }
.ticket .t-head .brandmark svg { width: 18px; height: 18px; }
.ticket .t-head .coin { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.28); border-radius: 50%; }
.ticket .t-amount { font-size: 38px; font-weight: 850; letter-spacing: -0.025em; margin-top: 16px; line-height: 1.1; font-variant-numeric: tabular-nums; }
/* the network of the balance (TRC-20), or «любая сеть» for an invoice payable from any */
.ticket .t-net {
  display: inline-block; margin-left: 8px; padding: 3px 9px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.16); font-size: 13px; font-weight: 700; letter-spacing: 0; vertical-align: middle;
}
.ticket .t-fiat { opacity: 0.8; font-weight: 600; margin-top: 4px; }
.ticket .perf { border-top: 2px dashed rgba(255, 255, 255, 0.3); margin: 22px -22px 16px; }
.ticket .t-meta { display: flex; flex-wrap: wrap; gap: 8px; }
.ticket .t-meta span { display: inline-flex; align-items: center; gap: 5px; background: rgba(255, 255, 255, 0.14); border-radius: 999px; padding: 5px 10px; font-size: 12.5px; font-weight: 650; }
.ticket .t-meta svg { width: 14px; height: 14px; }
.ticket .t-desc { margin-top: 12px; font-size: 15px; font-weight: 550; opacity: 0.95; }
.ticket .t-from { margin-top: 12px; font-size: 13px; opacity: 0.8; }
.progress { height: 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.18); overflow: hidden; margin-top: 14px; }
.progress div { height: 100%; background: linear-gradient(90deg, #ffffff, #b9ddd3); border-radius: 8px; }

.mini-ticket { display: flex; gap: 12px; align-items: center; width: 100%; padding: 12px; border-radius: 18px; border: 1px solid rgba(255, 255, 255, 0.12); color: #eef3f1; background: var(--grad-check); text-align: left; margin-bottom: 10px; position: relative; overflow: hidden; transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1); }
.mini-ticket:active { transform: scale(0.985); }
.mini-ticket.invoice { background: var(--grad-invoice); }
.mini-ticket.closed { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.mini-ticket .mt-ic { width: 42px; height: 42px; border-radius: 14px; background: rgba(255, 255, 255, 0.14); display: grid; place-items: center; flex: none; }
.mini-ticket.closed .mt-ic { background: var(--surface-2); color: var(--muted); }
.mini-ticket .mt-ic svg { width: 21px; height: 21px; }
.mini-ticket .main { flex: 1; min-width: 0; }
.mini-ticket .t { font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; }
.mini-ticket .s { font-size: 12.5px; opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-ticket .chev { width: 18px; height: 18px; opacity: 0.8; }

/* ---------- history ---------- */
.day { font-size: 13px; font-weight: 700; color: var(--muted); margin: 18px 6px 8px; text-transform: capitalize; }
.day:first-child { margin-top: 0; }
.tx-ic { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; flex: none; position: relative; }
.tx-ic svg { width: 20px; height: 20px; }
.tx-ic.in { background: var(--good-soft); color: var(--good); }
.tx-ic.out { background: var(--surface-2); color: var(--text); }
.tx-ic.check { background: rgba(94, 165, 151, 0.18); color: #8fdcc9; }
.tx-ic.swap { background: var(--accent-soft); color: var(--accent); }
.tx-ic.inv { background: rgba(126, 163, 182, 0.18); color: #a9c6d4; }
:root[data-theme="light"] .tx-ic.check { color: #1d6d5f; }
:root[data-theme="light"] .tx-ic.inv { color: #2f5a6f; }

/* ---------- profile ---------- */
.profile { display: flex; align-items: center; gap: 14px; margin: 4px 2px 18px; }
.avatar { width: 62px; height: 62px; border-radius: 22px; background: var(--grad); color: var(--on-grad); display: grid; place-items: center; font-weight: 800; font-size: 24px; flex: none; box-shadow: var(--grad-glow); }
.profile .name { font-size: 21px; font-weight: 800; }
.profile .handle { color: var(--muted); }

/* ---------- tab bar ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; background: var(--tabbar-bg); backdrop-filter: blur(24px) saturate(1.5); -webkit-backdrop-filter: blur(24px) saturate(1.5); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s; }
.tabbar.off { transform: translateY(calc(100% + 8px)); opacity: 0; pointer-events: none; }
.tabbar .inner { position: relative; display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; max-width: 560px; }
.tab { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; background: none; border: 0; color: var(--faint); font-size: 11px; font-weight: 650; transition: color 0.25s; }
.tab svg { width: 24px; height: 24px; transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1); }
.tab:active svg { transform: scale(0.88); }
.tab.active { color: var(--text); }
.tab.active svg { animation: tab-pop 0.42s cubic-bezier(0.3, 1.5, 0.5, 1); }
@keyframes tab-pop { 40% { transform: scale(1.14) translateY(-1px); } }
/* the light over the active tab slides from tab to tab with a little overshoot */
.tab-ind { position: absolute; left: 0; top: -6px; width: 25%; height: 3px; display: flex; justify-content: center; pointer-events: none; transition: transform 0.48s cubic-bezier(0.3, 1.35, 0.5, 1); }
.tab-ind::after { content: ""; width: 18px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
@media (prefers-reduced-motion: reduce) { .tabbar, .tab-ind { transition: none; } .tab.active svg { animation: none; } }

/* ---------- sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(2, 5, 7, 0.55); opacity: 0; transition: opacity 0.25s; touch-action: none; }
.sheet-backdrop.open { opacity: 1; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-width: 560px; margin: 0 auto; max-height: 86vh; overflow-y: auto; overscroll-behavior: contain;background: var(--sheet-bg); backdrop-filter: blur(30px) saturate(1.4); -webkit-backdrop-filter: blur(30px) saturate(1.4); border: 1px solid var(--line-strong); border-bottom: 0; border-radius: 26px 26px 0 0; padding: 6px 16px calc(18px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1); }
.sheet.open { transform: none; }
.sheet .grip { width: 40px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 6px auto 12px; }
.sheet h3 { margin: 0 2px 14px; font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.sheet .search { margin-bottom: 10px; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top)); z-index: 60; width: max-content; transform: translate(-50%, -140%); transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); display: flex; align-items: center; gap: 8px; max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 16px; background: var(--grad); color: var(--on-grad); font-weight: 650; font-size: 14px; box-shadow: var(--shadow); }
.toast.show { transform: translate(-50%, 0); }
.toast.error { background: var(--bad); color: #fff; }
.toast svg { width: 18px; height: 18px; flex: none; }

/* ---------- result ---------- */
.result { text-align: center; padding: 40px 8px 10px; }
.result .r-ic { width: 92px; height: 92px; margin: 0 auto 18px; border-radius: 50%; display: grid; place-items: center; background: var(--good-soft); color: var(--good); border: 1px solid var(--line); animation: pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1); }
.result .r-ic.wait { background: var(--accent-soft); color: var(--accent); }
.result .r-ic.fail { background: var(--bad-soft); color: var(--bad); }
.result .r-ic svg { width: 44px; height: 44px; }
.result .r-ic svg path { stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw 0.5s 0.2s forwards; }
.result h2 { margin: 0 0 6px; font-size: 24px; font-weight: 800; }
.result .big { font-size: 30px; font-weight: 850; letter-spacing: -0.02em; margin: 6px 0; font-variant-numeric: tabular-nums; }
.result p { color: var(--muted); margin: 4px 0 24px; }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; }

/* ---------- skeleton & boot ---------- */
.sk { border-radius: 12px; background: linear-gradient(90deg, var(--surface) 0%, var(--surface-3) 50%, var(--surface) 100%); background-size: 200% 100%; animation: sk 1.3s infinite; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.boot { min-height: 70vh; display: grid; place-items: center; }
.boot .logo { width: 76px; height: 76px; border-radius: 24px; overflow: hidden; animation: breathe 1.6s ease-in-out infinite; box-shadow: 0 0 0 1px var(--line-strong), 0 16px 44px rgba(0, 0, 0, 0.5), 0 0 60px rgba(185, 221, 211, 0.12); }
@keyframes breathe { 50% { transform: scale(0.94); opacity: 0.82; } }

.swap-wrap { position: relative; }
.swap-flip { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2; width: 44px; height: 44px; border-radius: 15px; border: 1px solid var(--line-strong); background: var(--grad); color: var(--on-grad); display: grid; place-items: center; box-shadow: var(--grad-glow); }
.swap-flip svg { width: 18px; height: 18px; }
/* a swap chip of a coin held per network: the coin over its network's tag (USDT / TRC-20) */
.chip .chip-c { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.08; }
.chip .chip-c small { font-size: 10.5px; font-weight: 700; color: var(--muted); }
.quote { text-align: center; color: var(--muted); font-size: 13.5px; margin: 4px 0 14px; min-height: 20px; }
/* under the rate: the most a swap can give of the target now, or why it gives nothing */
.swap-cap { text-align: center; color: var(--muted); font-size: 13.5px; line-height: 1.4; margin: -8px 4px 14px; }
.swap-cap:empty { display: none; }
.swap-cap.bad { color: var(--bad); }

.user-found { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 8px; border-radius: 12px; background: var(--good-soft); color: var(--good); font-weight: 650; font-size: 14px; }
.user-found .avatar { width: 30px; height: 30px; border-radius: 10px; font-size: 13px; }
.kv { display: grid; gap: 2px; margin-bottom: 12px; }
.kv .k { font-size: 12.5px; color: var(--muted); font-weight: 650; }
.kv .v { font-weight: 600; word-break: break-all; }
.center { text-align: center; }
.mt { margin-top: 14px; }
.mt-lg { margin-top: 22px; }
