@font-face { font-family: 'Golos Text'; font-weight: 400 700; font-display: swap; src: url(../fonts/GolosText-cyr.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Golos Text'; font-weight: 400 700; font-display: swap; src: url(../fonts/GolosText-lat.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: 'Unbounded'; font-weight: 400 800; font-display: swap; src: url(../fonts/Unbounded-cyr.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Unbounded'; font-weight: 400 800; font-display: swap; src: url(../fonts/Unbounded-lat.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+2212; }

:root {
  --bg: #f4f1ea; --card: #fffdf8; --ink: #1f2a24; --sub: #66736b; --line: #e3ddd0;
  --accent: #2f6b4f; --accent-soft: #e2efe7; --warn: #c98a12; --warn-soft: #fbf0d6; --over: #c0472f; --over-soft: #f8e1db;
  --radius: 20px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: 'Golos Text', system-ui, sans-serif; background: var(--bg); color: var(--ink); line-height: 1.45; -webkit-font-smoothing: antialiased; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
button, input, select { font: inherit; color: inherit; }
h1, h2, .tile b { font-family: 'Unbounded', 'Golos Text', sans-serif; letter-spacing: -.02em; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

.demo-bar { background: var(--ink); color: #dfe8e2; font-size: 12px; text-align: center; padding: 7px 16px; }
.demo-bar b { color: #fff; }

.top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 14px; padding-top: 22px; padding-bottom: 18px; }
.top h1 { font-size: clamp(20px, 3vw, 28px); margin-bottom: 8px; }
.month { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.month button { width: 36px; height: 36px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--card); font-size: 20px; line-height: 1; cursor: pointer; }
.month span { min-width: 136px; text-align: center; }
.who { display: inline-flex; padding: 4px; gap: 4px; background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; }
.who button { border: 0; background: none; padding: 8px 14px; border-radius: 10px; font-weight: 600; font-size: 14px; cursor: pointer; }
.who button[aria-pressed="true"] { background: var(--ink); color: #fff; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.sum { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tile { background: var(--card); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 4px; }
.tile span { font-size: 13px; color: var(--sub); }
.tile b { font-size: clamp(18px, 2.6vw, 26px); font-variant-numeric: tabular-nums; }
.tile small { font-size: 12px; color: var(--sub); }
.tile.accent { background: var(--accent); color: #fff; }
.tile.accent span, .tile.accent small { color: #cfe5d8; }

.card { background: var(--card); border-radius: var(--radius); padding: 18px; }
.card__head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.card h2 { font-size: 16px; }
.hint { font-size: 12px; color: var(--sub); }
.history { grid-row: span 3; grid-column: 2; grid-row-start: 2; }

.cats, .bills, .goals, .tx { list-style: none; }
.cat { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 10px; margin: 0 -10px; border: 0; background: none; border-radius: 12px; text-align: left; cursor: pointer; }
.cat:hover, .cat.on { background: var(--accent-soft); }
.cat__name { font-weight: 600; font-size: 14px; }
.cat__sum { font-size: 13px; font-variant-numeric: tabular-nums; }
.cat__sum small { color: var(--sub); }
.bar { grid-column: 1 / -1; height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; display: block; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .4s ease; }
.bar.big { height: 10px; margin: 8px 0 4px; }
.cat.warn .bar i { background: var(--warn); }
.cat.over .bar i { background: var(--over); }
.cat.over .cat__sum { color: var(--over); font-weight: 600; }

.bills li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.bills li:last-child { border-bottom: 0; }
.bills span { display: grid; font-weight: 600; font-size: 14px; }
.bills small { font-weight: 400; color: var(--sub); font-size: 12px; }
.bills .soon small { color: var(--warn); font-weight: 600; }
.bills .late small { color: var(--over); font-weight: 600; }
.bills .paid span { color: var(--sub); text-decoration: line-through; }
.chk { width: 32px; height: 32px; flex: none; border-radius: 10px; border: 1.5px solid var(--line); background: var(--card); font-weight: 700; color: #fff; cursor: pointer; }
.chk[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }

.goals li { padding: 8px 0 12px; }
.goal__top { display: flex; justify-content: space-between; font-weight: 600; font-size: 14px; }
.goals small { font-size: 12px; color: var(--sub); font-variant-numeric: tabular-nums; }

.tx li { display: grid; grid-template-columns: 36px 1fr auto 28px; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.tx .ic { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 12px; background: var(--bg); }
.tx__main { display: grid; min-width: 0; }
.tx__main b { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx__main small { font-size: 12px; color: var(--sub); }
.tx__main i { font-style: normal; font-weight: 600; }
.tx__sum { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx__sum.in { color: var(--accent); }
.del { width: 28px; height: 28px; border: 0; border-radius: 8px; background: none; color: var(--sub); font-size: 18px; cursor: pointer; opacity: .5; }
.del:hover, .del:focus-visible { opacity: 1; background: var(--over-soft); color: var(--over); }
.empty { color: var(--sub); padding: 16px 0; }
.tools { display: flex; justify-content: space-between; padding-top: 12px; }
.link { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 13px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.fab { position: fixed; right: max(16px, calc(50% - 524px)); bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 5; border: 0; border-radius: 18px; min-height: 56px; padding: 0 24px; background: var(--accent); color: #fff; font-weight: 700; font-size: 16px; box-shadow: 0 14px 30px -12px rgba(47, 107, 79, .7); cursor: pointer; }
.fab:active { transform: scale(.97); }

dialog { border: 0; border-radius: 24px; padding: 22px; width: calc(100% - 24px); max-width: 440px; background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(31, 42, 36, .45); }
dialog h2 { font-size: 18px; margin-bottom: 14px; }
.field { display: grid; gap: 6px; margin-bottom: 12px; font-size: 13px; color: var(--sub); }
.field input, .field select { height: 46px; border: 1.5px solid var(--line); border-radius: 12px; padding: 0 12px; background: #fff; color: var(--ink); font-size: 16px; width: 100%; }
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.seg input, .chip input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.seg label { text-align: center; padding: 9px; border-radius: 9px; font-weight: 600; cursor: pointer; }
.seg input:checked + label { background: var(--card); box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
.seg input:focus-visible + label, .chip input:focus-visible + label { outline: 3px solid rgba(47, 107, 79, .35); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip label { display: inline-block; padding: 7px 11px; border: 1.5px solid var(--line); border-radius: 99px; font-size: 13px; color: var(--ink); cursor: pointer; }
.chip input:checked + label { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.error { color: var(--over); font-size: 13px; min-height: 1.2em; }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.btn { min-height: 46px; padding: 0 20px; border-radius: 12px; border: 0; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; }
.btn.ghost { background: none; border: 1.5px solid var(--line); color: var(--ink); }

.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 6; }

.foot { padding-top: 24px; padding-bottom: 16px; }
.credit { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-size: 13px; color: #c9d6cf; background: var(--ink); padding: 10px 14px; border-radius: 14px; }
.credit img { width: 150px; height: auto; display: block; }

@media (max-width: 820px) {
  .grid { grid-template-columns: 1fr; }
  .history { grid-column: auto; grid-row: auto; }
}
@media (max-width: 520px) {
  .sum { grid-template-columns: 1fr 1fr; }
  .tile.accent { grid-column: 1 / -1; }
  .who button { padding: 8px 10px; }
}
@media (prefers-reduced-motion: reduce) { .bar i { transition: none; } }
