/* Утекло — дизайн-система. Все цвета только через токены; правила разметки о теме не знают. */
:root {
  color-scheme: light dark;
  --canvas: #f3f5f4; --card: #ffffff; --card-2: #eef1f0; --line: #e3e7e6;
  --ink: #111817; --ink-2: #5d6866; --ink-3: #8b9593;
  --accent: #0e7c7b; --accent-ink: #0b6a69; --accent-soft: #dcefee; --on-accent: #ffffff;
  --good: #1f8a4c; --bad: #c2410c; --bad-soft: #fde8dc; --warn: #b25000;
  --inbox: #d97706; --inbox-soft: #fdf1dc;
  --shadow: 0 1px 2px rgba(10, 30, 28, .06), 0 8px 24px rgba(10, 30, 28, .06);
  --r-card: 18px; --r-ctl: 12px; --r-pill: 999px;
  --fs: 17px; --fs-s: 15px; --fs-xs: 13px; --fs-hero: 40px; --fs-title: 28px;
  --tab-h: 58px; --side-w: 240px; --pad: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #000000; --card: #161b1a; --card-2: #212827; --line: #2a3130;
    --ink: #f2f5f4; --ink-2: #a3adab; --ink-3: #6f7977;
    --accent: #3ecfbf; --accent-ink: #5fdcce; --accent-soft: #113533; --on-accent: #06302d;
    --good: #4ade80; --bad: #fb923c; --bad-soft: #3a1f10; --warn: #fbbf24;
    --inbox: #fbbf24; --inbox-soft: #3a2c0c;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --canvas: #000000; --card: #161b1a; --card-2: #212827; --line: #2a3130;
  --ink: #f2f5f4; --ink-2: #a3adab; --ink-3: #6f7977;
  --accent: #3ecfbf; --accent-ink: #5fdcce; --accent-soft: #113533; --on-accent: #06302d;
  --good: #4ade80; --bad: #fb923c; --bad-soft: #3a1f10; --warn: #fbbf24;
  --inbox: #fbbf24; --inbox-soft: #3a2c0c;
  --shadow: none;
}
@media (min-width: 900px) { :root { --fs: 15px; --fs-s: 14px; --fs-xs: 12px; --fs-hero: 44px; --fs-title: 26px; } }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--canvas); color: var(--ink);
  font: var(--fs)/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
a { color: var(--accent-ink); text-decoration: none; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
.num { font-variant-numeric: tabular-nums lining-nums; }
.rub { font-size: .8em; opacity: .75; margin-left: .12em; }
[hidden] { display: none !important; }

/* ── каркас ─────────────────────────────────────────── */
#app { min-height: 100dvh; display: flex; }
.side { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 5; padding: calc(env(safe-area-inset-top, 0px) + 10px) var(--pad) 8px;
  background: color-mix(in srgb, var(--canvas) 82%, transparent); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
  display: flex; align-items: center; gap: 12px; min-height: 52px;
}
.top-title { font-size: var(--fs-title); flex: 1; }
.top-actions { display: flex; gap: 8px; }
.view { padding: 4px var(--pad) calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + 24px); max-width: 720px; width: 100%; margin: 0 auto; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px); display: flex; border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--ink-3); font-size: 10.5px; font-weight: 600; background: none; border: 0; position: relative; padding: 0; -webkit-tap-highlight-color: transparent;
}
.tab svg { width: 24px; height: 24px; }
.tab.on { color: var(--accent); }
.badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: var(--inbox); color: #fff; font-size: 11px; line-height: 17px; text-align: center; font-weight: 700; }
@media (min-width: 900px) {
  .side { display: flex; flex-direction: column; width: var(--side-w); padding: 22px 14px; border-right: 1px solid var(--line); position: sticky; top: 0; height: 100dvh; background: var(--card); }
  .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; color: var(--ink); padding: 4px 8px 22px; letter-spacing: -.02em; }
  .brand-mark { width: 30px; height: 30px; }
  .side-nav { display: flex; flex-direction: column; gap: 2px; }
  .side-nav .tab { flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px 12px; border-radius: var(--r-ctl); font-size: 15px; color: var(--ink-2); }
  .side-nav .tab.on { background: var(--accent-soft); color: var(--accent-ink); }
  .side-nav .badge { position: static; margin-left: auto; }
  .tabbar { display: none; }
  .view { padding: 8px 32px 48px; max-width: 860px; margin: 0; }
  .top { padding: 26px 32px 10px; }
}

/* ── карточки и списки ───────────────────────────────── */
.card { background: var(--card); border-radius: var(--r-card); box-shadow: var(--shadow); margin: 12px 0; overflow: hidden; }
.card-pad { padding: 16px; }
.card-title { font-size: var(--fs-xs); font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; padding: 18px var(--pad) 6px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); min-height: 56px; width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-bottom: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.row:first-child { border-top: 0; }
.row:active { background: var(--card-2); }
.row.static { cursor: default; }
.row-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; flex: 0 0 40px; background: var(--card-2); }
.row-ic.inbox { background: var(--inbox-soft); color: var(--inbox); font-weight: 800; font-size: 18px; }
.row-ic.excl { background: var(--card-2); color: var(--ink-3); }
.row-body { flex: 1; min-width: 0; }
.row-t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-s { font-size: var(--fs-xs); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.row-amt { font-weight: 600; white-space: nowrap; }
.row-amt.in { color: var(--good); }
.row-amt.muted { color: var(--ink-3); font-weight: 500; }
.row-chev { color: var(--ink-3); width: 18px; height: 18px; flex: 0 0 18px; }
.day-h { display: flex; justify-content: space-between; align-items: baseline; padding: 18px var(--pad) 6px; font-size: var(--fs-xs); color: var(--ink-3); font-weight: 600; }
.day-h b { color: var(--ink-2); font-weight: 600; }
.empty { text-align: center; color: var(--ink-3); padding: 42px 20px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.muted { color: var(--ink-3); }
.small { font-size: var(--fs-xs); }

/* ── обзор ───────────────────────────────────────────── */
.month-nav { display: flex; align-items: center; gap: 6px; }
.month-nav button { background: var(--card); border: 1px solid var(--line); width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
.month-nav button:disabled { opacity: .35; cursor: default; }
.month-nav .lbl { min-width: 128px; text-align: center; font-weight: 700; text-transform: capitalize; }
.hero { padding: 20px 18px 16px; background: linear-gradient(160deg, var(--card), var(--card) 60%, color-mix(in srgb, var(--accent-soft) 60%, var(--card))); }
.hero-l { font-size: var(--fs-xs); color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.hero-n { font-size: var(--fs-hero); font-weight: 800; letter-spacing: -.03em; line-height: 1.1; margin: 6px 0 8px; }
.hero-d { font-size: var(--fs-s); color: var(--ink-2); display: flex; gap: 14px; flex-wrap: wrap; }
.hero-d .up { color: var(--bad); } .hero-d .down { color: var(--good); }
.bars { display: block; width: 100%; height: 88px; margin-top: 14px; }
.bars rect { fill: var(--accent); opacity: .85; }
.bars rect.future { fill: var(--line); }
.bars rect.today { fill: var(--accent-ink); opacity: 1; }
.bars text { fill: var(--ink-3); font-size: 10px; }
.bars line { stroke: var(--line); }
.cat-row { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.cat-top { display: flex; align-items: center; gap: 12px; }
.cat-bar { height: 6px; border-radius: 3px; background: var(--card-2); overflow: hidden; margin-left: 52px; }
.cat-bar i { display: block; height: 100%; border-radius: 3px; }
.cat-bar i.over { background: var(--bad) !important; }
.cat-sub { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--ink-3); margin-left: 52px; }
.cat-sub .over { color: var(--bad); font-weight: 600; }
.hint { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--inbox-soft); color: var(--ink); border-radius: var(--r-card); margin: 12px 0; cursor: pointer; }
.hint .row-ic { background: var(--card); color: var(--inbox); }
.hint b { color: var(--inbox); }

/* ── управление ──────────────────────────────────────── */
.seg { display: flex; background: var(--card-2); border-radius: var(--r-ctl); padding: 3px; gap: 2px; margin: 10px 0; }
.seg button { flex: 1; border: 0; background: none; padding: 7px 4px; border-radius: 10px; font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.search { width: 100%; padding: 10px 14px; border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--card); outline: none; margin: 8px 0; -webkit-appearance: none; }
.search:focus { border-color: var(--accent); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: var(--r-ctl); border: 0; background: var(--accent); color: var(--on-accent); font-weight: 700; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: var(--card-2); color: var(--ink); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: var(--fs-xs); border-radius: 10px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.field label { font-size: var(--fs-xs); font-weight: 600; color: var(--ink-3); }
.field input, .field select, .field textarea { padding: 11px 14px; border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--card-2); outline: none; -webkit-appearance: none; width: 100%; }
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.toggle { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.toggle:first-child { border-top: 0; }
.toggle .row-body { flex: 1; }
.switch { position: relative; width: 50px; height: 30px; border-radius: 15px; background: var(--line); border: 0; cursor: pointer; flex: 0 0 50px; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 12px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(20px); }
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.chip { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--r-ctl); border: 1.5px solid var(--line); background: var(--card); cursor: pointer; text-align: left; font-weight: 600; font-size: var(--fs-s); -webkit-tap-highlight-color: transparent; }
.chip:active { background: var(--card-2); }
.chip.on { border-color: var(--accent); background: var(--accent-soft); }
.chip .e { font-size: 18px; }
.chip.wide { grid-column: 1 / -1; justify-content: center; }
.chip.neg { color: var(--bad); }
.chip.pos { color: var(--good); }
.color-dots { display: flex; gap: 8px; flex-wrap: wrap; }
.color-dots button { width: 30px; height: 30px; border-radius: 15px; border: 3px solid transparent; cursor: pointer; }
.color-dots button.on { border-color: var(--ink); }

/* ── шторка ──────────────────────────────────────────── */
.sheet-root { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--canvas); width: 100%; max-width: 560px; max-height: 92dvh; border-radius: 22px 22px 0 0; padding: 8px var(--pad) calc(18px + env(safe-area-inset-bottom, 0px)); overflow-y: auto; animation: rise .2s ease-out; }
@media (min-width: 900px) { .sheet-root { align-items: center; } .sheet { border-radius: 22px; max-height: 86dvh; } }
.grip { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 14px; }
.sheet-h { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.sheet-h .amt { font-size: 32px; font-weight: 800; letter-spacing: -.02em; }
.sheet-h .amt.in { color: var(--good); }
.sheet-h .who { font-weight: 600; font-size: var(--fs); margin-top: 2px; word-break: break-word; }
.meta { font-size: var(--fs-xs); color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 6px 0 12px; }
.raw { font-size: var(--fs-xs); color: var(--ink-3); background: var(--card-2); border-radius: 10px; padding: 8px 10px; word-break: break-word; margin: 6px 0 12px; }
.sheet h3 { font-size: var(--fs-xs); color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; margin: 14px 0 8px; }
.sheet-x { position: sticky; top: 0; display: flex; justify-content: flex-end; margin-bottom: -28px; }
.sheet-x button { border: 0; background: var(--card-2); width: 30px; height: 30px; border-radius: 15px; cursor: pointer; font-size: 16px; line-height: 30px; padding: 0; }
@keyframes rise { from { transform: translateY(40px); opacity: .6 } to { transform: none; opacity: 1 } }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

/* ── тост, вход, загрузка ────────────────────────────── */
.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + 16px); transform: translateX(-50%); z-index: 30; background: var(--ink); color: var(--canvas); padding: 10px 16px; border-radius: var(--r-pill); font-weight: 600; font-size: var(--fs-s); box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 92vw; text-align: center; }
@media (min-width: 900px) { .toast { bottom: 28px; } }
.login { min-height: 80dvh; display: grid; place-items: center; }
.login .card { width: 100%; max-width: 380px; padding: 30px 26px; text-align: center; }
.login .mark { width: 76px; height: 76px; margin-bottom: 8px; }
.login h2 { font-size: 26px; letter-spacing: -.02em; }
.login p { color: var(--ink-3); margin: 6px 0 18px; }
.login .err { color: var(--bad); font-size: var(--fs-s); min-height: 1.4em; margin: 8px 0; }
.drop { display: block; border: 2px dashed var(--line); border-radius: var(--r-card); padding: 34px 20px; text-align: center; color: var(--ink-2); cursor: pointer; background: var(--card); transition: border-color .15s; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop .big { font-size: 34px; margin-bottom: 6px; }
.drop input { display: none; }
.res { padding: 12px 16px; border-top: 1px solid var(--line); font-size: var(--fs-s); display: flex; gap: 10px; align-items: flex-start; }
.res:first-child { border-top: 0; }
.res .ok { color: var(--good); } .res .bad { color: var(--bad); }
.bank { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; font-weight: 800; font-size: 14px; color: #fff; flex: 0 0 32px; }
.bank.alfa { background: #ef3124; } .bank.sber { background: #21a038; }
.skel { height: 120px; border-radius: var(--r-card); background: linear-gradient(90deg, var(--card), var(--card-2), var(--card)); background-size: 200% 100%; animation: sh 1.2s infinite; margin: 12px 0; }
@keyframes sh { from { background-position: 200% 0 } to { background-position: -200% 0 } }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: var(--fs-s); }
.kv:first-child { border-top: 0; }
.kv span:last-child { color: var(--ink-2); text-align: right; }
.pill { display: inline-block; padding: 2px 8px; border-radius: var(--r-pill); font-size: 11px; font-weight: 700; background: var(--card-2); color: var(--ink-2); }
.pill.warn { background: var(--bad-soft); color: var(--bad); }
