/* ════════════════════════════════════════════════════════════════
   style.css — Семейный бюджет (РЕДИЗАЙН «вариант B», тёплый ledger)
   База (как было) + блок РЕДИЗАЙН (переопределения, идёт ПОСЛЕ базы).
   Шрифт Manrope подключается в index.html через <link>.
   ════════════════════════════════════════════════════════════════ */

/* ─────────────── БАЗА (исходные правила) ─────────────── */

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

:root {
  --bg:        #eef2f7;
  --card:      #ffffff;
  --primary:   #4f6cf7;
  --primary-h: #3a55e0;
  --success:   #10b981;
  --danger:    #ef4444;
  --text:      #1e293b;
  --muted:     #64748b;
  --border:    #e2e8f0;
  --radius:    12px;
  --shadow:    0 4px 24px rgba(0,0,0,.10);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 48px;
}

[x-cloak] { display: none !important; }

.card { opacity: 0; animation: fadeIn .2s .05s forwards; }
@keyframes fadeIn { to { opacity: 1; } }

/* ── Card ─────────────────────────────────────────────── */
.card {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ── Header ───────────────────────────────────────────── */
.header {
  background: linear-gradient(135deg, #4f6cf7, #7c3aed);
  color: #fff;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header__title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: .01em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.demo-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 18px;
  background: rgba(245, 158, 11, .14);
  color: #92600a;
  border-bottom: 1px solid rgba(245, 158, 11, .28);
  font-size: .82rem;
  line-height: 1.35;
}
.demo-banner .ic { flex-shrink: 0; }
.demo-banner .ic svg { width: 17px; height: 17px; }
html[data-theme="dark"] .demo-banner { color: #fbbf24; background: rgba(245, 158, 11, .12); }

.date-chip {
  background: rgba(255,255,255,.2);
  position: relative;
  border: none;
  color: #fff;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: .85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background .15s;
  white-space: nowrap;
}
.date-chip:hover { background: rgba(255,255,255,.3); }

.user-chip {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: .82rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background .15s;
  white-space: nowrap;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-chip:hover { background: rgba(255,255,255,.28); }

.reset-chip {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  border-radius: 20px;
  width: 30px;
  height: 30px;
  font-size: .9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  flex-shrink: 0;
}
.reset-chip:hover { background: rgba(255, 80, 80, .45); }

/* ── Progress bar ─────────────────────────────────────── */
.progress-bar {
  display: flex;
  padding: 12px 20px 0;
  gap: 5px;
}
.progress-bar__dot {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  transition: background .3s;
}
.progress-bar__dot.done   { background: var(--success); }
.progress-bar__dot.active { background: var(--primary); }

/* ── Summary ──────────────────────────────────────────── */
.summary {
  padding: 14px 20px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: .85rem;
}
.summary-row__label { color: var(--muted); }
.summary-row__value { font-weight: 500; text-align: right; max-width: 65%; word-break: break-word; }

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0 0;
}

/* ── Step content ─────────────────────────────────────── */
.step {
  padding: 20px;
}

/* Step header: back button + question on one line */
.step-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.btn-back {
  flex-shrink: 0;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color .15s, color .15s, transform .1s;
}
.btn-back:hover  { border-color: var(--primary); color: var(--primary); }
.btn-back:active { transform: scale(.95); }

.question {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0;
}

/* Amount input */
.amount-row {
  display: flex;
  gap: 8px;
}
.input-amount {
  flex: 1;
  font-size: 1.4rem;
  font-weight: 500;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color .15s;
}
.input-amount:focus { border-color: var(--primary); }

/* Text / comment input */
.input-text {
  width: 100%;
  font-size: 1rem;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  margin-bottom: 10px;
  transition: border-color .15s;
}
.input-text:focus { border-color: var(--primary); }

/* Options grid */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.options-grid--3col {
  grid-template-columns: 1fr 1fr 1fr;
}
.btn-option {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s, transform .1s;
  line-height: 1.3;
  word-break: break-word;
}
.btn-option:hover             { border-color: var(--primary); background: #f0f4ff; }
.btn-option:active            { transform: scale(.97); }
.btn-option--selected         { border-color: var(--primary); background: #eef2ff; color: var(--primary); }

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: .92rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background .15s, transform .1s, opacity .15s;
}
.btn:active   { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--primary-h); }

.btn--secondary { background: var(--bg); color: var(--text); border: 2px solid var(--border); }
.btn--secondary:hover { border-color: var(--primary); }

.btn--ghost { background: transparent; color: var(--muted); padding: 8px 12px; }
.btn--ghost:hover { color: var(--text); }

.btn--full { width: 100%; }

/* ── Comment actions ──────────────────────────────────── */
.comment-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Done / error states ──────────────────────────────── */
.done-block {
  padding: 18px 20px 22px;
  text-align: center;
}
.done-icon  { font-size: 3rem; margin-bottom: 12px; }
.done-title { font-size: 1.15rem; font-weight: 600; margin-bottom: 4px; }
.done-sub   { color: var(--muted); font-size: .9rem; margin-bottom: 6px; }

/* Остаток после операции */
.balance-info {
  display: inline-block;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: .88rem;
  color: #166534;
  margin-bottom: 4px;
  text-align: left;
  line-height: 1.6;
}

.error-msg {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .88rem;
  margin-top: 8px;
}

/* ── Date picker overlay ──────────────────────────────── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 16px;
  overflow-y: auto;
}
.picker-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 300px;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}
.picker-card h3 { margin-bottom: 14px; font-size: 1rem; }
.input-date {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  margin-bottom: 14px;
  outline: none;
  box-sizing: border-box;
}
.input-date:focus { border-color: var(--primary); }
.picker-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ── Auth form ────────────────────────────────────────── */
.auth-form {
  padding: 28px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.auth-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.auth-label {
  font-size: .82rem;
  font-weight: 500;
  color: var(--muted);
}

.pwd-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.pwd-wrap .input-text {
  width: 100%;
  padding-right: 42px;
  margin-bottom: 0;
}
.pwd-toggle {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 2px 4px;
  color: var(--muted);
  transition: color .15s;
  user-select: none;
}
.pwd-toggle:hover { color: var(--text); }

.auth-switch {
  margin-top: 18px;
  text-align: center;
  font-size: .85rem;
  color: var(--muted);
}

.auth-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.auth-link:hover { color: var(--primary-h); }

/* ── Tab bar ──────────────────────────────────────────── */
.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  flex: 1;
  padding: 10px 4px;
  font-size: .82rem;
  font-weight: 500;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.tab-btn:hover          { color: var(--text); }
.tab-btn--active        { color: var(--primary); border-bottom-color: var(--primary); }

/* ── History ──────────────────────────────────────────── */
.hist-balance {
  background: #f0fdf4;
  border-bottom: 1px solid #bbf7d0;
  color: #166534;
  font-size: .88rem;
  font-weight: 500;
  padding: 10px 20px;
}

.hist-empty {
  color: var(--muted);
  font-size: .9rem;
  text-align: center;
  padding: 24px 0 8px;
}

.hist-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 55vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}

.hist-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  border-left-width: 3px;
}
.hist-item--expense { border-left-color: var(--danger); }
.hist-item--income  { border-left-color: var(--success); }

.hist-item__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.hist-item__date {
  font-size: .78rem;
  color: var(--muted);
}
.hist-item__mode {
  font-size: .78rem;
  font-weight: 500;
  color: var(--muted);
}
.hist-item__bottom {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.hist-item__category {
  font-size: .85rem;
  color: var(--text);
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hist-item__amount {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.hist-item--income  .hist-item__amount { color: var(--success); }
.hist-item--expense .hist-item__amount { color: var(--danger); }
.hist-item__comment {
  font-size: .78rem;
  color: var(--muted);
  margin-top: 4px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Balances ─────────────────────────────────────────── */
.bal-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.bal-entry {
  display: flex;
  flex-direction: column;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.bal-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg);
  font-family: inherit;
  font-size: inherit;
  text-align: left;
}

.bal-item--clickable {
  cursor: pointer;
  border: none;
  width: 100%;
  transition: background .15s;
}
.bal-item--clickable:hover { background: #e8edf7; }
.bal-item--clickable:active { background: #dce3f5; }

.bal-item--total {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  margin-top: 4px;
}

.bal-item__right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.bal-chevron {
  font-size: .7rem;
  color: var(--muted);
  flex-shrink: 0;
}

.bal-item__name   { font-size: .88rem; color: var(--muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.bal-item__amount { font-size: 1rem; font-weight: 600; color: var(--text); white-space: nowrap; }
.bal-item--total .bal-item__name   { font-weight: 600; color: var(--text); }
.bal-item--total .bal-item__amount { color: var(--success); }

.bal-hist {
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 8px 12px 12px;
}
.bal-hist__loading {
  color: var(--muted);
  font-size: .88rem;
  padding: 10px 0 4px;
  text-align: center;
}
.bal-hist .hist-list {
  max-height: 40vh;
}
.bal-hist .hist-empty {
  padding: 12px 0 4px;
}

/* ── Done-page history ────────────────────────────────────── */
.done-hist {
  margin-top: 18px;
  text-align: left;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.done-hist__title {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}
.done-hist__sub {
  font-size: .78rem;
  font-weight: 400;
  color: var(--muted);
}
.done-hist .hist-list { max-height: 45vh; }

/* ── Refresh button (balances header) ─────────────────────── */
.btn-refresh {
  margin-left: auto;
  flex-shrink: 0;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  font-size: .95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color .15s, transform .3s;
}
.btn-refresh:hover:not(:disabled)  { border-color: var(--primary); }
.btn-refresh:active:not(:disabled) { transform: rotate(180deg); }
.btn-refresh:disabled              { opacity: .4; cursor: not-allowed; }

/* ── Admin button ─────────────────────────────────────── */
.admin-row {
  padding: 0 20px 16px;
  display: flex;
  justify-content: flex-end;
}
.btn--admin {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: .78rem;
  cursor: pointer;
  padding: 4px 6px;
}
.btn--admin:hover       { color: var(--text); }
.btn--admin:disabled    { opacity: .4; cursor: not-allowed; }

/* ═══════════════ РЕДИЗАЙН · вариант B (переопределения) ═══════════════ */
/* ── Токены темы ─────────────────────────────────────────────── */
  :root {
    --bg:#fafafa; --card:#ffffff; --text:#23262b; --muted:#6b6d73; --border:#e4e5e8;
    --field:#f1f2f4; --accent:#41576b; --primary:#41576b; --primary-h:#34475a;
    --accent-soft:#ebedf0; --success:#27795a; --danger:#bf5040; --pos:#27795a;
    --amt-in:#15a34a; --amt-out:#dc2f30;
    --headbg:#202226; --headink:#f1f2f4; --chipbg:rgba(255,255,255,.10);
    --chipink:#e6e7ea; --chiphover:rgba(255,255,255,.18);
    --radius:10px;
    --shadow:0 1px 2px rgba(30,41,59,.05), 0 16px 38px rgba(30,41,59,.09);
  }
  html[data-theme="dark"] {
    --bg:#0f1114; --card:#181a1e; --text:#e6e8ec; --muted:#7e828b; --border:#262a30;
    --field:#1d2025; --accent:#7e95ab; --primary:#7e95ab; --primary-h:#7188a0;
    --accent-soft:#171c23; --success:#52b88c; --danger:#d9755f; --pos:#52b88c;
    --amt-in:#3ed27e; --amt-out:#f1605f;
    --headbg:#0a0b0d; --headink:#e8eaee; --chipbg:rgba(255,255,255,.08);
    --chipink:#c2c6cd; --chiphover:rgba(255,255,255,.16);
    --shadow:0 1px 2px rgba(0,0,0,.5), 0 18px 44px rgba(0,0,0,.55);
  }

  /* ── Акцентные схемы (выбор в «Оформлении») ──────────────────── */
  html[data-accent="emerald"]    { --accent:#2f6f57; --primary:#2f6f57; --primary-h:#27604a; --pos:#2f6f57; --success:#2f6f57; }
  html[data-accent="terracotta"] { --accent:#a65a43; --primary:#a65a43; --primary-h:#8f4b37; }
  html[data-accent="plum"]       { --accent:#6b4a72; --primary:#6b4a72; --primary-h:#5a3d61; }
  html[data-accent="blue"]       { --accent:#2f6fe0; --primary:#2f6fe0; --primary-h:#2860c4; }
  html[data-accent="violet"]     { --accent:#8b3fe0; --primary:#8b3fe0; --primary-h:#7a33c8; }
  html[data-accent="rose"]       { --accent:#e0427a; --primary:#e0427a; --primary-h:#c8356a; }
  html[data-accent="amber"]      { --accent:#c8771a; --primary:#c8771a; --primary-h:#b06715; }
  html[data-accent="lime"]       { --accent:#05d545; --primary:#05d545; --primary-h:#04bd3c; }
  html[data-theme="dark"][data-accent="emerald"]    { --accent:#5fae8d; --primary:#5fae8d; --primary-h:#54a081; --pos:#5fae8d; --success:#5fae8d; }
  html[data-theme="dark"][data-accent="terracotta"] { --accent:#cf8064; --primary:#cf8064; --primary-h:#c0714f; }
  html[data-theme="dark"][data-accent="plum"]       { --accent:#a98bb0; --primary:#a98bb0; --primary-h:#9b7ba3; }
  html[data-theme="dark"][data-accent="blue"]       { --accent:#6a9bf2; --primary:#6a9bf2; --primary-h:#5d8eea; }
  html[data-theme="dark"][data-accent="violet"]     { --accent:#ab7df0; --primary:#ab7df0; --primary-h:#9d6de8; }
  html[data-theme="dark"][data-accent="rose"]       { --accent:#f06d99; --primary:#f06d99; --primary-h:#e85f8c; }
  html[data-theme="dark"][data-accent="amber"]      { --accent:#f0a847; --primary:#f0a847; --primary-h:#e89a35; }
  html[data-theme="dark"][data-accent="lime"]       { --accent:#2ee05f; --primary:#2ee05f; --primary-h:#22d452; }

  /* ── Шрифт ───────────────────────────────────────────────────── */
  body { font-family:'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif; }
  button, input, select, textarea { font-family: inherit; }
  .input-amount, .summary-row__value, .bal-item__amount, .op__amt,
  .hist-day__sub, .balance-info { font-variant-numeric: tabular-nums; }

  /* ── Иконки ──────────────────────────────────────────────────── */
  .ic { display:inline-flex; align-items:center; justify-content:center; line-height:0; }
  .ic svg { width:16px; height:16px; display:block; }
  .header__title { display:flex; align-items:center; gap:8px; font-weight:600; }
  .header__title .ic svg { width:19px; height:19px; }
  .tab-btn { display:inline-flex; align-items:center; justify-content:center; gap:7px; }
  .tab-btn .ic svg { width:16px; height:16px; }
  .btn .ic svg, .btn-back .ic svg, .btn-refresh .ic svg, .reset-chip .ic svg { width:18px; height:18px; }
  .date-chip .ic svg, .user-chip .ic svg { width:15px; height:15px; }
  .btn--admin .ic svg { width:14px; height:14px; }
  .pwd-toggle svg { width:18px; height:18px; display:block; }

  /* ── Карточка ────────────────────────────────────────────────── */
  .card { border:1px solid var(--border); box-shadow:var(--shadow); }

  /* ── Шапка (без градиента) ───────────────────────────────────── */
  .header { background:var(--headbg); color:var(--headink); }
  .date-chip, .user-chip, .reset-chip, .theme-chip {
    background:var(--chipbg); color:var(--headink);
  }
  .date-chip:hover, .user-chip:hover, .theme-chip:hover { background:var(--chiphover); }
  /* Чип даты как значение в строке сводки мастера */
  .summary-row--date { align-items:center; }
  .date-chip--inline {
    background:var(--field); color:var(--text);
    border:1px solid var(--border);
    padding:5px 11px; gap:7px; font-weight:600;
    flex-direction:row-reverse;
  }
  .date-chip--inline .ic { color:var(--muted); }
  .date-chip--inline:hover { background:color-mix(in srgb, var(--field) 70%, var(--border)); }
  /* Нативный input даты поверх всего чипа — клик открывает календарь без скрипта */
  .date-chip__native {
    position:absolute; inset:0; width:100%; height:100%;
    margin:0; padding:0; border:0; background:transparent; color:transparent;
    opacity:0; cursor:pointer;
  }
  .date-chip__native::-webkit-calendar-picker-indicator {
    position:absolute; inset:0; width:100%; height:100%; margin:0; padding:0;
    opacity:0; cursor:pointer;
  }
  .reset-chip:hover { background:rgba(191,80,64,.45); }
  .theme-chip {
    border:none; width:30px; height:30px; border-radius:20px; cursor:pointer;
    display:flex; align-items:center; justify-content:center; flex-shrink:0; transition:background .15s;
  }

  /* ── Каркас приложения: шапка сверху, контент в центре, навигация снизу ── */
  .card--app {
    display:flex;
    flex-direction:column;
    height:calc(100vh - 40px);
    height:calc(100dvh - 40px);
    margin-bottom:-32px;          /* компенсируем нижний padding body, оставляя ~16px отступ от низа экрана */
  }
  .card--app > .header { flex-shrink:0; }
  .card--app > .tab-panel {
    flex:1 1 auto;
    min-height:0;
    overflow-y:auto;
    -webkit-overflow-scrolling:touch;
  }
  .card--app > .tab-bar { flex-shrink:0; }

  /* ── Нижняя навигация (bottom nav) ──────────────────────────── */
  .tab-bar {
    background:var(--card);
    border-top:1px solid var(--border);
    border-bottom:none;
    z-index:20;
  }
  .tab-btn {
    flex-direction:column;
    gap:5px;
    padding:11px 4px max(8px, env(safe-area-inset-bottom, 0px));
    font-size:.68rem;
    letter-spacing:.01em;
    border-bottom:none;
    position:relative;
    color:var(--muted);
    transition:color .15s;
  }
  .tab-btn .ic svg { width:22px; height:22px; }
  .tab-btn:hover:not(:disabled) { color:var(--text); }
  .tab-btn--active,
  .tab-btn--active:hover {
    color:var(--accent);
    border-bottom-color:transparent;
    font-weight:600;
  }
  .tab-btn--active::before {
    content:"";
    position:absolute;
    top:0; left:50%; transform:translateX(-50%);
    width:30px; height:3px; border-radius:0 0 3px 3px;
    background:var(--accent);
  }
  /* Запланированные разделы (пока недоступны) */
  .tab-btn--soon { opacity:.4; cursor:default; }
  .tab-btn--soon:hover { color:var(--muted); }

  /* iOS (iPhone): поднимаем панель выше — над home-индикатором и
     скруглением экрана. @supports(-webkit-touch-callout) истинно только
     на iOS, поэтому Android не затрагивается. */
  @supports (-webkit-touch-callout: none) {
    .tab-btn { padding-bottom: max(18px, env(safe-area-inset-bottom, 0px)); }
  }

  /* ── Прогресс ────────────────────────────────────────────────── */
  .progress-bar__dot.done   { background:var(--accent); opacity:.38; }
  .progress-bar__dot.active { background:var(--accent); }

  /* ── Опции / поля ────────────────────────────────────────────── */
  /* Более лёгкое оформление: тонкие рамки 1px на всех кнопках/полях */
  .btn-option, .btn--secondary, .btn-back, .btn-refresh,
  .input-amount, .input-text, .input-date { border-width:1px; }
  .btn-option { background:var(--field); border-color:var(--border); color:var(--text); border-radius:8px; font-weight:500; }
  .btn-option:hover     { border-color:var(--accent); background:var(--accent-soft); }
  .btn-option--selected { border-color:var(--accent); background:var(--accent-soft); color:var(--accent); }
  .input-amount, .input-text, .input-date { background:var(--card); color:var(--text); border-color:var(--border); }
  .input-amount:focus, .input-text:focus, .input-date:focus { border-color:var(--accent); }
  .input-amount::placeholder, .input-text::placeholder { color:var(--muted); opacity:.6; }

  /* ── Кнопки ──────────────────────────────────────────────────── */
  .btn--primary { background:var(--accent); }
  .btn--primary:hover:not(:disabled) { background:var(--primary-h); }
  .btn--secondary { background:var(--field); border-color:var(--border); color:var(--text); }
  .btn--secondary:hover { border-color:var(--accent); }
  .btn-back { background:var(--field); border-color:var(--border); color:var(--muted); }
  .btn-back:hover { border-color:var(--accent); color:var(--accent); }
  .btn-refresh { background:var(--field); border-color:var(--border); color:var(--muted); }
  .btn-refresh:hover:not(:disabled) { border-color:var(--accent); color:var(--accent); }
  .btn--admin { color:var(--muted); display:inline-flex; align-items:center; gap:6px; }
  .btn--admin:hover { color:var(--text); }

  /* ── Завершение / инфо ───────────────────────────────────────── */
  .done-icon { color:var(--accent); margin-bottom:8px; display:flex; justify-content:center; }
  .done-icon svg { width:38px; height:38px; }
  .balance-info { background:var(--accent-soft); border:none; color:var(--accent); }
  .error-msg {
    background:color-mix(in srgb, var(--danger) 12%, var(--card));
    border:1px solid color-mix(in srgb, var(--danger) 32%, var(--card));
    color:var(--danger);
  }

  /* ── Оверлей / пикер даты ────────────────────────────────────── */
  .picker-card { background:var(--card); color:var(--text); }

  /* ── Авторизация ─────────────────────────────────────────────── */
  .auth-title { color:var(--text); }
  .auth-link  { color:var(--accent); }
  .auth-link:hover { color:var(--primary-h); }
  .pwd-toggle { color:var(--muted); }
  .pwd-toggle:hover { color:var(--text); }

  /* ── Остатки ─────────────────────────────────────────────────── */
  .hist-balance { background:var(--accent-soft); border:none; color:var(--accent); }
  .bal-entry { border-color:var(--border); }
  .bal-item  { background:var(--field); }
  .bal-item--clickable:hover  { background:var(--accent-soft); }
  .bal-item--clickable:active { background:color-mix(in srgb, var(--accent) 14%, var(--card)); }
  .bal-item--total { background:var(--accent-soft); border:none; }
  .bal-item--total .bal-item__amount { color:var(--accent); }
  .bal-item__amount--neg { color:var(--muted); }
  .bal-hist { background:var(--card); border-color:var(--border); }
  .bal-chevron { display:inline-flex; color:var(--muted); }
  .bal-chevron svg { width:16px; height:16px; display:block; transition:transform .18s; }
  .bal-chevron--up svg { transform:rotate(180deg); }

  /* ── История по дням ─────────────────────────────────────────── */
  .hist-list { gap:0; }
  .hist-day + .hist-day { margin-top:22px; }
  .hist-day__head {
    display:flex; justify-content:flex-start; align-items:baseline; gap:8px;
    padding:6px 4px 10px;
    border-bottom:1px solid var(--border);
  }
  .hist-day__date { font-size:1rem; font-weight:700; letter-spacing:.01em; color:var(--text); white-space:nowrap; }
  .hist-day__sub  { font-size:.72rem; font-weight:500; color:var(--muted); white-space:nowrap; }
  .hist-day__ops  { display:flex; flex-direction:column; }

  .op { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:12px 4px; }
  .hist-day__ops .op + .op { border-top:1px solid var(--border); }
  .op__main { min-width:0; }
  .op__cat  { font-size:.86rem; font-weight:500; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .op__who  {
    display:flex; align-items:center; gap:5px; margin-top:3px;
    font-size:.74rem; font-weight:500; color:var(--text);
    white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  }
  .op__who .ic { color:var(--muted); flex-shrink:0; }
  .op__who .ic svg { width:13px; height:13px; }
  .op__meta { font-size:.72rem; color:var(--muted); margin-top:2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .op__amt  { font-size:.86rem; font-weight:600; color:var(--amt-out); white-space:nowrap; flex-shrink:0; }
  .op--in .op__amt { color:var(--amt-in); }
  /* Перевод нейтрален во всех списках (лента, финиш, остатки) */
  .op--transfer .op__amt { color:var(--text); }

  /* Лента «Последние операции»: «Имя · Банк» — в правую колонку под сумму;
     «Тип траты» (op__meta) — слева под категорией; шрифт who/meta одинаковый.
     Ограничено .recent — экран «done» и «Остатки» не затрагиваются. */
  .recent .op { align-items:flex-start; }
  .recent .op__right { display:flex; flex-direction:column; align-items:flex-end; min-width:0; flex-shrink:0; }
  .recent .op__who {
    justify-content:flex-end; max-width:100%; margin-top:3px;
    color:var(--muted);
  }
  .recent .op__meta { font-size:.74rem; font-weight:500; color:var(--muted); }
  /* Перевод: сумма без знака и без цветовой окраски (нейтральная) */
  .recent .op--transfer .op__amt { color:var(--text); }

  /* спиннер вместо ⏳ */
  .spinner { display:inline-flex; color:var(--accent); }
  .spinner svg { width:40px; height:40px; animation:bspin 1s linear infinite; }
  .spinner--sm svg { width:18px; height:18px; }
  .bal-hist__loading, .hist-empty { display:flex; align-items:center; justify-content:center; gap:8px; }
  @keyframes bspin { to { transform:rotate(360deg); } }
  .ic--spin svg { animation:bspin 1s linear infinite; }

  /* ── Последние операции (первый экран «Запись») ──────────────── */
  .recent { padding:2px 20px 18px; }
  .recent__head {
    display:flex; align-items:center; justify-content:space-between; gap:8px;
    padding:13px 0 11px;
    border-top:1px solid var(--border);
  }
  .recent__title {
    font-size:.72rem; font-weight:600; letter-spacing:.06em;
    text-transform:uppercase; color:var(--muted);
  }
  .recent__refresh {
    flex-shrink:0;
    background:var(--field); border:1px solid var(--border); border-radius:8px;
    width:30px; height:30px; display:flex; align-items:center; justify-content:center;
    cursor:pointer; color:var(--muted); transition:border-color .15s, color .15s;
  }
  .recent__refresh:hover:not(:disabled)  { border-color:var(--accent); color:var(--accent); }
  .recent__refresh:disabled { opacity:.5; cursor:not-allowed; }
  .recent__tools { display:flex; align-items:center; gap:8px; flex-shrink:0; }
  .recent__filter { position:relative; display:flex; align-items:center; }
  .recent__select {
    appearance:none; -webkit-appearance:none;
    background:var(--field); border:1px solid var(--border); border-radius:8px;
    height:30px; padding:0 28px 0 11px;
    font-size:.8rem; font-weight:500; color:var(--text);
    cursor:pointer; transition:border-color .15s;
  }
  .recent__select:hover  { border-color:var(--accent); }
  .recent__select:focus  { outline:none; border-color:var(--accent); }
  .recent__chev {
    position:absolute; right:8px; top:50%; transform:translateY(-50%);
    width:15px; height:15px; pointer-events:none; color:var(--muted);
    display:flex; align-items:center; justify-content:center;
  }
  .recent__chev svg { width:100%; height:100%; }

  /* Строка фильтров под заголовком (переносится при нехватке места) */
  .recent__filters {
    display:flex; flex-wrap:wrap; gap:8px;
    padding:0 0 12px;
  }
  /* Кнопка-триггер мультивыбора выглядит как select */
  .recent__select--btn {
    display:inline-flex; align-items:center; white-space:nowrap;
    max-width:180px; overflow:hidden; text-overflow:ellipsis;
  }
  .recent__select--on { border-color:var(--accent); color:var(--accent); }
  /* Выпадающее меню с чекбоксами */
  .recent__menu {
    position:absolute; top:calc(100% + 6px); right:0; z-index:50;
    min-width:170px; max-width:min(240px, calc(100vw - 28px));
    max-height:50vh; overflow-y:auto;
    background:var(--card); border:1px solid var(--border); border-radius:10px;
    box-shadow:0 10px 28px rgba(0,0,0,.16);
    padding:5px;
  }
  .recent__opt {
    display:flex; align-items:center; gap:9px; width:100%;
    background:none; border:none; border-radius:7px; cursor:pointer;
    padding:8px 9px; font-size:.83rem; line-height:1.2; color:var(--text); text-align:left;
    transition:background .12s;
  }
  .recent__opt:hover { background:var(--field); }
  .recent__opt--on { color:var(--accent); font-weight:600; }
  .recent__optcheck {
    flex-shrink:0; width:16px; height:16px;
    display:flex; align-items:center; justify-content:center;
    color:var(--accent); opacity:0; transition:opacity .12s;
  }
  .recent__opt--on .recent__optcheck { opacity:1; }
  .recent__optcheck svg { width:100%; height:100%; }

  .recent .hist-list { max-height:none; overflow:visible; }
  .recent .hist-empty { padding:14px 0 4px; justify-content:flex-start; }

  /* ── Закреплённая кнопка «Показать остатки» ──────────────────── */
  .bal-submit-bar {
    position:sticky;
    bottom:0;
    margin:14px -20px 0;
    padding:12px 20px;
    background:var(--card);
    border-top:1px solid var(--border);
    box-shadow:0 -10px 16px -10px rgba(30,41,59,.18);
  }
  html[data-theme="dark"] .bal-submit-bar {
    box-shadow:0 -10px 16px -10px rgba(0,0,0,.6);
  }

/* ════════════════════════════════════════════════════════════════
   АДАПТАЦИЯ ПОД УСТРОЙСТВО
   ════════════════════════════════════════════════════════════════ */

/* Страховка: никакого горизонтального скролла страницы */
html, body { overflow-x: hidden; }

/* Шапка: заголовок сжимается, правый блок переносится — суммарная ширина
   чипов никогда не выталкивает контент за край */
.header        { flex-wrap: wrap; row-gap: 10px; }
.header__title { min-width: 0; flex: 1 1 auto; overflow-wrap: anywhere; }
.header-right  { min-width: 0; flex-shrink: 1; flex-wrap: wrap; justify-content: flex-end; }
.user-chip     { min-width: 0; }   /* усечётся по ellipsis (max-width:130px уже задан) */
.date-chip     { flex-shrink: 0; }

/* Поля во flex-строках должны уметь сжиматься (строка суммы с кнопкой «→») */
.input-amount, .input-text { min-width: 0; }
.amount-row { flex-wrap: wrap; }

@media (max-width: 540px) {
  /* Внешний документ НЕ скроллится: прокручивается только внутренний список
     операций (.tab-panel). Иначе при свайпе скроллится вся страница, тулбар
     браузера прячется/появляется, и нижняя навигация уезжает из видимой зоны. */
  html, body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
  }
  body { padding: 0; align-items: stretch; }

  /* Экран входа остаётся «карточкой» с воздухом от краёв */
  .card:not(.card--app) { margin: 20px 16px; max-width: none; }

  /* Основное приложение — во весь экран, без своего радиуса/боковых границ */
  .card--app {
    width: 100%; max-width: none; margin: 0;
    height: 100vh;            /* фолбэк */
    height: 100dvh;           /* динамическая высота (панель браузера) */
    border-radius: 0;
    border-left: none; border-right: none;
  }
  /* Внутренняя прокрутка не «протекает» во внешний документ */
  .card--app > .tab-panel { overscroll-behavior: contain; }

  /* Верх: статус-бар / «чёлка» */
  .card--app > .header {
    padding-top:   calc(18px + env(safe-area-inset-top, 0px));
    padding-left:  calc(20px + env(safe-area-inset-left, 0px));
    padding-right: calc(20px + env(safe-area-inset-right, 0px));
  }

  /* Компактнее к центру: отступы по бокам уводят кнопки от скруглённых
     углов экрана (iPhone). max() — учитываем insets в альбомной ориентации. */
  .tab-bar {
    padding-left:  max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
}

/* ══════════════════════════════════════════════════════════════════
   Голос (AI-ввод)
   ══════════════════════════════════════════════════════════════════ */
.voice { text-align: center; padding: 8px 0 4px; }
.voice__q { margin-bottom: 4px; }
.voice__hint { color: var(--muted); font-size: .85rem; margin-bottom: 22px; }

.voice__mic {
  width: 96px; height: 96px; border-radius: 50%;
  border: none; cursor: pointer;
  background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(79,108,247,.35);
  transition: transform .12s, background .15s;
}
.voice__mic:hover:not(:disabled) { background: var(--primary-h); }
.voice__mic:active { transform: scale(.96); }
.voice__mic:disabled { opacity: .6; cursor: default; }
.voice__mic .ic svg { width: 38px; height: 38px; }
.voice__mic--on { background: var(--danger); animation: voicePulse 1.4s infinite; }
@keyframes voicePulse {
  0%   { box-shadow: 0 0 0 0   rgba(239,68,68,.45); }
  70%  { box-shadow: 0 0 0 18px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0   rgba(239,68,68,0); }
}

.voice__status { margin-top: 16px; color: var(--muted); font-size: .9rem; }
.voice__transcript {
  margin-top: 18px; padding: 12px 14px; text-align: left;
  background: var(--field, var(--bg)); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size: .95rem; line-height: 1.4;
}
.voice__transcript--sm {
  font-size: .85rem; color: var(--muted); font-style: italic; margin-bottom: 16px;
}
.voice__manual { margin-top: 22px; display: flex; flex-direction: column; gap: 8px; }
.voice__manual .input-text { margin-bottom: 0; }

/* Сводка-черновик: редактируемые поля */
.voice-review { padding-top: 4px; }
.vrow { margin-bottom: 12px; }
.vrow__label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 5px; }
.vrow .input-text { margin-bottom: 0; }
.vselect { position: relative; }
.vselect select {
  width: 100%; appearance: none; -webkit-appearance: none;
  font-size: 1rem; padding: 10px 38px 10px 14px;
  background: var(--card); color: var(--text);
  border: 2px solid var(--border); border-radius: var(--radius);
  outline: none; cursor: pointer;
}
.vselect select:focus { border-color: var(--primary); }
.vselect__chev {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  pointer-events: none; color: var(--muted); line-height: 0;
}
.vselect__chev svg { width: 18px; height: 18px; display: block; }

.vrow--miss .input-text,
.vrow--miss .vselect select { border-color: var(--danger); background: rgba(239,68,68,.06); }
.vrow--miss .vrow__label { color: var(--danger); }

.voice__miss-hint { color: var(--danger); font-size: .82rem; text-align: center; margin: 4px 0 0; }
.voice-review__actions { display: flex; gap: 10px; margin-top: 18px; }
.voice-review__actions .btn { flex: 1; }

/* ════════════════ ОФОРМЛЕНИЕ: меню профиля + настройки ════════════════ */

/* ── Меню профиля (по нажатию на имя в шапке) ─────────────────── */
.user-menu-wrap { position:relative; flex-shrink:0; }
.user-chip { gap:6px; }
.user-chip__chev { transition:transform .18s; }
.user-chip__chev svg { width:13px; height:13px; }
.user-chip--open .user-chip__chev { transform:rotate(180deg); }

.user-menu {
  position:absolute; top:calc(100% + 8px); right:0;
  min-width:188px;
  background:var(--card); color:var(--text);
  border:1px solid var(--border); border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:6px;
  z-index:60;
  transform-origin:top right;
}
.user-menu__name {
  padding:8px 10px 6px;
  font-size:.72rem; letter-spacing:.04em; text-transform:uppercase;
  color:var(--muted);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.user-menu__sep { border:none; border-top:1px solid var(--border); margin:4px 2px; }
.user-menu__item {
  display:flex; align-items:center; gap:10px; width:100%;
  background:none; border:none; cursor:pointer;
  padding:9px 10px; border-radius:7px;
  font-size:.9rem; font-weight:500; color:var(--text); text-align:left;
  transition:background .14s, color .14s;
}
.user-menu__item:hover { background:var(--field); }
.user-menu__item .ic svg { width:17px; height:17px; }
.user-menu__item .ic { color:var(--muted); transition:color .14s; }
.user-menu__item:hover .ic { color:var(--accent); }
.user-menu__item--danger { color:var(--danger); }
.user-menu__item--danger .ic { color:var(--danger); }
.user-menu__item--danger:hover { background:rgba(191,80,64,.10); }
.user-menu__item--danger:hover .ic { color:var(--danger); }

/* ── Оверлей настроек оформления ─────────────────────────────── */
.settings-card { max-width:340px; text-align:left; padding:22px; }
.settings-head {
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom:18px;
}
.settings-head h3 { font-size:1.05rem; font-weight:700; color:var(--text); margin:0; }
.settings-head .ic svg { width:19px; height:19px; }
.settings-head__title { display:flex; align-items:center; gap:9px; }
.settings-head__title .ic { color:var(--accent); }
.settings-close {
  background:var(--field); border:none; border-radius:8px;
  width:30px; height:30px; cursor:pointer; color:var(--muted);
  display:flex; align-items:center; justify-content:center; transition:color .14s, background .14s;
}
.settings-close svg { width:16px; height:16px; }
.settings-close:hover { color:var(--text); background:var(--border); }

.settings-group { margin-bottom:18px; }
.settings-group:last-child { margin-bottom:0; }
.settings-label {
  font-size:.78rem; font-weight:600; letter-spacing:.02em;
  color:var(--muted); margin-bottom:9px; text-transform:uppercase;
}

/* Сегментированный переключатель */
.seg { display:flex; gap:6px; background:var(--field); padding:4px; border-radius:10px; }
.seg__btn {
  flex:1; background:none; border:none; cursor:pointer;
  padding:8px 6px; border-radius:7px;
  font-size:.88rem; font-weight:600; color:var(--muted);
  transition:background .15s, color .15s, box-shadow .15s;
  display:flex; align-items:center; justify-content:center; gap:6px;
}
.seg__btn .ic svg { width:16px; height:16px; }
.seg__btn:hover { color:var(--text); }
.seg__btn--active {
  background:var(--card); color:var(--accent);
  box-shadow:0 1px 2px rgba(0,0,0,.10);
}
.seg__btn--active:hover { color:var(--accent); }
.seg__btn--a-md { font-size:1rem; }
.seg__btn--a-lg { font-size:1.3rem; }
.seg__btn--a-xl { font-size:1.65rem; }
.seg__btn--a-md, .seg__btn--a-lg, .seg__btn--a-xl { font-weight:600; line-height:1; }

/* Свотчи акцента */
.swatches { display:flex; flex-wrap:wrap; gap:10px; }
.swatch {
  width:38px; height:38px; border-radius:50%;
  border:2px solid var(--border); cursor:pointer; padding:0;
  position:relative; transition:transform .12s, border-color .14s;
  display:flex; align-items:center; justify-content:center;
}
.swatch:hover { transform:translateY(-1px); }
.swatch--active { border-color:var(--text); }
.swatch__check { color:#fff; opacity:0; transition:opacity .12s; }
.swatch__check svg { width:16px; height:16px; display:block; }
.swatch--active .swatch__check { opacity:1; }
.sw-slate      { background:#41576b; }
.sw-emerald    { background:#2f6f57; }
.sw-terracotta { background:#a65a43; }
.sw-plum       { background:#6b4a72; }
.sw-blue       { background:#2f6fe0; }
.sw-violet     { background:#8b3fe0; }
.sw-rose       { background:#e0427a; }
.sw-amber      { background:#e08a1f; }
.sw-lime       { background:#05d545; }
html[data-theme="dark"] .sw-slate      { background:#7e95ab; }
html[data-theme="dark"] .sw-emerald    { background:#5fae8d; }
html[data-theme="dark"] .sw-terracotta { background:#cf8064; }
html[data-theme="dark"] .sw-plum       { background:#a98bb0; }
html[data-theme="dark"] .sw-blue       { background:#6a9bf2; }
html[data-theme="dark"] .sw-violet     { background:#ab7df0; }
html[data-theme="dark"] .sw-rose       { background:#f06d99; }
html[data-theme="dark"] .sw-amber      { background:#f0a847; }
html[data-theme="dark"] .sw-lime       { background:#2ee05f; }

/* Дозапись голосом на экране-сводке */
.voice-add {
  width: 100%; display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 11px 16px; margin-bottom: 14px;
  border: 2px dashed var(--border); border-radius: var(--radius);
  background: transparent; color: var(--primary);
  font-size: .92rem; font-weight: 600; cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.voice-add:hover:not(:disabled) { border-color: var(--primary); background: rgba(127,149,171,.08); }
.voice-add:disabled { opacity: .6; cursor: default; }
.voice-add .ic svg { width: 18px; height: 18px; }
.voice-add--on { border-style: solid; border-color: var(--danger); color: var(--danger); animation: voicePulse 1.4s infinite; }
.voice-add__hint { text-align: center; color: var(--muted); font-size: .85rem; margin: -6px 0 12px; font-style: italic; }

/* ══════════════════════════════════════════════════════════════════
   АНАЛИТИКА (раздел только для чтения) — дизайн-референс (Claude Design)
   ══════════════════════════════════════════════════════════════════ */
/* Палитра сегментов диаграмм — фиксирована (не зависит от акцента),
   читается в обеих темах. Нейтральный — для «Остального». */
:root {
  --cat-1:#5b7a99; --cat-2:#c08552; --cat-3:#5b9e7f; --cat-4:#8a6fae;
  --cat-5:#cf8295; --cat-6:#6fa6c4; --cat-7:#b0915a; --cat-rest:#b8bcc4;
}
html[data-theme="dark"] {
  --cat-1:#7e9bbd; --cat-2:#d49e6f; --cat-3:#74bd9b; --cat-4:#a78bca;
  --cat-5:#e0a3b3; --cat-6:#8db9d6; --cat-7:#cdb07a; --cat-rest:#565b66;
}
.seg-cat-1{color:var(--cat-1);} .seg-cat-2{color:var(--cat-2);} .seg-cat-3{color:var(--cat-3);}
.seg-cat-4{color:var(--cat-4);} .seg-cat-5{color:var(--cat-5);} .seg-cat-6{color:var(--cat-6);}
.seg-cat-7{color:var(--cat-7);} .seg-rest{color:var(--cat-rest);}

.an { padding:16px 20px 30px; }
.an-pos { color:var(--amt-in); } .an-neg { color:var(--amt-out); }

/* Управление: период */
.an-controls { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.an-period { display:flex; align-items:center; gap:6px; }
.an-nav {
  flex-shrink:0; width:34px; height:34px; border-radius:8px;
  background:var(--field); border:1px solid var(--border); color:var(--muted);
  display:flex; align-items:center; justify-content:center; cursor:pointer;
  transition:border-color .15s, color .15s;
}
.an-nav:hover:not(:disabled) { border-color:var(--accent); color:var(--accent); }
.an-nav:disabled { opacity:.35; cursor:not-allowed; }
.an-nav .ic svg { width:18px; height:18px; }
.an-period__label { font-size:1.02rem; font-weight:700; letter-spacing:.01em; min-width:120px; text-align:center; }

.an-gran { display:flex; gap:6px; margin-top:12px; }
.an-gran__btn {
  background:var(--field); border:1px solid var(--border); color:var(--muted);
  border-radius:8px; padding:6px 14px; font-size:.8rem; font-weight:600; cursor:pointer; font-family:inherit;
  transition:border-color .15s, color .15s;
}
.an-gran__btn--on { border-color:var(--accent); color:var(--accent); background:var(--accent-soft); }
.an-gran__btn:disabled { opacity:.45; cursor:not-allowed; }

/* Секции */
.an-body { margin-top:4px; }
.an-sec { padding:20px 0; border-top:1px solid var(--border); }
.an-sec:first-child { border-top:none; }
.an-h {
  font-size:.72rem; font-weight:700; letter-spacing:.06em; text-transform:uppercase;
  color:color-mix(in srgb, var(--muted) 40%, var(--text)); margin-bottom:14px;
}
.an-h--ai { display:flex; align-items:center; gap:8px; }
.an-ai__spark { color:var(--accent); }
.an-ai__spark svg { width:18px; height:18px; }

/* Сводка */
.an-sum { display:grid; grid-template-columns:1fr 1fr 1fr; gap:10px; }
.an-sum__card { background:var(--field); border:1px solid var(--border); border-radius:12px; padding:13px 12px; }
.an-sum__card--net { background:var(--accent-soft); border-color:transparent; }
.an-sum__label { font-size:.72rem; font-weight:600; color:var(--muted); margin-bottom:6px; }
.an-sum__val { font-size:1.04rem; font-weight:700; color:var(--text); font-variant-numeric:tabular-nums; line-height:1.2; }
.an-sum__foot { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-top:12px; flex-wrap:wrap; }
.an-delta { display:flex; align-items:center; gap:8px; font-size:.78rem; }
.an-delta__chip { display:inline-flex; align-items:center; gap:4px; padding:3px 9px; border-radius:20px; font-weight:600; font-variant-numeric:tabular-nums; }
.an-delta--good { background:color-mix(in srgb, var(--amt-in) 14%, var(--card)); color:var(--amt-in); }
.an-delta--bad  { background:color-mix(in srgb, var(--amt-out) 14%, var(--card)); color:var(--amt-out); }
.an-delta__cap { color:var(--muted); }

/* Расходы по категориям: donut + легенда */
.an-cats { display:flex; gap:18px; align-items:center; }
.an-donut { position:relative; flex-shrink:0; width:140px; height:140px; }
.an-donut__ring { position:absolute; inset:0; border-radius:50%; transition:background .5s ease; }
.an-donut__hole { position:absolute; inset:18px; border-radius:50%; background:var(--card); }
.an-donut__center { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; }
.an-donut__clabel { font-size:.66rem; font-weight:600; letter-spacing:.04em; text-transform:uppercase; color:var(--muted); }
.an-donut__cval { font-size:1.18rem; font-weight:700; color:var(--text); font-variant-numeric:tabular-nums; line-height:1.15; }
.an-donut__ccur { font-size:.62rem; color:var(--muted); }

.an-legend { flex:1; min-width:0; display:flex; flex-direction:column; }
.an-legitem { border-bottom:1px solid var(--border); }
.an-legitem:last-child { border-bottom:none; }
.an-legrow {
  display:flex; align-items:center; gap:9px; width:100%; padding:8px 2px;
  background:none; border:none; cursor:pointer; font-family:inherit; text-align:left;
  transition:background .12s;
}
.an-legrow:hover { background:var(--field); }
.an-legrow--open { background:var(--field); }
.an-legrow--sub { padding-left:8px; }
.an-dot { width:11px; height:11px; border-radius:3px; flex-shrink:0; background:currentColor; }
.an-dot--muted { color:var(--muted); opacity:.5; }
.an-dot--in { color:var(--amt-in); } .an-dot--out { color:var(--amt-out); }
.an-legrow__cat { flex:1; min-width:0; font-size:.86rem; font-weight:500; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.an-legrow__amt { font-size:.84rem; font-weight:600; color:var(--text); font-variant-numeric:tabular-nums; white-space:nowrap; }
.an-legrow__pct { font-size:.76rem; color:var(--muted); font-variant-numeric:tabular-nums; width:34px; text-align:right; flex-shrink:0; }
.an-legrow__chev { color:var(--muted); flex-shrink:0; transition:transform .2s; }
.an-legrow__chev svg { width:15px; height:15px; }
.an-legrow__chev--up { transform:rotate(180deg); }
.an-legrow--rest .an-legrow__cat { color:var(--muted); }
.an-rest { padding-bottom:4px; }
.an-detail { padding:2px 0 10px 20px; }
.an-detail__load { display:flex; justify-content:center; padding:10px 0; }

/* Динамика по месяцам */
.an-dyn { display:flex; align-items:flex-end; gap:3px; height:120px; }
.an-dyn__col {
  flex:1; min-width:0; display:flex; flex-direction:column; align-items:center; gap:6px;
  background:none; border:none; cursor:pointer; font-family:inherit; padding:4px 0 0; border-radius:6px;
  transition:background .12s;
}
.an-dyn__col:hover { background:var(--field); }
.an-dyn__bars { display:flex; align-items:flex-end; gap:2px; height:90px; width:100%; justify-content:center; }
.an-dyn__bar { width:7px; border-radius:3px 3px 0 0; transition:height .4s ease; }
.an-dyn__bar--in  { background:color-mix(in srgb, var(--amt-in) 55%, var(--card)); }
.an-dyn__bar--out { background:color-mix(in srgb, var(--amt-out) 55%, var(--card)); }
.an-dyn__col--active .an-dyn__bar--in  { background:var(--amt-in); }
.an-dyn__col--active .an-dyn__bar--out { background:var(--amt-out); }
.an-dyn__col--active { background:var(--accent-soft); }
.an-dyn__lbl { font-size:.66rem; color:var(--muted); font-weight:500; }
.an-dyn__col--active .an-dyn__lbl { color:var(--accent); font-weight:700; }
.an-legmini { display:flex; gap:16px; margin-top:12px; font-size:.74rem; color:var(--muted); flex-wrap:wrap; }
.an-legmini span { display:inline-flex; align-items:center; gap:6px; }
.an-legmini .an-dot { width:9px; height:9px; }

/* Динамика сбережений */
.an-sav__head { display:flex; gap:10px; margin-bottom:16px; }
.an-sav__metric { flex:1; background:var(--field); border:1px solid var(--border); border-radius:12px; padding:11px 13px; }
.an-sav__mlbl { font-size:.72rem; font-weight:600; color:var(--muted); margin-bottom:5px; }
.an-sav__mval { font-size:1.04rem; font-weight:700; font-variant-numeric:tabular-nums; line-height:1.2; }
.an-sav { position:relative; }
.an-sav__cum { position:absolute; left:4.1%; right:4.1%; top:0; height:108px; width:91.8%; color:var(--accent); pointer-events:none; z-index:2; overflow:visible; }
.an-sav__cols { display:flex; align-items:stretch; gap:3px; position:relative; z-index:1; }
.an-sav__col {
  flex:1; min-width:0; display:flex; flex-direction:column; align-items:center; gap:6px;
  background:none; border:none; cursor:pointer; font-family:inherit; padding:4px 0 0; border-radius:6px;
  transition:background .12s;
}
.an-sav__col:hover { background:var(--field); }
.an-sav__col--active { background:var(--accent-soft); }
.an-sav__plot { position:relative; width:100%; height:108px; }
.an-sav__plot::before { content:""; position:absolute; left:0; right:0; top:50%; height:1px; background:var(--border); }
.an-sav__bar { position:absolute; left:50%; transform:translateX(-50%); width:8px; border-radius:3px; transition:height .4s ease; }
.an-sav__bar--pos { background:color-mix(in srgb, var(--amt-in) 55%, var(--card)); border-radius:3px 3px 0 0; }
.an-sav__bar--neg { background:color-mix(in srgb, var(--amt-out) 55%, var(--card)); border-radius:0 0 3px 3px; }
.an-sav__col--active .an-sav__bar--pos { background:var(--amt-in); }
.an-sav__col--active .an-sav__bar--neg { background:var(--amt-out); }
.an-sav__lbl { font-size:.66rem; color:var(--muted); font-weight:500; }
.an-sav__col--active .an-sav__lbl { color:var(--accent); font-weight:700; }
.an-sav__linekey { display:inline-block; width:14px; height:0; border-top:2px solid var(--accent); border-radius:2px; }

/* Заграница / валюты */
.an-fx__total { display:flex; justify-content:space-between; align-items:baseline; padding:10px 12px; background:var(--field); border-radius:10px; font-size:.86rem; font-weight:600; }
.an-fx__totval { font-variant-numeric:tabular-nums; }
.an-fx__rows { display:flex; flex-direction:column; gap:9px; margin-top:12px; }
.an-fx__row { display:flex; align-items:center; gap:10px; font-size:.82rem; }
.an-fx__cur { width:58px; flex-shrink:0; color:var(--text); font-weight:500; }
.an-fx__bar { flex:1; height:7px; background:var(--field); border-radius:5px; overflow:hidden; }
.an-fx__bar > span { display:block; height:100%; border-radius:5px; background:var(--cat-2); transition:width .5s ease; }
.an-fx__rub { width:78px; text-align:right; flex-shrink:0; font-variant-numeric:tabular-nums; font-weight:600; color:var(--text); }
.an-fx__note { margin-top:10px; font-size:.74rem; color:var(--muted); }

/* ИИ-аналитика */
.an-ai__lead { font-size:.9rem; color:var(--text); line-height:1.5; margin-bottom:14px; }
.an-ai__btn { width:100%; }
.an-ai__btn .ic svg { width:18px; height:18px; }
.an-ai__disc { display:flex; align-items:center; gap:7px; margin-top:12px; font-size:.74rem; color:var(--muted); }
.an-ai__disc .ic { flex-shrink:0; } .an-ai__disc .ic svg { width:14px; height:14px; }
.an-ai__loadhead { display:flex; align-items:center; gap:10px; font-size:.88rem; color:var(--text); margin-bottom:14px; }
.an-ai__summary { font-size:.92rem; line-height:1.55; color:var(--text); margin-bottom:14px; padding:12px 14px; background:var(--accent-soft); border-radius:10px; }
.an-insights { display:flex; flex-direction:column; gap:10px; }
.an-ins {
  display:flex; gap:12px; padding:13px 14px; border-radius:12px;
  background:var(--card); border:1px solid var(--border); border-left:3px solid var(--cat-rest);
}
.an-ins--tap { cursor:pointer; transition:background .12s, border-color .12s; }
.an-ins--tap:hover { background:var(--field); }
.an-ins__icon { flex-shrink:0; width:30px; height:30px; border-radius:9px; background:var(--field); color:var(--muted); display:flex; align-items:center; justify-content:center; }
.an-ins__icon svg { width:18px; height:18px; }
.an-ins__body { min-width:0; flex:1; }
.an-ins__head { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:3px; }
.an-ins__kind { font-size:.68rem; font-weight:700; letter-spacing:.05em; text-transform:uppercase; color:var(--muted); }
.an-ins__metric { font-size:.78rem; font-weight:700; font-variant-numeric:tabular-nums; padding:2px 8px; border-radius:20px; background:var(--field); color:var(--text); white-space:nowrap; }
.an-ins__title { font-size:.92rem; font-weight:600; color:var(--text); line-height:1.35; margin-bottom:3px; text-wrap:pretty; }
.an-ins__detail { font-size:.82rem; color:var(--muted); line-height:1.5; text-wrap:pretty; }
.an-ins__link { font-size:.78rem; font-weight:600; color:var(--accent); margin-top:7px; }
/* типы инсайтов — акцент слева + иконка */
.an-ins--внимание   { border-left-color:var(--cat-2); } .an-ins--внимание   .an-ins__icon { color:var(--cat-2); background:color-mix(in srgb, var(--cat-2) 14%, var(--card)); }
.an-ins--изменение  { border-left-color:var(--cat-1); } .an-ins--изменение  .an-ins__icon { color:var(--cat-1); background:color-mix(in srgb, var(--cat-1) 14%, var(--card)); }
.an-ins--зависимость{ border-left-color:var(--cat-4); } .an-ins--зависимость .an-ins__icon { color:var(--cat-4); background:color-mix(in srgb, var(--cat-4) 14%, var(--card)); }
.an-ins--позитив    { border-left-color:var(--amt-in); } .an-ins--позитив    .an-ins__icon { color:var(--amt-in); background:color-mix(in srgb, var(--amt-in) 13%, var(--card)); }
.an-ins--факт       { border-left-color:var(--cat-rest); } .an-ins--факт .an-ins__icon { color:var(--muted); }
.an-ins--skel { height:64px; border-left-color:var(--border); background:linear-gradient(90deg, var(--field) 25%, color-mix(in srgb,var(--field) 50%, var(--card)) 50%, var(--field) 75%); background-size:200% 100%; animation:anShine 1.3s linear infinite; border-style:solid; }
@keyframes anShine { to { background-position:-200% 0; } }
.an-ai__refresh { margin-top:14px; }
.an-ai__refresh .ic svg { width:16px; height:16px; }
.an-ai__msg { padding:18px 16px; background:var(--field); border-radius:12px; text-align:center; }
.an-ai__msg--err { background:color-mix(in srgb, var(--danger) 10%, var(--card)); }
.an-ai__msgtitle { font-size:.92rem; font-weight:600; color:var(--text); margin-bottom:5px; }
.an-ai__msgsub { font-size:.82rem; color:var(--muted); line-height:1.45; margin-bottom:12px; }
.an-ai__msg .btn { margin-top:2px; }

/* Состояния / скелетоны / пусто-ошибка */
.an-state { text-align:center; padding:46px 20px; }
.an-state__ic { color:var(--muted); margin-bottom:12px; }
.an-state__ic svg { width:40px; height:40px; }
.an-state--err .an-state__ic { color:var(--danger); }
.an-state__title { font-size:1rem; font-weight:600; color:var(--text); margin-bottom:6px; }
.an-state__sub { font-size:.86rem; color:var(--muted); margin-bottom:14px; }
.an-skel { padding:8px 0; }
.an-skel__row--cards { display:grid; grid-template-columns:1fr 1fr 1fr; gap:10px; margin:14px 0; }
.an-skel span, .an-skel__block { display:block; border-radius:12px; background:linear-gradient(90deg, var(--field) 25%, color-mix(in srgb,var(--field) 50%, var(--card)) 50%, var(--field) 75%); background-size:200% 100%; animation:anShine 1.3s linear infinite; }
.an-skel__row--cards span { height:74px; }
.an-skel__block { height:150px; margin:14px 0; }
.an-skel__block--sm { height:90px; }

@media (min-width:560px) {
  .an-sum__val { font-size:1.12rem; }
}
