/* Финансы — мини-приложение. Цвета берутся из темы Telegram,
   свои — только смысловые: доход, минус, перерасход, «на кого». */

:root {
  --bg: var(--tg-theme-secondary-bg-color, #efeff4);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --sub: var(--tg-theme-subtitle-text-color, var(--hint));
  --link: var(--tg-theme-link-color, #2481cc);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --accent-ink: var(--tg-theme-accent-text-color, var(--link));
  --head: var(--tg-theme-section-header-text-color, var(--hint));
  --danger: var(--tg-theme-destructive-text-color, #e53935);
  --sep: var(--tg-theme-section-separator-color, rgba(60, 60, 67, .16));
  --accent-soft: rgba(36, 129, 204, .12);
  --accent-mid: rgba(36, 129, 204, .45);

  --income: #1d9a52;
  --negative: #e0453a;
  --warn: #ec835a;
  --pressed: rgba(0, 0, 0, .05);
  --field: rgba(118, 118, 128, .12);
  --seg-on: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);
  --scrim: rgba(0, 0, 0, .38);

  /* «на кого»: постоянные цвета, различимые и на светлом, и на тёмном */
  --w0: #a3a3ad;
  --w1: #4f8ef7;
  --w2: #ef6c9a;
  --w3: #9b6bea;
  --w4: #f2a541;
  --w5: #2fb3a3;
  --w6: #8d9f3a;

  --r: 14px;
  --safe-b: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --tabbar-h: 58px;
  --vh: var(--tg-viewport-height, 100vh);
  color-scheme: light;
}

:root[data-scheme="dark"] {
  --bg: var(--tg-theme-secondary-bg-color, #000000);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #1c1c1e));
  --text: var(--tg-theme-text-color, #ffffff);
  --hint: var(--tg-theme-hint-color, #8d8e93);
  --sep: var(--tg-theme-section-separator-color, rgba(84, 84, 88, .55));
  --link: var(--tg-theme-link-color, #5aa7f0);
  --accent: var(--tg-theme-button-color, #3e88f7);
  --income: #3bcf7a;
  --negative: #ff6a5f;
  --warn: #f0905f;
  --pressed: rgba(255, 255, 255, .07);
  --field: rgba(118, 118, 128, .24);
  --seg-on: #636366;
  --shadow: none;
  --scrim: rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body { min-height: var(--vh); overscroll-behavior-y: none; }
body.locked { overflow: hidden; }

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
input, textarea, select { font: inherit; }

.icon { flex: none; display: block; }

/* ------------------------------------------------------------ каркас */

.pane {
  max-width: 640px;
  margin: 0 auto;
  padding: 6px 16px calc(var(--tabbar-h) + var(--safe-b) + 92px);
}
.pane.page { padding-bottom: calc(var(--safe-b) + 32px); }
body.with-main .pane { padding-bottom: calc(var(--safe-b) + 96px); }

.hdr { padding: 10px 4px 4px; }
.hdr-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.hdr-title { font-size: 30px; font-weight: 750; letter-spacing: -.02em; line-height: 1.12; }
.hdr-sub { color: var(--hint); font-size: 14px; margin-top: 3px; }
.page-title { font-size: 24px; font-weight: 750; letter-spacing: -.015em; padding: 10px 4px 2px; }
.page-sub { color: var(--hint); font-size: 14px; padding: 0 4px; }

.boot { min-height: 70vh; display: grid; place-items: center; }

/* ------------------------------------------------------------ нижние вкладки */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center;
  padding: 4px 6px calc(4px + var(--safe-b));
  background: var(--card);
  border-top: .5px solid var(--sep);
}
.tabbar-in { display: flex; width: 100%; max-width: 640px; }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 5px 0 3px; border: 0; background: none; color: var(--hint);
  font-size: 10.5px; font-weight: 500; letter-spacing: .01em;
}
.tab.on { color: var(--accent); }
.tab:active .icon { transform: scale(.92); }

.fab {
  position: fixed; z-index: 29; right: max(16px, calc(50vw - 320px + 16px));
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px);
  width: 56px; height: 56px; border-radius: 50%; border: 0;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .22);
}
.fab:active { transform: scale(.94); }
body.typing .tabbar, body.typing .fab { display: none; }

/* ------------------------------------------------------------ группы и строки */

.group { margin-top: 22px; }
.group-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 0 4px 7px; color: var(--head);
  font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .035em;
}
.group-head .link { text-transform: none; letter-spacing: 0; font-size: 14px; }
.group-extra { text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.group-hint { color: var(--hint); font-size: 13px; padding: 7px 4px 0; line-height: 1.4; }

.link { border: 0; background: none; padding: 0; color: var(--link); font-weight: 500; }
.link:active { opacity: .6; }

.card {
  display: block; width: 100%; text-align: left;
  background: var(--card); border: 0; border-radius: var(--r);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.card.tap:active { background: var(--pressed); }
.card + .card { margin-top: 10px; }

.list { background: var(--card); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.list.pad { padding: 4px 0; }

.row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 50px; padding: 9px 14px;
  background: none; border: 0; text-align: left; position: relative;
}
.row.tap:active { background: var(--pressed); }
.row + .row::before {
  content: ""; position: absolute; top: 0; right: 0;
  left: var(--row-inset, 60px); border-top: .5px solid var(--sep);
}
.list.flat .row + .row::before { left: 14px; }
.row-ic { flex: none; display: grid; place-items: center; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 13px; color: var(--hint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.row-end { flex: none; display: flex; flex-direction: column; align-items: flex-end; text-align: right; max-width: 48%; }
.row-end-main { font-size: 15.5px; white-space: nowrap; }
.row-end-sub { font-size: 12.5px; color: var(--hint); white-space: nowrap; margin-top: 1px; }
.row .chev { color: var(--hint); opacity: .55; margin-right: -4px; }
.row.danger .row-title { color: var(--danger); }
.row.muted .row-title { color: var(--hint); }

.cat-ic {
  display: grid; place-items: center; border-radius: 10px; flex: none;
  background: var(--accent-soft); line-height: 1; font-weight: 600; color: var(--accent-ink);
}
.cat-ic.income { background: rgba(46, 170, 96, .14); color: var(--income); }
.set-ic {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  color: #fff; flex: none;
}

.amt { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.amt.inc { color: var(--income); }
.amt.neg { color: var(--negative); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--hint); }
.neg-text { color: var(--negative); }
.small { font-size: 13px; }

/* ------------------------------------------------------------ главная */

.hero { padding: 16px 16px 14px; }
.hero-label { color: var(--hint); font-size: 13.5px; }
.hero-value { font-size: 34px; font-weight: 750; letter-spacing: -.02em; margin-top: 2px; line-height: 1.15; }
.hero-split { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.hero-split .k { color: var(--hint); font-size: 12.5px; }
.hero-split .v { font-size: 16px; font-weight: 650; margin-top: 1px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hero-foot { margin-top: 12px; padding-top: 10px; border-top: .5px solid var(--sep); color: var(--hint); font-size: 13.5px; }

.banner {
  display: flex; align-items: center; gap: 12px;
  background: var(--accent); color: var(--accent-text);
}
.banner .banner-text { flex: 1; }
.banner b { display: block; font-size: 15.5px; }
.banner span { font-size: 13.5px; opacity: .9; }
.banner.card.tap:active { background: var(--accent); opacity: .9; }

.limit { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 13px 16px 12px; }
.limit.tap:active { background: var(--pressed); }
.limit + .limit { border-top: .5px solid var(--sep); }
.limit-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.limit-top .limit-left { flex: none; }
.limit-name { font-weight: 600; font-size: 15px; line-height: 1.3; }
.limit-left { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.limit-left.over { color: var(--warn); }
.limit-rule { color: var(--hint); font-size: 12.5px; margin-top: 1px; }
.limit-foot { display: flex; justify-content: space-between; gap: 10px; color: var(--hint); font-size: 12.5px; margin-top: 7px; font-variant-numeric: tabular-nums; }
.lbar { position: relative; height: 8px; border-radius: 4px; background: var(--accent-soft); margin-top: 9px; }
.lbar-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--accent); }
.lbar-over { position: absolute; top: 0; bottom: 0; border-radius: 0 4px 4px 0; background: var(--warn); }
.lbar-norm { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--text); opacity: .5; }

.paydate {
  width: 42px; flex: none; text-align: center; border-radius: 10px; padding: 4px 0 5px;
  background: var(--field); line-height: 1.05;
}
.paydate b { display: block; font-size: 17px; }
.paydate span { font-size: 11px; color: var(--hint); }
.paydate.soon { background: var(--accent-soft); color: var(--accent-ink); }
.paydate.soon span { color: var(--accent-ink); }

/* ------------------------------------------------------------ переключатели */

.seg { display: flex; background: var(--field); border-radius: 10px; padding: 2px; gap: 2px; }
.seg button {
  flex: 1; border: 0; background: none; padding: 7px 6px; border-radius: 8px;
  font-size: 14px; font-weight: 500; white-space: nowrap;
}
.seg button.on { background: var(--seg-on); font-weight: 650; box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 7px 12px; border-radius: 999px; border: 0;
  background: var(--card); font-size: 14px; font-weight: 500; white-space: nowrap;
}
.card .chip { background: var(--field); }
.chip.on { background: var(--accent); color: var(--accent-text); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }

.toggle {
  width: 50px; height: 30px; border-radius: 15px; border: 0; padding: 0; flex: none;
  background: var(--field); position: relative; transition: background .2s;
}
.toggle span {
  position: absolute; top: 2px; left: 2px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform .2s;
}
.toggle.on { background: #34c759; }
.toggle.on span { transform: translateX(20px); }

.mswitch { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.mbtn {
  width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--card);
  display: grid; place-items: center; color: var(--accent-ink); flex: none;
}
.mbtn:disabled { opacity: .3; }
.mtitle {
  border: 0; background: none; font-size: 17px; font-weight: 650;
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 8px;
}
.mtitle .icon { color: var(--hint); }

.mpick-year { font-weight: 650; color: var(--hint); font-size: 13px; padding: 12px 2px 6px; }
.mpick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mpick-m {
  border: 0; border-radius: 10px; background: var(--card); padding: 11px 0;
  font-size: 15px; position: relative; text-transform: capitalize;
}
.mpick-m.on { background: var(--accent); color: var(--accent-text); font-weight: 650; }
.mpick-m:disabled { opacity: .3; }
.mpick-mark { position: absolute; top: 3px; right: 6px; font-size: 11px; color: var(--income); }
.mpick-m.on .mpick-mark { color: inherit; }

/* ------------------------------------------------------------ кнопки и поля */

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 48px; padding: 12px 16px; border-radius: 12px; border: 0;
  font-size: 16px; font-weight: 600;
}
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.secondary { background: var(--accent-soft); color: var(--accent-ink); }
.btn.plain { background: var(--card); color: var(--accent-ink); }
.btn.danger { background: var(--card); color: var(--danger); }
.btn.danger-fill { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .45; }
.btn:not(:disabled):active { opacity: .82; }
.btns { display: grid; gap: 10px; margin-top: 18px; }
.btns.two { grid-template-columns: 1fr 1fr; }

.field { display: block; background: var(--card); border-radius: 12px; padding: 9px 14px 10px; }
.sheet .field { background: var(--card); }
.field + .field { margin-top: 10px; }
.field-label { display: block; font-size: 12.5px; color: var(--hint); margin-bottom: 3px; }
.field-hint { display: block; font-size: 12.5px; color: var(--hint); margin-top: 4px; }
.field .input { background: none; padding: 2px 0; border-radius: 0; }
.input {
  width: 100%; border: 0; border-radius: 12px; background: var(--card);
  padding: 11px 12px; font-size: 16px; color: var(--text); outline: none;
}
.input::placeholder { color: var(--hint); opacity: .8; }
.search { position: relative; }
.search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--hint); }
.search .input { padding-left: 36px; background: var(--card); }
.search .clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--hint); padding: 6px; }

/* ------------------------------------------------------------ записи */

.day-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 18px 4px 7px; font-size: 13px; font-weight: 600; color: var(--head);
}
.day-head .num { font-weight: 600; }
.sum-strip { display: flex; gap: 16px; padding: 10px 4px 0; color: var(--hint); font-size: 13.5px; flex-wrap: wrap; }
.sum-strip b { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }
.sum-strip b.inc { color: var(--income); }
.tx-tags { display: inline-flex; gap: 4px; align-items: center; }
.whom-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 3px; vertical-align: 1px; }
.filters-bar { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.filters-bar .search { flex: 1; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 0; flex: none;
  background: var(--card); display: grid; place-items: center; color: var(--accent-ink); position: relative;
}
.icon-btn .badge {
  position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--accent); color: var(--accent-text); font-size: 10.5px; font-weight: 700;
  display: grid; place-items: center;
}

/* ------------------------------------------------------------ форма записи */

.amount-box { text-align: center; padding: 6px 0 2px; }
.amount-input {
  width: 100%; border: 0; background: none; outline: none; text-align: center;
  font-size: 42px; font-weight: 750; letter-spacing: -.02em; color: var(--text);
  font-variant-numeric: tabular-nums; padding: 0;
}
.amount-input::placeholder { color: var(--hint); opacity: .5; }
.amount-tools { display: flex; justify-content: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.amount-note { text-align: center; color: var(--hint); font-size: 13.5px; min-height: 19px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.amount-note.bad { color: var(--negative); }

.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cat-btn {
  display: flex; align-items: center; gap: 9px; padding: 9px 10px; min-height: 48px;
  border-radius: 12px; background: var(--card); border: 1.5px solid transparent;
  font-size: 14px; font-weight: 500; text-align: left; line-height: 1.2;
}
.cat-btn.on { border-color: var(--accent); background: var(--accent-soft); }
.cat-btn .cat-ic { width: 30px; height: 30px; font-size: 16px; }
.datechip { position: relative; overflow: hidden; }
.datechip input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
[hidden] { display: none !important; }
.form-label { color: var(--head); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .035em; margin: 18px 4px 8px; }
.form-note { color: var(--hint); font-size: 13px; padding: 8px 4px 0; }

/* ------------------------------------------------------------ окна снизу */

.sheet-wrap { position: fixed; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; }
.sheet-back { position: absolute; inset: 0; background: var(--scrim); animation: fade .2s ease; }
.sheet {
  position: relative; background: var(--bg); border-radius: 16px 16px 0 0;
  max-height: calc(var(--vh) - 28px); display: flex; flex-direction: column;
  width: 100%; max-width: 640px; margin: 0 auto;
  animation: up .26s cubic-bezier(.2, .8, .2, 1);
}
.sheet-grip { width: 36px; height: 5px; border-radius: 3px; background: var(--hint); opacity: .35; margin: 7px auto 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 16px 6px; }
.sheet-title { font-size: 18px; font-weight: 700; }
.sheet-x {
  width: 30px; height: 30px; border-radius: 50%; border: 0; flex: none;
  background: var(--field); color: var(--hint); display: grid; place-items: center;
}
.sheet-body {
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 6px 16px calc(var(--safe-b) + 22px);
}
body.with-main .sheet-body { padding-bottom: calc(var(--safe-b) + 92px); }

@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ------------------------------------------------------------ подсказка внизу */

.toast {
  position: fixed; z-index: 90; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 84px);
  width: calc(100% - 32px); max-width: 520px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-radius: 13px;
  background: rgba(36, 36, 38, .94); color: #fff; font-size: 14.5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  animation: toast .22s ease;
}
.toast.error { background: rgba(190, 45, 38, .96); }
.toast button { border: 0; background: none; color: #7cc0ff; font-weight: 650; padding: 0; flex: none; }
body.no-tabs .toast { bottom: calc(var(--safe-b) + 24px); }
body.with-main .toast { bottom: calc(var(--safe-b) + 88px); }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

.fallback-main {
  position: fixed; z-index: 80; left: 0; right: 0; bottom: 0;
  padding: 10px 16px calc(10px + var(--safe-b));
  background: var(--bg); border-top: .5px solid var(--sep);
  display: flex; justify-content: center;
}
.fallback-main .btn { max-width: 608px; }

/* ------------------------------------------------------------ пустые и загрузка */

.empty { text-align: center; color: var(--hint); padding: 34px 20px; }
.empty-ic { font-size: 42px; line-height: 1; margin-bottom: 10px; }
.empty-title { color: var(--text); font-weight: 650; font-size: 16px; }
.empty-text { margin-top: 4px; font-size: 14px; line-height: 1.4; }
.errbox {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--card); border-radius: var(--r); padding: 14px 16px; color: var(--negative);
}

.sk {
  border-radius: 7px;
  background: linear-gradient(90deg, var(--field) 25%, var(--pressed) 45%, var(--field) 65%);
  background-size: 300% 100%; animation: sk 1.3s ease-in-out infinite;
}
.sk.round { border-radius: 10px; }
.sk-row { display: flex; gap: 12px; align-items: center; padding: 10px 14px; }
@keyframes sk { from { background-position: 100% 0; } to { background-position: 0 0; } }

.spinner {
  display: inline-block; border-radius: 50%;
  border: 2.5px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite; opacity: .7;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-dim { opacity: .55; transition: opacity .15s; }

/* ------------------------------------------------------------ графики */

.barlist { display: flex; flex-direction: column; }
.bl-row {
  display: flex; flex-direction: column; gap: 6px; width: 100%;
  padding: 9px 0; border: 0; background: none; text-align: left;
}
.bl-row + .bl-row { border-top: .5px solid var(--sep); }
.bl-row.tap:active { opacity: .6; }
.bl-top { display: flex; align-items: center; gap: 8px; }
.bl-ic { width: 22px; text-align: center; flex: none; font-size: 16px; }
.bl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.bl-val { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 14.5px; }
.bl-pct { color: var(--hint); width: 38px; text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; }
.bl-track { display: block; height: 6px; border-radius: 3px; background: var(--field); overflow: hidden; }
.bl-fill { display: block; height: 100%; border-radius: 3px; }

.stack-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; }
.stack-bar span { display: block; height: 100%; }
.stack-legend { display: flex; flex-direction: column; margin-top: 8px; }
.lg {
  display: flex; align-items: center; gap: 8px; padding: 7px 0; border: 0; background: none; text-align: left; width: 100%;
}
.lg + .lg { border-top: .5px solid var(--sep); }
.lg-name { flex: 1; font-size: 14.5px; }
.lg-val { font-weight: 650; font-variant-numeric: tabular-nums; font-size: 14.5px; }
.lg-pct { color: var(--hint); width: 38px; text-align: right; font-size: 13px; }
.lg-mini { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--hint); margin-right: 12px; white-space: nowrap; }

.cross-legend { display: flex; flex-wrap: wrap; row-gap: 4px; padding-bottom: 6px; }
.cross-row { display: flex; flex-direction: column; gap: 6px; width: 100%; padding: 9px 0; border: 0; background: none; text-align: left; }
.cross-row + .cross-row { border-top: .5px solid var(--sep); }
.cross-top { display: flex; align-items: center; gap: 8px; }
.cross-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; gap: 1.5px; }
.cross-bar span { display: block; height: 100%; }
.cross-nums { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--hint); font-variant-numeric: tabular-nums; }
.cross-nums .dot { width: 7px; height: 7px; margin-right: 4px; vertical-align: 0; }

.chart { position: relative; width: 100%; padding-left: 34px; }
.chart-scroll { overflow-x: auto; scrollbar-width: none; }
.chart-scroll::-webkit-scrollbar { display: none; }
.chart svg { display: block; }
.chart-axis { position: absolute; left: 0; top: 0; bottom: 0; pointer-events: none; z-index: 1; }
.chart-axis { width: 30px; }
.chart-axis span {
  position: absolute; right: 0; font-size: 10px; color: var(--hint); white-space: nowrap;
  line-height: 14px; font-variant-numeric: tabular-nums;
}
.chart .gridl { stroke: var(--sep); stroke-width: 1; }
.chart .axis0 { stroke: var(--hint); stroke-opacity: .5; stroke-width: 1; }
.chart .avgl { stroke: var(--hint); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .pickl { stroke: var(--hint); stroke-opacity: .5; stroke-width: 1; }
.chart .lbl { font-size: 10px; fill: var(--hint); }
.chart .lbl.on { fill: var(--text); font-weight: 700; }
.chart .b-inc { fill: var(--income); }
.chart .b-exp { fill: var(--accent); }
.chart .b-exp.partial { fill: var(--accent-mid); }
.chart .b-exp.today { fill: var(--warn); }
.chart .b-future { fill: var(--field); }
.chart .b-pos { fill: var(--income); }
.chart .b-neg { fill: var(--negative); }
.chart .b-whom { fill: var(--w3); }
.chart .dim { opacity: .35; }
.chart g { cursor: pointer; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--hint); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.picked {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  font-size: 13.5px; padding: 0 0 10px; min-height: 28px;
}
.picked-title { font-weight: 650; }
.picked-body { color: var(--hint); flex: 1; font-variant-numeric: tabular-nums; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 14.5px; }
.kv + .kv { border-top: .5px solid var(--sep); }
.kv .k { color: var(--hint); }
.kv .v { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.kv.strong .k { color: var(--text); font-weight: 600; }
.kv.ind .k { padding-left: 14px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border-radius: var(--r); padding: 12px 14px; box-shadow: var(--shadow); }
.stat .k { color: var(--hint); font-size: 12.5px; }
.stat .v { font-size: 19px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat .d { font-size: 12.5px; color: var(--hint); margin-top: 2px; }
.delta-up, .stat .d.delta-up { color: var(--income); }
.delta-down, .stat .d.delta-down { color: var(--negative); }

.avg-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
.avg-table th { color: var(--hint); font-weight: 500; font-size: 12.5px; text-align: right; padding: 0 0 6px; }
.avg-table th:first-child, .avg-table td:first-child { text-align: left; }
.avg-table td { text-align: right; padding: 7px 0; border-top: .5px solid var(--sep); white-space: nowrap; }

/* ------------------------------------------------------------ капитал и остатки */

.tree-kid .row-title { font-size: 14.5px; }
.tree-kid { --row-inset: 60px; }
.tree-kid .row-ic { width: 34px; }
.delta { font-size: 12px; font-variant-numeric: tabular-nums; }

.decl-row { display: flex; align-items: center; gap: 10px; padding: 9px 14px; position: relative; }
.decl-row + .decl-row::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; border-top: .5px solid var(--sep); }
.decl-main { flex: 1; min-width: 0; }
.decl-name { font-size: 15px; line-height: 1.25; overflow-wrap: anywhere; }
.decl-prev { font-size: 12.5px; color: var(--hint); margin-top: 1px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.decl-prev button { border: 0; background: var(--field); color: var(--accent-ink); border-radius: 6px; font-size: 12px; padding: 1px 7px; font-weight: 600; }
.decl-input {
  width: 118px; flex: none; border: 0; border-radius: 10px; background: var(--field);
  padding: 9px 10px; text-align: right; font-size: 16px; font-weight: 600; color: var(--text);
  outline: none; font-variant-numeric: tabular-nums;
}
.decl-input:focus { box-shadow: 0 0 0 2px var(--accent); }
.decl-input.changed { background: var(--accent-soft); }
.decl-cur { width: 14px; color: var(--hint); font-size: 14px; flex: none; }
.decl-sign {
  width: 28px; height: 34px; flex: none; border: 0; border-radius: 8px; background: var(--field);
  color: var(--hint); font-weight: 700; font-size: 15px; padding: 0;
}
.decl-total { display: flex; justify-content: space-between; padding: 8px 14px 10px; color: var(--hint); font-size: 13.5px; border-top: .5px solid var(--sep); }
.decl-total b { color: var(--text); font-variant-numeric: tabular-nums; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; background: var(--field); color: var(--hint); white-space: nowrap;
}
.pill.ok { background: rgba(46, 170, 96, .15); color: var(--income); }
.pill.warn { background: rgba(236, 131, 90, .16); color: var(--warn); }

.summary { position: relative; }
.summary .kv .v.big { font-size: 17px; }

.note { background: var(--accent-soft); color: var(--text); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; line-height: 1.4; }
.note.warn { background: rgba(236, 131, 90, .15); }

.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.emoji-grid button { border: 0; background: var(--card); border-radius: 10px; font-size: 22px; padding: 6px 0; line-height: 1.2; }
.emoji-grid button.on { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }

.help p { margin: 0 0 10px; line-height: 1.45; }
.help b { font-weight: 650; }

@media (min-width: 700px) {
  .hdr-title { font-size: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
