/* Нативный вид Telegram: цвета темы Telegram (SDK выставляет --tg-theme-*), системный шрифт,
   сгруппированные списки как в настройках Telegram. Запасные значения — для открытия в браузере. */
:root {
  color-scheme: light;
  --bg: var(--tg-theme-secondary-bg-color, #efeff4);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --link: var(--tg-theme-link-color, #2481cc);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --section-head: var(--tg-theme-section-header-text-color, var(--hint));
  --danger: var(--tg-theme-destructive-text-color, #e53935);
  --line: color-mix(in srgb, var(--hint) 25%, transparent);
  --soft: color-mix(in srgb, var(--hint) 14%, transparent);
  --good: #31a24c;
  --series-1: var(--accent);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: var(--tg-theme-secondary-bg-color, #000000);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #1c1c1e));
  --text: var(--tg-theme-text-color, #ffffff);
  --hint: var(--tg-theme-hint-color, #8d8e93);
  --good: #4cd964;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 400 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(70px + 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: 8px 16px 24px; max-width: 640px; margin: 0 auto; }

h2 { font-size: 13px; font-weight: 400; color: var(--section-head); text-transform: uppercase; letter-spacing: .02em;
     margin: 26px 16px 7px; }
.card { background: var(--card); border-radius: 12px; padding: 14px 16px; }
.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: 26px 16px; font-size: 15px; line-height: 1.45; }

/* --- Месяц --- */
.month-switch { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 14px; }
.month-switch b { font-size: 17px; font-weight: 600; }
.icon-btn { border: 0; background: none; color: var(--link); width: 40px; height: 36px; display: grid; place-items: center; }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:disabled { color: var(--hint); opacity: .4; }

/* --- Капитал --- */
.hero { text-align: center; padding: 6px 0 4px; }
.hero .label { color: var(--hint); font-size: 14px; }
.hero .value { font-size: 36px; font-weight: 700; letter-spacing: -.02em; margin: 2px 0 4px; font-variant-numeric: tabular-nums; }
.hero .value small { font-size: 20px; font-weight: 600; color: var(--hint); margin-left: 4px; }
.hero .meta { color: var(--hint); font-size: 13px; }

/* --- Итоги месяца --- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--card); border-radius: 12px; margin-top: 16px; }
.stat { padding: 12px 10px; text-align: center; min-width: 0; }
.stat + .stat { border-left: .5px solid var(--line); }
.stat .label { color: var(--hint); font-size: 13px; }
.stat .value { font-size: 17px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat .value.in { color: var(--good); }
.stat .note { color: var(--hint); font-size: 12px; margin-top: 1px; }

/* --- Столбики по дням --- */
.chart-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; }
.columns { position: relative; height: 130px; display: flex; align-items: flex-end; gap: 2px;
           border-bottom: .5px solid var(--line); margin-top: 16px; 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: 3px 3px 0 0; transition: opacity .15s; }
.columns .col.zero i { background: transparent; }
.columns.has-active .col:not(.active) i { opacity: .35; }
.columns .gridline { position: absolute; left: 30px; right: 0; border-top: .5px 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%); }

/* --- Списки (как в настройках Telegram) --- */
.list { background: var(--card); border-radius: 12px; overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 16px; width: 100%; min-height: 48px;
        border: 0; background: none; text-align: left; position: relative; }
.item + .item::before { content: ""; position: absolute; top: 0; right: 0; left: 62px; border-top: .5px solid var(--line); }
.list.plain .item + .item::before { left: 16px; }
button.item:active { background: var(--soft); }
.item .ico { width: 34px; height: 34px; border-radius: 9px; background: var(--soft); display: grid; place-items: center; font-size: 18px; flex: none; }
.item .title { font-size: 16px; }
.item .sub { color: var(--hint); font-size: 14px; margin-top: 1px; }
.item .right { text-align: right; flex: none; }
.item .right .sub { font-size: 13px; }
.item .chev { color: var(--hint); opacity: .6; font-size: 20px; line-height: 1; }
.item .meter { height: 4px; border-radius: 2px; background: var(--soft); margin-top: 6px; overflow: hidden; }
.item .meter i { display: block; height: 100%; background: var(--series-1); border-radius: 2px; }
.amount-in { color: var(--good); }
.pill { border: 0; background: var(--accent); color: var(--accent-text); border-radius: 999px; padding: 6px 14px;
        font-size: 14px; font-weight: 600; flex: none; }
.pill:active { opacity: .7; }
.pill.danger { background: var(--soft); color: var(--danger); }
.install-hint { background: var(--accent); color: var(--accent-text); padding: 10px 16px; font-size: 14px; text-align: center; }
.neg { color: var(--danger); }
.more { display: block; width: 100%; border: 0; background: none; color: var(--link); padding: 12px 16px; text-align: left;
        border-top: .5px solid var(--line); font-size: 16px; }
.day-head { display: flex; justify-content: space-between; margin: 22px 16px 7px; font-size: 13px; color: var(--section-head); text-transform: uppercase; letter-spacing: .02em; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 0; background: var(--card); padding: 7px 14px; border-radius: 999px; white-space: nowrap; font-size: 15px; }
.chip.active { background: 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(--soft); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: none; padding: 7px 4px; border-radius: 7px; font-size: 14px; font-weight: 500; }
.seg button.active { background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); font-weight: 600; }
.field { margin-top: 16px; }
.field > label { display: block; font-size: 13px; color: var(--section-head); text-transform: uppercase; letter-spacing: .02em; margin: 0 16px 7px; }
.input { width: 100%; border: 0; background: var(--card); border-radius: 12px; padding: 13px 16px; outline: none; }
.input:focus { box-shadow: inset 0 0 0 1.5px var(--accent); }
.amount-wrap { background: var(--card); border-radius: 12px; position: relative; margin-top: 16px; }
.amount-wrap .big-amount { font-size: 36px; font-weight: 700; text-align: center; padding: 18px 14px; background: none; }
.amount-wrap .big-amount:focus { box-shadow: none; }
.amount-wrap .big-amount:focus::placeholder { color: transparent; }
.amount-wrap .cur { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--hint); font-size: 17px; font-weight: 600; }
.check { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 12px; padding: 13px 16px; }
.field > label.check { margin: 0; font-size: 16px; color: var(--text); text-transform: none; letter-spacing: 0; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.btn { display: block; width: 100%; border: 0; border-radius: 12px; padding: 14px; font-weight: 600; font-size: 16px;
       background: var(--accent); color: var(--accent-text); margin-top: 20px; }
.btn.secondary { background: var(--card); color: var(--link); font-weight: 500; margin-top: 10px; }
.btn.danger { background: var(--card); color: var(--danger); font-weight: 500; margin-top: 10px; }
.btn:disabled { opacity: .5; }
.hint-line { font-size: 13px; color: var(--hint); margin: 7px 16px 0; line-height: 1.4; }

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

/* --- Шторка, тост, подсказка --- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); 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: 14px 14px 0 0; padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
         max-width: 640px; margin: 0 auto; animation: up .22s cubic-bezier(.2, .8, .2, 1); }
.sheet .grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { margin: 0 16px 2px; font-size: 20px; font-weight: 700; }
.sheet .sheet-sub { color: var(--hint); font-size: 14px; margin: 0 16px 6px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 30;
         background: rgba(0, 0, 0, .82); color: #fff; padding: 12px 16px; border-radius: 12px; text-align: center; font-size: 15px;
         max-width: 480px; margin: 0 auto; }
.tooltip { position: fixed; z-index: 25; background: rgba(0, 0, 0, .82); color: #fff; padding: 5px 9px;
           border-radius: 8px; font-size: 13px; pointer-events: none; transform: translate(-50%, -100%); white-space: nowrap; }
.skeleton { height: 110px; border-radius: 12px; background: var(--card); opacity: .6; margin-top: 12px; }
