/* =====================================================================
   Разделы, финансы и мобильная вёрстка.
   Подключается после styles.css, поэтому здесь же живут переопределения
   общих правил для узких экранов.
   ===================================================================== */

/* ---------- Тема раздела ----------
   Достаточно одного атрибута на body: акцентные цвета наследуют и кнопки,
   и графики, и подсветка карточек. */
body[data-section="finance"] {
  --accent: #34d399;
  --accent-rgb: 52, 211, 153;
  --accent-ink: #b6f5da;
  --accent-soft: #6ee7b7;
  --accent-2: #a78bfa;
  background-image:
    radial-gradient(1000px 520px at 82% -8%, rgba(52, 211, 153, .16), transparent 70%),
    radial-gradient(760px 420px at 6% 4%, rgba(167, 139, 250, .13), transparent 68%);
}

/* ---------- Экран входа ---------- */
.login__globe { position: relative; display: inline-block; }
.login__coin { position: absolute; right: -20px; bottom: -4px; font-size: 26px; }
.login__card h1 { font-size: 27px; line-height: 1.2; }

.section { display: none; }
.section--active { display: block; animation: section-in .28s ease; }

@keyframes section-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Переключатель разделов ----------
   Он же заменяет логотип, поэтому оформлен сдержанно: подложка активного
   раздела — мягкая заливка акцентом, а не яркая плашка, иначе шапка
   перетягивает внимание на себя. */
.switcher {
  position: relative;
  display: flex;
  padding: 5px;
  /* Полупрозрачное дно, а не сплошной цвет: шапка сама по себе размыта,
     и на ней дорожка переключателя читается лучше, чем плоская плашка. */
  background: rgba(0, 0, 0, .3);
  border: 1px solid var(--line);
  border-radius: 999px;
}

/* Подложка едет за активной кнопкой — отсюда ощущение одного движения.
   Она намеренно нейтральная: цветная обводка на тёмном фоне читалась как
   предупреждение. За принадлежность к разделу отвечает точка у подписи. */
.switcher__pill {
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 5px;
  width: calc(50% - 5px);
  border-radius: 999px;
  background: var(--surface-2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08),
              0 2px 10px rgba(0, 0, 0, .45);
  transition: transform .32s cubic-bezier(.4, 1.25, .5, 1);
}

body[data-section="finance"] .switcher__pill { transform: translateX(100%); }

/* Точки видны обе сразу, поэтому цвета заданы явно, а не через --accent:
   иначе оба кружка перекрашивались бы вместе с темой. */
.switcher__btn::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
  transition: opacity .22s, box-shadow .22s;
}

.switcher__btn[data-section="travel"]::before { background: #ff7a59; }
.switcher__btn[data-section="finance"]::before { background: #34d399; }
.switcher__btn:not(.switcher__btn--on)::before { opacity: .35; }
.switcher__btn--on[data-section="travel"]::before { box-shadow: 0 0 10px rgba(255, 122, 89, .8); }
.switcher__btn--on[data-section="finance"]::before { box-shadow: 0 0 10px rgba(52, 211, 153, .8); }

.switcher__btn {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 9px 22px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -.01em;
  white-space: nowrap;
  transition: color .22s;
}

.switcher__btn--on { color: var(--text); }
.switcher__btn:not(.switcher__btn--on):hover { color: var(--text); }

/* Значки нужны только когда для подписей не хватает ширины. */
.switcher__icon { display: none; font-size: 17px; }

.tab { display: flex; align-items: center; gap: 7px; }
.tab__icon { display: none; font-size: 17px; line-height: 1; }

/* ---------- Кнопка быстрого добавления (только телефон) ---------- */
.fab {
  display: none;
  position: fixed;
  right: 18px;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  z-index: 45;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0a0e1a;
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .5);
}

.fab:active { transform: scale(.94); }

/* =====================================================================
   ФИНАНСЫ
   ===================================================================== */

.networth {
  display: flex;
  align-items: center;
  gap: 24px;
  background: linear-gradient(140deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 28px;
  box-shadow: var(--shadow);
}

.networth--empty { background: var(--surface); box-shadow: none; }
.networth--empty .networth__hint { max-width: 56ch; margin-top: 12px; line-height: 1.6; }

.networth__main { flex: 1; min-width: 0; }
.networth__label { color: var(--muted); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.networth__value { font-size: 46px; font-weight: 800; letter-spacing: -.03em; margin-top: 6px; line-height: 1.05; }
.networth__delta { margin-top: 8px; font-weight: 700; font-size: 14px; }
.networth__delta.is-up { color: var(--ok); }
.networth__delta.is-down { color: var(--danger); }
.networth__hint { margin-top: 10px; color: var(--muted); font-size: 12px; }
.networth__chart { width: min(380px, 48%); }

.chart { width: 100%; height: 130px; display: block; overflow: visible; }
.chart-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 30px 10px; }

/* Состав капитала: доли задаются через flex-grow. */
.kindbar { display: flex; gap: 3px; height: 10px; margin-top: 14px; }
.kindbar__seg { border-radius: 999px; min-width: 6px; }
.kindbar__seg--cash { background: #4ade80; }
.kindbar__seg--card { background: #60a5fa; }
.kindbar__seg--bank { background: #38bdf8; }
.kindbar__seg--savings { background: #facc15; }
.kindbar__seg--investment { background: #fb923c; }
.kindbar__seg--crypto { background: #a78bfa; }
.kindbar__seg--other { background: #8b95b8; }

.kindlegend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 12px; }
.kindlegend__item { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.kindlegend__item b { color: var(--text); }
.kindlegend__dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

.fin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 22px;
}

/* На широком экране раскладка задаётся руками: главные карточки — месяц и
   динамика — шире остальных, иначе шесть одинаковых плиток читаются как
   список, а не как сводка. */
@media (min-width: 1180px) {
  .fin-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .fincard--month { grid-column: span 2; }
  .fincard--flow { grid-column: span 2; }
  .fincard--start { grid-column: span 3; }
}

.fincard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
}

.fincard__head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.fincard__head h3 { font-size: 17px; }
.fincard__sub { margin-left: auto; color: var(--muted); font-size: 13px; }
.fincard__hint { color: var(--muted); font-size: 12px; margin: 14px 0 0; line-height: 1.5; }
.fin-empty { color: var(--muted); font-size: 14px; line-height: 1.6; margin: 0; }

.fin-empty--action {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  padding: 26px;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.fin-empty--action p { margin: 0; max-width: 60ch; }

/* ---------- Первый экран: три шага ---------- */
.fincard--start h3 { font-size: 19px; margin-bottom: 18px; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }
.step { display: flex; gap: 14px; align-items: flex-start; }

.step__num {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(var(--accent-rgb), .16);
  border: 1px solid rgba(var(--accent-rgb), .45);
  color: var(--accent-ink);
  font-weight: 800;
  font-size: 14px;
}

.step.is-done .step__num { background: rgba(74, 222, 128, .16); border-color: rgba(74, 222, 128, .5); color: var(--ok); }
.step.is-done .step__num::after { content: '✓'; }
.step.is-done .step__num { font-size: 0; }
.step.is-done .step__num::after { font-size: 15px; }

.step__body { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.step__body b { font-size: 15px; }
.step__body small { color: var(--muted); font-size: 13px; line-height: 1.55; max-width: 62ch; }
.step__body .btn, .step__actions { margin-top: 4px; }
.step__actions { display: flex; gap: 8px; }

/* ---------- Темп трат ---------- */
.pace { display: flex; flex-direction: column; gap: 14px; }
.pace__main { display: flex; flex-direction: column; gap: 2px; }
.pace__value { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.pace__label { color: var(--muted); font-size: 12px; }

.pace__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

.pace__row b { color: var(--text); font-size: 15px; }
.pace__row.is-over b { color: var(--danger); }
.pace__bar { display: grid; gap: 7px; }
.pace__bar small { color: var(--muted); font-size: 12px; }

.monthpick {
  margin-left: auto;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text);
  outline: none;
}

.money3 { display: flex; flex-wrap: wrap; gap: 16px 26px; }
.money3__item { display: flex; flex-direction: column; gap: 3px; }
.money3__label { color: var(--muted); font-size: 12px; }
.money3__value { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.is-income { color: var(--ok); }
.is-expense { color: var(--danger); }

.iebar { display: grid; gap: 6px; margin-top: 16px; }
.iebar__row { height: 9px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.iebar__fill { display: block; height: 100%; border-radius: 999px; transition: width .4s; }
.iebar__fill.is-income { background: var(--ok); }
.iebar__fill.is-expense { background: var(--danger); }

/* ---------- Кольцо расходов ---------- */
.donutwrap { position: relative; width: 170px; margin: 0 auto 18px; }
.donut { width: 100%; display: block; }
.donut__track { fill: none; stroke: var(--bg-soft); stroke-width: 16; }
.donut__seg { fill: none; stroke-width: 16; transition: stroke-dasharray .4s; }

.donut__center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.donut__label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.donut__value { font-size: 19px; font-weight: 800; letter-spacing: -.02em; }

.catlist { display: grid; gap: 4px; }

.catrow {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  font-size: 13px;
  padding: 5px 7px;
  margin: 0 -7px;
  border: 0;
  background: transparent;
  border-radius: 9px;
  text-align: left;
  cursor: pointer;
  transition: background .15s;
}

.catrow:disabled { cursor: default; }
.catrow:not(:disabled):hover { background: var(--bg-soft); }
.catrow__dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.catrow__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catrow__share { color: var(--muted); font-size: 12px; }
.catrow__sum { font-weight: 700; white-space: nowrap; }

/* ---------- Столбики доходов и расходов ---------- */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 150px; }
.bars__group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; }
.bars__pair { flex: 1; display: flex; align-items: flex-end; gap: 3px; width: 100%; justify-content: center; }
.bars__bar { width: 12px; border-radius: 5px 5px 0 0; min-height: 2px; transition: height .4s; }
.bars__bar.is-income { background: var(--ok); }
.bars__bar.is-expense { background: var(--danger); }
.bars__label { color: var(--muted); font-size: 11px; }

.duelist, .reclist, .acclist, .goals { display: grid; gap: 10px; }

.duerow {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.duerow.is-late { border-color: rgba(248, 113, 113, .5); }
.duerow__icon { font-size: 19px; }
.duerow__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.duerow__body b { font-size: 14px; }
.duerow__body small { color: var(--muted); font-size: 12px; }
.duerow__sum { font-weight: 700; font-size: 14px; white-space: nowrap; }

/* ---------- Прогресс ---------- */
.pbar { height: 8px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.pbar--lg { height: 12px; }

.pbar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .45s ease;
}

.goalmini { margin-bottom: 14px; }
.goalmini:last-child { margin-bottom: 0; }
.goalmini__top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 7px; }
.goalmini__top span:last-child { color: var(--muted); white-space: nowrap; }

/* ---------- Счета ---------- */
.acclist { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.acclist--muted { opacity: .55; }

.acc {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  overflow: hidden;
}

/* Цветная полоска сверху подсказывает тип счёта без лишних подписей. */
.acc::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--accent);
}

.acc--cash::before { background: #4ade80; }
.acc--card::before { background: #60a5fa; }
.acc--bank::before { background: #38bdf8; }
.acc--savings::before { background: #facc15; }
.acc--investment::before { background: #fb923c; }
.acc--crypto::before { background: #a78bfa; }
.acc--other::before { background: #8b95b8; }

.acc__top { display: flex; align-items: center; gap: 11px; }
.acc__icon { font-size: 24px; }
.acc__name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.acc__name b { font-size: 15px; }
.acc__name small { color: var(--muted); font-size: 12px; }
.acc__balance { font-size: 27px; font-weight: 800; letter-spacing: -.02em; margin-top: 14px; }
.acc__converted { color: var(--muted); font-size: 13px; margin-top: 3px; }

.acc__share { margin-top: 12px; display: grid; gap: 5px; }
.acc__share small { color: var(--muted); font-size: 11px; }

.acc__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

/* ---------- Операции ---------- */
.txfilters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.txfilters .search { flex: 1 1 240px; }
.txfilters .select { width: auto; flex: 0 1 190px; }
.txfilters .presets { margin: 0; }

/* Итоги за выбранный период — первое, что хочется узнать, открыв ленту. */
.txsum {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 28px;
  padding: 16px 20px;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.txsum__item { display: flex; flex-direction: column; gap: 2px; }
.txsum__item small { color: var(--muted); font-size: 12px; }
.txsum__item b { font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.txsum__count { margin-left: auto; color: var(--muted); font-size: 12px; }

.txday { margin-bottom: 22px; }

.txday__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 0 4px 8px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.txday__sum { color: var(--danger); font-weight: 700; }

.tx {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, transform .12s;
}

.tx:hover { border-color: var(--accent); transform: translateX(2px); }
.tx--expense { border-left-color: var(--danger); }
.tx--income { border-left-color: var(--ok); }
.tx--transfer { border-left-color: #60a5fa; }
.tx--adjust { border-left-color: var(--warn); }

.tx__icon { font-size: 20px; width: 26px; text-align: center; flex: none; }
.tx__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tx__title { font-size: 14px; font-weight: 600; }
.tx__sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx__amount { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; white-space: nowrap; }
.tx__amount b { font-size: 15px; }
.tx__amount small { color: var(--muted); font-size: 11px; }
.tx--expense .tx__amount b { color: var(--danger); }
.tx--income .tx__amount b { color: var(--ok); }

/* ---------- Бюджеты ---------- */
.budget-month { color: var(--muted); font-size: 13px; margin: 0 0 16px; }

.catline {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  margin-bottom: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  transition: border-color .15s;
}

.catline:hover { border-color: var(--accent); }
.catline:hover .catline__act { opacity: 1; }
.catline__dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.catline__name { flex: 1; min-width: 0; }
.catline__sum { font-weight: 700; white-space: nowrap; }
.catline__act { color: var(--accent); font-size: 12px; opacity: 0; transition: opacity .15s; white-space: nowrap; }

.budget {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 15px 18px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color .15s;
}

.budget:hover { border-color: var(--accent); }
.budget.is-over { border-color: rgba(248, 113, 113, .55); }
.budget__top { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 9px; font-size: 14px; }
.budget__name { font-weight: 600; }
.budget__sum { color: var(--muted); font-size: 13px; white-space: nowrap; }
.budget__foot { margin-top: 8px; color: var(--muted); font-size: 12px; }

/* ---------- Регулярные платежи ---------- */
.rec {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.rec.is-off { opacity: .5; }
.rec__icon { font-size: 20px; }
.rec__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rec__body b { font-size: 14px; }
.rec__body small { color: var(--muted); font-size: 12px; }
.rec__sum { font-weight: 700; white-space: nowrap; }
.rec__actions { display: flex; align-items: center; gap: 8px; }

/* ---------- Цели ---------- */
.goals { grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }

.goal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
}

.goal.is-done { border-color: rgba(74, 222, 128, .45); }
.goal__head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.goal__icon { font-size: 26px; line-height: 1; }
.goal__title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.goal__title b { font-size: 16px; }
.goal__title small { color: var(--muted); font-size: 12px; }
.goal__nums { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.goal__nums b { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.goal__nums span { color: var(--muted); font-size: 13px; }

.goal__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.goal__due { margin-top: 8px; color: var(--muted); font-size: 12px; }

.movelist { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 7px; }
.moverow { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.moverow b { margin-left: auto; color: var(--ok); }

/* ---------- Формы финансов ---------- */
.kindtabs { display: flex; gap: 4px; background: var(--bg-soft); padding: 4px; border-radius: 999px; margin-bottom: 20px; }

.kindtab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: background .15s, color .15s;
}

.kindtab--on { background: var(--accent); color: #0a0e1a; }

.form-grid .field--wide { grid-column: 1 / -1; }
.field--amount input { font-size: 30px; font-weight: 800; padding: 14px 16px; letter-spacing: -.02em; }
.amount-hint { grid-column: 1 / -1; color: var(--muted); font-size: 13px; margin: -8px 0 12px; min-height: 18px; }

.field--check { display: flex; align-items: center; gap: 10px; }
.field--check input { width: auto; flex: none; }
.field--check > span { margin: 0; font-size: 13px; color: var(--text); }

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.form-actions .btn--danger { margin-right: auto; }

.modal__lead { color: var(--muted); font-size: 14px; margin: -6px 0 18px; }
.modal__hint { color: var(--muted); font-size: 12px; line-height: 1.55; margin: 16px 0 0; }

.catgrid { display: flex; flex-wrap: wrap; gap: 7px; }

.catchip {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}

.catchip:hover { color: var(--text); border-color: var(--accent); }
.catchip--on { background: var(--accent); border-color: var(--accent); color: #0a0e1a; font-weight: 600; }

.icon-btn {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--muted);
  border-radius: 9px;
  width: 30px;
  height: 30px;
  flex: none;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.icon-btn:hover { color: var(--text); border-color: var(--accent); }

.linkbtn {
  border: 0;
  background: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  padding: 0;
}

.linkbtn:hover { text-decoration: underline; }
.linkbtn--muted { color: var(--muted); }
.linkbtn--muted:hover { color: var(--text); }
.acc__links { display: flex; align-items: center; gap: 12px; }

.section-head--sub { margin-top: 26px; }
.section-head--sub h3 { font-size: 15px; color: var(--muted); font-weight: 600; }

/* =====================================================================
   ТЕЛЕФОН
   Вкладки уезжают в нижнюю панель, модалки становятся шторками,
   крупные числа уменьшаются — всё дотягивается большим пальцем.
   ===================================================================== */

@media (max-width: 760px) {
  /* backdrop-filter у шапки делает её контейнером для position: fixed,
     и нижняя панель вкладок «прилипала» бы к шапке, а не к экрану. */
  .topbar {
    padding: 10px 14px;
    gap: 10px;
    row-gap: 10px;
    backdrop-filter: none;
    background: rgba(10, 14, 26, .97);
  }

  .topbar__brand { font-size: 17px; }
  .topbar__backup { display: none; }
  .topbar__right { gap: 8px; }
  .switcher { order: 2; flex: 1 1 100%; }
  .switcher__btn { padding: 9px 10px; font-size: 13px; }

  /* Вкладки — нижняя панель навигации. */
  .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 44;
    gap: 0;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    border-radius: 0;
    border-top: 1px solid var(--line);
    background: rgba(10, 14, 26, .94);
    backdrop-filter: blur(16px);
  }

  .tab { flex: 1; flex-direction: column; gap: 3px; padding: 7px 2px; font-size: 11px; border-radius: 12px; }
  .tab__icon { display: block; }
  .tab__text { font-size: 11px; }

  .main { padding: 16px 16px 92px; }
  .fab { display: flex; align-items: center; justify-content: center; }
  .fab.hidden { display: none !important; }

  /* Капитал */
  .networth { flex-direction: column; align-items: stretch; gap: 16px; padding: 20px; }
  .networth__value { font-size: 36px; }
  .networth__chart { width: 100%; }
  .chart { height: 110px; }
  .kindlegend { gap: 6px 14px; font-size: 12px; }

  .fin-grid { grid-template-columns: 1fr; gap: 12px; margin-top: 18px; }
  .fincard { padding: 17px 18px; }
  .money3 { gap: 14px 20px; }
  .money3__value { font-size: 19px; }
  .bars { height: 120px; gap: 6px; }
  .bars__bar { width: 9px; }

  .acclist, .goals { grid-template-columns: 1fr; }
  .acc__balance { font-size: 24px; }

  .txfilters { gap: 8px; }
  .txfilters .search { flex-basis: 100%; }
  .txfilters .select { flex: 1 1 45%; }
  /* Чипы периода прокручиваются вбок, а не переносятся: подпись вроде
     «Этот месяц» не должна разрываться на две строки. */
  .txfilters .presets {
    flex-basis: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .txfilters .presets::-webkit-scrollbar { display: none; }
  .txfilters .preset { flex: none; white-space: nowrap; }
  .txsum { padding: 14px 16px; gap: 12px 20px; }
  .txsum__item b { font-size: 17px; }
  .txsum__count { flex-basis: 100%; margin-left: 0; }
  .catline__act { display: none; }
  .step__body small { font-size: 12.5px; }
  .tx { padding: 11px 12px; gap: 10px; }
  .tx__icon { font-size: 18px; width: 22px; }

  .rec { flex-wrap: wrap; }
  .rec__sum { margin-left: auto; }
  .rec__actions { flex-basis: 100%; justify-content: flex-end; }

  /* Модалка — шторка снизу: до кнопок легко дотянуться. */
  .modal { align-items: flex-end; padding: 0; }
  .modal__card { width: 100%; max-height: 92vh; border-radius: 22px 22px 0 0; animation: sheet-in .25s ease; }
  .modal__body { padding: 20px 18px calc(24px + env(safe-area-inset-bottom, 0px)); }
  .form-grid { grid-template-columns: 1fr; }
  .form-actions { position: sticky; bottom: 0; background: var(--surface); padding-bottom: 4px; }
  .field--amount input { font-size: 26px; }

  /* Поля не должны подхватывать зум Safari — ниже 16px он приближает экран. */
  .field input, .field select, .field textarea, .select, .search__input { font-size: 16px; }

  .docs { grid-template-columns: 1fr; }
  .doc { padding: 13px 14px; gap: 10px; }
  .doc__status b { font-size: 12px; }
  .map-legend { gap: 6px 14px; font-size: 12px; }
}

@keyframes sheet-in {
  from { transform: translateY(28px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

@media (max-width: 330px) {
  .switcher__text { display: none; }
  .switcher__btn { padding: 9px 6px; }
  .switcher__btn::before { display: none; }
  .switcher__icon { display: block; font-size: 18px; }
  .networth__value { font-size: 31px; }
  .tab__text { font-size: 10px; }
}

/* ---------- Документы ---------- */
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.docs--muted { opacity: .55; }

.doc {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 15px 17px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ok);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, transform .12s;
}

.doc:hover { transform: translateX(2px); }
.doc.is-soon { border-left-color: var(--warn); }
.doc.is-dead { border-left-color: var(--danger); }

.doc__icon { font-size: 24px; flex: none; }
.doc__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.doc__body b { font-size: 15px; }
.doc__body small { color: var(--muted); font-size: 12px; }
.doc__note { font-style: italic; }
.doc__status { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; white-space: nowrap; }
.doc__status b { font-size: 13px; }
.doc__status small { color: var(--muted); font-size: 11px; }
.doc.is-dead .doc__status small { color: var(--danger); }
.doc.is-soon .doc__status small { color: var(--warn); }

/* ---------- Траты по поездке ---------- */
.trip__spend {
  margin-top: 14px;
  padding: 13px 15px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.trip__spend-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 9px;
}

.trip__spend-row { display: flex; align-items: center; gap: 9px; font-size: 13px; padding: 3px 0; }
.trip__spend-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.trip__spend-name { flex: 1; min-width: 0; }
.trip__spend-sum { font-weight: 700; }

/* ---------- Легенда карты ---------- */
.map-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 14px 0 6px; }
.map-legend__item { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.map-legend__item i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* Архивные категории: видно, что они выключены, но их можно вернуть. */
.chip--archived { opacity: .6; border-style: dashed; }
.chip--archived:hover { opacity: 1; }

/* Переключатель архива отделён от остальных полей — раньше он стоял
   вплотную к кнопке «Сохранить», и его задевали случайно. */
.field--archive {
  margin-top: 6px;
  padding: 12px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  align-items: flex-start;
}

.field--archive > span { color: var(--muted); line-height: 1.5; }
.field--archive input { margin-top: 2px; }
