/* Бухгалтер — помесячная сетка. Без геймификации: «тупо числа», как в таблице. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --line: #e6e8ec;
  --text: #1a1d21;
  --muted: #8a9099;
  --accent: #2d6cdf;
  --income: #1f8a4c;
  --expense: #c0392b;
  --net-pos: #1f8a4c;
  --net-neg: #c0392b;
  --head-bg: #eef0f3;
  --col-now: #e8f0ff;
  --row-h: 38px;
  --cat-w: 116px;
  --col-w: 92px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171b; --surface: #1d2024; --line: #2c3036; --text: #e8eaed;
    --muted: #8a9099; --head-bg: #232730; --col-now: #1b2740;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  font-feature-settings: "tnum"; -webkit-font-smoothing: antialiased;
}
.screen { min-height: 100%; }
.hidden { display: none !important; }

/* Гейт / лендинг */
.gate-box { max-width: 520px; margin: 0 auto; padding: 48px 20px; text-align: center; }
.gate-icon { font-size: 44px; }
.gate-title { font-size: 20px; font-weight: 700; margin-top: 12px; }
.gate-sub { color: var(--muted); margin-top: 6px; }
.gate-landing { margin-top: 24px; text-align: left; line-height: 1.5; color: var(--text); }
.gate-landing p { margin: 10px 0; }
.gate-link { color: var(--accent); text-decoration: none; }

/* Топбар + зоны */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.zones { display: flex; gap: 6px; flex: 1; overflow-x: auto; }
.zone-btn {
  border: 1px solid var(--line); background: transparent; color: var(--text);
  padding: 6px 12px; border-radius: 16px; font-size: 13px; font-weight: 600;
  white-space: nowrap; cursor: pointer;
}
.zone-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.icon-btn {
  border: none; background: transparent; color: var(--text); font-size: 18px;
  width: 36px; height: 36px; border-radius: 10px; cursor: pointer;
}

/* Сетка */
.grid-wrap { overflow: auto; max-width: 100%; }
.grid { display: grid; width: max-content; font-size: 13px; }
.cell {
  height: var(--row-h); display: flex; align-items: center; padding: 0 8px;
  border-bottom: 1px solid var(--line); border-right: 1px solid var(--line);
  white-space: nowrap; overflow: hidden;
}
/* левая залипающая колонка (категории) */
.cat {
  position: sticky; left: 0; z-index: 10; background: var(--surface);
  width: var(--cat-w); min-width: var(--cat-w); gap: 6px; font-weight: 500;
}
.cat .emoji { width: 18px; text-align: center; }
.cat .name { overflow: hidden; text-overflow: ellipsis; }
/* шапка месяцев (залипает сверху) */
.hcell {
  position: sticky; top: 0; z-index: 20; background: var(--head-bg);
  justify-content: center; font-weight: 700; font-size: 12px;
  width: var(--col-w); min-width: var(--col-w);
}
.hcell.now { background: var(--col-now); }
.corner { position: sticky; left: 0; top: 0; z-index: 40; background: var(--head-bg);
  width: var(--cat-w); min-width: var(--cat-w); }
/* числовые ячейки */
.num { width: var(--col-w); min-width: var(--col-w); justify-content: flex-end;
  cursor: pointer; font-variant-numeric: tabular-nums; }
.num.now { background: var(--col-now); }
.num.zero { color: var(--muted); }
.num.plan { color: var(--muted); font-style: italic; }       /* будущее = план */
/* групповые/итоговые строки */
.group { background: var(--head-bg); font-weight: 700; font-size: 11px;
  text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.subtotal { font-weight: 700; }
.subtotal.income { color: var(--income); }
.subtotal.expense { color: var(--expense); }
.netrow .num { font-weight: 800; }
.net-pos { color: var(--net-pos); }
.net-neg { color: var(--net-neg); }

.cell.cat.catname { cursor: pointer; }
.cell.cat.addrow { color: var(--accent); cursor: pointer; font-weight: 600; }
.cell.num.addrow { cursor: default; }

.hint { color: var(--muted); font-size: 12px; padding: 10px 14px; text-align: center; }

/* Нижний лист */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.4);
  display: flex; align-items: flex-end; }
.sheet-box { background: var(--surface); width: 100%; border-radius: 16px 16px 0 0;
  padding: 16px; max-width: 560px; margin: 0 auto; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-title { font-weight: 700; font-size: 16px; }
.sheet-mode { color: var(--muted); font-size: 13px; margin: 4px 0 12px; }
.sheet-amount {
  width: 100%; font-size: 30px; font-weight: 700; text-align: right; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--text);
  font-variant-numeric: tabular-nums;
}
.sheet-comment { width: 100%; margin-top: 10px; padding: 10px 12px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--text); }
.sheet-actions { display: flex; gap: 8px; margin-top: 14px; }
.btn { flex: 1; padding: 12px; border: none; border-radius: 12px; font-size: 15px;
  font-weight: 600; cursor: pointer; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost { background: var(--bg); color: var(--text); border: 1px solid var(--line); }

.drawer-list { margin-top: 12px; max-height: 50vh; overflow-y: auto; }
.drawer-item { display: flex; align-items: center; justify-content: space-between;
  padding: 10px 4px; border-bottom: 1px solid var(--line); gap: 10px; }
.drawer-item .di-main { overflow: hidden; }
.drawer-item .di-comment { color: var(--muted); font-size: 12px; }
.drawer-item .di-amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.di-del { border: none; background: transparent; color: var(--expense); font-size: 16px; cursor: pointer; }
.drawer-empty { color: var(--muted); text-align: center; padding: 24px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: #333; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px;
  max-width: 90%; }
