/* =========================================================================
   Семейный бюджет — светлый минимализм: белый фон, чёрная типографика,
   кислотно-лаймовый акцент.
   ========================================================================= */
:root {
  color-scheme: light;
  --bg: #FFFFFF;          /* фон */
  --surface: #F2F2F2;     /* подложки */
  --text: #000000;        /* текст */
  --text-2: #8A8A8A;      /* второстепенный */
  --accent: #A9D4FF;      /* акцент: светло-синий */
  --banner: #7ED321;      /* баннер */
  --tab-active: #A38B73;  /* активная вкладка */
  --line: #E4E4E4;        /* тонкие разделители и обводки */
  --track: #F2F2F2;       /* дорожка полос */
  --future: #D9D9D9;      /* будущие дни на графике */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --error: #c62828;
  --nav-h: 64px;
  --font: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; background: var(--bg); }
body {
  /* clip, а не hidden: hidden делает body прокручиваемым контейнером и ломает position: sticky */
  margin: 0; background: var(--bg); color: var(--text); overflow-x: clip; width: 100%;
  font: 400 15px/1.45 var(--font); -webkit-tap-highlight-color: transparent;
}
h1, h2 { margin: 0; font-weight: 800; text-transform: lowercase; letter-spacing: -0.02em; line-height: 1.05; }
h1 { font-size: 40px; }
h2 { font-size: 24px; }
p { margin: 0; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.cap { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .15em; color: var(--text-2); }
.hint { margin-top: -8px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.error { color: var(--error); font-size: 14px; }
.error:empty { display: none; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

/* ---------- кнопки ---------- */
.btn {
  font: 600 13px/1 var(--font); text-transform: uppercase; letter-spacing: .15em;
  border: 1px solid var(--text); border-radius: 0; padding: 16px 20px; cursor: pointer;
  background: var(--bg); color: var(--text); transition: background .15s, color .15s;
}
.btn.primary { background: var(--text); color: var(--bg); }
.btn.primary:hover { background: #222; }
.btn.ghost:hover { background: var(--surface); }
.btn.big { padding: 20px 28px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.small-btn { padding: 9px 12px; font-size: 11px; }
.icon-btn {
  width: 40px; height: 40px; padding: 0; border: 0; background: none; color: var(--text);
  display: grid; place-items: center; flex: none; cursor: pointer;
}
.icon-btn:disabled { color: var(--line); cursor: default; }
.link-btn {
  font: 500 11px var(--font); text-transform: uppercase; letter-spacing: .15em; color: var(--text);
  background: none; border: 0; padding: 6px 0; cursor: pointer; text-align: left;
}

/* ---------- поля ---------- */
label { display: grid; gap: 8px; min-width: 0; }
input, select, textarea {
  font: 400 16px var(--font); color: var(--text); background: var(--surface);
  border: 0; border-radius: 0; padding: 14px 14px;
  min-width: 0; width: 100%; max-width: 100%; display: block; margin: 0;
}
input::placeholder, textarea::placeholder { color: var(--text-2); }
textarea { resize: none; line-height: 1.4; overflow: hidden; }
input:focus, select:focus, textarea:focus { outline: 1px solid var(--text); outline-offset: 0; }
select { -webkit-appearance: none; appearance: none; background-image: linear-gradient(45deg, transparent 50%, #000 50%), linear-gradient(135deg, #000 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
/* iOS рисует поле даты по-своему и раздувает его ширину — приводим к обычному полю */
input[type="date"] { -webkit-appearance: none; appearance: none; min-height: 50px; line-height: 22px; text-align: left; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
input[type="date"]::-webkit-calendar-picker-indicator { opacity: .6; }
.stack { display: grid; gap: 12px; }

/* ---------- пилюли: переключатели и чипы ---------- */
.pills, .chips { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.pills button, .chips button {
  font: 500 14px/1.2 var(--font); color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 999px; padding: 9px 16px; cursor: pointer;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pills button:hover, .chips button:hover { border-color: var(--text); }
.pills button.on, .chips button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.pills.small button { padding: 6px 12px; font-size: 13px; }
.chips button.add { border-style: dashed; color: var(--text-2); }
.chips button:disabled { cursor: default; }
.chips button:disabled:not(.on) { color: var(--text-2); }

/* ---------- аватары ---------- */
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--surface); color: var(--text); font-weight: 700; overflow: hidden;
  background-size: cover; background-position: center;
}
.avatar.sm { width: 36px; height: 36px; font-size: 15px; }
.avatar.xl { width: 112px; height: 112px; font-size: 44px; }

/* ---------- вход ---------- */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 64px;
  max-width: 1120px; margin: 0 auto; padding: 64px 32px; align-items: center;
}
.hero { display: grid; gap: 20px; justify-items: start; }
.hero h1 { font-size: 72px; }
.eyebrow {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .15em;
  background: var(--accent); padding: 6px 10px;
}
.lead { font-size: 18px; max-width: 34em; }
.features { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.features li::before { content: ""; display: inline-block; width: 8px; height: 8px; background: var(--accent); outline: 1px solid var(--text); margin-right: 12px; vertical-align: middle; }
.auth-card { display: grid; gap: 24px; min-width: 0; }
.auth-card form { display: grid; gap: 16px; }

/* ---------- шапка ---------- */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: 12px 32px; padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.who { min-width: 0; flex: 1; }
.fam { font-weight: 800; font-size: 20px; text-transform: lowercase; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .cap { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; gap: 8px; }
.tabs button {
  font: 500 11px var(--font); text-transform: uppercase; letter-spacing: .15em; color: var(--text);
  border: 0; background: none; cursor: pointer; padding: 8px 12px; display: flex; align-items: center; gap: 8px;
}
.tabs button.on { color: var(--tab-active); }
#refresh.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.demo-bar {
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--accent);
}
.demo-bar .cap { color: var(--text); }
.demo-bar select { width: auto; padding: 8px 32px 8px 12px; font-size: 14px; display: inline-block; background-color: var(--bg); }
.demo-bar .demo-exit { background: var(--bg); }
.mobile-only { display: none; }
.demo-exit { white-space: nowrap; flex: none; }

main { max-width: 880px; margin: 0 auto; padding: 32px 32px 64px; }
.view { display: grid; grid-template-columns: minmax(0, 1fr); gap: 48px; }
.block { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; min-width: 0; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }

/* ---------- внести ---------- */
.entry-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.entry-form.editing .amount { box-shadow: inset 0 -3px 0 var(--accent); }
.amount-field { gap: 4px; }
input.amount {
  background: none; padding: 0; font-size: 72px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
input.amount:focus { outline: 0; box-shadow: inset 0 -3px 0 var(--text); }
.save-bar { background: var(--bg); padding: 8px 0 0; }

.entries, .members { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.entries li, .members li {
  display: flex; align-items: center; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); min-width: 0;
}
.entries li:last-child, .members li:last-child { border-bottom: 1px solid var(--line); }
.entries .main { flex: 1; min-width: 0; text-align: left; font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.entries .main:disabled { cursor: default; }
.entries .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entries .sub { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entries .sum { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; flex: none; }
.entries .sum.income::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--banner); margin-right: 6px; vertical-align: middle; }
/* строка записи: верхний слой сдвигается свайпом, под ним красная кнопка с корзиной */
.entries li.entry { display: block; position: relative; overflow: hidden; padding: 0; touch-action: pan-y; }
.swipe-row {
  display: flex; align-items: center; gap: 12px; padding: 16px 0; min-width: 0;
  position: relative; z-index: 1; background: var(--bg); transition: transform .2s ease, padding .2s ease;
}
/* у открытой строки сумма не прилипает к красной кнопке */
.entries li.open .swipe-row { padding-right: 20px; }
.swipe-del {
  position: absolute; top: 0; right: 0; bottom: 0; width: 88px; border: 0; cursor: pointer;
  background: #E53935; color: #fff; display: grid; place-items: center;
}
.swipe-del svg { width: 26px; height: 26px; }
.swipe-del { visibility: hidden; }              /* иначе краешек просвечивает у каждой строки */
li.reveal .swipe-del { visibility: visible; }
.entries li.active .swipe-row { background: var(--accent); }
.edit-actions { display: flex; gap: 20px; }
.link-btn.danger { color: var(--error); }
.del {
  border: 0; background: none; color: var(--text-2); font-size: 22px; width: 32px; height: 32px; cursor: pointer; flex: none;
}
.del:hover { color: var(--text); }
.empty { color: var(--text-2); padding: 12px 0; }
.members .main { flex: 1; min-width: 0; }

/* ---------- отчёт ---------- */
.filters { display: flex; gap: 12px; flex-wrap: wrap; justify-content: space-between; }
.period-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -24px 0; }
.period-nav .cap { color: var(--text); font-size: 12px; text-align: center; }

.report-hero { display: grid; gap: 24px; }
.big-sum { display: grid; gap: 6px; }
.big-sum .v { font-size: 80px; font-weight: 800; letter-spacing: -0.04em; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.big-sum .v small { font-size: .45em; font-weight: 700; letter-spacing: 0; margin-left: 4px; }
.big-sum .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.badge-delta {
  display: inline-block; background: var(--text); color: var(--accent); font-size: 12px; font-weight: 600;
  padding: 3px 8px; letter-spacing: .02em; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.stat { background: var(--bg); padding: 16px; display: grid; gap: 6px; align-content: start; min-width: 0; }
.stat .v { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .s { font-size: 12px; color: var(--text-2); }
.meter { height: 4px; background: var(--track); overflow: hidden; }
.meter > div { height: 100%; }
.status { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; }

.hbars { display: grid; gap: 16px; }
.hbar { display: grid; gap: 6px; min-width: 0; }
.hbar-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; min-width: 0; }
.hbar-top .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.hbar-top .val { white-space: nowrap; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 8px; }
.hbar-top .pct { font-weight: 700; min-width: 3ch; text-align: right; }
.delta { background: var(--text); color: var(--accent); font-size: 11px; font-weight: 600; padding: 2px 6px; }
.track { height: 3px; background: var(--track); }
.track > div { height: 100%; background: var(--text); min-width: 2px; }

.chart { position: relative; width: 100%; min-width: 0; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; fill: initial; stroke: none; }
.chart text { font: 400 11px var(--font); fill: var(--text-2); font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--text); }
.chart .bar.future { fill: var(--future); }
.chart .bar.hover { fill: #444; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .base { stroke: var(--text); stroke-width: 1; }
.chart .avg { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .hit { fill: transparent; cursor: pointer; }
.legend-note { font-size: 12px; color: var(--text-2); display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; }
.legend-note .sw { display: inline-block; width: 16px; height: 0; border-top: 1px dashed var(--text-2); vertical-align: middle; margin-right: 6px; }

.advice { display: grid; gap: 8px; }
.tip { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 14px; padding: 16px; background: var(--surface); }
.tip .badge {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; background: var(--text); color: var(--accent);
}
.tip.warning .badge { background: var(--warning); color: var(--text); }
.tip.critical .badge { background: var(--critical); color: #fff; }
.tip.good .badge { background: var(--banner); color: var(--text); }
.tip b { display: block; margin-bottom: 4px; font-weight: 700; }
.tip p { color: #555; font-size: 14px; }

/* ---------- профиль ---------- */
.profile-hero { display: grid; justify-items: center; gap: 12px; text-align: center; padding-top: 8px; }
.profile-hero h1 { font-size: 36px; max-width: 100%; overflow-wrap: anywhere; text-transform: none; }
.role-pill {
  background: var(--text); color: var(--bg); border-radius: 999px; padding: 6px 14px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .15em;
}
.menu { display: grid; border-top: 1px solid var(--line); }
.menu button {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  background: none; border: 0; border-bottom: 1px solid var(--line); padding: 20px 0; cursor: pointer; color: var(--text);
  font: 800 24px/1.1 var(--font); text-transform: lowercase; letter-spacing: -0.02em; text-align: left;
}
.menu button span { font-weight: 400; font-size: 28px; color: var(--text); }
.menu button:hover { padding-left: 6px; }
.menu .menu-quiet { color: var(--text-2); }
.subpage { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.invite-code {
  font-size: 36px; font-weight: 800; letter-spacing: .15em; font-variant-numeric: tabular-nums;
  padding: 20px 14px; background: var(--accent); text-align: center; overflow-wrap: anywhere;
}

/* ---------- статистика ---------- */
.stats-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.stats-body h2 { margin-top: 16px; }
.stats-body .stat.disk { border: 1px solid var(--line); }
.table-wrap { overflow-x: auto; }
.stat-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.stat-table th {
  font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: .12em; color: var(--text-2);
  text-align: right; padding: 8px 6px; border-bottom: 1px solid var(--text);
}
.stat-table td { text-align: right; padding: 10px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.stat-table th:first-child, .stat-table td:first-child { text-align: left; padding-left: 0; white-space: normal; }
.stat-table td:first-child { font-weight: 600; overflow-wrap: anywhere; }
.stat-table td:last-child { white-space: normal; }
.retention { margin: 0; padding-left: 18px; display: grid; gap: 6px; }

/* ---------- всплывающие ---------- */
.tooltip {
  position: fixed; z-index: 50; pointer-events: none; background: var(--text); color: var(--bg);
  padding: 8px 10px; font-size: 13px; line-height: 1.35; white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px));
}
.tooltip b { color: var(--accent); font-weight: 600; }
@media (min-width: 761px) { .swipe-del { display: none; } }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; max-width: calc(100vw - 32px);
  background: var(--text); color: var(--bg); padding: 12px 18px; font-size: 14px;
}

/* ---------- телефон ---------- */
@media (max-width: 760px) {
  h1 { font-size: 34px; }
  h2 { font-size: 22px; }
  .auth { grid-template-columns: minmax(0, 1fr); padding: 32px 16px; gap: 40px; }
  .hero h1 { font-size: 48px; }
  .lead { font-size: 16px; }
  .top { padding-left: 16px; padding-right: 8px; gap: 8px; }
  .fam { font-size: 17px; line-height: 1.1; white-space: normal; overflow: visible; overflow-wrap: anywhere; }
  .who .cap { white-space: normal; overflow: visible; font-size: 10px; letter-spacing: .12em; }
  .top .avatar.sm { width: 32px; height: 32px; font-size: 13px; }
  .mobile-only { display: inline-block; }
  .desktop-only { display: none; }
  .top .demo-exit { padding: 8px 8px; font-size: 10px; letter-spacing: .1em; }

  /* нижняя навигация и баннер над ней */
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--bg);
    border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  }
  .tabs button { flex-direction: column; gap: 4px; font-size: 10px; padding: 4px 8px; flex: 1; }
  main { padding: 20px 16px calc(var(--nav-h) + 32px + env(safe-area-inset-bottom)); }
  .view { gap: 40px; }

  /* «Сохранить» прилипает над нижней навигацией, пока видна форма. Когда форма
     заканчивается (линия перед «Последними записями»), кнопка уходит вверх вместе с ней
     и не закрывает список */
  .save-bar {
    position: sticky; z-index: 18; margin: 0 -16px; padding: 8px 16px; background: var(--bg);
    bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  }
  input.amount { font-size: 56px; }

  .pills button { padding: 8px 12px; font-size: 13px; white-space: normal; }
  .auth-card .pills { flex-wrap: nowrap; }
  .auth-card .pills button { flex: 1; padding: 8px 6px; text-align: center; }
  .filters .pills { width: 100%; flex-wrap: nowrap; }
  .filters .pills button { flex: 1; text-align: center; }
  .period-nav { margin: -16px 0; }

  .big-sum .v { font-size: 56px; }
  .stats { grid-template-columns: minmax(0, 1fr); }
  .stat { padding: 14px; }
  .stat .v { font-size: 24px; }
  .stats-body .stats { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .stats-body .stat .v { font-size: 20px; }

  .menu button { font-size: 22px; padding: 18px 0; }
  .toast { bottom: calc(var(--nav-h) + 80px + env(safe-area-inset-bottom)); }
}

/* ---------- мои категории: один список ---------- */
.cat-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); border-top: 1px solid var(--line); }
.cat-row { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 12px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.cat-main { flex: 1; min-width: 0; display: grid; gap: 6px; }
.cat-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-row.off .cat-title { color: var(--text-2); font-weight: 500; }
label.oneoff { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; justify-self: start; }
label.oneoff input { width: 18px; height: 18px; margin: 0; padding: 0; accent-color: var(--text); flex: none; cursor: pointer; }
label.oneoff input:disabled, label.oneoff input:disabled + span { cursor: default; opacity: .6; }
.cat-del { width: 40px; height: 40px; border: 0; background: none; color: var(--text-2); display: grid; place-items: center; cursor: pointer; flex: none; }
.cat-del:hover { color: #E53935; }
.cat-del svg { width: 20px; height: 20px; }
/* переключатель «в списке» */
label.switch { position: relative; display: block; width: 46px; height: 28px; flex: none; cursor: pointer; }
label.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; z-index: 1; }
.sw-track { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .15s; }
.sw-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--bg); box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
label.switch input:checked + .sw-track { background: var(--text); }
label.switch input:checked + .sw-track::after { transform: translateX(18px); }
label.switch input:focus-visible + .sw-track { outline: 2px solid var(--text); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#catForm { margin-top: 8px; }

/* тост с кнопкой «Отменить» */
.toast.with-act { display: flex; align-items: center; gap: 16px; }
.toast-act { background: none; border: 0; padding: 4px 0; color: var(--accent); font: 600 13px var(--font); text-transform: uppercase; letter-spacing: .1em; cursor: pointer; white-space: nowrap; }

/* ---------- подсказки к показателям отчёта ---------- */
.cap.k { display: flex; align-items: center; gap: 6px; }
/* кнопка «?»: видимый кружок 16px, область нажатия больше */
.q {
  position: relative; display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; padding: 0;
  border: 1px solid var(--text-2); background: none; color: var(--text-2); cursor: pointer; flex: none;
  font: 700 10px/1 var(--font); letter-spacing: 0; text-transform: none;
}
.q::after { content: ""; position: absolute; inset: -12px; }
.q:hover, .q[aria-expanded="true"] { background: var(--text); border-color: var(--text); color: var(--accent); }
/* все подсказки одного размера, со скруглёнными углами */
.hint-pop {
  position: fixed; z-index: 55; pointer-events: none; background: var(--text); color: var(--bg);
  width: min(320px, calc(100vw - 32px)); min-height: 116px; border-radius: 14px;
  padding: 12px 16px; font-size: 13px; line-height: 1.4; box-shadow: 0 8px 24px rgba(0,0,0,.18);
  display: flex; align-items: center; justify-content: center; text-align: center;
}
/* заголовки с валютой — с большой буквы, как написано */
#listTitle, #catTitle, #memberTitle, #adviceTitle { text-transform: none; }

/* ---------- круговые диаграммы ---------- */
.donut { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; align-items: center; }
.donut-svg { min-width: 0; }
.donut svg { display: block; width: 100%; max-width: 300px; height: auto; margin: 0 auto; overflow: visible; fill: initial; stroke: none; }
.donut .arc { transition: opacity .15s; cursor: pointer; stroke-linecap: butt; }
.donut .slice-ic { fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.donut .slice-letter { fill: #fff; font: 700 14px var(--font); pointer-events: none; }
.donut .pct-label { fill: var(--text-2); font: 500 13px var(--font); font-variant-numeric: tabular-nums; }
.donut .center-v { fill: var(--text); font: 800 28px var(--font); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.donut .center-s { fill: var(--text-2); font: 500 12px var(--font); }
.donut.focus .slice:not(.on) { opacity: .3; }
.donut.focus .lg-chip:not(.on) { opacity: .45; }
.donut-legend { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.lg-chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-width: 0;
  background: var(--surface); border: 0; border-radius: 999px; padding: 4px 14px 4px 4px; cursor: pointer;
  font: 500 14px/1.2 var(--font); color: var(--text); transition: opacity .15s;
}
.lg-chip.on { box-shadow: inset 0 0 0 1px var(--text); }
.lg-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-val { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dot-ic {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none;
  color: #fff; font-weight: 700; font-size: 13px;
}
.donut .dot-ic svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; margin: 0; }
.tooltip { white-space: normal; max-width: 240px; }

@media (max-width: 760px) {
  .donut { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .donut svg { max-width: 280px; }
}

/* ---------- импорт выписки ---------- */
.import { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.import #impTitle { text-transform: none; }
.import-open { text-decoration: underline; text-underline-offset: 4px; }
.import-open:disabled { color: var(--text-2); text-decoration: none; cursor: default; }
.imp-fx { display: grid; gap: 8px; background: var(--surface); padding: 14px; }
.imp-fx-row { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.imp-fx input.imp-rate { width: 120px; flex: none; background: var(--bg); padding: 10px 12px; font-variant-numeric: tabular-nums; }
.imp-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); border-top: 1px solid var(--line); }
.imp-row {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; column-gap: 12px; row-gap: 8px;
  align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); min-width: 0;
}
.imp-check { display: grid; place-items: center; cursor: pointer; }
.imp-check input { width: 20px; height: 20px; margin: 0; padding: 0; accent-color: var(--text); cursor: pointer; }
.imp-main { min-width: 0; }
.imp-row .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.imp-row .sub { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.imp-sum { text-align: right; }
.imp-sum .sum { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.imp-sum .sum.income { color: var(--good); }
.imp-row select.imp-cat { grid-column: 2 / 4; padding: 10px 36px 10px 12px; font-size: 15px; }
.imp-row.off .title, .imp-row.off .imp-sum .sum { color: var(--text-2); font-weight: 500; }
.imp-row.off select.imp-cat { opacity: .55; }
@media (min-width: 761px) {
  .import .save-bar { position: sticky; bottom: 0; z-index: 18; padding: 12px 0 16px; }
}
/* похожие на ручные записи: не снимаем галочку, а просим проверить */
.imp-similar { display: grid; gap: 6px; background: #FFF4D6; padding: 14px; font-size: 14px; }
.imp-similar .link-btn { justify-self: start; text-decoration: underline; text-underline-offset: 4px; }
.imp-sim-note { grid-column: 2 / 4; margin: 0; font-size: 13px; background: #FFF4D6; padding: 8px 10px; }
/* предупреждение: похожая запись уже есть */
.dup-warn { display: grid; gap: 12px; background: #FFF4D6; padding: 14px; font-size: 14px; }
.dup-actions { display: flex; gap: 8px; flex-wrap: wrap; }
