/* ============================================================
   Финансы — Telegram Mini App prototype
   Native Telegram base + orange accent (#E8590C)
   ============================================================ */

:root {
  /* accent (own character) */
  --accent: #E8590C;
  --accent-press: #d24e08;
  --accent-soft: rgba(232, 89, 12, 0.12);
  --accent-text: #ffffff;

  /* currency tints */
  --rub: #2f6fed;
  --byn: #1f8a5b;
  --usd: #0f9d8f;

  --green: #1f8a5b;
  --red: #e0383e;

  /* radii & motion */
  --r-card: 14px;
  --r-field: 12px;
  --r-pill: 999px;
  --ease: cubic-bezier(.22,.61,.36,1);
  --shadow-screen: 0 30px 80px -30px rgba(15, 23, 35, 0.45);

  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
}

/* ---------- Telegram theme tokens: LIGHT ---------- */
.theme-light {
  --bg: #ffffff;            /* root background */
  --secondary-bg: #efeff4;  /* grouped list backdrop */
  --section-bg: #ffffff;    /* cards */
  --section-sep: #e9e9ee;
  --text: #0f1115;
  --hint: #8a8f99;
  --subtitle: #6d7079;
  --field-bg: #f1f2f6;
  --field-border: #e3e4ea;
  --header-bg: #f7f7fa;
  --backdrop: #d9dbe2;
  --skeleton: #e8e9ee;
  --skeleton-hi: #f3f4f8;
  --page-bg: #c9ccd6;
}

/* ---------- Telegram theme tokens: DARK ---------- */
.theme-dark {
  --bg: #17212b;
  --secondary-bg: #0e1621;
  --section-bg: #232e3c;
  --section-sep: #2b3543;
  --text: #ffffff;
  --hint: #6d7f8f;
  --subtitle: #aab8c2;
  --field-bg: #18222d;
  --field-border: #2b3644;
  --header-bg: #1d2733;
  --backdrop: #0b121a;
  --skeleton: #243140;
  --skeleton-hi: #2c3a4b;
  --page-bg: #05090d;
  --accent-soft: rgba(232, 89, 12, 0.20);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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

body {
  background: var(--page-bg, #c9ccd6);
  transition: background .35s var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
  overscroll-behavior: none;
}

#root { display: contents; }

/* ============================================================
   Screen shell (the "phone screen", no bezel)
   ============================================================ */
.tg-app {
  position: relative;
  width: 100%;
  max-width: 412px;
  height: 100dvh;
  max-height: 920px;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 0;
  box-shadow: var(--shadow-screen);
  transition: background .35s var(--ease), color .35s var(--ease);
}
@media (min-width: 460px) and (min-height: 720px) {
  .tg-app { border-radius: 28px; height: min(900px, 94dvh); }
}

/* ---------- Telegram header bar ---------- */
.tg-header {
  flex: 0 0 auto;
  height: 52px;
  background: var(--header-bg);
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  align-items: center;
  border-bottom: 1px solid var(--section-sep);
  position: relative;
  z-index: 30;
  transition: background .35s var(--ease);
}
.tg-header__title {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tg-header__sub {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--green);
  margin-top: 1px;
}
.tg-back {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 100%;
  padding-left: 12px;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity .2s var(--ease), transform .2s var(--ease);
  pointer-events: none;
}
.tg-back.is-on { opacity: 1; transform: none; pointer-events: auto; }
.tg-back svg { width: 12px; height: 20px; }
.tg-header__right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding-right: 14px;
  color: var(--hint);
}
.tg-header__dots, .tg-header__close {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}

/* ---------- Scroll body ---------- */
.tg-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  background: var(--secondary-bg);
  transition: background .35s var(--ease);
}
.tg-body::-webkit-scrollbar { width: 0; height: 0; }
.tg-body.is-plain { background: var(--bg); }

.screen { min-height: 100%; display: flex; flex-direction: column; }
.screen-pad { padding: 14px 14px 28px; }
.screen-pad--main { padding-bottom: 96px; } /* room for MainButton */
.screen-pad--tab { padding-bottom: 78px; }  /* room for tab bar */

/* page entrance */
@media (prefers-reduced-motion: no-preference) {
  .screen-anim { animation: screenIn .26s var(--ease) both; }
  @keyframes screenIn {
    from { opacity: 0; transform: translateX(14px); }
    to { opacity: 1; transform: none; }
  }
  .screen-anim-back { animation: screenInBack .26s var(--ease) both; }
  @keyframes screenInBack {
    from { opacity: 0; transform: translateX(-14px); }
    to { opacity: 1; transform: none; }
  }
}

/* ============================================================
   Typography helpers
   ============================================================ */
.h-title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin: 4px 2px 14px; }
.h-eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--hint); margin: 18px 4px 8px; }
.muted { color: var(--hint); }
.subtle { color: var(--subtitle); }
.tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* ============================================================
   Cards / grouped sections
   ============================================================ */
.card {
  background: var(--section-bg);
  border-radius: var(--r-card);
  transition: background .35s var(--ease);
}
.group {
  background: var(--section-bg);
  border-radius: var(--r-card);
  overflow: hidden;
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  position: relative;
  min-height: 50px;
}
.row + .row::before {
  content: "";
  position: absolute;
  top: 0; left: 14px; right: 0;
  border-top: 1px solid var(--section-sep);
}
.row__main { flex: 1 1 auto; min-width: 0; }
.row__label { font-size: 16px; }
.row__value { color: var(--hint); font-size: 16px; }
.row.tappable { cursor: pointer; }
.row.tappable:active { background: var(--field-bg); }
.chev { color: var(--hint); flex: 0 0 auto; }

/* ============================================================
   Converter
   ============================================================ */
.conv-card { padding: 6px 4px; position: relative; }
.conv-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px;
}
.conv-line + .conv-line { border-top: 1px solid var(--section-sep); }
.conv-line__field { flex: 1 1 auto; min-width: 0; }
.conv-line__cap { font-size: 12px; color: var(--hint); font-weight: 600; margin-bottom: 4px; letter-spacing: .02em; }
.conv-input {
  width: 100%;
  border: none;
  background: none;
  color: var(--text);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  padding: 0;
  outline: none;
  font-variant-numeric: tabular-nums;
}
.conv-input::placeholder { color: var(--hint); opacity: .5; }
.conv-result {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}
.conv-result.is-empty { color: var(--hint); opacity: .5; }

/* currency pill */
.cur-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 12px 0 8px;
  border-radius: var(--r-pill);
  background: var(--field-bg);
  border: 1px solid var(--field-border);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.cur-pill:active { background: var(--accent-soft); border-color: var(--accent); }
.cur-flag {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #fff;
  letter-spacing: -0.04em;
}
.cur-pill .chev { color: var(--hint); }

/* swap */
.conv-swap-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
}
.conv-swap {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 3px solid var(--section-bg);
  background: var(--accent);
  color: var(--accent-text);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px -2px var(--accent-soft);
  transition: transform .45s var(--ease), background .15s;
}
.conv-swap:active { background: var(--accent-press); }
.conv-swap.spin { transform: rotate(180deg); }

.rate-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 2px;
  font-size: 14px;
}
.rate-line__pair { font-weight: 600; font-variant-numeric: tabular-nums; }
.rate-line__date { color: var(--hint); font-size: 13px; }
.rate-stale { color: var(--red); }

/* quick chips */
.chips { display: flex; gap: 8px; margin: 14px 2px 0; flex-wrap: wrap; }
.chip {
  flex: 1 1 0;
  min-width: 64px;
  height: 38px;
  border-radius: var(--r-pill);
  border: 1px solid var(--field-border);
  background: var(--section-bg);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .1s, background .15s;
  font-variant-numeric: tabular-nums;
}
.chip:active { transform: scale(.94); background: var(--accent-soft); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 50px;
  padding: 0 18px;
  border-radius: var(--r-field);
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: transform .1s, background .15s, opacity .15s;
}
.btn:active { transform: scale(.985); }
.btn--accent { background: var(--accent); color: var(--accent-text); }
.btn--accent:active { background: var(--accent-press); }
.btn--soft { background: var(--accent-soft); color: var(--accent); }
.btn--ghost { background: var(--field-bg); color: var(--text); }
.btn--danger { background: var(--field-bg); color: var(--red); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-row { display: flex; gap: 10px; }

.link-btn {
  background: none; border: none; cursor: pointer;
  color: var(--accent); font-size: 16px; font-weight: 600;
  padding: 0;
}

/* ============================================================
   MainButton (Telegram bottom action)
   ============================================================ */
.mainbtn {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--section-sep);
  z-index: 40;
  transform: translateY(120%);
  transition: transform .3s var(--ease);
}
.mainbtn.is-on { transform: none; }
.mainbtn__inner {
  height: 50px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-text);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .2s;
}
.mainbtn__inner:active { background: var(--accent-press); }
.mainbtn__inner.is-disabled { opacity: .5; pointer-events: none; }
.mainbtn__inner.is-loading { pointer-events: none; }
.mainbtn .spinner { width: 20px; height: 20px; }

/* ============================================================
   Tab bar
   ============================================================ */
.tabbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: calc(64px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--header-bg);
  border-top: 1px solid var(--section-sep);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 35;
  transition: background .35s var(--ease), transform .3s var(--ease);
}
.tabbar.is-hidden { transform: translateY(120%); }
.tab {
  border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  color: var(--hint);
  font-size: 10.5px; font-weight: 600;
  transition: color .15s;
}
.tab svg { width: 24px; height: 24px; }
.tab.is-active { color: var(--accent); }

/* ============================================================
   Bottom sheet
   ============================================================ */
.sheet-overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 18, 0);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  transition: background .28s var(--ease);
}
.sheet-overlay.is-on { background: rgba(8, 12, 18, 0.5); }
.sheet {
  width: 100%;
  background: var(--bg);
  border-radius: 18px 18px 0 0;
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform .3s var(--ease);
  max-height: 92%;
  overflow-y: auto;
  scrollbar-width: none;
}
.sheet::-webkit-scrollbar { display: none; }
.sheet-overlay.is-on .sheet { transform: none; }
.sheet__grab { width: 38px; height: 5px; border-radius: 3px; background: var(--field-border); margin: 6px auto 10px; }
.sheet__title { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; margin: 2px 2px 14px; text-align: center; }

/* currency picker rows */
.pick-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 12px;
  border-radius: 12px;
  cursor: pointer;
}
.pick-row:active { background: var(--field-bg); }
.pick-row.is-sel { background: var(--accent-soft); }
.pick-row__name { flex: 1 1 auto; }
.pick-row__code { font-size: 15px; font-weight: 700; }
.pick-row__full { font-size: 13px; color: var(--hint); }
.pick-check { color: var(--accent); }

/* ============================================================
   Fields / forms
   ============================================================ */
.field { margin-bottom: 14px; }
.field__label { font-size: 13px; font-weight: 600; color: var(--hint); margin: 0 4px 7px; letter-spacing: .01em; }
.input {
  width: 100%;
  height: 50px;
  border-radius: var(--r-field);
  border: 1px solid var(--field-border);
  background: var(--field-bg);
  color: var(--text);
  font-size: 17px;
  padding: 0 14px;
  outline: none;
  transition: border-color .15s, background .15s;
}
.input:focus { border-color: var(--accent); background: var(--bg); }
.input::placeholder { color: var(--hint); opacity: .7; }
.input.amount { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.input-err { border-color: var(--red) !important; }
.field__hint { font-size: 12px; color: var(--hint); margin: 6px 4px 0; }
.field__hint.err { color: var(--red); }

.amount-field { position: relative; }
.amount-field .sym {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--hint); font-size: 17px; font-weight: 600; pointer-events: none;
}

/* segmented control */
.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
  padding: 3px;
  background: var(--field-bg);
  border-radius: 12px;
}
.seg__opt {
  border: none; background: none; cursor: pointer;
  height: 40px; border-radius: 9px;
  color: var(--subtitle); font-size: 15px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .18s var(--ease), color .18s, box-shadow .18s;
}
.seg__opt.is-on { background: var(--section-bg); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.theme-dark .seg__opt.is-on { background: var(--section-bg); }

/* emoji picker */
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.emoji-cell {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; border-radius: 10px; cursor: pointer;
  background: none; border: none;
  transition: background .12s, transform .1s;
}
.emoji-cell:active { transform: scale(.9); }
.emoji-cell.is-sel { background: var(--accent-soft); }

/* color dots */
.dot-row { display: flex; gap: 12px; flex-wrap: wrap; padding: 2px; }
.dot {
  width: 34px; height: 34px; border-radius: 50%;
  cursor: pointer; border: 3px solid transparent;
  position: relative;
  transition: transform .1s;
}
.dot:active { transform: scale(.9); }
.dot.is-sel { border-color: var(--bg); box-shadow: 0 0 0 2px currentColor; }

/* ============================================================
   Goal cards
   ============================================================ */
.goal-card {
  background: var(--section-bg);
  border-radius: var(--r-card);
  padding: 15px;
  margin-bottom: 12px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform .12s var(--ease), background .35s var(--ease);
}
.goal-card:active { transform: scale(.985); }
.goal-card.is-done { opacity: .92; }
.goal-card__top { display: flex; align-items: center; gap: 12px; margin-bottom: 13px; }
.goal-emoji {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex: 0 0 auto;
}
.goal-card__name { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.goal-card__meta { font-size: 13px; color: var(--hint); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.goal-pct { margin-left: auto; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.goal-card__amt { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 9px; }
.goal-card__cur { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.goal-card__tgt { font-size: 14px; color: var(--hint); font-variant-numeric: tabular-nums; }
.badge-done {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 700; color: var(--green);
}

/* progress bar */
.pbar { height: 9px; border-radius: 6px; background: var(--field-bg); overflow: hidden; }
.pbar__fill {
  height: 100%; border-radius: 6px;
  background: var(--accent);
  transition: width .6s var(--ease);
  position: relative;
}
.pbar--lg { height: 12px; border-radius: 8px; }

/* ============================================================
   Goal detail
   ============================================================ */
.detail-hero {
  text-align: center;
  padding: 22px 16px 20px;
  background: var(--section-bg);
  border-radius: var(--r-card);
}
.detail-emoji {
  width: 64px; height: 64px; border-radius: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 34px; margin-bottom: 12px;
}
.detail-pct { font-size: 44px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.detail-cur { font-size: 17px; margin-top: 10px; font-variant-numeric: tabular-nums; }
.detail-cur b { font-weight: 700; }
.detail-rest { font-size: 14px; color: var(--hint); margin-top: 4px; }
.pace-hint {
  display: flex; align-items: center; gap: 8px;
  margin-top: 14px; padding: 11px 13px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 11px; font-size: 13.5px; font-weight: 600; text-align: left;
}

/* transaction list */
.tx { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.tx + .tx::before { content:""; position:absolute; }
.tx-list .tx { position: relative; }
.tx-list .tx + .tx::before { content:""; position:absolute; top:0; left:50px; right:0; border-top:1px solid var(--section-sep); }
.tx-ic {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.tx-ic.dep { background: rgba(31,138,91,.14); color: var(--green); }
.tx-ic.wdr { background: rgba(224,56,62,.14); color: var(--red); }
.tx-main { flex: 1 1 auto; min-width: 0; }
.tx-title { font-size: 15px; font-weight: 600; }
.tx-sub { font-size: 12.5px; color: var(--hint); margin-top: 1px; }
.tx-amt { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-amt.dep { color: var(--green); }
.tx-amt.wdr { color: var(--red); }
.tx-conv { font-size: 12px; color: var(--hint); text-align: right; margin-top: 1px; font-variant-numeric: tabular-nums; }

/* preview chip in deposit */
.conv-preview {
  margin-top: 12px; padding: 13px 14px;
  background: var(--accent-soft); border-radius: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.conv-preview__lbl { font-size: 13px; color: var(--accent); font-weight: 600; }
.conv-preview__val { font-size: 17px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.conv-preview__rate { font-size: 12px; color: var(--accent); opacity: .8; }

/* ============================================================
   Empty state
   ============================================================ */
.empty {
  flex: 1 1 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 40px 30px;
  gap: 6px;
}
.empty__art {
  width: 96px; height: 96px; border-radius: 28px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 44px; margin-bottom: 14px;
}
.empty__title { font-size: 19px; font-weight: 700; }
.empty__text { font-size: 14px; color: var(--hint); max-width: 240px; line-height: 1.45; margin-bottom: 16px; }

/* ============================================================
   Skeletons
   ============================================================ */
.sk {
  background: var(--skeleton);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}
.sk::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, var(--skeleton-hi), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* ============================================================
   Toast
   ============================================================ */
.toast-wrap {
  position: absolute; left: 0; right: 0; bottom: 84px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 70; pointer-events: none;
}
.toast {
  background: rgba(20, 28, 38, 0.94);
  color: #fff;
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 14px; font-weight: 500;
  max-width: 86%;
  box-shadow: 0 8px 24px -6px rgba(0,0,0,.4);
  display: flex; align-items: center; gap: 8px;
  animation: toastIn .26s var(--ease) both;
}
.toast.err { background: rgba(168, 36, 40, 0.96); }
.toast.ok { background: rgba(22, 110, 70, 0.96); }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ============================================================
   Confetti / celebration
   ============================================================ */
.celebrate {
  position: absolute; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8,12,18,0);
  transition: background .3s var(--ease);
}
.celebrate.is-on { background: rgba(8,12,18,.55); }
.celebrate canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.celebrate__card {
  position: relative; z-index: 2;
  background: var(--bg); color: var(--text);
  border-radius: 20px; padding: 28px 24px 22px;
  width: 84%; max-width: 320px; text-align: center;
  transform: scale(.8); opacity: 0;
  transition: transform .35s var(--ease), opacity .35s var(--ease);
}
.celebrate.is-on .celebrate__card { transform: none; opacity: 1; }
.celebrate__emoji { font-size: 56px; }
.celebrate__title { font-size: 22px; font-weight: 800; margin: 8px 0 6px; letter-spacing: -0.01em; }
.celebrate__text { font-size: 14px; color: var(--hint); margin-bottom: 18px; line-height: 1.4; }

/* spinner */
.spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* confirm dialog */
.confirm-card {
  background: var(--bg); border-radius: 16px;
  width: 84%; max-width: 300px; overflow: hidden;
  transform: scale(.85); opacity: 0;
  transition: transform .25s var(--ease), opacity .25s var(--ease);
}
.celebrate.is-on .confirm-card, .sheet-overlay.is-on .confirm-card { transform: none; opacity: 1; }
.confirm-card__body { padding: 20px 18px 16px; text-align: center; }
.confirm-card__title { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.confirm-card__text { font-size: 13.5px; color: var(--hint); line-height: 1.4; }
.confirm-card__acts { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--section-sep); }
.confirm-btn {
  border: none; background: none; cursor: pointer;
  height: 48px; font-size: 16px; color: var(--accent);
}
.confirm-btn + .confirm-btn { border-left: 1px solid var(--section-sep); }
.confirm-btn.danger { color: var(--red); font-weight: 700; }
.confirm-btn.cancel { font-weight: 400; }

/* small meta pill */
.meta-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  background: var(--field-bg); font-size: 12px; font-weight: 600; color: var(--subtitle);
}
.meta-pill.warn { background: rgba(224,56,62,.12); color: var(--red); }

.fab {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; border: none;
}

/* ============================================================
   LEDGER MODULE — overview / add / categories
   ============================================================ */

/* period switcher */
.period-bar { display: flex; align-items: center; gap: 10px; margin: 2px 2px 14px; }
.period-nav {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--section-bg); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  border: none; cursor: pointer; flex: 0 0 auto;
}
.period-nav:disabled { opacity: .35; pointer-events: none; }
.period-label { flex: 1 1 auto; text-align: center; font-size: 15px; font-weight: 700; letter-spacing: -0.01em; text-transform: capitalize; }
.period-label small { display: block; font-size: 11px; font-weight: 500; color: var(--hint); text-transform: none; margin-top: 1px; }
.seg--period { margin: 0 2px 14px; }

/* balance card */
.bal-card { padding: 18px 16px 16px; }
.bal-row { display: flex; align-items: flex-end; justify-content: space-between; }
.bal-main { }
.bal-cap { font-size: 12.5px; color: var(--hint); font-weight: 600; margin-bottom: 4px; }
.bal-amt { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.bal-amt.pos { color: var(--green); }
.bal-amt.neg { color: var(--red); }
.cmp {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
}
.cmp.up { background: rgba(224,56,62,.12); color: var(--red); }    /* расходы выросли — плохо */
.cmp.down { background: rgba(31,138,91,.14); color: var(--green); }
.cmp.flat { background: var(--field-bg); color: var(--hint); }
.bal-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.bal-chip { padding: 11px 12px; border-radius: 12px; background: var(--field-bg); }
.bal-chip__cap { font-size: 12px; color: var(--hint); display: flex; align-items: center; gap: 5px; margin-bottom: 3px; }
.bal-chip__val { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bal-chip__val.inc { color: var(--green); }
.bal-chip__val.exp { color: var(--red); }
.dot-mark { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* donut */
.donut-wrap { display: flex; flex-direction: column; align-items: center; padding: 8px 0 4px; }
.donut-svg { transform: rotate(-90deg); }
.donut-center { text-align: center; }
.donut-center .dc-cap { font-size: 11.5px; color: var(--hint); font-weight: 600; }
.donut-center .dc-val { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

/* category top list */
.cat-line { display: flex; align-items: center; gap: 11px; padding: 11px 4px; }
.cat-ic {
  width: 38px; height: 38px; border-radius: 11px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; font-size: 19px;
}
.cat-line__main { flex: 1 1 auto; min-width: 0; }
.cat-line__name { font-size: 15px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.cat-line__amt { font-variant-numeric: tabular-nums; font-weight: 700; }
.cat-line__bar { height: 6px; border-radius: 4px; background: var(--field-bg); margin-top: 6px; overflow: hidden; }
.cat-line__fill { height: 100%; border-radius: 4px; transition: width .5s var(--ease); }
.cat-line__pct { font-size: 12px; color: var(--hint); margin-top: 3px; font-variant-numeric: tabular-nums; }

/* dynamics bars */
.dyn { display: flex; align-items: flex-end; gap: 4px; height: 130px; padding: 6px 2px 0; }
.dyn-col { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 5px; height: 100%; cursor: default; }
.dyn-bar-wrap { width: 100%; flex: 1 1 auto; display: flex; align-items: flex-end; justify-content: center; }
.dyn-bar { width: 72%; max-width: 22px; border-radius: 5px 5px 3px 3px; background: var(--accent); min-height: 3px; transition: height .5s var(--ease); }
.dyn-bar.muted { background: var(--field-border); }
.dyn-lbl { font-size: 9.5px; color: var(--hint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.dyn-val { font-size: 9px; color: var(--hint); font-variant-numeric: tabular-nums; height: 11px; }

/* operations list (grouped) */
.op-day-head { display: flex; justify-content: space-between; align-items: baseline; margin: 16px 6px 7px; }
.op-day-date { font-size: 13px; font-weight: 700; color: var(--subtitle); text-transform: capitalize; }
.op-day-sum { font-size: 12.5px; color: var(--hint); font-variant-numeric: tabular-nums; }
.op { display: flex; align-items: center; gap: 12px; padding: 11px 14px; cursor: pointer; }
.op:active { background: var(--field-bg); }
.op-ic { width: 40px; height: 40px; border-radius: 12px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.op-main { flex: 1 1 auto; min-width: 0; }
.op-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.op-sub { font-size: 12.5px; color: var(--hint); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.op-amt { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.op-amt.exp { color: var(--text); }
.op-amt.inc { color: var(--green); }
.op-amt-sub { font-size: 11.5px; color: var(--hint); text-align: right; font-variant-numeric: tabular-nums; }

/* FAB add */
.fab-add {
  position: absolute; right: 16px; bottom: calc(78px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 18px;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 24px -6px rgba(232,89,12,.6);
  z-index: 38;
  transition: transform .15s var(--ease);
}
.fab-add:active { transform: scale(.9); }

/* ===== ADD operation screen ===== */
.add-screen { display: flex; flex-direction: column; height: 100%; background: var(--bg); }

/* new add screen: natural scroll + sticky footer, native keyboard */
.add-screen2 { display: flex; flex-direction: column; height: 100%; background: var(--bg); }
.add-scroll { flex: 1 1 auto; overflow-y: auto; scrollbar-width: none; }
.add-scroll::-webkit-scrollbar { display: none; }
.add-footer {
  flex: 0 0 auto;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--section-sep);
}

/* big native amount input */
.amt-field {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 4px 12px;
}
.amt-field__sign { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; flex: 0 0 auto; }
.amt-field.exp .amt-field__sign { color: var(--text); }
.amt-field.inc .amt-field__sign { color: var(--green); }
.amt-field__input {
  flex: 1 1 auto; min-width: 0;
  border: none; background: none; outline: none; padding: 0;
  font-size: 40px; font-weight: 800; letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.amt-field.inc .amt-field__input { color: var(--green); }
.amt-field__input::placeholder { color: var(--hint); opacity: .45; }

/* category grid (all visible, page scrolls) */
.cat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px;
  margin-top: 4px;
}
.add-top { padding: 8px 16px 0; }
.add-type-seg { margin-bottom: 12px; }
.seg__opt.exp.is-on { color: var(--red); }
.seg__opt.inc.is-on { color: var(--green); }
.add-amount {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 0 6px; min-height: 64px;
}
.add-amount__num { font-size: 44px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.add-amount__num.exp { color: var(--text); }
.add-amount__num.inc { color: var(--green); }
.add-amount__num.zero { color: var(--hint); opacity: .5; }
.add-cur-pill {
  display: inline-flex; align-items: center; gap: 5px; height: 34px; padding: 0 12px;
  border-radius: 999px; background: var(--field-bg); border: 1px solid var(--field-border);
  font-size: 15px; font-weight: 700; color: var(--text); cursor: pointer;
}
.add-cur-conv { text-align: center; font-size: 12.5px; color: var(--hint); margin-bottom: 6px; font-variant-numeric: tabular-nums; }

.add-cats-label { font-size: 12px; font-weight: 600; color: var(--hint); margin: 6px 16px 8px; letter-spacing: .03em; text-transform: uppercase; }
.add-cats {
  flex: 1 1 auto; overflow-y: auto; padding: 0 12px 10px;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; align-content: start;
  scrollbar-width: none;
}
.add-cats::-webkit-scrollbar { display: none; }
.cat-pick {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 10px 4px; border-radius: 14px; cursor: pointer; border: 2px solid transparent;
  background: var(--section-bg);
  transition: transform .1s, border-color .15s;
}
.cat-pick:active { transform: scale(.94); }
.cat-pick.is-sel { border-color: currentColor; }
.cat-pick__ic { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 21px; }
.cat-pick__name { font-size: 11px; font-weight: 600; color: var(--text); text-align: center; line-height: 1.15; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-pick--add .cat-pick__ic { background: var(--field-bg); color: var(--accent); border: 1.5px dashed var(--field-border); }

/* numeric keypad */
.keypad {
  flex: 0 0 auto;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  background: var(--section-sep);
  border-top: 1px solid var(--section-sep);
}
.keypad__row { display: contents; }
.key {
  background: var(--bg); border: none; cursor: pointer;
  height: 54px; font-size: 23px; font-weight: 600; color: var(--text);
  display: flex; align-items: center; justify-content: center;
  transition: background .08s;
  font-variant-numeric: tabular-nums;
}
.key:active { background: var(--field-bg); }
.key.accent { color: var(--accent); }

/* add meta rows (date/note) */
.add-meta { display: flex; gap: 8px; padding: 8px 16px 0; }
.add-meta-row {
  flex: 1 1 0; display: flex; align-items: center; gap: 7px;
  padding: 9px 12px; border-radius: 11px; background: var(--field-bg);
  font-size: 13px; color: var(--subtitle); cursor: pointer; min-width: 0;
}
.add-meta-row .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.add-note-input { width: 100%; border: none; background: none; color: var(--text); font-size: 13px; outline: none; }

/* category management */
.cat-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; }
.cat-row__ic { width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 19px; flex: 0 0 auto; }
.cat-row__name { flex: 1 1 auto; font-size: 15px; font-weight: 600; }
.cat-row__act { color: var(--hint); cursor: pointer; padding: 4px; }

/* empty small */
.empty-sm { text-align: center; padding: 30px 24px; color: var(--hint); font-size: 14px; line-height: 1.5; }
.empty-sm .empty__art { margin: 0 auto 12px; width: 72px; height: 72px; border-radius: 22px; font-size: 32px; }

/* section header with action */
.sec-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 4px 8px; }
.sec-head__title { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--hint); }
.sec-head__act { font-size: 13px; font-weight: 600; color: var(--accent); cursor: pointer; }

/* per-currency filter chips (All Operations) */
.cur-filter { display: flex; gap: 7px; margin: 0 2px 14px; flex-wrap: wrap; }
.cur-chip {
  height: 34px; padding: 0 13px; border-radius: 999px;
  border: 1px solid var(--field-border); background: var(--section-bg);
  color: var(--subtitle); font-size: 13.5px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  transition: background .15s, color .15s, border-color .15s;
}
.cur-chip.is-on { background: var(--accent); color: #fff; border-color: var(--accent); }
