/* Тёмно-зелёная светлая тема (макет дизайн/макет-v1-зелёный.html, утверждён 16.10.2026) */
:root {
  --bg: #f3f3ee;
  --card: #ffffff;
  --fg: #0c0c0c;
  --muted: #8b8b87;
  --line: #ececea;
  --soft: #e9efe9;
  --press: #e2e8e2;
  --hero: #1d4a39;
  --hero-fg: #ffffff;
  --hero-muted: rgba(255, 255, 255, 0.62);
  --accent: #1d4a39;
  --on-accent: #ffffff;
  --expense: #e5484d;
  --warn: #e8900c;
  --income: #2f9e5c;
  --c1: #1d4a39; --c2: #3f7a5f; --c3: #7fb08f; --c4: #b6d1bd; --c5: #dde8df;
  --tab-h: 64px;
  --tab-gap: calc(env(safe-area-inset-bottom) + 10px);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
input, select {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 16px; /* меньше 16px — iPhone приближает страницу при вводе */
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

#app { max-width: 480px; margin: 0 auto; height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 0;
}
.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -16px;
  padding: 0 16px calc(var(--tab-h) + var(--tab-gap) + 24px);
}

/* ---------- общие блоки ---------- */
.head { display: flex; align-items: center; justify-content: space-between; min-height: 52px; margin-bottom: 8px; }
.head small { display: block; color: var(--muted); font-size: 13px; }
.head h1 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -0.01em; }
.head.center h1 { font-size: 18px; text-align: center; }
.round {
  position: relative;
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  background: var(--card); display: grid; place-items: center; overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.round:active { background: var(--press); }
.round:disabled { opacity: 0.35; }
.round input[type="date"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; padding: 0; }

.hero { background: var(--hero); color: var(--hero-fg); border-radius: 26px; padding: 18px 18px 16px; }
.hero .label { color: var(--hero-muted); font-size: 13px; }
.hero .label b { color: var(--hero-fg); font-weight: 600; }
.big { font-size: 40px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.12; margin: 4px 0 2px; white-space: nowrap; }
.big .kop { font-size: 22px; color: var(--hero-muted); font-weight: 600; letter-spacing: 0; }
.big .cur { font-size: 28px; }
.big.neg { color: #ffb4b4; }
.hero .row2 { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.hero .split { display: flex; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, 0.14); }
.hero .split div { flex: 1; min-width: 0; }
.hero .split small { display: block; color: var(--hero-muted); font-size: 12px; }
.hero .split b { font-size: 15px; font-weight: 600; white-space: nowrap; }

.pill {
  height: 40px; padding: 0 16px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 14px; white-space: nowrap;
}
.pill svg.i { width: 16px; height: 16px; }
.pill.white { background: #fff; color: #0c0c0c; }
.pill.ghost { background: rgba(255, 255, 255, 0.13); color: #fff; }
.pill.dark { background: var(--accent); color: var(--on-accent); }
.pill:active { opacity: 0.8; }

.sec { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 20px 4px 10px; }
.sec b { font-size: 16px; font-weight: 600; }
.sec span, .sec button { color: var(--muted); font-size: 13px; }
.sec button { color: var(--accent); font-weight: 600; }

.card { background: var(--card); border-radius: 22px; padding: 14px 16px; }
.ic { width: 38px; height: 38px; border-radius: 50%; background: var(--soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.ic svg.i { width: 17px; height: 17px; }
.empty-note { text-align: center; color: var(--muted); padding: 40px 0; }
.error { color: var(--expense); font-size: 14px; min-height: 20px; }

/* ---------- нижнее меню ---------- */
.tabbar {
  position: fixed; z-index: 5;
  left: max(16px, calc(50% - 224px)); right: max(16px, calc(50% - 224px));
  bottom: var(--tab-gap);
  height: var(--tab-h); border-radius: 999px; background: var(--card);
  display: flex; align-items: center; gap: 2px; padding: 0 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.10), 0 1px 2px rgba(0, 0, 0, 0.05);
}
.tabbar button {
  flex: 1; height: 48px; border-radius: 999px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: 11px; font-weight: 600;
}
.tabbar button svg.i { width: 22px; height: 22px; }
.tabbar button[aria-current="page"] { flex: 1.5; flex-direction: row; gap: 7px; background: var(--accent); color: var(--on-accent); font-size: 13px; }

/* ---------- ввод траты ---------- */
.view.add { padding-bottom: calc(var(--tab-h) + var(--tab-gap) + 12px); }
.amount-hero { padding: 14px 18px; }
.amount-hero .big { font-size: 44px; }
.amount-hero .big.empty { color: var(--hero-muted); }
.amount-hero .big.nudge { animation: nudge 0.3s; }
@keyframes nudge { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.amount-hero .pill[aria-pressed="true"] { background: #fff; color: #0c0c0c; }
.amount-hero .pill[aria-pressed="false"] { background: rgba(255, 255, 255, 0.13); color: #fff; }
.note-input { margin-top: 8px; }

.cats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cat {
  height: 50px; padding: 0 6px 0 7px; border-radius: 16px; background: var(--card);
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 550; line-height: 1.15; text-align: left;
  min-width: 0; overflow: hidden;
}
.cat span:last-child {
  min-width: 0; overflow: hidden; -webkit-hyphens: auto; hyphens: auto;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.cat .ic { width: 26px; height: 26px; }
.cat .ic svg.i { width: 15px; height: 15px; }
.cat:active { background: var(--press); }
.cat.more { justify-content: center; color: var(--muted); }
.view.add .sec { margin: 14px 4px 8px; }

.pad {
  flex: 1; min-height: 176px; max-height: 270px; margin-top: 8px;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(4, 1fr); gap: 8px;
}
.key { background: var(--card); border-radius: 14px; font-size: 22px; font-weight: 500; display: grid; place-items: center; }
.key.fn { background: transparent; }
.key svg.i { width: 24px; height: 24px; }
.key:active { background: var(--press); }

/* ---------- списки ---------- */
.day { display: flex; justify-content: space-between; gap: 12px; margin: 16px 6px 8px; font-size: 13px; color: var(--muted); }
.day b { color: var(--fg); font-weight: 600; }
.list { background: var(--card); border-radius: 22px; padding: 2px 14px; }
.row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 0; text-align: left; }
.row + .row { border-top: 1px solid var(--line); }
.row .t { flex: 1; min-width: 0; }
.row .t b { display: block; font-weight: 550; font-size: 15px; }
.row .t small { display: block; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .s { font-weight: 600; white-space: nowrap; }
.row .s.plus { color: var(--income); }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: #fdecec; color: var(--expense); margin-left: 4px; vertical-align: 1px; }

/* ---------- месяц ---------- */
.limit + .limit { margin-top: 14px; }
.limit .l1 { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.limit .l1 span:last-child { font-weight: 600; white-space: nowrap; }
.limit .l1 small { color: var(--muted); font-weight: 400; }
.track { height: 10px; border-radius: 999px; background: var(--soft); margin-top: 7px; overflow: hidden; }
.track i { display: block; height: 100%; width: var(--w); border-radius: 999px; background: var(--accent); }
.track.over i { background: var(--expense); }
.track.warn i { background: var(--warn); }
.limit .note { font-size: 12px; color: var(--muted); margin-top: 5px; }
.limit.over .note, .limit.over .l1 span:last-child { color: var(--expense); }

.donut-row { display: flex; align-items: center; gap: 14px; }
.donut { position: relative; width: 132px; height: 132px; flex: none; }
.donut svg { transform: rotate(-90deg); }
.donut .mid { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut .mid b { font-size: 16px; font-weight: 650; }
.donut .mid small { color: var(--muted); font-size: 11px; }
.legend { flex: 1; min-width: 0; display: grid; gap: 7px; font-size: 13px; }
.legend div { display: flex; align-items: center; gap: 7px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.legend span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend b { font-weight: 600; }
.cat-rows { margin-top: 10px; }

/* ---------- копилка ---------- */
.goal + .goal { margin-top: 10px; }
.goal .g1 { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; }
.goal .g1 .t { flex: 1; min-width: 0; }
.goal .g1 .t b { display: block; font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal .g1 .t small { color: var(--muted); font-size: 12.5px; }
.pct { font-size: 13px; font-weight: 650; padding: 4px 10px; border-radius: 999px; background: var(--soft); white-space: nowrap; }
.pct.done { background: #e7f5ec; color: var(--income); }
.goal .g2 { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.goal .g2 .left { display: flex; flex-direction: column; font-size: 12.5px; color: var(--muted); }
.goal .g2 .left b { color: var(--fg); font-weight: 600; font-size: 15px; }
.goal .pill { height: 36px; font-size: 13px; }

/* ---------- окна ---------- */
dialog {
  border: 0;
  border-radius: 26px 26px 0 0;
  margin: auto auto 0;
  width: 100%;
  max-width: 480px;
  max-height: 90dvh;
  padding: 20px 16px calc(env(safe-area-inset-bottom) + 16px);
  background: var(--bg);
  color: var(--fg);
}
dialog::backdrop { background: rgba(10, 20, 15, 0.45); }
dialog h2 { margin: 0 0 14px; font-size: 19px; font-weight: 650; }
dialog .sec { margin: 16px 4px 8px; }
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin: 0 4px 4px; }
.check { display: flex; align-items: center; gap: 10px; margin: 12px 4px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.actions { display: flex; gap: 8px; margin-top: 16px; }
.btn { flex: 1; height: 50px; border-radius: 999px; background: var(--card); font-weight: 600; }
.btn:active { background: var(--press); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--expense); }
.cats.all { max-height: 60dvh; overflow-y: auto; }
.limits-hint { font-size: 13px; margin: -6px 4px 12px; }
.limits-list { max-height: 55vh; overflow-y: auto; background: var(--card); border-radius: 22px; padding: 4px 14px; margin-bottom: 8px; }
.limit-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 15px; }
.limit-row + .limit-row { border-top: 1px solid var(--line); }
.limit-row input { width: 110px; text-align: right; background: var(--bg); border-color: transparent; }
.savings-list { max-height: 30vh; overflow-y: auto; background: var(--card); border-radius: 22px; padding: 2px 14px; margin-bottom: 8px; }
.savings-list:empty { display: none; }
.saving-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; font-size: 15px; }
.saving-row + .saving-row { border-top: 1px solid var(--line); }
.saving-row span:first-child { color: var(--muted); flex: 1; }
.saving-row span:nth-child(2) { font-weight: 600; }
.saving-row button { width: 36px; height: 36px; display: grid; place-items: center; color: var(--muted); }
.saving-row button svg.i { width: 16px; height: 16px; }

/* ---------- уведомление ---------- */
.toast {
  position: fixed; z-index: 10;
  left: 16px; right: 16px; bottom: calc(var(--tab-h) + var(--tab-gap) + 12px);
  max-width: 448px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px; border-radius: 18px;
  background: var(--hero); color: var(--hero-fg); font-size: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}
.toast button { color: inherit; font-weight: 600; text-decoration: underline; }

/* ---------- вход ---------- */
.login { justify-content: center; gap: 12px; padding-bottom: 12vh; }
.login .hero { margin-bottom: 8px; }
.login .hero h1 { margin: 2px 0 0; font-size: 30px; font-weight: 650; letter-spacing: -0.02em; }
.login .btn { flex: none; }

/* невысокие iPhone (SE, mini): ужимаем экран ввода, чтобы всё помещалось без прокрутки */
@media (max-height: 740px) {
  .view.add .head { min-height: 44px; margin-bottom: 4px; }
  .amount-hero { padding: 10px 16px 12px; }
  .amount-hero .big { font-size: 36px; }
  .hero .row2 { margin-top: 10px; }
  .view.add .sec { margin: 10px 4px 6px; }
  .view.add .sec span { display: none; }
  .cat { height: 44px; }
  .pad { min-height: 150px; gap: 6px; margin-top: 6px; }
}
