/* Личные деньги — вид «А, карта трат». Шрифт Geologica лежит локально.
   Правила крупности: текст не мельче 17 px, всё нажимаемое — не меньше 56 px. */
@font-face { font-family: 'Geologica'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(../fonts/geologica-cyrillic-wght.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Geologica'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(../fonts/geologica-latin-ext-wght.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Geologica'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(../fonts/geologica-latin-wght.woff2) format('woff2');
  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+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --ink: #17302A; --quiet: #55645E; --paper: #EDF1EC; --line: #D8DED6; --white: #fff;
  --c-food: #BCD3B1; --c-kids: #AECADB; --c-car: #E6CB88; --c-cafe: #E9BDAD; --c-home: #A5D0C6; --c-other: #D5D9D1;
  --cash-border: #6F8A7C; --warn: #F3DDA4; --bad: #B4472F; --warn-ink: #8A5A12;
  --top: max(18px, env(safe-area-inset-top)); --bottom: max(10px, env(safe-area-inset-bottom));
  --tap: 56px;
  color-scheme: light;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: var(--paper); }
body { color: var(--ink); font-family: 'Geologica', system-ui, sans-serif; font-size: 19px; line-height: 1.3;
  -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; text-align: inherit; touch-action: manipulation; }
input { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

#app { height: 100%; max-width: 480px; margin: 0 auto; }
.screen { height: 100%; display: flex; flex-direction: column; padding: var(--top) 16px var(--bottom); overflow: hidden; }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; min-height: 0; margin: 0 -16px; padding: 0 16px; }

/* ---------- главный экран ---------- */
.top { display: flex; align-items: center; gap: 6px; min-height: var(--tap); padding-left: 6px; flex: none; }
.lbl { font-size: 21px; font-weight: 500; color: var(--quiet); flex: 1; }
.round { width: var(--tap); height: var(--tap); border-radius: 28px; display: grid; place-items: center; background: rgba(23,48,42,.06); font-size: 28px; font-weight: 600; color: var(--ink); flex: none; }
.round:disabled { opacity: .25; }
.big { font-size: 62px; font-weight: 800; letter-spacing: -.025em; line-height: 1.12; padding: 0 6px; white-space: nowrap; flex: none; overflow: hidden; }
.big.s56 { font-size: 56px; } .big.s50 { font-size: 50px; } .big.s44 { font-size: 44px; }
.sub { font-size: 19px; color: var(--quiet); padding: 2px 6px 0; line-height: 1.3; min-height: 25px; flex: none; }
.banner { background: var(--warn); color: var(--ink); border-radius: 16px; padding: 14px; font-size: 18px; font-weight: 500; margin-bottom: 10px; line-height: 1.25; display: block; width: 100%; min-height: var(--tap); flex: none; }
.map { flex: 1; position: relative; margin: 12px -3px 8px; min-height: 120px; }
.screen.main { overflow-y: auto; } /* крайний случай (несколько плашек на iPhone SE): прокрутка, а не обрезка */
.tile { position: absolute; padding: 3px; }
.tile > div { width: 100%; height: 100%; border-radius: 20px; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; gap: 4px; }
/* имя не сжимается и не пропадает: до двух строк, потом — одна с многоточием. Слово посреди не рвётся:
   раскладка даёт плитке ширину самого длинного слова; не вышло — тогда уж перенос с дефисом (.squeeze) */
.tile b { flex: none; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
  font-weight: 500; font-size: 19px; line-height: 1.15; overflow-wrap: normal; word-break: normal; }
.tile b.squeeze, .cats button.squeeze { overflow-wrap: anywhere; hyphens: auto; -webkit-hyphens: auto; }
.tile b.one { -webkit-line-clamp: 1; }
.tile .bottom { flex: none; min-width: 0; }
.tile i { font-style: normal; font-weight: 700; letter-spacing: -.015em; white-space: nowrap; line-height: 1.05; display: block; overflow: hidden; }
.tile small { font-size: 17px; line-height: 1.2; color: #30443D; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; margin-top: 3px; overflow-wrap: normal; }
.tile small.one { -webkit-line-clamp: 1; }
.tile.cash > div { background: transparent; border: 2.5px dashed var(--cash-border); }
.tile:active > div { filter: brightness(.95); }
.empty { position: absolute; inset: 3px; border-radius: 20px; border: 2.5px dashed var(--line); display: grid; place-items: center; text-align: center; color: var(--quiet); padding: 24px; font-size: 19px; }
.empty .first { display: flex; flex-direction: column; gap: 18px; align-items: stretch; font-size: 20px; line-height: 1.35; color: var(--ink); }
.empty .first .main-btn { font-size: 24px; }
/* строка состояния всегда одной высоты (56 px): текст в одну-две строки, рядом — кнопка «N непонятных» */
.status { font-size: 17px; color: var(--quiet); text-align: center; margin-bottom: 8px; display: flex; justify-content: center; align-items: center; gap: 12px; flex: none; line-height: 1.25; min-height: var(--tap); }
.status span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.status.with-btn { justify-content: space-between; }
.status.with-btn span { flex: 1 1 auto; text-align: left; padding-left: 6px; }
.status.with-btn .unclear-btn { flex: none; }
.unclear-btn { background: var(--white); color: var(--ink); min-height: var(--tap); padding: 0 18px; border-radius: 16px; font-weight: 600; font-size: 18px; }
.main-btn { height: 86px; border-radius: 26px; background: var(--ink); color: #fff; font-weight: 700; font-size: 27px; display: flex; align-items: center; justify-content: center; width: 100%; flex: none; text-align: center; padding: 0 16px; line-height: 1.15; }
.main-btn:disabled { opacity: .35; }
.main-btn.light { background: var(--white); color: var(--ink); }
.tabs { display: flex; margin-top: 8px; height: var(--tap); align-items: center; justify-content: space-around; font-size: 21px; font-weight: 500; color: var(--quiet); flex: none; }
.tabs button { min-height: var(--tap); padding: 0 16px; border-bottom: 3px solid transparent; }
.tabs .on { color: var(--ink); font-weight: 700; border-bottom-color: var(--ink); }
.tabs .gear { width: var(--tap); height: var(--tap); padding: 0; border: 0; display: grid; place-items: center; }
.tabs .gear img { width: 28px; height: 28px; opacity: .8; }

/* ---------- заголовок вложенных экранов ---------- */
.h2 { display: flex; justify-content: space-between; align-items: center; font-size: 23px; font-weight: 600; padding: 0 6px; min-height: var(--tap); gap: 10px; flex: none; }
.h2 .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h2 .link { font-size: 20px; font-weight: 500; color: var(--quiet); min-height: var(--tap); padding: 0 4px 0 16px; }
.back { font-size: 20px; font-weight: 500; color: var(--quiet); min-height: var(--tap); padding: 0 16px 0 0; display: flex; align-items: center; gap: 4px; flex: none; }
.back::before { content: '‹'; font-size: 30px; line-height: 20px; margin-top: -3px; }

/* ---------- списки трат ---------- */
.rows { display: flex; flex-direction: column; gap: 6px; margin: 14px 0 12px; }
.row { display: flex; align-items: center; gap: 12px; background: var(--white); border-radius: 18px; padding: 14px 16px; min-height: 76px; width: 100%; }
.row .l { flex: 1; min-width: 0; }
.row .l b { display: block; font-weight: 600; font-size: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .l small { display: block; font-size: 17px; color: var(--quiet); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .l small.warn { color: var(--warn-ink); white-space: normal; }
.row .r { font-weight: 700; font-size: 21px; white-space: nowrap; }
.row.off { opacity: .55; }
.row.off .r { text-decoration: line-through; }
.row .sw { width: 28px; height: 28px; border-radius: 9px; flex: none; }
.row .sw.cash { border: 2.5px dashed var(--cash-border); }
.small-btn { flex: none; min-height: var(--tap); padding: 0 16px; border-radius: 14px; background: var(--paper); font-weight: 600; font-size: 18px; color: var(--bad); }
.note { font-size: 17px; color: var(--quiet); padding: 6px 6px; line-height: 1.35; }
.raw { background: rgba(255,255,255,.6); border-radius: 14px; padding: 12px 14px; font-size: 17px; color: var(--quiet); line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; margin: 12px 0 0; }
.raw .clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.unclear { margin-bottom: 14px; }
.unclear .ask { font-size: 19px; font-weight: 600; line-height: 1.35; padding: 4px 6px 0; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.pair button { background: var(--white); min-height: 64px; border-radius: 18px; font-weight: 600; font-size: 20px; text-align: center; }

/* ---------- трата: три большие кнопки, кнопки всегда на экране ---------- */
.screen.entry .scroll { padding-bottom: 6px; }
.amount-xl { font-size: 56px; font-weight: 800; letter-spacing: -.025em; padding: 6px 6px 0; line-height: 1.1; white-space: nowrap; overflow: hidden; }
.who { font-size: 26px; font-weight: 700; padding: 10px 6px 0; line-height: 1.2; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.when2 { font-size: 18px; color: var(--quiet); padding: 4px 6px 0; }
.now-cat { display: inline-flex; align-items: center; gap: 8px; margin: 12px 6px 0; padding: 8px 14px; border-radius: 12px; font-weight: 600; font-size: 18px; }
.actions { display: flex; flex-direction: column; gap: 8px; padding-top: 10px; flex: none; }
.actions .note { padding: 0 6px; }
.act { height: 76px; border-radius: 22px; background: var(--white); font-weight: 700; font-size: 23px; display: flex; align-items: center; justify-content: center; width: 100%; text-align: center; }
.act.on { background: var(--ink); color: #fff; }
.act.danger { color: var(--bad); height: 64px; font-size: 21px; background: transparent; }
.always { display: flex; align-items: center; gap: 14px; padding: 4px 6px; font-size: 19px; font-weight: 500; min-height: var(--tap); width: 100%; }
.always .box { width: 32px; height: 32px; border-radius: 9px; border: 2.5px solid var(--ink); flex: none; display: grid; place-items: center; font-size: 22px; font-weight: 800; }
.always .what { min-width: 0; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.always.on .box { background: var(--ink); color: #fff; }
.always .box::after { content: ''; }
.always.on .box::after { content: '✓'; }

/* ---------- сетка категорий ---------- */
.cats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; flex: none; }
.cats button { height: 96px; border-radius: 20px; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 600; text-align: center; padding: 6px 6px;
  line-height: 1.15; overflow-wrap: normal; overflow: hidden; }
.cats.r3 button { height: 80px; }
.cats.r4 button { height: 66px; font-size: 19px; }
.cats.wide { grid-template-columns: repeat(2, 1fr); } /* длинные имена: два столбца, слово не рвётся */
.cats button.more { background: var(--white); color: var(--ink); }
.cats button:disabled { opacity: .45; }
.cats.all { margin-top: auto; }

/* ---------- наличные: сумма и клавиатура ----------
   Высоты не постоянные: на iPhone 16 Pro Max всё крупное, на SE сумма, плитки и клавиши ужимаются
   (клавиши не ниже 56 px), и весь экран с клавиатурой помещается. Совсем не влезло — прокрутка, а не обрезка. */
.screen.cash { overflow-y: auto; }
.sum-line { flex: 0 1 122px; min-height: 72px; display: flex; align-items: flex-end; container-type: size; }
.sum { font-size: 104px; font-size: min(104px, 84cqh, 26.1cqw); font-weight: 800; letter-spacing: -.03em; line-height: 1.1; padding: 0 6px; white-space: nowrap; }
.sum.s88 { font-size: 88px; font-size: min(88px, 84cqh, 22.1cqw); }
.sum.s72 { font-size: 72px; font-size: min(72px, 84cqh, 18.1cqw); }
.sum.s60 { font-size: 60px; font-size: min(60px, 84cqh, 15.1cqw); }
.sum.zero { color: #9AA8A1; }
.when { display: flex; justify-content: space-between; align-items: center; padding: 2px 6px 8px; font-size: 19px; color: var(--quiet); line-height: 1.3; gap: 12px; flex: none; min-height: 60px; }
.when .day { white-space: nowrap; background: var(--white); color: var(--ink); min-height: var(--tap); padding: 0 18px; border-radius: 14px; font-weight: 500; flex: none; }
.keys { margin-top: auto; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(4, minmax(56px, 1fr)); gap: 7px; padding-top: 10px;
  flex: 0 1 351px; min-height: 255px; }
.keys button { min-height: 56px; background: var(--white); border-radius: 20px; display: flex; align-items: center; justify-content: center; font-size: 36px; font-weight: 600; }
.cats.two { flex: 0 1 182px; min-height: 118px; grid-template-rows: repeat(2, minmax(56px, 1fr)); }
.cats.two button { height: auto; min-height: 56px; }
.keys button:active { background: #DDE5DC; }
.keys .q { background: transparent; color: var(--quiet); font-size: 28px; }
.keys .q img { width: 40px; height: 40px; opacity: .7; }
.screen.cash .main-btn { margin-top: auto; }
.screen.cash .main-btn + .keys { margin-top: 0; }

/* ---------- формы, вход, настройка ---------- */
.center { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 0 6px; }
.title + .text { margin-top: 10px; }
.title { font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1.12; padding: 0 6px; }
.text { font-size: 19px; color: var(--quiet); line-height: 1.38; padding: 0 6px; }
.text strong { color: var(--ink); font-weight: 600; }
.field { width: 100%; height: 72px; border-radius: 20px; border: 2.5px solid var(--line); background: var(--white); padding: 0 18px; font-size: 28px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.field.plain { text-transform: none; letter-spacing: 0; font-size: 22px; }
.field:focus { outline: none; border-color: var(--ink); }
.err { color: var(--bad); font-size: 17px; font-weight: 500; min-height: 22px; padding: 4px 6px 0; }
.code-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0; }
.code-grid div { background: var(--white); border-radius: 18px; height: 78px; display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 36px; font-weight: 700; letter-spacing: .08em; }
.code-grid div small { font-size: 17px; color: var(--quiet); letter-spacing: 0; font-weight: 500; }
.code-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 8px; }
.two .code-inputs { grid-template-columns: 1fr; }
.code-cell { display: flex; flex-direction: column; gap: 4px; }
.code-cell span { font-size: 17px; color: var(--quiet); padding: 0 6px; }
.code-inputs input { height: 68px; border-radius: 18px; border: 2.5px solid var(--line); background: var(--white); text-align: center; font-size: 30px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; width: 100%; }
.code-inputs input:focus { outline: none; border-color: var(--ink); }
.textbtn { font-size: 19px; font-weight: 500; color: var(--quiet); text-decoration: underline; text-underline-offset: 4px; min-height: var(--tap); padding: 0 12px; align-self: center; text-align: center; flex: none; }
.textbtn.left { align-self: flex-start; padding-left: 6px; }
.textbtn.danger { color: var(--bad); display: block; margin: 0 auto 6px; }
.brand { font-size: 23px; font-weight: 700; padding: 0 6px; }
.lockmark { width: 84px; height: 84px; border-radius: 26px; background: var(--white); display: grid; place-items: center; margin: 0 6px; }
.lockmark img { width: 40px; height: 40px; }

/* ---------- настройки и iPhone ---------- */
.menu { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; }
.menu button { min-height: 76px; border-radius: 18px; background: var(--white); padding: 12px 18px; font-size: 21px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 10px; }
.menu button small { font-size: 17px; color: var(--quiet); font-weight: 500; display: block; margin-top: 2px; line-height: 1.3; }
.menu button::after { content: '›'; font-size: 28px; color: var(--quiet); font-weight: 400; }
.copy { background: var(--white); border-radius: 18px; padding: 14px 16px; margin: 8px 0; display: flex; flex-direction: column; gap: 8px; }
.copy .k { font-size: 17px; color: var(--quiet); font-weight: 500; line-height: 1.35; }
.copy .v { font-size: 18px; font-weight: 600; overflow-wrap: anywhere; line-height: 1.3; }
.copy button { background: var(--ink); color: #fff; border-radius: 16px; min-height: var(--tap); padding: 0 20px; font-weight: 700; font-size: 20px; text-align: center; }
.steps { counter-reset: s; display: flex; flex-direction: column; gap: 12px; margin: 8px 0 16px; }
.steps li { list-style: none; counter-increment: s; display: flex; gap: 12px; font-size: 18px; line-height: 1.4; }
.steps li::before { content: counter(s); flex: none; width: 32px; height: 32px; border-radius: 16px; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 17px; margin-top: -2px; }
.steps b { font-weight: 600; }
.h3 { font-size: 22px; font-weight: 700; padding: 18px 6px 4px; }

/* ---------- всплывашка: над самой нижней тёмной кнопкой (место считает dom.js), не на ней ---------- */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--bottom) + 75px); background: var(--ink); color: #fff; border-radius: 20px; padding: 0 8px 0 22px; min-height: 56px; display: flex; align-items: center; gap: 6px; font-size: 18px; font-weight: 600; box-shadow: 0 10px 30px rgba(23,48,42,.25); z-index: 10; width: calc(100% - 32px); max-width: 448px; line-height: 1.25; }
.toast span { flex: 1; padding: 8px 0; }
.toast button { color: #CFE3D6; font-weight: 700; padding: 0 16px; min-height: var(--tap); border-radius: 14px; flex: none; }
.busy { position: fixed; inset: 0; background: rgba(237,241,236,.7); display: grid; place-items: center; font-size: 20px; font-weight: 600; z-index: 20; }
