:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f3f5);
  --text: var(--tg-theme-text-color, #14171a);
  --hint: var(--tg-theme-hint-color, #6b7580);
  --accent: var(--tg-theme-button-color, #2a7de1);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --pos: #1a8f4c;
  --neg: #c93b3b;
  --line: color-mix(in srgb, var(--text) 12%, transparent);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--tg-theme-bg-color, #17181b);
    --bg2: var(--tg-theme-secondary-bg-color, #212327);
    --text: var(--tg-theme-text-color, #f1f2f4);
    --hint: var(--tg-theme-hint-color, #8d96a1);
    --pos: #4cc481;
    --neg: #ff7b7b;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg2); color: var(--text); }
body { font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
main { max-width: 640px; margin: 0 auto; padding: 12px 16px 32px; }
h1 { font-size: 20px; margin: 8px 0 12px; }
h2 { font-size: 15px; margin: 20px 0 8px; color: var(--hint); font-weight: 600; text-transform: none; }
.muted { color: var(--hint); }
.small { font-size: 13px; margin: -6px 0 12px; }
.card > .small, .card .small:last-child { margin: 2px 0 8px; }
.block-title { font-weight: 600; margin-bottom: 4px; }
.center { text-align: center; padding: 32px 0; }
.card { background: var(--bg); border-radius: 14px; padding: 14px 16px; margin: 0 0 10px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.big { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.tiles .card { margin: 0; }
.tile-label { font-size: 13px; color: var(--hint); }
.tile-value { font-size: 20px; font-weight: 700; margin-top: 2px; }
.list .item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: var(--bg); border: 0; width: 100%; text-align: left; color: inherit; font: inherit; cursor: pointer; border-bottom: 1px solid var(--line); }
.list .item:first-child { border-radius: 14px 14px 0 0; }
.list .item:last-child { border-radius: 0 0 14px 14px; border-bottom: 0; }
.list .item:only-child { border-radius: 14px; }
.item .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { font-size: 13px; color: var(--hint); }
.item .amount { font-weight: 600; white-space: nowrap; }
input, select { width: 100%; font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; margin: 4px 0 12px; }
label { font-size: 13px; color: var(--hint); }
.btn { display: block; width: 100%; font: inherit; font-weight: 600; border: 0; border-radius: 12px; padding: 12px 16px; background: var(--accent); color: var(--accent-text); cursor: pointer; margin: 8px 0; }
.btn.secondary { background: var(--bg); color: var(--accent); }
.btn.danger { background: var(--bg); color: var(--neg); }
.btn[disabled] { opacity: .5; cursor: default; }
.op { padding: 12px 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
.op:first-child { border-radius: 14px 14px 0 0; }
.op:last-child { border-radius: 0 0 14px 14px; border-bottom: 0; }
.op:only-child { border-radius: 14px; }
.op.cancelled .title, .op.cancelled .amount { text-decoration: line-through; color: var(--hint); }
.op .title { font-weight: 500; }
.op .meta { font-size: 13px; color: var(--hint); margin-top: 2px; word-break: break-word; }
.op .amount { font-weight: 600; white-space: nowrap; }
.link-btn { background: none; border: 0; color: var(--accent); font: inherit; padding: 6px 0 0; cursor: pointer; }
.link-btn.danger { color: var(--neg); }
.notice { background: var(--bg); border-radius: 12px; padding: 12px 14px; margin: 10px 0; font-size: 14px; word-break: break-all; }
.error { color: var(--neg); }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--bg2); color: var(--hint); margin-left: 6px; }
.back { background: none; border: 0; color: var(--accent); font: inherit; padding: 4px 0; cursor: pointer; }
