/* ============ токены ============ */

:root {
  color-scheme: light;
  --bg: #f3f3f0;
  --surface: #ffffff;
  --surface-2: #f1f1ee;
  --surface-3: #e6e6e1;
  --text: #121211;
  --text-2: #5a5955;
  --muted: #6f6e68;
  --line: #e5e4df;
  --line-strong: #d4d3cc;
  --accent: #2456c4;
  --accent-hover: #1e4aab;
  --accent-ink: #ffffff;
  --accent-soft: #e4ebfb;
  --accent-text: #1f4fb3;
  --own-bubble: #2456c4;
  --own-ink: #ffffff;
  --income: #1baf7a;       /* серия «доходы» на графиках */
  --expense: #eb6834;      /* серия «расходы» на графиках */
  --income-text: #0f7a3f;  /* текст сумм дохода */
  --danger: #c2332f;
  --danger-soft: #fbe7e6;
  --grid: #e5e4df;
  --axis: #6f6e68;
  --shadow-sm: 0 1px 2px rgba(18, 18, 17, 0.05), 0 1px 1px rgba(18, 18, 17, 0.03);
  --shadow-md: 0 2px 6px rgba(18, 18, 17, 0.06), 0 12px 32px -8px rgba(18, 18, 17, 0.12);
  --shadow-lg: 0 8px 20px rgba(18, 18, 17, 0.10), 0 32px 64px -16px rgba(18, 18, 17, 0.24);
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --nav-h: 60px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  /* оттенки плашек категорий: фон / значок */
  --tone-orange-bg: #fdeadf; --tone-orange-fg: #b9470f;
  --tone-green-bg:  #ddf3e6; --tone-green-fg:  #137a44;
  --tone-yellow-bg: #faefcc; --tone-yellow-fg: #8a5a00;
  --tone-blue-bg:   #e1eafb; --tone-blue-fg:   #1f4fb3;
  --tone-red-bg:    #fbe3e3; --tone-red-fg:    #b42a2a;
  --tone-violet-bg: #ebe5fa; --tone-violet-fg: #5b3fb3;
  --tone-pink-bg:   #fbe3ee; --tone-pink-fg:   #b0306a;
  --tone-teal-bg:   #dcf2f3; --tone-teal-fg:   #0f6f78;
  --tone-slate-bg:  #e8e8e4; --tone-slate-fg:  #4f4e49;

  /* роли шрифта: фиксированная шкала, шаг ~1.15 */
  --fs-xs: 12px;     /* метаданные, подписи осей */
  --fs-sm: 13.5px;   /* ярлыки, подписи полей, вторичный текст */
  --fs-md: 15px;     /* основной текст, строки списков */
  --fs-lg: 17px;     /* заголовок экрана, суммы в сводке */
  --fs-xl: 20px;     /* заголовки карточек входа */
  --fs-display: 40px;/* остаток за период */
  --lh-body: 1.45;
  --ls-body: 0;

  font-family: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "tnum" 0;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e0e0d;
    --surface: #1a1a19;
    --surface-2: #242423;
    --surface-3: #30302e;
    --text: #f4f4f1;
    --text-2: #bdbcb4;
    --muted: #9a9992;
    --line: #2a2a28;
    --line-strong: #3a3a37;
    --accent: #4a84f0;
    --accent-hover: #6396f4;
    --accent-soft: #1c2b4d;
    --accent-text: #7ea8f5;
    --own-bubble: #2d63d4;
    --income: #199e70;
    --expense: #d95926;
    --income-text: #3cc47a;
    --danger: #ef6b67;
    --danger-soft: #3b1f1e;
    --grid: #2a2a28;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.4), 0 12px 32px -8px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 8px 20px rgba(0, 0, 0, 0.5), 0 32px 64px -16px rgba(0, 0, 0, 0.7);
    --tone-orange-bg: #3d2416; --tone-orange-fg: #f2a070;
    --tone-green-bg:  #16301f; --tone-green-fg:  #6fd39a;
    --tone-yellow-bg: #3a2e10; --tone-yellow-fg: #e8bd4a;
    --tone-blue-bg:   #1a2742; --tone-blue-fg:   #8fb3f7;
    --tone-red-bg:    #3d1c1c; --tone-red-fg:    #f0908c;
    --tone-violet-bg: #27203f; --tone-violet-fg: #b7a4f3;
    --tone-pink-bg:   #3b1c2a; --tone-pink-fg:   #ef8fbb;
    --tone-teal-bg:   #13302f; --tone-teal-fg:   #70d0d5;
    --tone-slate-bg:  #2c2c2a; --tone-slate-fg:  #bcbbb3;
    --lh-body: 1.5;
    --ls-body: 0.004em;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0e0d;
  --surface: #1a1a19;
  --surface-2: #242423;
  --surface-3: #30302e;
  --text: #f4f4f1;
  --text-2: #bdbcb4;
  --muted: #9a9992;
  --line: #2a2a28;
  --line-strong: #3a3a37;
  --accent: #4a84f0;
  --accent-hover: #6396f4;
  --accent-soft: #1c2b4d;
  --accent-text: #7ea8f5;
  --own-bubble: #2d63d4;
  --income: #199e70;
  --expense: #d95926;
  --income-text: #3cc47a;
  --danger: #ef6b67;
  --danger-soft: #3b1f1e;
  --grid: #2a2a28;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.4), 0 12px 32px -8px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 8px 20px rgba(0, 0, 0, 0.5), 0 32px 64px -16px rgba(0, 0, 0, 0.7);
  --tone-orange-bg: #3d2416; --tone-orange-fg: #f2a070;
  --tone-green-bg:  #16301f; --tone-green-fg:  #6fd39a;
  --tone-yellow-bg: #3a2e10; --tone-yellow-fg: #e8bd4a;
  --tone-blue-bg:   #1a2742; --tone-blue-fg:   #8fb3f7;
  --tone-red-bg:    #3d1c1c; --tone-red-fg:    #f0908c;
  --tone-violet-bg: #27203f; --tone-violet-fg: #b7a4f3;
  --tone-pink-bg:   #3b1c2a; --tone-pink-fg:   #ef8fbb;
  --tone-teal-bg:   #13302f; --tone-teal-fg:   #70d0d5;
  --tone-slate-bg:  #2c2c2a; --tone-slate-fg:  #bcbbb3;
  --lh-body: 1.5;
  --ls-body: 0.004em;
}

/* ============ база ============ */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-md);
  line-height: var(--lh-body);
  letter-spacing: var(--ls-body);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  text-rendering: optimizeLegibility;
}
[hidden] { display: none !important; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { letter-spacing: -0.015em; text-wrap: balance; font-weight: 650; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; touch-action: manipulation; }
a { color: var(--accent-text); }
::selection { background: var(--accent-soft); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.num, .tabular { font-variant-numeric: tabular-nums; }
.icon { width: 20px; height: 20px; flex: none; }

/* ============ контролы ============ */

.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 12px 18px; min-height: 44px;
  font-weight: 600; font-size: 15px; line-height: 1;
  background: var(--btn-bg); color: var(--btn-fg);
  text-decoration: none;
  transition: background-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.btn .icon { width: 18px; height: 18px; }
.btn:hover { background: color-mix(in srgb, var(--btn-bg) 92%, var(--text)); }
.btn:active { transform: scale(0.98); }
.btn.primary { --btn-bg: var(--accent); --btn-fg: var(--accent-ink); box-shadow: 0 1px 2px rgba(36, 86, 196, 0.3); }
.btn.primary:hover { --btn-bg: var(--accent-hover); }
.btn.ghost { --btn-bg: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { --btn-bg: transparent; --btn-fg: var(--danger); box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { padding: 9px 14px; min-height: 36px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn.loading { color: transparent; position: relative; pointer-events: none; }
.btn.loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; color: var(--btn-fg);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  border: 0; background: transparent; width: 40px; height: 40px; border-radius: 12px;
  color: var(--text-2); display: inline-grid; place-items: center; flex: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { background: var(--surface-3); }

.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--text-2); font-weight: 500; }
.form label { display: grid; gap: 6px; font-size: 13px; color: var(--text-2); font-weight: 500; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 16px; /* iOS не зумит поля от 16px */
  font-weight: 450;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--line-strong) 60%, var(--muted)); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236f6e68' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
.form-error { color: var(--danger); font-size: 13.5px; display: flex; gap: 6px; align-items: flex-start; }
.form-error:empty { display: none; }
.row { display: flex; gap: 10px; align-items: end; }
.grow { flex: 1; min-width: 0; }

.segmented {
  display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface-2);
}
.segmented button {
  flex: 1; border: 0; background: transparent; padding: 8px 10px; border-radius: 9px; min-height: 36px;
  font-weight: 600; font-size: 14px; color: var(--text-2); white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.chip {
  border: 0; border-radius: 999px; padding: 8px 13px; min-height: 36px; font-size: 14px; font-weight: 500;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-strong); white-space: nowrap; color: var(--text-2);
  display: inline-flex; align-items: center; gap: 7px;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}
.chip:hover { background: var(--surface-2); color: var(--text); }
.chip:active { transform: scale(0.97); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); box-shadow: none; }
.chip .icon { width: 16px; height: 16px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

.cat-icon {
  width: 38px; height: 38px; border-radius: 12px; display: inline-grid; place-items: center; flex: none;
  background: var(--tone-bg, var(--surface-2)); color: var(--tone-fg, var(--text-2));
}
.cat-icon.sm { width: 30px; height: 30px; border-radius: 9px; }
.cat-icon.sm .icon { width: 16px; height: 16px; }
.cat-icon .icon { width: 19px; height: 19px; }
.tone-orange { --tone-bg: var(--tone-orange-bg); --tone-fg: var(--tone-orange-fg); }
.tone-green  { --tone-bg: var(--tone-green-bg);  --tone-fg: var(--tone-green-fg); }
.tone-yellow { --tone-bg: var(--tone-yellow-bg); --tone-fg: var(--tone-yellow-fg); }
.tone-blue   { --tone-bg: var(--tone-blue-bg);   --tone-fg: var(--tone-blue-fg); }
.tone-red    { --tone-bg: var(--tone-red-bg);    --tone-fg: var(--tone-red-fg); }
.tone-violet { --tone-bg: var(--tone-violet-bg); --tone-fg: var(--tone-violet-fg); }
.tone-pink   { --tone-bg: var(--tone-pink-bg);   --tone-fg: var(--tone-pink-fg); }
.tone-teal   { --tone-bg: var(--tone-teal-bg);   --tone-fg: var(--tone-teal-fg); }
.tone-slate  { --tone-bg: var(--tone-slate-bg);  --tone-fg: var(--tone-slate-fg); }

.avatar {
  border-radius: 50%; display: grid; place-items: center; flex: none;
  color: #fff; font-size: 13px; font-weight: 700; letter-spacing: 0;
  box-shadow: 0 0 0 2px var(--surface);
}

/* ============ вход ============ */

.auth {
  min-height: 100%; display: grid; place-items: center; padding: calc(24px + var(--safe-t)) 16px calc(24px + var(--safe-b));
  background:
    radial-gradient(60% 50% at 50% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface); border-radius: var(--r-lg); padding: 28px 24px 24px;
  box-shadow: var(--shadow-md); display: grid; gap: 20px;
}
.brand { display: grid; gap: 14px; justify-items: start; }
.brand img { width: 52px; height: 52px; border-radius: 15px; box-shadow: var(--shadow-sm); }
.brand h1 { font-size: var(--fs-xl); font-weight: 700; }
.brand p { font-size: 14.5px; color: var(--text-2); margin-top: 4px; }
.invite-banner {
  background: var(--accent-soft); color: var(--text); border-radius: 12px; padding: 12px 14px; font-size: 14px;
  display: flex; gap: 10px; align-items: flex-start;
}
.invite-banner .icon { color: var(--accent-text); margin-top: 1px; }

/* ============ каркас ============ */

.app { height: 100dvh; display: flex; flex-direction: column-reverse; }
.main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: var(--bg);
}
.topbar h2 { font-size: var(--fs-lg); font-weight: 700; }
.theme-btn .icon { transition: transform 0.35s var(--ease-out); }
.theme-btn:active .icon { transform: rotate(-30deg) scale(0.9); }
.topbar .sub { font-size: var(--fs-sm); color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar > div:first-child { min-width: 0; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.member-dots { display: flex; }
.member-dots .avatar { width: 30px; height: 30px; box-shadow: 0 0 0 2px var(--bg); }
.member-dots .avatar + .avatar { margin-left: -8px; }

.nav {
  display: flex; justify-content: space-around; background: var(--surface);
  border-top: 1px solid var(--line); padding: 4px 8px calc(4px + var(--safe-b)); flex: none;
}
.nav-brand { display: none; }
.nav-item {
  flex: 1; border: 0; background: transparent; display: grid; justify-items: center; gap: 3px;
  padding: 6px 4px 4px; font-size: 11px; font-weight: 600; color: var(--muted);
  transition: color 0.15s ease;
}
.nav-item .icon-wrap {
  width: 48px; height: 28px; border-radius: 14px; display: grid; place-items: center;
  transition: background-color 0.2s var(--ease-out);
}
.nav-item .icon { width: 22px; height: 22px; }
.nav-item[aria-current="page"] { color: var(--accent-text); }
.nav-item[aria-current="page"] .icon-wrap { background: var(--accent-soft); }
.nav-item[aria-current="page"] .icon { stroke-width: 2.1; }

.view { flex: 1; min-height: 0; }
.scroll { overflow-y: auto; padding: 4px 16px 32px; -webkit-overflow-scrolling: touch; }

@media (min-width: 900px) {
  .app { flex-direction: row; }
  .nav {
    flex-direction: column; justify-content: flex-start; width: 232px; border-top: 0;
    border-right: 1px solid var(--line); padding: 20px 12px; gap: 2px;
  }
  .nav-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 4px 10px 22px; }
  .nav-brand img { border-radius: 9px; }
  .nav-item {
    flex: none; display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px;
    font-size: 14.5px; justify-items: start; color: var(--text-2);
  }
  .nav-item .icon-wrap { width: auto; height: auto; border-radius: 0; }
  .nav-item:hover { background: var(--surface-2); color: var(--text); }
  .nav-item[aria-current="page"] { background: var(--surface-2); color: var(--text); }
  .nav-item[aria-current="page"] .icon-wrap { background: transparent; }
  .nav-item[aria-current="page"] .icon { color: var(--accent-text); }
  .main > * { width: 100%; max-width: 760px; margin-inline: auto; }
  .topbar { padding: 24px 24px 12px; }
  .scroll { padding-inline: 24px; }
  .chat-view { padding-inline: 8px; }
}

/* ============ чат ============ */

.chat-view { display: flex; flex-direction: column; }
.messages { flex: 1; overflow-y: auto; padding: 8px 12px 12px; display: flex; flex-direction: column; gap: 10px; }
.day-sep {
  align-self: center; font-size: 12px; font-weight: 600; color: var(--muted); padding: 4px 10px; margin: 6px 0 2px;
  background: var(--surface-2); border-radius: 999px;
}
.msg { display: flex; flex-direction: column; gap: 5px; max-width: min(88%, 520px); align-self: flex-start; }
.msg.own { align-self: flex-end; align-items: flex-end; }
.msg.new { animation: msg-in 0.32s var(--ease-out); }
@keyframes msg-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
.msg-head { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-2); padding: 0 4px; }
.bubble {
  background: var(--surface); padding: 9px 13px; border-radius: 18px 18px 18px 5px; box-shadow: var(--shadow-sm);
  white-space: pre-wrap; word-break: break-word; font-size: 15.5px; line-height: 1.4;
}
.msg.own .bubble { background: var(--own-bubble); color: var(--own-ink); border-radius: 18px 18px 5px 18px; }
.bubble time { font-size: 11px; opacity: 0.6; margin-left: 10px; float: right; margin-top: 5px; font-variant-numeric: tabular-nums; }
.reply {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: 14px; color: var(--text-2); background: var(--surface-2); border-radius: 14px; padding: 9px 12px;
  white-space: pre-wrap; max-width: 100%; line-height: 1.45;
}
.reply .icon { width: 16px; height: 16px; margin-top: 2px; color: var(--muted); }
.cards { display: grid; gap: 6px; width: 100%; }

.tx-card {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px;
  background: var(--surface); border-radius: var(--r-md); padding: 9px 12px 9px 9px; box-shadow: var(--shadow-sm);
  text-align: left; border: 0; width: 100%; min-width: 240px; color: var(--text);
  transition: background-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}
.tx-card:hover { box-shadow: var(--shadow-md); }
.tx-card:active { transform: scale(0.985); background: var(--surface-2); }
.tx-card.deleted { opacity: 0.6; box-shadow: inset 0 0 0 1px var(--line); background: transparent; }
.tx-card.deleted .tx-amount, .tx-card.deleted .tx-title { text-decoration: line-through; }
.tx-card.deleted .cat-icon { filter: grayscale(1); }
.tx-main { min-width: 0; display: grid; gap: 1px; }
.tx-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-amount { font-weight: 650; font-size: 15px; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; letter-spacing: -0.01em; }
.tx-amount.income { color: var(--income-text); }
.tx-amount small { display: block; font-size: 11.5px; font-weight: 500; color: var(--muted); letter-spacing: 0; }

.composer {
  padding: 8px 12px calc(8px + var(--safe-b-composer, 0px)); background: var(--surface); border-top: 1px solid var(--line);
  display: grid; gap: 8px;
}
.suggestions { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 1px 0; }
.suggestions::-webkit-scrollbar { display: none; }
.suggestions:empty { display: none; }
.suggestions .chip { min-height: 32px; padding: 6px 12px; font-size: 13.5px; background: var(--surface-2); box-shadow: none; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea {
  resize: none; max-height: 140px; border-radius: 22px; padding: 11px 16px; line-height: 1.4; min-height: 44px;
  background: var(--surface-2); border-color: transparent;
}
.composer textarea:focus { background: var(--surface); border-color: var(--accent); }
.send {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; flex: none;
  display: grid; place-items: center; transition: transform 0.12s ease, opacity 0.15s ease, background-color 0.15s ease;
}
.send:hover { background: var(--accent-hover); }
.send:active { transform: scale(0.92); }
.send:disabled { opacity: 0.35; }
.send .icon { width: 22px; height: 22px; stroke-width: 2.2; }

.empty-chat { margin: auto; text-align: center; max-width: 360px; display: grid; gap: 14px; padding: 24px 8px; color: var(--text-2); }
.empty-chat .cat-icon { margin: 0 auto 2px; width: 56px; height: 56px; border-radius: 18px; }
.empty-chat .cat-icon .icon { width: 26px; height: 26px; }
.empty-chat h3 { color: var(--text); font-size: 19px; }
.empty-chat p { font-size: 14.5px; }
.examples { display: grid; gap: 6px; text-align: left; }
.example {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; width: 100%;
  background: var(--surface); border: 0; border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow-sm);
  text-align: left; color: var(--text); font-size: 14px;
  transition: background-color 0.15s ease, transform 0.12s ease;
}
.example:hover { background: var(--surface-2); }
.example:active { transform: scale(0.98); }
.example code { font-family: inherit; font-weight: 600; }
.example span { color: var(--muted); font-size: 13px; }

/* ============ фильтры ============ */

.filters { display: grid; gap: 8px; margin: 8px 0 14px; }
.chip-row { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; }
.chip-row::-webkit-scrollbar { display: none; }
.custom-range { display: flex; gap: 8px; }
.custom-range input { padding: 8px 10px; font-size: 14px; }

/* ============ статистика ============ */

.stats { display: grid; gap: 12px; }
.card { background: var(--surface); border-radius: var(--r-lg); padding: 16px; box-shadow: var(--shadow-sm); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.card h3 { font-size: var(--fs-md); font-weight: 650; }
.card-head .hint { font-size: 13px; color: var(--muted); }
.card.inset { padding: 4px 0; }
.card.inset .card-head { padding: 12px 16px 4px; margin: 0; }

.summary { display: grid; gap: 14px; }
.summary-label { font-size: 13.5px; color: var(--text-2); font-weight: 500; }
.summary-value { font-size: var(--fs-display); font-weight: 750; letter-spacing: -0.035em; line-height: 1; font-variant-numeric: tabular-nums; margin-top: 4px; }
.summary-value.negative { color: var(--danger); }
.summary-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.summary-item { display: grid; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); min-width: 0; }
.summary-item .k { font-size: 12.5px; color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.summary-item .v { font-size: var(--fs-lg); font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary-item .v.income { color: var(--income-text); }
.ratio { display: grid; gap: 6px; }
.ratio-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; display: flex; }
.ratio-bar > div { height: 100%; background: var(--expense); border-radius: 4px; }
.ratio-bar > div.over { background: var(--danger); }
.ratio-text { font-size: 13px; color: var(--text-2); }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

.legend { display: flex; gap: 12px; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-box { position: relative; height: 210px; }

.bar-list { display: grid; }
.bar-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 2px 12px; padding: 9px 16px; align-items: center;
  border: 0; background: transparent; text-align: left; width: 100%; color: var(--text);
  transition: background-color 0.15s ease;
}
.bar-row:hover { background: var(--surface-2); }
.bar-row:active { background: var(--surface-3); }
.bar-row .label { font-size: 14.5px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .value { font-size: 14.5px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.bar-row .value small { color: var(--muted); font-weight: 500; margin-left: 6px; font-size: 12.5px; }
.bar-track { grid-column: 2 / -1; height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; background: var(--expense); display: block; }
.bar-fill.income { background: var(--income); }

.people { display: grid; }
.person { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 16px; }
.person .avatar { width: 36px; height: 36px; font-size: 14px; }
.person-name { font-weight: 600; font-size: 14.5px; }
.person-name .muted { font-size: 12.5px; font-weight: 500; }
.person-nums { text-align: right; font-size: 14px; font-variant-numeric: tabular-nums; font-weight: 600; }
.person-nums .in { color: var(--income-text); }
.share { grid-column: 2 / -1; height: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.share div { height: 100%; background: var(--expense); border-radius: 3px; }

.note {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 13.5px; color: var(--text-2); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; line-height: 1.45;
}
.note .icon { width: 17px; height: 17px; margin-top: 1px; color: var(--muted); }
.empty-state { text-align: center; color: var(--muted); padding: 36px 16px; display: grid; gap: 6px; justify-items: center; }
.empty-state .icon { width: 28px; height: 28px; margin-bottom: 4px; }
.empty-state b { color: var(--text); font-weight: 600; }

/* ============ операции ============ */

.list-tools { display: grid; gap: 10px; margin-bottom: 12px; }
.search-box { position: relative; }
.search-box .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; pointer-events: none; }
.search-box input { padding-left: 38px; border-radius: 12px; background: var(--surface); }
.search-box input::-webkit-search-cancel-button { -webkit-appearance: none; }
.active-chip { margin-bottom: 10px; }
.tx-list { display: grid; gap: 16px; }
.day-group { display: grid; gap: 6px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 6px; }
.day-head .num { font-weight: 500; }
.group { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow: hidden; display: grid; }
.group .tx-card { border-radius: 0; box-shadow: none; padding: 10px 14px 10px 12px; }
.group .tx-card:hover { box-shadow: none; background: var(--surface-2); }
.group .tx-card:active { transform: none; background: var(--surface-3); }
.group > * + * { position: relative; }
.group > * + *::before {
  content: ""; position: absolute; left: 62px; right: 0; top: 0; height: 1px; background: var(--line);
}
.group > .tx-card.deleted { opacity: 0.6; box-shadow: none; }

/* ============ семья / настройки ============ */

.settings { display: grid; gap: 22px; padding-top: 4px; }
.section { display: grid; gap: 8px; }
.section-title { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); padding: 0 6px; }
.section-note { font-size: 13px; color: var(--muted); padding: 0 6px; line-height: 1.45; }
.invite-card { display: grid; gap: 12px; }
.invite-card h3 { font-size: 16px; }
.invite-card p { font-size: 14px; color: var(--text-2); line-height: 1.45; }
.invite-url {
  display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 12px; padding: 8px 8px 8px 12px;
}
.invite-url code { font-family: inherit; font-size: 13.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.invite-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.invite-actions .btn { flex: 1 1 auto; white-space: nowrap; }
.rows { display: grid; }
.rowi {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 52px;
  border: 0; background: transparent; width: 100%; text-align: left; color: var(--text); font-size: 15px;
  transition: background-color 0.15s ease;
}
button.rowi:hover { background: var(--surface-2); }
button.rowi:active { background: var(--surface-3); }
.rowi .lead { color: var(--text-2); }
.rowi .body { flex: 1; min-width: 0; display: grid; gap: 1px; }
.rowi .body b { font-weight: 600; }
.rowi .body .muted { font-size: 13px; }
.rowi .trail { color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 6px; }
.rowi.danger { color: var(--danger); }
.rowi.danger .lead { color: var(--danger); }
.rowi .avatar { width: 34px; height: 34px; }
.settings .group > * + *::before { left: 16px; }
.inline-form { display: flex; gap: 8px; padding: 12px 16px; align-items: center; }
.theme-pick { padding: 12px 16px; }
.theme-pick .segmented button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 6px; font-size: var(--fs-sm); }
.theme-pick .icon { width: 16px; height: 16px; }
.inline-form input { background: var(--surface-2); border-color: transparent; }
.inline-form input:focus { background: var(--surface); border-color: var(--accent); }

/* ============ шторка ============ */

.sheet {
  border: 0; padding: 0; border-radius: var(--r-lg); background: var(--surface); color: var(--text);
  width: min(440px, calc(100% - 24px)); box-shadow: var(--shadow-lg);
}
.sheet::backdrop { background: rgba(10, 10, 10, 0.45); backdrop-filter: blur(2px); }
.sheet form { padding: 16px 20px 20px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.sheet-head h3 { font-size: 18px; }
.grabber { display: none; width: 36px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 2px auto 10px; }
.amount-field input { font-size: 26px; font-weight: 700; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; padding: 10px 13px; }
.edit-meta { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.sheet .row.actions { padding-top: 4px; }
@media (max-width: 600px) {
  .sheet { margin: auto 0 0; width: 100%; max-width: 100%; border-radius: var(--r-lg) var(--r-lg) 0 0; padding-bottom: var(--safe-b); }
  .sheet[open] { animation: sheet-up 0.32s var(--ease-out); }
  .grabber { display: block; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }

/* ============ тост ============ */

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 118px + var(--safe-b)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 14px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg); z-index: 50; display: flex; gap: 14px; align-items: center; max-width: calc(100% - 32px);
  animation: toast-in 0.28s var(--ease-out);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }
.toast button { border: 0; background: none; color: inherit; font-weight: 700; padding: 0; opacity: 0.95; }
.toast button:hover { text-decoration: underline; }
@media (min-width: 900px) { .toast { bottom: 28px; } }

/* ============ скелетоны ============ */

.skel { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-card { background: var(--surface); border-radius: var(--r-lg); padding: 16px; display: grid; gap: 12px; box-shadow: var(--shadow-sm); }
.skel-row { display: grid; grid-template-columns: 38px 1fr 70px; gap: 12px; align-items: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
