:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #222222);
  --hint: var(--tg-theme-hint-color, #888888);
  --card: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --accent: var(--tg-theme-button-color, #2ea6ff);
  --green: #34c759;
  --red: #ff3b30;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 12px 14px 40px;
}

.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.month-nav button {
  background: var(--card);
  color: var(--text);
  border: none;
  border-radius: 10px;
  font-size: 16px;
  padding: 8px 16px;
}
#monthLabel { font-size: 17px; font-weight: 600; text-transform: capitalize; }

.totals { display: flex; gap: 8px; margin-bottom: 16px; }
.total-card {
  flex: 1;
  background: var(--card);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
}
.total-card span { display: block; font-size: 12px; color: var(--hint); }
.total-card b { font-size: 15px; }
.total-card.income b { color: var(--green); }
.total-card.expense b { color: var(--red); }

.chart-wrap { position: relative; width: 200px; margin: 0 auto 6px; }
#donut { width: 200px; height: 200px; }
.chart-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
#chartTotal { font-size: 18px; font-weight: 700; }
.chart-center small { color: var(--hint); font-size: 12px; }

.section { margin-top: 18px; }
.section h3 { font-size: 14px; color: var(--hint); margin-bottom: 8px; font-weight: 600; }

.cat-row, .user-row, .tx-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  background: var(--card);
  border-radius: 10px;
  margin-bottom: 6px;
}
.cat-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cat-name, .tx-desc { flex: 1; font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-sum, .tx-sum { font-size: 14px; font-weight: 600; white-space: nowrap; }
.cat-pct { color: var(--hint); font-size: 12px; width: 38px; text-align: right; }

.tx-row { cursor: default; }
.tx-row.receipt, .cat-row.clickable, .item-row.link { cursor: pointer; }
.tx-meta { color: var(--hint); font-size: 12px; }
.tx-sum.expense { color: var(--red); }
.tx-sum.income { color: var(--green); }

.empty { color: var(--hint); font-size: 14px; text-align: center; padding: 16px; }

.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end;
  z-index: 10;
}
.modal.hidden { display: none; }
.modal-body {
  background: var(--bg);
  width: 100%;
  max-height: 70vh;
  overflow-y: auto;
  border-radius: 16px 16px 0 0;
  padding: 16px;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal-head button { background: none; border: none; font-size: 18px; color: var(--hint); }
.item-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--card); font-size: 14px; gap: 10px; }
.item-row .n { flex: 1; }
.item-row .c { color: var(--hint); font-size: 12px; white-space: nowrap; }
