/* MoneyUP — тёмная «банковская» тема, индиго-акцент, mobile-first */
:root{
  --bg:#0e0e13;
  --bg-grad:radial-gradient(130% 90% at 50% -20%, #1d1640 0%, #0e0e13 52%);
  --surface:#16161d;
  --surface-2:#1f1f29;
  --surface-3:#272733;
  --border:#2a2a36;
  --text:#f3f3f6;
  --text-dim:#9596a6;
  --text-faint:#666778;
  --accent:#7c5cff;
  --accent-2:#9d7bff;
  --accent-grad:linear-gradient(135deg,#7c5cff 0%,#a17bff 100%);
  --income:#2fd47b;
  --expense:#ff5c7c;
  --radius:20px;
  --radius-sm:14px;
  --shadow:0 18px 50px rgba(0,0,0,.45);
  --nav-h:64px;
  --safe-b:env(safe-area-inset-bottom,0px);
  --safe-t:env(safe-area-inset-top,0px);
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;padding:0}
body{
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  background:var(--bg);color:var(--text);
  -webkit-font-smoothing:antialiased;
  overscroll-behavior-y:none;
  touch-action:pan-y;            /* подсказка браузеру: жест = вертикальный скролл (убирает задержку) */
}
/* Дешёвый фиксированный фон-слой (без background-attachment:fixed — он тормозит на мобильных) */
body::before{content:"";position:fixed;inset:0;z-index:-1;background:var(--bg-grad)}
button{font-family:inherit;cursor:pointer;border:0;background:none;color:inherit}
input,select{font-family:inherit}
::-webkit-scrollbar{width:0;height:0}

/* ---- Каркас приложения ---- */
#app{min-height:100dvh}
.screen{
  max-width:480px;margin:0 auto;min-height:100vh;
  padding:calc(var(--safe-t) + 14px) 16px calc(var(--nav-h) + var(--safe-b) + 24px);
  position:relative;
}
/* Анимация входа — только прозрачность (без transform), чтобы не было лишних перерисовок при скролле */
.fade-in{animation:fade .25s ease both}
@keyframes fade{from{opacity:0}to{opacity:1}}

/* ---- Шапка ---- */
.topbar{display:flex;align-items:center;justify-content:space-between;margin-bottom:18px}
.topbar .greet{font-size:13px;color:var(--text-dim)}
.topbar .title{font-size:20px;font-weight:800;letter-spacing:-.4px}
.icon-btn{width:42px;height:42px;border-radius:13px;background:var(--surface-2);
  display:flex;align-items:center;justify-content:center;border:1px solid var(--border)}
.icon-btn:active{transform:scale(.94)}
.icon-btn svg{width:20px;height:20px;stroke:var(--text);fill:none;stroke-width:1.8}

/* ---- Hero баланс ---- */
.hero{
  position:relative;border-radius:26px;padding:24px 22px 22px;margin-bottom:18px;
  background:var(--accent-grad);overflow:hidden;box-shadow:0 16px 40px rgba(124,92,255,.35);
}
.hero::after{content:"";position:absolute;right:-40px;top:-60px;width:200px;height:200px;
  background:radial-gradient(circle,rgba(255,255,255,.25),transparent 70%);}
.hero .label{font-size:13px;color:rgba(255,255,255,.8);font-weight:500}
.hero .amount{font-size:40px;font-weight:800;letter-spacing:-1px;margin:6px 0 2px;line-height:1.05}
.hero .cur{font-size:24px;font-weight:700;opacity:.85}
.hero .row{display:flex;gap:10px;margin-top:18px}
.hero .pill{flex:1;background:rgba(255,255,255,.16);border-radius:14px;padding:10px 12px}
.hero .pill .t{font-size:12px;color:rgba(255,255,255,.85);display:flex;align-items:center;gap:5px}
.hero .pill .v{font-size:17px;font-weight:700;margin-top:3px}
.dot{width:8px;height:8px;border-radius:50%;display:inline-block}
.dot.inc{background:#baffd9}.dot.exp{background:#ffd0da}

/* ---- Секции ---- */
.section-head{display:flex;align-items:center;justify-content:space-between;margin:22px 4px 12px}
.section-head h2{font-size:16px;font-weight:700;margin:0}
.section-head a,.section-head button{font-size:13px;color:var(--accent-2);font-weight:600}

/* ---- Карточки счетов (горизонтальный скролл) ---- */
.acc-scroll{display:flex;gap:12px;overflow-x:auto;padding:2px 0 4px;scroll-snap-type:x mandatory}
.acc-card{min-width:150px;scroll-snap-align:start;background:var(--surface);border:1px solid var(--border);
  border-radius:var(--radius);padding:16px}
.acc-card .ico{font-size:22px}
.acc-card .nm{font-size:13px;color:var(--text-dim);margin-top:10px}
.acc-card .bal{font-size:18px;font-weight:700;margin-top:2px}

/* ---- Список операций ---- */
.list{display:flex;flex-direction:column;gap:2px}
.tx{display:flex;align-items:center;gap:13px;padding:12px 12px;border-radius:16px;transition:background .15s;
  content-visibility:auto;contain-intrinsic-size:0 70px}  /* ленивый рендер строк вне экрана — плавный скролл длинных списков */
.tx:active{background:var(--surface-2)}
.tx .av{width:46px;height:46px;border-radius:14px;display:flex;align-items:center;justify-content:center;
  font-size:22px;flex:none;background:var(--surface-2)}
.tx .mid{flex:1;min-width:0}
.tx .nm{font-size:15px;font-weight:600;line-height:1.3;overflow-wrap:anywhere}
.tx .sub{font-size:12.5px;color:var(--text-dim);margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tx .amt{font-size:15.5px;font-weight:700;flex:none}
.tx .amt.inc{color:var(--income)}
.tx .amt.exp{color:var(--text)}
.day-label{font-size:12px;color:var(--text-faint);font-weight:600;margin:16px 6px 6px;text-transform:capitalize}

/* ---- Пусто ---- */
.empty{text-align:center;padding:50px 20px;color:var(--text-dim)}
.empty .em{font-size:46px;margin-bottom:10px}
.empty p{margin:6px 0;font-size:14px}

/* ---- Нижняя навигация + FAB ---- */
.nav{position:fixed;left:0;right:0;bottom:0;z-index:40;height:calc(var(--nav-h) + var(--safe-b));
  padding-bottom:var(--safe-b);
  background:#13131a;border-top:1px solid var(--border)}
.nav-inner{max-width:480px;margin:0 auto;height:var(--nav-h);display:grid;grid-template-columns:1fr 1fr 84px 1fr 1fr;align-items:center}
.nav-btn{display:flex;flex-direction:column;align-items:center;gap:3px;color:var(--text-faint);font-size:10.5px;font-weight:600}
.nav-btn svg{width:23px;height:23px;stroke:currentColor;fill:none;stroke-width:1.9}
.nav-btn.active{color:var(--accent-2)}
.fab-wrap{display:flex;justify-content:center}
.fab{width:60px;height:60px;border-radius:20px;background:var(--accent-grad);
  display:flex;align-items:center;justify-content:center;margin-top:-26px;
  box-shadow:0 10px 26px rgba(124,92,255,.5)}
.fab:active{transform:scale(.93)}
.fab svg{width:28px;height:28px;stroke:#fff;stroke-width:2.4}

/* ---- Bottom sheet ---- */
.sheet-back{position:fixed;inset:0;z-index:60;background:rgba(0,0,0,.55);opacity:0;transition:opacity .25s;
  display:flex;align-items:flex-end;justify-content:center}
.sheet-back.open{opacity:1}
.sheet{width:100%;max-width:480px;background:var(--surface);border-radius:26px 26px 0 0;
  padding:10px 18px calc(20px + var(--safe-b));max-height:94dvh;overflow-y:auto;
  transform:translateY(100%);transition:transform .3s cubic-bezier(.32,.72,0,1)}
.sheet-back.open .sheet{transform:none}
.grab{width:44px;height:5px;border-radius:3px;background:var(--surface-3);margin:8px auto 14px;position:relative;cursor:grab;touch-action:none}
.grab:active{cursor:grabbing}
/* увеличенная зона захвата пальцем */
.grab::after{content:"";position:absolute;left:-70px;right:-70px;top:-16px;bottom:-16px}
.sheet h3{margin:0 0 16px;font-size:18px;font-weight:700;text-align:center}

/* ---- Сегмент-переключатель ---- */
.seg{display:flex;background:var(--surface-2);border-radius:14px;padding:4px;margin-bottom:18px}
.seg button{flex:1;padding:11px;border-radius:11px;font-size:14px;font-weight:700;color:var(--text-dim);transition:.18s}
.seg button.on.exp{background:var(--expense);color:#fff}
.seg button.on.inc{background:var(--income);color:#06281a}

/* ---- Сумма ---- */
.amount-display{text-align:center;font-size:46px;font-weight:800;letter-spacing:-1px;margin:6px 0 4px;min-height:56px}
.amount-display .cur{font-size:26px;color:var(--text-dim);margin-left:6px}
.amount-display.zero{color:var(--text-faint)}

/* ---- Поля ---- */
.field{margin-bottom:14px}
.field label{display:block;font-size:12.5px;color:var(--text-dim);margin:0 0 7px 2px}
.input{width:100%;padding:14px;border-radius:13px;background:var(--surface-2);border:1px solid var(--border);
  color:var(--text);font-size:15px}
.input:focus{outline:none;border-color:var(--accent)}

/* ---- Категории/счета выбор ---- */
.chip-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:10px}
.chip{display:flex;flex-direction:column;align-items:center;gap:6px;padding:12px 4px;border-radius:15px;
  background:var(--surface-2);border:1.5px solid transparent;transition:.15s}
.chip .e{width:42px;height:42px;border-radius:13px;display:flex;align-items:center;justify-content:center;font-size:22px}
.chip .l{font-size:11px;color:var(--text-dim);text-align:center;line-height:1.15;
  max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chip.sel{border-color:var(--accent);background:var(--surface-3)}
.chip.sel .l{color:var(--text)}

.pick-row{display:flex;gap:10px;overflow-x:auto;padding-bottom:4px}
.pick{flex:none;display:flex;align-items:center;gap:8px;padding:10px 14px;border-radius:13px;
  background:var(--surface-2);border:1.5px solid transparent;font-size:14px;font-weight:600;color:var(--text-dim)}
.pick.sel{border-color:var(--accent);color:var(--text);background:var(--surface-3)}

/* ---- Кнопки ---- */
.btn{width:100%;padding:16px;border-radius:15px;font-size:16px;font-weight:700;
  background:var(--accent-grad);color:#fff;box-shadow:0 8px 22px rgba(124,92,255,.4)}
.btn:active{transform:scale(.985)}
.btn:disabled{opacity:.45;box-shadow:none}
.btn-ghost{width:100%;padding:14px;border-radius:14px;font-weight:600;background:var(--surface-2);color:var(--text)}
.btn-danger{color:var(--expense);background:rgba(255,92,124,.1)}

/* ---- Числовая клавиатура ---- */
.keypad{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:10px 0 16px}
.key{padding:16px;border-radius:15px;background:var(--surface-2);font-size:24px;font-weight:600;text-align:center}
.key:active{background:var(--surface-3)}
.key.wide{font-size:20px}

/* ---- PIN экран ---- */
.lock{max-width:480px;margin:0 auto;min-height:100dvh;background:var(--bg-grad);
  display:flex;flex-direction:column;align-items:center;justify-content:center;padding:30px;text-align:center}
.lock .logo{font-size:30px;font-weight:800;letter-spacing:-.6px;margin-bottom:6px}
.lock .logo span{color:var(--accent-2)}
.lock .hint{color:var(--text-dim);font-size:14px;margin-bottom:30px}
.pin-dots{display:flex;gap:14px;margin-bottom:14px;min-height:18px}
.pin-dots .pd{width:14px;height:14px;border-radius:50%;background:var(--surface-3);transition:.15s}
.pin-dots .pd.on{background:var(--accent-2);transform:scale(1.1)}
.lock.err .pin-dots{animation:shake .4s}
@keyframes shake{0%,100%{transform:translateX(0)}20%,60%{transform:translateX(-8px)}40%,80%{transform:translateX(8px)}}
.lock .keypad{width:100%;max-width:300px;margin-top:24px}

/* ---- Аналитика ---- */
.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:18px;margin-bottom:14px}
.chart-wrap{position:relative;height:230px}
.donut-center{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;pointer-events:none}
.donut-center .t{font-size:12px;color:var(--text-dim)}
.donut-center .v{font-size:22px;font-weight:800;margin-top:2px}
.legend{margin-top:6px;display:flex;flex-direction:column;gap:2px}
.legend .li{display:flex;align-items:center;gap:10px;padding:9px 4px}
.legend .li .e{font-size:18px;width:24px;text-align:center}
.legend .li .nm{flex:1;font-size:14px}
.legend .li .bar{height:6px;border-radius:3px;background:var(--surface-3);flex:none;width:70px;overflow:hidden;margin-right:8px}
.legend .li .bar i{display:block;height:100%;border-radius:3px}
.legend .li .v{font-size:14px;font-weight:700}
.legend .li .pc{font-size:11px;color:var(--text-faint);width:38px;text-align:right}

/* ---- Фильтры месяца ---- */
.month-nav{display:flex;align-items:center;justify-content:center;gap:16px;margin-bottom:14px}
.month-nav button{width:36px;height:36px;border-radius:11px;background:var(--surface-2);display:flex;align-items:center;justify-content:center;border:1px solid var(--border)}
.month-nav button svg{width:18px;height:18px;stroke:var(--text);fill:none;stroke-width:2}
.month-nav .m{font-size:15px;font-weight:700;min-width:130px;text-align:center;text-transform:capitalize}

.filters{display:flex;gap:8px;overflow-x:auto;padding-bottom:8px;margin-bottom:6px}
.filters .f{flex:none;padding:8px 14px;border-radius:11px;background:var(--surface-2);font-size:13px;font-weight:600;color:var(--text-dim);border:1px solid var(--border)}
.filters .f.on{background:var(--accent);color:#fff;border-color:var(--accent)}

/* ---- Настройки ---- */
.set-group{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);overflow:hidden;margin-bottom:14px}
.set-row{display:flex;align-items:center;gap:12px;padding:15px 16px;border-bottom:1px solid var(--border)}
.set-row:last-child{border-bottom:0}
.set-row .e{font-size:20px;width:26px;text-align:center}
.set-row .nm{flex:1;font-size:15px}
.set-row .val{font-size:14px;color:var(--text-dim)}
.set-row svg{width:18px;height:18px;stroke:var(--text-faint);fill:none;stroke-width:2}
.set-row:active{background:var(--surface-2)}

/* ---- Toast ---- */
#toast{position:fixed;left:50%;bottom:calc(var(--nav-h) + var(--safe-b) + 18px);transform:translateX(-50%) translateY(20px);
  z-index:90;background:var(--surface-3);color:var(--text);padding:13px 20px;border-radius:14px;font-size:14px;font-weight:600;
  box-shadow:var(--shadow);opacity:0;transition:.28s;pointer-events:none;border:1px solid var(--border);max-width:88vw}
#toast.show{opacity:1;transform:translateX(-50%) translateY(0)}
#toast.ok{border-color:rgba(47,212,123,.4)}
#toast.err{border-color:rgba(255,92,124,.4)}

/* ---- Загрузка ---- */
.skeleton{background:linear-gradient(90deg,var(--surface) 25%,var(--surface-2) 50%,var(--surface) 75%);
  background-size:200% 100%;animation:sk 1.3s infinite;border-radius:14px}
@keyframes sk{0%{background-position:200% 0}100%{background-position:-200% 0}}
.spinner{width:34px;height:34px;border:3px solid var(--surface-3);border-top-color:var(--accent);border-radius:50%;animation:spin .8s linear infinite;margin:60px auto}
@keyframes spin{to{transform:rotate(360deg)}}

/* ---- Статусы (план / факт) ---- */
.hero .forecast{margin-top:10px;display:inline-flex;align-items:center;gap:6px;font-size:13px;
  background:rgba(255,255,255,.16);padding:6px 12px;border-radius:11px}
.hero .forecast b{font-weight:700}
.tx .check{width:30px;height:30px;border-radius:50%;border:2px solid var(--surface-3);
  display:flex;align-items:center;justify-content:center;flex:none;margin-left:4px;color:transparent;font-size:15px;transition:.15s}
.tx .check.done{background:var(--income);border-color:var(--income);color:#06281a}
.tx .check:active{transform:scale(.88)}
.tx.is-planned .av{opacity:.92}
.tx.is-planned .amt{opacity:.82}
.tx .when{color:var(--text-faint)}
.tx .when.over{color:var(--expense);font-weight:600}
.seg button.on.plan{background:var(--accent);color:#fff}
.seg button.on.done{background:var(--income);color:#06281a}
.planfact{display:flex;flex-direction:column;gap:12px}
.pf-row{display:flex;align-items:center;gap:12px}
.pf-row .pf-ic{width:38px;height:38px;border-radius:12px;display:flex;align-items:center;justify-content:center;font-size:18px;flex:none}
.pf-row .pf-mid{flex:1}
.pf-row .pf-t{font-size:13px;color:var(--text-dim)}
.pf-row .pf-v{font-size:16px;font-weight:700;margin-top:2px}
.pf-row .pf-v small{font-weight:500;color:var(--text-faint);font-size:12px}
.pf-bar{height:6px;border-radius:3px;background:var(--surface-3);overflow:hidden;margin-top:6px}
.pf-bar i{display:block;height:100%;border-radius:3px}
.badge-over{display:inline-block;font-size:10px;font-weight:700;color:var(--expense);
  background:rgba(255,92,124,.14);padding:2px 7px;border-radius:7px;margin-left:6px}
.rep-mark{font-size:11px;opacity:.7;margin-left:4px}

/* мини-помощники */
.row-between{display:flex;align-items:center;justify-content:space-between}
.muted{color:var(--text-dim)}
.mt8{margin-top:8px}.mt16{margin-top:16px}
.emoji-pick{display:grid;grid-template-columns:repeat(8,1fr);gap:6px;
  max-height:44dvh;overflow-y:auto;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;
  margin-bottom:12px;padding-right:2px}
.emoji-pick button{font-size:22px;padding:6px;border-radius:10px}
.emoji-pick button.sel{background:var(--surface-3)}
