:root {
  --bg-fb: #ffffff; --sec-fb: #eef2f6; --text-fb: #0f172a; --hint-fb: #64748b; --line-fb: rgba(15, 23, 42, .08);
  --accent: #1a8fd8; --accent-2: #14b8a6; --pos: #0ea271; --neg: #e5484d; --warn: #d98a0b;
  --bg: var(--tg-theme-bg-color, var(--bg-fb));
  --sec: var(--tg-theme-secondary-bg-color, var(--sec-fb));
  --text: var(--tg-theme-text-color, var(--text-fb));
  --hint: var(--tg-theme-hint-color, var(--hint-fb));
  --line: var(--line-fb);
  --btn: var(--tg-theme-button-color, var(--accent));
  --btn-text: var(--tg-theme-button-text-color, #fff);
  --radius: 18px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg-fb: #17212b; --sec-fb: #0e1621; --text-fb: #f1f5f9; --hint-fb: #8b9bb0; --line-fb: rgba(255, 255, 255, .08);
          --pos: #3ddc97; --neg: #ff7a7f; --warn: #f0b44a; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--sec); }
body { margin: 0; background: var(--sec); color: var(--text); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Segoe UI", sans-serif;
       -webkit-font-smoothing: antialiased; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
main, .top { max-width: 560px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.num { font-variant-numeric: tabular-nums; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: calc(12px + env(safe-area-inset-top)); padding-bottom: 8px; }
.month { display: flex; align-items: center; gap: 4px; min-width: 0; }
.month-name { font-weight: 650; font-size: 18px; min-width: 132px; text-align: center; white-space: nowrap; }
.icon-btn { width: 36px; height: 36px; border-radius: 12px; font-size: 24px; line-height: 1; color: var(--accent); }
.icon-btn:disabled { opacity: .25; cursor: default; }
.seg { display: inline-flex; background: var(--bg); border-radius: 12px; padding: 3px; flex-shrink: 0; }
.seg button { padding: 6px 14px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--hint); }
.seg button.on { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }

.card { background: var(--bg); border-radius: var(--radius); padding: 16px; margin-top: 12px; }
.card h2 { margin: 0 0 12px; font-size: 15px; font-weight: 650; color: var(--hint); letter-spacing: .02em; text-transform: uppercase; }
.hero { margin-top: 4px; padding: 20px 18px; color: #fff; background: linear-gradient(135deg, #1a73d8 0%, #1a8fd8 45%, #14b8a6 100%); border-radius: 22px; box-shadow: 0 10px 28px rgba(26, 143, 216, .28); }
.hero .label { font-size: 13px; opacity: .85; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.hero .big { font-size: 40px; font-weight: 750; letter-spacing: -.02em; margin: 4px 0 2px; }
.hero .delta { font-size: 13px; opacity: .92; }
.hero .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.hero .cell { background: rgba(255, 255, 255, .16); border-radius: 14px; padding: 10px 12px; }
.hero .cell small { display: block; font-size: 12px; opacity: .85; }
.hero .cell b { font-size: 19px; font-weight: 700; }
.hero .foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; font-size: 13px; opacity: .92; flex-wrap: wrap; }

.banner { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: color-mix(in srgb, var(--warn) 14%, var(--bg)); border-radius: var(--radius); padding: 14px 16px; margin-top: 12px; }
.banner b { display: block; }
.banner small { color: var(--hint); }
.banner .arrow { margin-left: auto; color: var(--hint); font-size: 22px; }
.note { font-size: 13px; color: var(--hint); margin-top: 10px; }

.donut-wrap { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.donut { width: 132px; height: 132px; flex-shrink: 0; margin: 0 auto; }
.donut text { fill: var(--text); text-anchor: middle; }
.legend { flex: 1 1 200px; min-width: 0; display: grid; gap: 2px; }
.legend button { display: grid; grid-template-columns: 12px 1fr auto; gap: 10px; align-items: center; padding: 8px 4px; border-radius: 10px; text-align: left; }
.legend .dot { width: 12px; height: 12px; border-radius: 4px; }
.legend .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend .val { color: var(--hint); font-size: 14px; }

.bars { width: 100%; height: 130px; display: block; }
.bars text { fill: var(--hint); font-size: 10px; }

.list { display: grid; }
.item { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.ico { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; font-size: 19px; }
.item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { font-size: 13px; color: var(--hint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .a { font-weight: 650; text-align: right; white-space: nowrap; }
.item .a small { display: block; font-weight: 500; color: var(--hint); font-size: 12px; }
.pos { color: var(--pos); } .neg { color: var(--text); } .own { color: var(--hint); }
.day-h { display: flex; justify-content: space-between; margin: 18px 4px 6px; font-size: 13px; color: var(--hint); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 12px; border-radius: 999px; background: var(--sec); font-size: 14px; font-weight: 550; }
.chip.on { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.chip.warn { background: color-mix(in srgb, var(--warn) 18%, var(--bg)); }
.tag { display: inline-block; font-size: 11px; font-weight: 650; padding: 2px 7px; border-radius: 7px; background: var(--sec); color: var(--hint); margin-left: 6px; vertical-align: 1px; }
.empty { text-align: center; color: var(--hint); padding: 36px 12px; }
.empty .e { font-size: 38px; display: block; margin-bottom: 6px; }

.acc { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.acc:last-child { border-bottom: 0; }
.acc .nm { font-weight: 650; overflow-wrap: anywhere; }
.acc .logo { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; color: #fff; font-weight: 750; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.acc .bal { font-weight: 700; font-size: 17px; text-align: right; white-space: nowrap; }
.acc .meta { font-size: 13px; color: var(--hint); }
.link { color: var(--accent); font-size: 13px; font-weight: 600; padding: 2px 0; }
.stack { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--sec); margin: 10px 0 4px; }

.q { border-left: 4px solid var(--accent); padding: 14px 16px 16px; }
.q-xfer { border-left-color: #6366f1; } .q-in { border-left-color: var(--pos); } .q-out { border-left-color: var(--warn); }
.q .qh { display: flex; justify-content: space-between; font-size: 12px; font-weight: 650; color: var(--hint); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 8px; }
.q .qa { font-size: 24px; font-weight: 750; margin: 2px 0; }
.q .qt { font-weight: 650; }
.q .qs { color: var(--hint); font-size: 14px; margin: 2px 0 12px; }
.q .amt { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; }
.q .amt input { width: 150px; padding: 8px 10px; font: inherit; font-weight: 650; color: var(--text); background: var(--sec); border: 0; border-radius: 10px; }
.q .grp { margin-top: 10px; font-size: 12px; color: var(--hint); text-transform: uppercase; letter-spacing: .03em; font-weight: 650; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(5, 1fr); align-items: end; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
          background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); max-width: 100%; }
.tabbar button { display: grid; justify-items: center; gap: 2px; padding: 6px 2px; font-size: 11px; font-weight: 600; color: var(--hint); position: relative; }
.tabbar button.on { color: var(--accent); }
.tabbar .plus { padding: 0; justify-items: center; }
.tabbar .plus span { width: 52px; height: 52px; margin-top: -22px; border-radius: 18px; display: grid; place-items: center; font-size: 30px; line-height: 1; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 8px 20px rgba(26, 143, 216, .42); }
.tabbar .ti { font-size: 20px; line-height: 1.1; }
.tabbar b { position: absolute; top: 2px; left: calc(50% + 6px); background: var(--neg); color: #fff; font-size: 10px; min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }

.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 20; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: var(--bg); border-radius: 24px 24px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 92vh; overflow-y: auto; max-width: 560px; margin: 0 auto; }
.sheet h3 { margin: 0 0 14px; font-size: 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--hint); margin-bottom: 6px; font-weight: 600; }
.field input[type=text], .field input[type=number], .field input[type=date], .field select { width: 100%; min-width: 0; max-width: 100%; padding: 12px 14px; font: inherit; font-size: 16px; color: var(--text); background: var(--sec); border: 0; border-radius: 12px; appearance: none; -webkit-appearance: none; }
.field input.amount { font-size: 30px; font-weight: 700; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.switch { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; }
.btn { width: 100%; padding: 14px; border-radius: 14px; font-weight: 650; font-size: 16px; color: var(--btn-text); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.btn.sec { background: var(--sec); color: var(--text); margin-top: 8px; }
.btn:disabled { opacity: .5; }
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 30; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, var(--bg), var(--sec), var(--bg)); background-size: 200% 100%; animation: sh 1.4s infinite; margin-top: 12px; }
@keyframes sh { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
[hidden] { display: none !important; }
input[type=number]::-webkit-outer-spin-button, input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }
.switch input { appearance: none; -webkit-appearance: none; width: 50px; height: 30px; border-radius: 999px; background: var(--sec); position: relative; transition: background .2s; margin: 0; cursor: pointer; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s; }
.switch input:checked { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.switch input:checked::after { transform: translateX(20px); }

/* --- аналитика, цели, детали операции --- */
.hero.slim { padding: 14px 18px; }
.sech { margin: 18px 4px 4px; font-size: 13px; font-weight: 650; color: var(--hint); text-transform: uppercase; letter-spacing: .03em; }
.ins { border-left: 4px solid var(--accent); padding: 14px 16px 12px; }
.ins .qt { font-weight: 650; }
.ins-act { display: flex; gap: 16px; flex-wrap: wrap; }
.link.mute { color: var(--hint); font-weight: 500; }
.goals { display: grid; gap: 10px; margin-bottom: 12px; }
.goal { display: block; width: 100%; text-align: left; background: var(--sec); border-radius: 14px; padding: 12px 14px; }
.gl-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 650; margin-bottom: 8px; }
.track { position: relative; height: 10px; border-radius: 999px; background: color-mix(in srgb, var(--hint) 22%, transparent); overflow: visible; margin-bottom: 8px; }
.fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.fill.f-warn { background: var(--warn); } .fill.f-risk { background: #f97316; } .fill.f-bad { background: var(--neg); } .fill.f-mute { background: var(--hint); }
.tick { position: absolute; top: -3px; width: 2px; height: 16px; background: var(--text); opacity: .55; border-radius: 1px; }
.gl-n { font-weight: 650; font-size: 15px; } .gl-s { font-size: 13px; color: var(--hint); margin-top: 2px; }
.st { font-size: 11px; font-weight: 650; padding: 3px 8px; border-radius: 8px; background: var(--sec); color: var(--hint); white-space: nowrap; }
.st-ok { background: color-mix(in srgb, var(--pos) 18%, var(--bg)); color: var(--pos); }
.st-warn { background: color-mix(in srgb, var(--warn) 20%, var(--bg)); color: var(--warn); }
.st-risk { background: color-mix(in srgb, #f97316 20%, var(--bg)); color: #f97316; }
.st-bad { background: color-mix(in srgb, var(--neg) 18%, var(--bg)); color: var(--neg); }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpis > div { background: var(--sec); border-radius: 14px; padding: 10px 12px; }
.kpis small { display: block; font-size: 12px; color: var(--hint); } .kpis b { font-size: 18px; }
.legend-row { display: flex; gap: 16px; font-size: 13px; color: var(--hint); margin-top: 2px; }
.legend-row .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.bars.hist { height: 150px; }
.dl { font-size: 12px; font-weight: 650; padding: 1px 7px; border-radius: 7px; background: var(--sec); color: var(--hint); }
.dl.up { background: color-mix(in srgb, var(--warn) 22%, var(--bg)); color: var(--warn); } .dl.down { background: color-mix(in srgb, var(--pos) 18%, var(--bg)); color: var(--pos); }
.finding { padding: 8px 0; border-bottom: 1px solid var(--line); border-left: 3px solid var(--hint); padding-left: 10px; margin-bottom: 4px; }
.finding .s { font-size: 13px; color: var(--hint); } .finding.f-error { border-left-color: var(--neg); } .finding.f-warn { border-left-color: var(--warn); }
.disclaimer { text-align: center; margin: 14px 8px 0; }
.subhead { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 4px 0; }
.subhead b { font-size: 17px; } .subhead .link { justify-self: start; font-size: 16px; }
.item[data-action="tx"] { cursor: pointer; } .item[data-action="tx"]:active { background: var(--sec); }
.dh { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; } .dt { font-weight: 700; font-size: 18px; overflow-wrap: anywhere; }
.dsum { font-size: 34px; font-weight: 750; letter-spacing: -.02em; } .dsum.pos { color: var(--pos); } .dsum.own { color: var(--hint); }
.dsub { font-size: 13px; color: var(--hint); margin: 2px 0 10px; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.kvs { border-top: 1px solid var(--line); margin-top: 6px; }
.kv { display: grid; grid-template-columns: 42% 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv span { color: var(--hint); } .kv b { font-weight: 550; text-align: right; overflow-wrap: anywhere; }
.grp-l { font-size: 12px; color: var(--hint); text-transform: uppercase; letter-spacing: .03em; font-weight: 650; margin: 12px 0 8px; }
.btn.danger { background: var(--neg); color: #fff; } .btn.danger-t { color: var(--neg); }
.item.two { grid-template-columns: 1fr auto; }
