/* JetBudget — один столбец под телефон. Цвет несёт смысл: зелёный — мои деньги,
   янтарный — обязательное, красный — долг и снижение. Всё остальное — нейтральное. */

@font-face {
  font-family: "Onest";
  src: url("/fonts/onest-cyrillic-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Onest";
  src: url("/fonts/onest-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+20BD, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #F3F5F2;
  --surface: #FFFFFF;
  --sunken: #E8ECE7;
  --ink: #1A1F22;
  --muted: #667077;
  --faint: #98A1A6;
  --line: #DDE2DC;
  --money: #146C43;
  --money-bg: #E1F1E7;
  --duty: #8F5B00;
  --duty-bg: #F7EBD2;
  --debt: #B3261E;
  --debt-bg: #FBE4E1;
  --focus: #2F6FDE;

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 22px;
  --pad: 20px;
  --tabbar: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121517;
    --surface: #1B1F22;
    --sunken: #242A2E;
    --ink: #ECEFEC;
    --muted: #9AA3A8;
    --faint: #6E777C;
    --line: #2C3337;
    --money: #58C58F;
    --money-bg: #173326;
    --duty: #E2AE4A;
    --duty-bg: #372B14;
    --debt: #F07468;
    --debt-bg: #3A1E1B;
    --focus: #7EA8F5;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; white-space: nowrap; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.tone-money { color: var(--money); }
.tone-debt { color: var(--debt); }
.tone-duty { color: var(--duty); }

.boot { min-height: 100vh; display: grid; place-items: center; color: var(--faint); font-weight: 600; }

/* ---------- каркас */

.page {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 16px) var(--pad) calc(var(--tabbar) + env(safe-area-inset-bottom) + 28px);
}
.page.flow { padding-bottom: calc(env(safe-area-inset-bottom) + 28px); display: flex; flex-direction: column; }
.page.flow > .grow { flex: 1; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; margin-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: -0.01em; }
.brand svg { width: 22px; height: 22px; }
.back {
  display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 8px 4px 8px 0;
  color: var(--muted); cursor: pointer; font-size: 15px;
}
.back svg { width: 18px; height: 18px; }

h1 { font-size: 26px; line-height: 1.2; font-weight: 650; letter-spacing: -0.02em; margin: 4px 0 8px; }
h2 { font-size: 17px; font-weight: 620; margin: 28px 0 10px; }
p.lead { color: var(--muted); margin: 0 0 22px; max-width: 34em; }

/* ---------- главная */

.hero { padding: 6px 0 22px; }
.hero .label { color: var(--muted); font-size: 15px; }
.hero .big {
  font-size: clamp(38px, 13vw, 52px); line-height: 1.05; font-weight: 640; letter-spacing: -0.035em; margin-top: 4px;
}
.hero .big .kop { font-size: 0.5em; letter-spacing: -0.01em; color: var(--muted); }
.hero .note { margin-top: 10px; font-size: 13px; color: var(--faint); max-width: 30em; }

.month { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 22px; }
.stat { background: var(--surface); border-radius: var(--r-md); padding: 12px 14px; }
.stat .k { font-size: 13px; color: var(--muted); }
.stat .v { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }

.debts { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 22px; display: flex; justify-content: space-between; gap: 12px; }
.debts .k { font-size: 13px; color: var(--muted); }
.debts .v { font-size: 17px; font-weight: 600; }
.debts > div:last-child { text-align: right; }

.quick { display: flex; gap: 8px; margin-bottom: 10px; }
.quick input { flex: 1; }

/* ---------- элементы ввода */

.input, select.input, textarea.input {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 12px 14px; font-size: 16px; min-height: 48px;
}
.input:focus { border-color: var(--focus); outline: none; }
textarea.input { min-height: 80px; resize: vertical; }
.input.amount { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.field .hint { font-size: 13px; color: var(--faint); margin-top: 5px; }

.amount-hero { display: flex; align-items: baseline; gap: 8px; border-bottom: 2px solid var(--ink); padding: 6px 0; margin: 8px 0 24px; }
.amount-hero input {
  flex: 1; min-width: 0; border: 0; background: none; outline: none; padding: 0;
  font-size: 44px; font-weight: 640; letter-spacing: -0.03em; font-variant-numeric: tabular-nums;
}
.amount-hero .cur { font-size: 26px; color: var(--muted); font-weight: 500; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 560; font-size: 16px;
}
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.danger { color: var(--debt); border-color: currentColor; background: transparent; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.block { width: 100%; }
.btn.icon { width: 48px; padding: 0; }
.btn.icon svg { width: 22px; height: 22px; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.busy { opacity: 0.7; cursor: progress; }
.btn-row { display: flex; gap: 10px; margin-top: 18px; }
.btn-row > .btn { flex: 1; }
.btn-row > .btn.wide { flex: 2; }

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; font-size: 15px;
}
.pill.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pill.soft { background: var(--sunken); border-color: transparent; }
.pill .amt { color: var(--muted); }
.pill.on .amt { color: inherit; opacity: 0.75; }
.pill.add { border-style: dashed; color: var(--muted); background: transparent; }

.seg { display: flex; background: var(--sunken); border-radius: var(--r-sm); padding: 3px; gap: 3px; margin-bottom: 14px; }
.seg button { flex: 1; min-height: 40px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font-size: 15px; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 580; }

.choices { display: grid; gap: 10px; }
.choice {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  min-height: 60px; padding: 0 18px; border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-size: 18px; font-weight: 560; text-align: left;
}
.choice small { font-size: 14px; font-weight: 400; color: var(--muted); }

.divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 13px; margin: 20px 0 14px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- карточка подтверждения */

.confirm .sum { font-size: 40px; font-weight: 640; letter-spacing: -0.03em; margin: 2px 0 14px; }
.rows { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 54px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.row > .k { color: var(--muted); font-size: 14px; flex-shrink: 0; }
.row > .v { text-align: right; min-width: 0; }
.row select, .row input[type=date] { border: 0; background: transparent; text-align: right; font-size: 16px; padding: 6px 0; max-width: 100%; cursor: pointer; }
.row .linkish { background: none; border: 0; padding: 6px 0; cursor: pointer; font-size: 16px; text-align: right; }
.row.top { align-items: flex-start; }
.row.top > .k { padding-top: 10px; }
.ctx { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.ctx-edit { padding: 12px 0 4px; border-bottom: 1px solid var(--line); }
.ctx-edit .pills { margin-top: 10px; }

/* ---------- лента */

.day {
  position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; gap: 12px;
  font-size: 14px; color: var(--muted); background: var(--bg);
  padding: calc(env(safe-area-inset-top) + 10px) 0 6px; margin-top: 12px; border-bottom: 1px solid var(--line);
}
.day:first-of-type { margin-top: 0; }
.day .tot { display: flex; gap: 10px; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; }
.filter-chip svg { width: 16px; height: 16px; }
.sentinel { height: 1px; }

/* ---------- статистика */

.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.month-nav button { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); cursor: pointer; display: grid; place-items: center; }
.month-nav button svg { width: 20px; height: 20px; }
.month-nav button:disabled { opacity: .35; cursor: default; }
.month-nav .m { font-size: 18px; font-weight: 600; }
.cat { width: 100%; background: none; border: 0; padding: 10px 0 12px; text-align: left; cursor: pointer; border-bottom: 1px solid var(--line); }
.cat .top { display: flex; justify-content: space-between; gap: 12px; }
.cat .bar { height: 6px; border-radius: 3px; background: var(--sunken); margin-top: 8px; overflow: hidden; }
.cat .bar i { display: block; height: 100%; background: var(--ink); border-radius: 3px; }
.cat .share { color: var(--faint); font-size: 13px; margin-left: 8px; }
.subcats { padding: 2px 0 8px 14px; border-left: 2px solid var(--line); margin-bottom: 6px; }
.subcats .row { min-height: 40px; padding: 4px 0; font-size: 15px; }
.op { display: flex; align-items: center; gap: 12px; padding: 11px 0; width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; cursor: pointer; }
.op:last-child { border-bottom: 0; }
.op .mark { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; background: var(--sunken); color: var(--muted); }
.op .mark svg { width: 18px; height: 18px; }
.op .mark.in { background: var(--money-bg); color: var(--money); }
.op .body { flex: 1; min-width: 0; }
.op .t { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.op .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.op .a { font-size: 15px; font-weight: 560; }
.op.gone .t, .op.gone .a { text-decoration: line-through; color: var(--faint); }
.op.system .t { color: var(--muted); }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--sunken); color: var(--muted); margin-left: 6px; }
.more { margin-top: 12px; }
.linkbtn { background: none; border: 0; padding: 10px 0; color: var(--muted); cursor: pointer; font-size: 15px; }

/* ---------- счета */

.acc-group { margin-bottom: 8px; }
.acc { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; padding: 13px 0; border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer; text-align: left; }
.acc .n { font-size: 16px; }
.acc .d { font-size: 13px; color: var(--muted); }
.acc .b { font-weight: 580; }
.group-total { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); margin: 26px 0 2px; }
.group-total b { color: var(--ink); font-weight: 600; }

/* ---------- банки */

.bank { border-bottom: 1px solid var(--line); }
.bank-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; width: 100%; padding: 14px 0; background: none; border: 0; cursor: pointer; text-align: left; }
.bank-name { display: inline-flex; align-items: center; gap: 4px; font-size: 17px; font-weight: 600; }
.chev { display: inline-flex; color: var(--faint); }
.chev svg { width: 18px; height: 18px; }
.bank-sum { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; font-weight: 580; }
.bank-sum .tone-debt { font-size: 14px; font-weight: 500; }
.bank-list { padding: 0 0 6px 14px; border-left: 2px solid var(--line); margin: -4px 0 10px; }
.bank-list .acc:last-child { border-bottom: 0; }
.subhead { font-size: 14px; color: var(--muted); margin: 14px 0 0; }

/* ---------- мастер */

.steps { display: flex; gap: 6px; margin-bottom: 20px; }
.steps i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.steps i.done { background: var(--ink); }
.added { margin: 0 0 18px; }
.added .acc { cursor: default; }
.panel { background: var(--surface); border-radius: var(--r-md); padding: 16px; }
.summary .row .v { font-weight: 600; font-size: 18px; }

/* ---------- таббар, лист, тост */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar nav { max-width: 460px; margin: 0 auto; height: var(--tabbar); display: grid; grid-template-columns: repeat(4, 1fr); align-items: center; }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; color: var(--faint); font-size: 12px; }
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.on { color: var(--ink); }
.tabbar .plus { justify-self: center; width: 50px; height: 50px; border-radius: 50%; background: var(--ink); color: var(--bg); display: grid; place-items: center; border: 0; cursor: pointer; }
.tabbar .plus svg { width: 24px; height: 24px; }

.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.38); z-index: 30; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out; }
.sheet {
  width: 100%; max-width: 460px; max-height: 88vh; overflow: auto; background: var(--bg);
  border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 10px var(--pad) calc(env(safe-area-inset-bottom) + 22px);
  animation: rise .2s ease-out;
}
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 14px; }
.sheet h3 { font-size: 20px; margin: 0; font-weight: 620; min-width: 0; }
.sheet { transition: transform .15s ease-out; overflow-x: hidden; }
/* Строка с галочкой: длинная подпись переносится, а не выталкивает галочку за край экрана. */
.check-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; cursor: pointer; }
.check-row > span { flex: 1; min-width: 0; font-size: 15px; color: var(--ink); }
.check-row > span small { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.check-row input { width: 22px; height: 22px; flex-shrink: 0; margin: 0; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sheet-x { width: 40px; height: 40px; margin: -6px -8px 0 0; flex-shrink: 0; border: 0; border-radius: 50%; background: var(--sunken); color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.sheet-x svg { width: 20px; height: 20px; }
/* Страница никогда не шире экрана: длинные суммы переносятся, а не растягивают вёрстку. */
html, body { overflow-x: hidden; }
.wrap { white-space: normal; overflow-wrap: anywhere; }
.row > .v { overflow-wrap: anywhere; }

.toast {
  position: fixed; left: 12px; right: 12px; z-index: 40; max-width: 436px; margin: 0 auto;
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 12px);
  background: var(--ink); color: var(--bg); border-radius: var(--r-md);
  padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 14px; animation: rise .18s ease-out;
}
.toast.err { background: var(--debt); color: #fff; }
.toast button { background: none; border: 0; color: inherit; opacity: .75; font-weight: 600; cursor: pointer; padding: 4px 0 4px 8px; white-space: nowrap; }

.error { background: var(--debt-bg); color: var(--debt); border-radius: var(--r-sm); padding: 10px 12px; font-size: 14px; margin: 10px 0; }
.empty { color: var(--muted); padding: 24px 0; }

@keyframes rise { from { transform: translateY(16px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- вход */

.login { max-width: 360px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 18vh) var(--pad) 40px; }
.login .brand { font-size: 26px; margin-bottom: 28px; }
.login .brand svg { width: 30px; height: 30px; }

/* ---------- лимит */

.meter { height: 8px; border-radius: 4px; background: var(--sunken); margin-top: 12px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--money); border-radius: 4px; transition: width .3s; }
.meter i.over { background: var(--debt); }
.free-line { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 15px; }
.upcoming { border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 14px; margin-bottom: 22px; }
.upcoming .k { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.upcoming .u { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: 15px; }
.hint-card { display: block; background: var(--sunken); color: var(--ink); text-decoration: none; border-radius: var(--r-md); padding: 12px 14px; font-size: 14px; margin-bottom: 22px; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.days button { min-height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 15px; }
.days button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.plan { display: flex; justify-content: space-between; gap: 12px; width: 100%; padding: 12px 0; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer; }
.plan .d { font-size: 13px; color: var(--muted); }
.badge-debt { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--debt-bg); color: var(--debt); margin-left: 6px; }
.toast.good { background: var(--money); color: #fff; }

/* Пояснения по нажатию на «i» — экран без простыней текста */
.field-label { display: flex !important; align-items: center; gap: 4px; }
.info-head { display: flex; align-items: center; gap: 4px; }
.info-btn { display: inline-grid; place-items: center; width: 28px; height: 28px; margin: -6px 0; padding: 0;
  border: 0; border-radius: 50%; background: none; color: var(--faint); cursor: pointer; flex-shrink: 0; }
.info-btn svg { width: 17px; height: 17px; }
.info-btn.on { color: var(--ink); }
.info-text { font-size: 13.5px; line-height: 1.45; color: var(--muted); background: var(--sunken);
  border-radius: var(--r-sm); padding: 10px 12px; margin: 2px 0 10px; font-weight: 400; }
h2 + .info-text { margin-top: -4px; }
.month-days { margin-bottom: 6px; }
.month-days button { min-height: 38px; font-variant-numeric: tabular-nums; }
.days-note { font-size: 13px; color: var(--muted); margin: 4px 0 14px; min-height: 1.2em; }
.warn { background: var(--duty-bg); color: var(--duty); border-radius: var(--r-sm); padding: 10px 12px; font-size: 14px; margin-top: 14px; }

/* Статистика: итог периода, «куда ушли деньги», цена долга, капитал, запас прочности */
.verdict { padding: 4px 0 20px; }
.verdict .label { color: var(--muted); font-size: 15px; }
.verdict .big { font-size: 44px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.1; margin: 4px 0 2px; }
.verdict .rate { max-width: 360px; }
.verdict-note { font-size: 15px; margin-top: 10px; }
.meter { position: relative; }
.meter .goal { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: .5; border-radius: 1px; }
.card { background: var(--surface); border-radius: var(--r-lg); padding: 16px 16px 14px; margin-bottom: 12px; }
.card.good { background: var(--money-bg); }
.card-title { font-weight: 600; margin-bottom: 2px; }
.card .info-head { font-size: 16px; font-weight: 600; }
.big-sm { font-size: 28px; font-weight: 640; letter-spacing: -0.02em; line-height: 1.2; }
.big-sm .unit { font-size: 17px; font-weight: 500; color: var(--muted); }
.alloc { display: flex; gap: 2px; height: 14px; border-radius: 7px; overflow: hidden; background: var(--surface); }
.alloc i { display: block; min-width: 4px; }
.g-saved { background: var(--money); }
.g-fixed { background: var(--duty); }
.g-life { background: var(--faint); }
/* Долг ещё и штрихуется: красный рядом с зелёным и янтарным не все различают по цвету. */
.g-debt { background: var(--debt) repeating-linear-gradient(135deg, transparent 0 3px, rgba(255,255,255,.45) 3px 5px); }
.alloc-rows { margin-top: 10px; }
.alloc-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; padding: 9px 0;
  background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; cursor: pointer; font-size: 15px; }
.alloc-row:last-child { border-bottom: 0; }
.alloc-row:disabled { cursor: default; opacity: 1; }
.alloc-row .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: 0; }
.debt-line { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 15px; white-space: normal; }
.spark-wrap { position: relative; margin-top: 10px; }
.spark { display: block; width: 100%; height: 96px; touch-action: pan-y; cursor: crosshair; overflow: visible; }
.spark-line { fill: none; stroke: var(--money); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark-line.down { stroke: var(--debt); }
.spark-zero { stroke: var(--line); stroke-dasharray: 3 3; }
.spark-cross { stroke: var(--faint); stroke-width: 1; }
.spark-tip { position: absolute; top: 0; transform: translate(-50%, 0); background: var(--ink); color: var(--bg);
  font-size: 12px; padding: 3px 8px; border-radius: 6px; pointer-events: none; }
.meter.cushion { margin-top: 10px; }
.scale { position: relative; height: 16px; font-size: 12px; margin-top: 4px; }
.scale span { position: absolute; top: 0; }
.scale span:nth-child(2) { left: 50%; transform: translateX(-50%); }
.scale span:nth-child(3) { right: 0; }

/* Выбор категорий у нижнего края — в зоне большого пальца. Раскладкой, без position: fixed,
   чтобы при открытой клавиатуре поле ввода оставалось видно. */
.thumb { margin-top: auto; padding-top: 12px; }
.thumb-title { font-size: 22px; margin: 18px 0 12px; }
.thumb-nav { display: flex; margin-top: 18px; padding-top: 4px; }
.thumb-nav .back { min-height: 48px; padding: 0 14px 0 2px; }

/* Категории v2: иконки, подсказки при создании, шаблоны, управление */
.ci { flex-shrink: 0; }
.pill .ci { margin: 0 6px 0 -2px; vertical-align: -3px; color: var(--muted); }
.pill.on .ci { color: inherit; }
.newcat { flex-basis: 100%; }
.hint-box { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; justify-content: space-between;
  background: var(--sunken); border-radius: var(--r-sm); padding: 10px 12px; margin-bottom: 10px; font-size: 14px; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.tpl-list .check-row.hl { background: var(--money-bg); border-radius: var(--r-sm); padding-left: 8px; padding-right: 8px; }
.tpl-list .check-row .ci { vertical-align: -3px; margin-right: 4px; color: var(--muted); }
.tag.on { background: var(--money-bg); color: var(--money); }
.cat-name { display: inline-flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; font: inherit;
  font-size: 17px; font-weight: 600; cursor: pointer; text-align: left; color: inherit; flex-wrap: wrap; }
.cat-name .ci { color: var(--muted); }
.cat-head { display: flex; gap: 10px; margin-bottom: 12px; }
.cat-head .input { flex: 1; }
.icon-pick { width: 48px; height: 48px; flex-shrink: 0; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); display: grid; place-items: center; cursor: pointer; color: inherit; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 6px; }
.icon-grid button { height: 48px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; color: inherit; }
.icon-grid button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.menu { display: flex; flex-direction: column; border-top: 1px solid var(--line); margin-top: 12px; }
.menu > button, .menu > a, .menu .menu-btn { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  min-height: 48px; padding: 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none;
  font: inherit; font-size: 16px; color: inherit; text-align: left; cursor: pointer; text-decoration: none; width: 100%; }
.menu .menu-btn { justify-content: flex-start; font-weight: 400; }
.menu > .danger { color: var(--debt); }
.menu .faint { font-size: 13px; }
.target-list { max-height: 55vh; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.target-list .acc:disabled { opacity: .4; cursor: default; }
.picker-btn { display: flex; align-items: center; gap: 8px; text-align: left; cursor: pointer; background: var(--surface); }
.picker-btn .ci { color: var(--muted); }

/* Крупные траты (§8): от светло-красного (×1) к насыщенному (×100). --li — интенсивность 0…1. */
.op.large .mark { background: color-mix(in srgb, var(--debt) calc(14% + 70% * var(--li)), var(--debt-bg)); color: var(--debt); }
.op.large .mark svg { color: color-mix(in srgb, var(--surface) calc(100% * var(--li)), var(--debt)); }
.op .a { text-align: right; }
.large-badge { display: block; margin-top: 2px; font-size: 12px; font-weight: 600; white-space: nowrap; text-align: right;
  color: color-mix(in srgb, var(--debt) calc(55% + 45% * var(--li)), var(--muted)); }
.op .a .large-badge { font-variant-numeric: tabular-nums; }
.large-note .large-badge { display: inline; margin: 0 4px 0 0; }

/* Статистика за любой период (правка 1, §2) */
.period-pills { margin: -4px 0 12px; }
.period-pills .pill { min-height: 36px; font-size: 14px; }
.period-dates { display: flex; gap: 10px; margin: 0 0 12px; flex-wrap: wrap; }
.period-dates label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }
.period-dates input { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; min-height: 40px; }
.totals3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 16px; }
.totals3 > div { background: var(--surface); border-radius: var(--r-md); padding: 10px 12px; min-width: 0; }
.totals3 .k { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.totals3 b { display: block; font-size: 14px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tgroup { display: flex; gap: 8px; margin: 0 0 10px; }
.tgroup label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.tgroup select { font: inherit; font-size: 15px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; min-height: 42px; width: 100%; }
.ttotal { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); font-weight: 600; }
.trow { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; width: 100%; padding: 9px 0 8px; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; cursor: pointer; color: var(--ink); font: inherit; font-size: 15px; }
.trow .tlabel { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow .tlabel .ci { margin-right: 6px; vertical-align: -3px; color: var(--muted); }
.trow .tval { white-space: nowrap; }
.trow .tbar { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: var(--sunken); overflow: hidden; }
.trow .tbar i { display: block; height: 100%; background: var(--ink); opacity: .55; border-radius: 2px; }
.trow.none .tlabel { color: var(--muted); font-style: italic; }
.trow.none .tbar i { opacity: .25; }
.trow[aria-expanded="true"] { font-weight: 580; }
.tchildren, .tops { padding-left: 14px; border-left: 2px solid var(--line); margin: 0 0 6px 2px; }
.tnode.d1 .trow { font-size: 14px; }
.tops .op { padding: 8px 0; }

/* Достижения (правка 1, §3): золото медалей — те же тона, что «обязательное». */
.ach-page h2 { margin: 26px 0 10px; }
.ach-top { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; }
.ach-top h1 { margin: 0; font-size: 18px; text-align: center; }
.days-card { --gold: #E2B65E; background: #17191A; color: #F4F2EC; border-radius: var(--r-lg); padding: 18px 20px 20px; }
:root[data-theme="dark"] .days-card { background: #0C0E0F; border: 1px solid var(--line); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .days-card { background: #0C0E0F; border: 1px solid var(--line); } }
.days-card .dc-k { font-size: 13px; color: #A6A9A6; }
.days-card .dc-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.days-card .dc-n { font-size: 52px; font-weight: 750; line-height: 1.05; letter-spacing: -0.02em; }
.days-card .dc-next { font-size: 13px; color: #A6A9A6; text-align: right; }
.days-card .dc-bar { height: 6px; border-radius: 3px; background: #33373A; margin: 14px 0 0; overflow: hidden; }
.days-card .dc-bar i { display: block; height: 100%; background: var(--gold); border-radius: 3px; }
.days-card .dc-medals { display: flex; justify-content: space-between; gap: 6px; margin-top: 16px; }
.medal { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700;
  border: 1.5px dashed #4A4E51; color: #7E8285; font-variant-numeric: tabular-nums; }
.medal.on { background: var(--gold); border: 0; color: #2A1F08; }
.medal.next { border: 2px solid var(--gold); color: var(--gold); }
.days-card.compact { padding: 14px 18px 16px; margin: 18px 0 4px; }
.days-card.compact .dc-n { font-size: 34px; }
.days-card.compact .dc-bar { margin-top: 10px; }
.days-link { display: block; text-decoration: none; color: inherit; }
.no-spend { display: block; margin: 8px 0 0; font-size: 15px; }
.streaks { display: flex; flex-direction: column; gap: 8px; }
.streak { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; }
.streak .st-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: var(--money-bg); color: var(--money); }
.streak .st-body { flex: 1; min-width: 0; }
.streak .st-t { display: block; font-size: 15px; font-weight: 600; }
.streak .st-s { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.streak .st-v { white-space: nowrap; font-size: 13px; color: var(--muted); }
.streak .st-v b { font-size: 21px; color: var(--ink); font-weight: 750; }
.streak.frozen { background: var(--sunken); border-style: dashed; }
.streak.frozen .st-icon { background: var(--line); color: var(--muted); }
.streak.frozen .st-t, .streak.frozen .st-v b { color: var(--muted); }
.streak .st-pause { margin-right: 8px; font-weight: 700; letter-spacing: -1px; }
.ach-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 10px 20px; }
.ach { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; }
.ach-ring { position: relative; width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; background: var(--sunken); color: var(--faint); border: 1.5px solid var(--line); margin-bottom: 8px; }
.ach.on .ach-ring { background: var(--duty-bg); color: var(--duty); border-color: color-mix(in srgb, var(--duty) 45%, var(--duty-bg)); }
.ach-count { position: absolute; right: -6px; bottom: -2px; background: var(--ink); color: var(--bg); font-size: 11px; font-weight: 700; border-radius: 10px; padding: 1px 6px; }
.ach-t { font-size: 14px; font-weight: 650; line-height: 1.2; }
.ach:not(.on) .ach-t { color: var(--muted); }
.ach-c { font-size: 12px; color: var(--muted); line-height: 1.3; margin-top: 4px; }
.new-ach { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0 0 4px; }
.new-ach .na-k { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--duty); }
.new-ach .na-ring { width: 128px; height: 128px; border-radius: 50%; display: grid; place-items: center; margin: 18px 0;
  background: var(--duty-bg); color: var(--duty); border: 3px solid color-mix(in srgb, var(--duty) 45%, var(--duty-bg)); }
.new-ach .na-t { font-size: 26px; font-weight: 750; }
.new-ach .na-c { font-size: 15px; color: var(--muted); margin-top: 6px; }
.new-ach .btn-row { width: 100%; margin-top: 22px; }

/* Медалька дней в шапке главной: одно число, без подписей. Видимая часть — 28px, как шестерёнка настроек
   справа; зона нажатия — те же 48px, что у кнопки, за счёт невидимого ::before. Отступ слева зеркалит
   отступ шестерёнки от правого края. */
.home-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.home-top > a.btn.icon { justify-self: end; }
.days-medal { position: relative; min-width: 28px; height: 28px; padding: 0 7px; margin-left: 10px; border-radius: 14px;
  display: grid; place-items: center; box-sizing: border-box;
  background: var(--duty-bg); color: var(--duty); border: 1.5px solid color-mix(in srgb, var(--duty) 55%, var(--duty-bg));
  font-size: 13px; font-weight: 750; line-height: 1; text-decoration: none; }
.days-medal::before { content: ""; position: absolute; inset: -10px; }
.days-medal:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button.streak { width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.streak-about { font-size: 15px; line-height: 1.5; }
.streak-about .sa-v { font-size: 34px; font-weight: 750; line-height: 1.1; }
.streak-about p { margin: 12px 0 0; }
.ach:not(.on) .ach-t { margin-top: 0; }

/* Шапка главной: медалька слева, логотип по центру, настройки справа. */
.home-top .home-left { justify-self: start; display: flex; align-items: center; min-height: 48px; }
.home-top .brand { justify-self: center; }

/* Лента: поиск и фильтры */
.feed-search { position: relative; margin: -6px 0 10px; }
.feed-search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--faint); pointer-events: none; }
.feed-search .input { padding-left: 42px; width: 100%; box-sizing: border-box; }
.feed-search .input::-webkit-search-cancel-button { cursor: pointer; }
.feed-filters { margin: 0 0 14px; }
.feed-filters .pill { min-height: 36px; font-size: 14px; }
a.pill { color: inherit; text-decoration: none; display: inline-flex; align-items: center; }
a.pill.on { color: var(--bg); }
