/* Финансы — «банкнотная» палитра: холодная бумага, зелёные чернила, янтарь для крупных покупок.
   Своя палитра вместо темы Telegram; светлая/тёмная выбираются по Telegram.colorScheme (data-theme). */
:root {
  color-scheme: light;
  --bg: #f1f4f0;
  --card: #ffffff;
  --sunk: #e6ebe5;
  --text: #13231c;
  --hint: #66766e;
  --line: #dce3dc;
  --accent: #1e6a4c;
  --accent-text: #ffffff;
  --accent-soft: #dcebe2;
  --link: #1e6a4c;
  --good: #1e6a4c;
  --amber: #c27a0b;
  --danger: #b4372f;
  --series-1: #1e6a4c;
  --shadow: 0 1px 0 rgba(19, 35, 28, .06);
  --display: "Unbounded", "Onest", system-ui, sans-serif;
  --body: "Onest", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1511;
  --card: #15201a;
  --sunk: #1c2a23;
  --text: #e4ede7;
  --hint: #8c9e94;
  --line: #24332b;
  --accent: #4bbd8a;
  --accent-text: #0b1a13;
  --accent-soft: #1d3a2c;
  --link: #6fd0a3;
  --good: #6fd0a3;
  --amber: #e2a33c;
  --danger: #f07a6f;
  --series-1: #4bbd8a;
  --shadow: none;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 400 15px/1.45 var(--body);
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  overscroll-behavior-y: contain;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

#screen { padding: 14px 16px 28px; max-width: 640px; margin: 0 auto; }

/* Заголовок раздела: Unbounded, без капса */
h2 { font: 600 15px/1.2 var(--display); letter-spacing: -.01em; margin: 30px 2px 12px; }
.card { background: var(--card); border-radius: 18px; padding: 16px; box-shadow: var(--shadow); }
.muted { color: var(--hint); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; color: var(--hint); padding: 28px 16px; line-height: 1.5; }

/* --- Шапка месяца --- */
.month-switch { display: flex; align-items: baseline; gap: 8px; margin: 2px 2px 18px; }
.month-switch b { font: 700 24px/1.1 var(--display); letter-spacing: -.02em; text-transform: capitalize; }
.month-switch .year { color: var(--hint); font: 500 15px var(--display); }
.month-switch .arrows { margin-left: auto; display: flex; gap: 6px; align-self: center; }
.icon-btn { border: 0; background: var(--card); width: 36px; height: 36px; border-radius: 50%;
            display: grid; place-items: center; box-shadow: var(--shadow); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:disabled { opacity: .3; }

/* --- Капитал --- */
.capital { padding: 4px 2px 0; }
.capital .label { color: var(--hint); font-size: 14px; }
.capital .value { font: 700 40px/1.05 var(--display); letter-spacing: -.035em; margin: 6px 0 8px;
                  font-variant-numeric: tabular-nums; }
.capital .value small { font-size: 18px; letter-spacing: 0; color: var(--hint); font-weight: 500; margin-left: 6px; }
.capital .meta { color: var(--hint); font-size: 13px; }
.capital .meta b { color: var(--text); font-weight: 600; }

/* --- Итог месяца одной полосой --- */
.flow { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--card); border-radius: 18px;
        margin-top: 18px; box-shadow: var(--shadow); }
.flow > div { padding: 13px 14px; min-width: 0; }
.flow > div + div { border-left: 1px solid var(--line); }
.flow .label { color: var(--hint); font-size: 12.5px; }
.flow .value { font: 600 16px/1.3 var(--display); letter-spacing: -.02em; margin-top: 3px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.flow .value.in { color: var(--good); }
.flow .note { color: var(--hint); font-size: 12px; margin-top: 2px; }

/* --- Столбики по дням --- */
.chart-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.chart-head .muted { font-size: 13px; }
.columns { position: relative; height: 132px; display: flex; align-items: flex-end; gap: 2px;
           border-bottom: 1px solid var(--line); margin-top: 14px; padding-left: 30px; }
.columns .col { flex: 1; height: 100%; display: flex; align-items: flex-end; position: relative; }
.columns .col i { display: block; width: 100%; background: var(--series-1); border-radius: 4px 4px 0 0; transition: opacity .15s; }
.columns .col.zero i { background: transparent; }
.columns .col.today i { background: var(--amber); }
.columns.has-active .col:not(.active) i { opacity: .35; }
.columns .gridline { position: absolute; left: 30px; right: 0; border-top: 1px dashed var(--line); pointer-events: none; }
.columns .gridline span { position: absolute; right: calc(100% + 5px); top: -8px; font-size: 11px; color: var(--hint); font-variant-numeric: tabular-nums; }
.axis { position: relative; height: 16px; font-size: 11px; color: var(--hint); margin: 5px 0 0 30px; }
.axis span { position: absolute; transform: translateX(-50%); }

/* --- Чек за месяц: главная деталь --- */
.receipt { position: relative; background: var(--card); border-radius: 18px 18px 0 0; padding: 20px 18px 14px;
           margin-bottom: 12px; }
.receipt::after { content: ""; position: absolute; left: 0; right: 0; bottom: -10px; height: 10px;
  background: linear-gradient(135deg, var(--card) 50%, transparent 50%) 0 0 / 14px 10px repeat-x,
              linear-gradient(-135deg, var(--card) 50%, transparent 50%) 0 0 / 14px 10px repeat-x; }
.receipt .head { text-align: center; padding-bottom: 14px; border-bottom: 1px dashed var(--line); margin-bottom: 12px; }
.receipt .head b { display: block; font: 600 15px var(--display); letter-spacing: -.01em; }
.receipt .head span { color: var(--hint); font-size: 13px; }
.receipt .line { display: flex; align-items: baseline; gap: 6px; padding: 5px 0; font-size: 14.5px; }
.receipt .line .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 62%; }
.receipt .line .dots { flex: 1; border-bottom: 1.5px dotted var(--line); transform: translateY(-4px); min-width: 12px; }
.receipt .line .share { color: var(--hint); font-size: 12px; width: 32px; text-align: right; }
.receipt .line.major .name { color: var(--amber); }
.receipt .total { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px dashed var(--line);
                  margin-top: 10px; padding-top: 12px; }
.receipt .total b { font: 700 18px var(--display); letter-spacing: -.02em; }
.receipt .sub-total { display: flex; justify-content: space-between; font-size: 13px; color: var(--hint); padding-top: 4px; }
.toggle-link { border: 0; background: none; color: var(--link); padding: 8px 0 2px; font-size: 14px; font-weight: 500; }

/* --- Доходы: полосы --- */
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar .top { display: flex; justify-content: space-between; gap: 8px; font-size: 14.5px; }
.bar .track { height: 6px; border-radius: 3px; background: var(--sunk); margin-top: 6px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--series-1); border-radius: 0 3px 3px 0; }

/* --- Списки --- */
.list { background: var(--card); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; width: 100%; border: 0; background: none; text-align: left; }
.item + .item { border-top: 1px solid var(--line); }
.item .ico { width: 38px; height: 38px; border-radius: 12px; background: var(--sunk); display: grid; place-items: center; font-size: 18px; flex: none; }
.item .title { font-weight: 500; }
.item .sub { color: var(--hint); font-size: 13px; }
.item .chev { color: var(--hint); font-size: 18px; }
.amount-in { color: var(--good); }
.accounts .item .num { font-weight: 600; }
.accounts .item .neg { color: var(--danger); }
.day-head { display: flex; justify-content: space-between; margin: 22px 4px 8px; font-size: 13.5px; }
.day-head span:first-child { font-weight: 600; }
.day-head span:last-child { color: var(--hint); }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--line); background: var(--card); padding: 7px 13px; border-radius: 999px; white-space: nowrap; font-size: 14px; }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.wrap { flex-wrap: wrap; overflow: visible; }

/* --- Формы --- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--sunk); border-radius: 14px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: none; padding: 9px 4px; border-radius: 11px; font-size: 14px; font-weight: 500; color: var(--hint); }
.seg button.active { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.field { margin-top: 18px; }
.field > label { display: block; font-size: 13px; color: var(--hint); margin: 0 4px 8px; }
.input { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 12px 14px; outline: none; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.amount-wrap { background: var(--card); border-radius: 20px; position: relative; box-shadow: var(--shadow); }
.amount-wrap .big-amount { font: 700 40px/1.1 var(--display); letter-spacing: -.03em; text-align: center; padding: 22px 14px;
                           border: 0; background: none; box-shadow: none; border-radius: 20px; }
.amount-wrap .cur { position: absolute; right: 16px; bottom: 12px; color: var(--hint); font: 500 13px var(--display); }
.check { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.field > label.check { margin: 0; font-size: 15px; color: var(--text); }
.btn { display: block; width: 100%; border: 0; border-radius: 16px; padding: 15px; font-weight: 600; font-size: 16px;
       background: var(--accent); color: var(--accent-text); margin-top: 20px; }
.btn.secondary { background: var(--card); color: var(--text); border: 1px solid var(--line); margin-top: 10px; font-size: 15px; padding: 12px; }
.btn.danger { background: none; color: var(--danger); margin-top: 6px; }
.btn:disabled { opacity: .5; }
.hint-line { font-size: 13px; color: var(--hint); margin: 8px 4px 0; line-height: 1.45; }

/* --- Нижняя панель --- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr);
          background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
          border-top: 1px solid var(--line); padding: 7px 4px calc(7px + env(safe-area-inset-bottom)); z-index: 10; }
.tabbar button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 3px;
                 font-size: 11px; font-weight: 500; color: var(--hint); padding: 3px 0; }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button.active { color: var(--accent); }
.tabbar button.active svg { stroke-width: 2.2; }

/* --- Шторка, тост, подсказка --- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(8, 18, 13, .45); z-index: 20; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 90vh; overflow-y: auto; z-index: 21;
         background: var(--bg); border-radius: 24px 24px 0 0; padding: 10px 16px calc(22px + env(safe-area-inset-bottom));
         max-width: 640px; margin: 0 auto; animation: up .2s cubic-bezier(.2, .8, .2, 1); }
.sheet .grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.sheet h3 { margin: 0 4px 4px; font: 600 19px var(--display); letter-spacing: -.02em; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 30;
         background: var(--text); color: var(--bg); padding: 13px 16px; border-radius: 14px; text-align: center; font-weight: 500;
         max-width: 480px; margin: 0 auto; animation: up .2s ease-out; }
.tooltip { position: fixed; z-index: 25; background: var(--text); color: var(--bg); padding: 6px 10px;
           border-radius: 9px; font-size: 13px; font-weight: 500; pointer-events: none; transform: translate(-50%, -100%); white-space: nowrap; }
.skeleton { height: 120px; border-radius: 18px; background: var(--card); opacity: .55; margin-top: 12px; }
.amount-wrap .big-amount:focus::placeholder { color: transparent; }
