/* Кольори — з теми Telegram (світла / темна); запасні значення — для перегляду поза Telegram. */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #f1f2f6);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #16181d);
  --hint: var(--tg-theme-hint-color, #8a8f98);
  --link: var(--tg-theme-link-color, #2b7de9);
  --accent: var(--tg-theme-button-color, #2b7de9);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #e5484d);
  --ok: #30a46c;
  --warn: #f5a524;
  --line: color-mix(in srgb, var(--hint) 25%, transparent);
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--bg); }
.title { font-size: 20px; font-weight: 700; }
.icon-btn { border: 0; background: var(--card); color: var(--text); width: 36px; height: 36px; border-radius: 50%;
  font-size: 18px; cursor: pointer; }

main { padding: 0 12px 12px; display: grid; gap: 12px; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px 16px; }
.card h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--hint);
  margin: 0 0 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.big { font-size: 28px; font-weight: 750; letter-spacing: -.01em; }
.big.neg, .neg { color: var(--danger); }
.pos { color: var(--ok); }
.muted { color: var(--hint); font-size: 13px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0;
  border-top: 1px solid var(--line); }
.row:first-of-type { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amount { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--line); }

.bar { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--ok); }
.bar > i.warn { background: var(--warn); }
.bar > i.over { background: var(--danger); }

.chart-box { position: relative; height: 220px; }
.chart-box.small { height: 180px; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: grid; grid-template-columns: repeat(6, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding: 4px 2px calc(4px + env(safe-area-inset-bottom)); }
.tabs button { border: 0; background: none; color: var(--hint); font-size: 10.5px; padding: 4px 0; display: grid;
  justify-items: center; gap: 1px; cursor: pointer; }
.tabs button span { font-size: 19px; }
.tabs button.active { color: var(--accent); font-weight: 600; }

.btn { border: 0; border-radius: 10px; padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.ghost { background: var(--line); color: var(--text); }
.btn.danger { background: none; color: var(--danger); padding: 6px 8px; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.icon { width: 34px; height: 34px; padding: 0; flex: none; font-size: 16px; line-height: 1; }
.btn.block { width: 100%; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.link { color: var(--link); background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filters .wide { grid-column: 1 / -1; }
input, select { width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 10px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--hint); margin-bottom: 10px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
label.check input { width: auto; }
.seg { display: flex; background: var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; border-radius: 8px; padding: 7px; background: none; color: var(--text); font: inherit;
  cursor: pointer; }
.seg button.on { background: var(--card); font-weight: 600; }

dialog { border: 0; border-radius: 18px; padding: 0; width: min(440px, calc(100vw - 24px)); background: var(--card);
  color: var(--text); }
dialog::backdrop { background: rgb(0 0 0 / 45%); }
dialog form { padding: 18px; max-height: 85vh; overflow-y: auto; }
dialog h3 { margin: 0 0 14px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.error { color: var(--danger); min-height: 1em; margin: 4px 0; font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 10px; font-size: 14px; opacity: 0;
  pointer-events: none; transition: opacity .2s; max-width: calc(100vw - 32px); }
.toast.show { opacity: .92; }
.empty { text-align: center; color: var(--hint); padding: 24px 8px; }
.skeleton { height: 90px; border-radius: var(--radius); background: var(--card); opacity: .6; }
