/* Вернём · «Voyage Ledger».
   Тёмная тема по умолчанию, светлая по prefers-color-scheme. Зелёный только для денег и успеха,
   янтарный только для обязанностей и сроков. В тёмной теме вместо теней рамки и тонкий блик сверху. */

@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/onest-cyrillic-wght-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/onest-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+20BD, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #0b0b0b;
  --surface: #141413;
  --surface-2: #1c1c1a;
  --line: rgba(244, 241, 234, .12);
  --line-strong: rgba(244, 241, 234, .28);
  --text: #f4f1ea;
  --text-2: rgba(244, 241, 234, .62); /* 6.5:1 на surface-2 */
  --money: #a0f0a0;
  --money-soft: rgba(160, 240, 160, .10);
  --amber: #f0d9a0;
  --amber-soft: rgba(240, 217, 160, .10);
  --danger: #ffb4a8;
  --seg-1: #a0f0a0;
  --seg-2: #7fd1c7;
  --seg-3: #c9b6f2;
  --seg-4: #f0d9a0;
  --highlight: inset 0 1px 0 rgba(255, 255, 255, .05);
  --shadow: none;
  --scrim: rgba(0, 0, 0, .6);
  --focus: #f4f1ea;

  --font: "Onest", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --r-input: 8px;
  --r-card: 14px;
  --r-hero: 20px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

/* Светлая тема: системная настройка или Telegram со светлой темой */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f1ea;
    --surface: #fbfaf6;
    --surface-2: #ece8de;
    --line: rgba(11, 11, 11, .10);
    --line-strong: rgba(11, 11, 11, .26);
    --text: #0b0b0b;
    --text-2: rgba(11, 11, 11, .64); /* 5.4:1 на surface-2 */
    --money: #1a6e44; /* 5.2:1 на surface-2 */
    --money-soft: rgba(26, 110, 68, .09);
    --amber: #7a5810;
    --amber-soft: rgba(138, 100, 20, .10);
    --danger: #a3261a;
    --seg-1: #3fae6a;
    --seg-2: #3a9e93;
    --seg-3: #8f74d6;
    --seg-4: #c99a2e;
    --highlight: none;
    --shadow: 0 1px 2px rgba(11, 11, 11, .04), 0 8px 24px rgba(11, 11, 11, .05);
    --scrim: rgba(11, 11, 11, .35);
    --focus: #0b0b0b;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f4f1ea;
  --surface: #fbfaf6;
  --surface-2: #ece8de;
  --line: rgba(11, 11, 11, .10);
  --line-strong: rgba(11, 11, 11, .26);
  --text: #0b0b0b;
  --text-2: rgba(11, 11, 11, .64);
  --money: #1a6e44;
  --money-soft: rgba(26, 110, 68, .09);
  --amber: #7a5810;
  --amber-soft: rgba(138, 100, 20, .10);
  --danger: #a3261a;
  --seg-1: #3fae6a;
  --seg-2: #3a9e93;
  --seg-3: #8f74d6;
  --seg-4: #c99a2e;
  --highlight: none;
  --shadow: 0 1px 2px rgba(11, 11, 11, .04), 0 8px 24px rgba(11, 11, 11, .05);
  --scrim: rgba(11, 11, 11, .35);
  --focus: #0b0b0b;
  color-scheme: light;
}

/* Telegram: фон и текст из темы Telegram, с явными запасными значениями (без цикла переменных).
   Поверхности смешиваются из них, чтобы карточки всегда отличались от фона. */
:root.tg {
  --bg: var(--tg-theme-bg-color, #0b0b0b);
  --text: var(--tg-theme-text-color, #f4f1ea);
  --surface: color-mix(in srgb, var(--text) 5%, var(--bg));
  --surface-2: color-mix(in srgb, var(--text) 9%, var(--bg));
  --line: color-mix(in srgb, var(--text) 12%, transparent);
  --line-strong: color-mix(in srgb, var(--text) 28%, transparent);
  --text-2: color-mix(in srgb, var(--text) 66%, var(--bg));
  --focus: var(--text);
}
:root.tg[data-theme="light"] {
  --bg: var(--tg-theme-bg-color, #f4f1ea);
  --text: var(--tg-theme-text-color, #0b0b0b);
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p { margin: 0; }
h1, h2, .display { letter-spacing: -.035em; font-weight: 600; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

.money,
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

.icon {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  fill: currentColor;
  vertical-align: -.25em;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -48px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--text);
  color: var(--bg);
  border-radius: 999px;
  text-decoration: none;
}
.skip-link:focus { top: 8px; }

/* ---------- Шапка ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  text-decoration: none;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -.02em;
}
.brand-mark { width: 28px; height: 28px; flex: none; }
.brand-mark .ring { stroke: var(--text); }
.brand-mark .dot { fill: var(--money); }

.topbar-spacer { flex: 1; }

.pill {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-height: 36px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  box-shadow: var(--highlight);
  font-size: 14px;
  color: var(--text-2);
  white-space: nowrap;
  transition: opacity .3s var(--ease), transform .3s var(--ease);
}
.pill b { color: var(--money); font-weight: 600; font-size: 16px; }
.pill.is-bump { animation: bump .6s var(--ease); }
@keyframes bump { 40% { transform: scale(1.06); } }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: none;
  color: var(--text-2);
  transition: background .2s, color .2s, transform .15s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn .icon { width: 22px; height: 22px; }

.ask-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: transparent;
  font-weight: 500;
  transition: background .2s, transform .15s var(--ease);
}
.ask-btn:hover { background: var(--surface-2); }
.ask-btn:active { transform: scale(.97); }

@media (max-width: 520px) {
  .topbar:has(.pill:not([hidden])) .brand-word { display: none; }
  .ask-btn span { display: none; }
  .ask-btn { width: 44px; padding: 0; justify-content: center; }
  .pill { font-size: 13px; padding: 7px 12px; }
}

/* ---------- Каркас экранов ---------- */

main { outline: none; }

.screen {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px calc(40px + var(--safe-b));
  animation: enter .45s var(--ease) both;
}
.screen-wide { max-width: 760px; }

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

.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-2);
}

.footer {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px calc(24px + var(--safe-b));
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-2);
}
.footer a { color: var(--text-2); text-underline-offset: 3px; }
.footer a:hover { color: var(--text); }

/* ---------- Кнопки ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 24px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  font-size: 16px;
  text-decoration: none;
  transition: transform .15s var(--ease), opacity .2s, background .2s;
}
.btn:hover { opacity: .92; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: default; transform: none; }
.btn-block { width: 100%; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line-strong);
}
.btn-ghost:hover { background: var(--surface-2); opacity: 1; }

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--text-2);
  font-size: 15px;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 4px;
}
.link-btn:hover { color: var(--text); }

/* ---------- Главный экран ---------- */

.home-hero { padding: 24px 0 8px; }
.home-hero h1 {
  font-size: clamp(34px, 9vw, 52px);
  line-height: 1.04;
  max-width: 12ch;
}
.home-hero h1 .accent { color: var(--money); }
.home-hero .sub {
  margin-top: 16px;
  font-size: 18px;
  color: var(--text-2);
  max-width: 34ch;
}

.banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 24px 0 0;
  padding: 14px 16px;
  border-radius: var(--r-card);
  border: 1px solid color-mix(in srgb, var(--amber) 40%, transparent);
  background: var(--amber-soft);
  color: var(--text);
  font-size: 15px;
}
.banner .icon { color: var(--amber); margin-top: 2px; }
.banner b { font-weight: 600; }
.banner .muted { color: var(--text-2); }

.resume {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
  padding: 16px;
  border-radius: var(--r-card);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--highlight), var(--shadow);
}
.resume-text { flex: 1; min-width: 0; }
.resume-text p { color: var(--text-2); font-size: 14px; }
.resume-text b { font-size: 22px; color: var(--money); font-weight: 600; letter-spacing: -.02em; }

.section-title {
  margin: 32px 0 12px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -.01em;
}

.goals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.goal {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  min-height: 132px;
  padding: 16px;
  text-align: left;
  border-radius: var(--r-card);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--highlight), var(--shadow);
  transition: border-color .2s, transform .15s var(--ease), background .2s;
  animation: enter .5s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.goal:hover { border-color: var(--line-strong); }
.goal:active { transform: scale(.97); }
.goal-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--surface-2);
}
.goal-icon .icon { width: 22px; height: 22px; }
.goal-label { font-weight: 600; font-size: 16px; line-height: 1.25; }
.goal-range { margin-top: auto; font-size: 14px; color: var(--text-2); line-height: 1.35; }
.goal-range b { color: var(--money); font-weight: 600; }
.goal-wide { grid-column: 1 / -1; min-height: 0; flex-direction: row; align-items: center; }
.goal-wide .goal-range { margin-top: 0; }
.goal-wide .goal-text { display: flex; flex-direction: column; gap: 2px; }

@media (min-width: 720px) {
  .goals { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.alt-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.alt {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 12px 16px;
  border-radius: var(--r-card);
  border: 1px dashed var(--line-strong);
  background: transparent;
  text-align: left;
  font-size: 15px;
  transition: background .2s, transform .15s var(--ease);
}
.alt:hover { background: var(--surface); }
.alt:active { transform: scale(.97); }
.alt small { display: block; color: var(--text-2); font-size: 13px; }
@media (max-width: 420px) { .alt-row { grid-template-columns: 1fr; } }
.sections { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.sections .alt { border-style: solid; background: var(--surface); text-decoration: none; color: inherit; }
.sections .alt:hover { background: var(--surface-2); }
.sections .icon { flex: none; color: var(--money); }
@media (max-width: 720px) { .sections { grid-template-columns: 1fr; } }

.or {
  margin: 28px 0 0;
  color: var(--text-2);
  font-size: 15px;
}

.trust {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-2);
}
.trust .icon { color: var(--money); }

/* ---------- Вопросы ---------- */

.flow-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -8px 0 20px;
}
.back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px 0 10px;
  margin-left: -10px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--text-2);
  font-size: 15px;
}
.back:hover { background: var(--surface-2); color: var(--text); }
.left { font-size: 14px; color: var(--text-2); }

.progress {
  height: 3px;
  margin-bottom: 28px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--text);
  border-radius: inherit;
  transition: width .6s var(--ease);
}

.question h2 {
  margin-top: 8px;
  font-size: clamp(24px, 6vw, 30px);
  line-height: 1.15;
  outline: none;
}
.question .hint { margin-top: 12px; color: var(--text-2); font-size: 16px; }

.tiles {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}
.tiles-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tiles-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.tile {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 14px 16px;
  border-radius: var(--r-card);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--highlight);
  text-align: left;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.3;
  transition: border-color .2s, background .2s, transform .15s var(--ease);
  animation: enter .4s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 30ms);
}
.tile:hover { border-color: var(--line-strong); }
.tile:active { transform: scale(.97); }
.tile .check {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-left: auto;
  flex: none;
  border-radius: 999px;
  border: 1.5px solid var(--line-strong);
  color: transparent;
}
.tile .check .icon { width: 14px; height: 14px; }
.tile[aria-pressed="true"],
.tile.is-current {
  border-color: var(--text);
  background: var(--surface-2);
}
.tile[aria-pressed="true"] .check { background: var(--text); border-color: var(--text); color: var(--bg); }
.tiles-2 .tile,
.tiles-3 .tile { justify-content: center; text-align: center; }

.fields { display: grid; gap: 14px; margin-top: 24px; }
.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  color: var(--text-2);
}
.input-wrap { position: relative; }
.input {
  width: 100%;
  min-height: 60px;
  padding: 12px 48px 12px 16px;
  border-radius: var(--r-input);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
  transition: border-color .2s, box-shadow .2s;
}
.input:focus { outline: none; border-color: var(--text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 14%, transparent); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input-suffix {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-2);
  font-size: 20px;
  pointer-events: none;
}
.field-group { display: grid; gap: 10px; }
.field-group + .field-group { padding-top: 14px; border-top: 1px solid var(--line); }
.field-group-title { font-size: 14px; font-weight: 600; }

.q-error { margin-top: 12px; color: var(--danger); font-size: 15px; }

.q-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-top: 24px;
}
.q-actions .link-btn { align-self: center; }

/* В Telegram «Далее» живёт в MainButton, «Назад» в BackButton */
:root.tg .tg-main { display: none; }
:root.tg .flow-top .back { visibility: hidden; }

@media (max-width: 640px) {
  .q-actions.sticky {
    position: sticky;
    bottom: 0;
    margin: 24px -16px 0;
    padding: 12px 16px calc(12px + var(--safe-b));
    background: linear-gradient(to top, var(--bg) 70%, transparent);
  }
}

/* ---------- Итог ---------- */

.hero {
  position: relative;
  padding: 28px 24px 24px;
  border-radius: var(--r-hero);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--highlight), var(--shadow);
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: -40% -20% auto auto;
  width: 70%;
  aspect-ratio: 1;
  background: radial-gradient(closest-side, var(--money-soft), transparent);
  pointer-events: none;
}
.hero > * { position: relative; }
.hero-label { font-size: 16px; color: var(--text-2); }
.hero-total {
  margin: 4px 0 2px;
  font-size: min(72px, 13vw);
  line-height: 1;
  font-weight: 600;
  letter-spacing: -.035em;
  color: var(--money);
  white-space: nowrap;
}
.hero-total.is-long { font-size: min(72px, 10.5vw); }
.hero-total.is-plain { color: var(--text); font-size: clamp(30px, 8vw, 44px); line-height: 1.1; white-space: normal; }
.hero-sub { color: var(--text-2); font-size: 16px; }
.hero-text { margin-top: 12px; font-size: 16px; color: var(--text-2); max-width: 52ch; }

.bar {
  display: flex;
  gap: 3px;
  height: 14px;
  margin-top: 24px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-2);
}
.bar span {
  height: 100%;
  transform-origin: left;
  animation: grow .9s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 90ms + 150ms);
}
@keyframes grow { from { transform: scaleX(0); } }

.legend { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.legend li { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.legend .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .name { flex: 1; min-width: 0; }
.legend .amt { font-weight: 600; }

.years {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 20px;
}
.year-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--text-2);
}
.year-chip b { font-size: 15px; color: var(--text); font-weight: 600; white-space: nowrap; }
.year-chip.is-urgent { border-color: color-mix(in srgb, var(--amber) 50%, transparent); }
.year-chip.is-urgent .due { color: var(--amber); font-weight: 500; }
.year-chip.is-empty b { color: var(--text-2); font-weight: 500; }

.note-line {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 16px;
  font-size: 15px;
  color: var(--text-2);
}
.note-line .icon { margin-top: 2px; }
.note-line.money-note .icon { color: var(--money); }
.note-line.warn .icon { color: var(--amber); }

.cards { display: grid; gap: 10px; }

.card {
  padding: 18px;
  border-radius: var(--r-card);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--highlight), var(--shadow);
}
.card-head { display: flex; align-items: flex-start; gap: 12px; }
.card-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  background: var(--surface-2);
}
.card-icon .icon { width: 22px; height: 22px; }
.card-title { flex: 1; min-width: 0; align-self: center; }
.card-title h3 { font-size: 17px; font-weight: 600; line-height: 1.3; letter-spacing: -.01em; }
.card-amount { font-size: 18px; font-weight: 600; color: var(--money); white-space: nowrap; }
.card p.why { margin-top: 10px; color: var(--text-2); font-size: 15px; }
.card .by-year { margin-top: 8px; font-size: 14px; color: var(--text-2); }

.statuses { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0 52px; }
.statuses:empty { display: none; }
.status {
  display: inline-flex;
  white-space: nowrap;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--text-2);
}
.status.ok { background: var(--money-soft); color: var(--money); }
.status.carry { background: color-mix(in srgb, var(--seg-2) 14%, transparent); color: var(--text); }
.status.warn { background: var(--amber-soft); color: var(--amber); }

details.law { margin-top: 10px; }
details.law summary,
details.more summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  list-style: none;
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
}
details summary::-webkit-details-marker { display: none; }
details summary .icon { width: 16px; height: 16px; transition: transform .2s var(--ease); }
details[open] > summary .icon { transform: rotate(180deg); }
.law-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-2);
}

.card.advice-obligation {
  border-color: color-mix(in srgb, var(--amber) 40%, transparent);
  background: linear-gradient(var(--amber-soft), var(--amber-soft)), var(--surface);
}
.card.advice-obligation .card-icon { color: var(--amber); background: var(--amber-soft); }
.card.advice-info .card-icon { color: var(--text-2); }

.family {
  border-color: color-mix(in srgb, var(--money) 35%, transparent);
}
.family .gain { font-size: 28px; font-weight: 600; letter-spacing: -.03em; color: var(--money); }
.split { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; }
.split li { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; padding: 8px 0; border-top: 1px solid var(--line); }
.split li span:last-child { color: var(--text-2); text-align: right; }
.assumptions { margin-top: 10px; font-size: 13px; color: var(--text-2); }

.regimes { display: grid; gap: 12px; margin-top: 16px; }
.regime { display: grid; gap: 6px; }
.regime-row { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; }
.regime-row .amt { font-weight: 600; white-space: nowrap; }
.regime-track { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.regime-track span { display: block; height: 100%; border-radius: inherit; background: var(--text-2); transform-origin: left; animation: grow .9s var(--ease) both; }
.regime.best .regime-track span { background: var(--money); }
.regime.best .amt { color: var(--money); }
.regime.na { opacity: .55; }
.best-tag { margin-left: 8px; font-size: 12px; font-weight: 600; color: var(--money); }
.regime-notes { margin-top: 12px; font-size: 13px; color: var(--text-2); display: grid; gap: 4px; }

.result-actions { display: grid; gap: 10px; margin-top: 28px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: transparent;
  font-size: 15px;
  transition: background .2s, transform .15s var(--ease);
}
.chip:hover { background: var(--surface-2); }
.chip:active { transform: scale(.97); }

.answers-list { list-style: none; margin: 8px 0 0; padding: 0; }
.answers-list li { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); font-size: 15px; }
.answers-list .q { flex: 1; min-width: 0; color: var(--text-2); }
.answers-list .a { font-weight: 500; text-align: right; }
.answers-list .link-btn { font-size: 14px; }

/* ---------- План ---------- */

.plan-head h1 { font-size: clamp(30px, 8vw, 44px); line-height: 1.05; }
.plan-head p { margin-top: 10px; color: var(--text-2); font-size: 17px; }
.plan-head .money { color: var(--money); font-weight: 600; }

.steps { list-style: none; margin: 24px 0 0; padding: 0; display: grid; gap: 10px; counter-reset: step; }
.step {
  position: relative;
  padding: 18px 18px 18px 64px;
  border-radius: var(--r-card);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--highlight), var(--shadow);
  counter-increment: step;
}
.step::before {
  content: counter(step);
  position: absolute;
  left: 18px;
  top: 18px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.step.is-done::before { content: "✓"; background: var(--money); border-color: var(--money); color: var(--bg); }
.step.is-done h3 { text-decoration: line-through; text-decoration-color: var(--line-strong); color: var(--text-2); }
.step.obligation { border-color: color-mix(in srgb, var(--amber) 40%, transparent); }
.step h3 { font-size: 17px; font-weight: 600; letter-spacing: -.01em; line-height: 1.3; }
.step p { margin-top: 8px; color: var(--text-2); font-size: 15px; }
.step ul { margin: 10px 0 0; padding: 0 0 0 18px; display: grid; gap: 6px; font-size: 15px; }
.step .group-title { margin-top: 14px; font-size: 14px; font-weight: 600; }
.step .tag { display: inline-block; margin-top: 8px; padding: 3px 10px; border-radius: 999px; font-size: 13px; background: var(--surface-2); color: var(--text-2); }
.step .tag.urgent { background: var(--amber-soft); color: var(--amber); }
.step a.ext { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; font-weight: 500; text-underline-offset: 3px; }

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 32px;
  font-size: 15px;
  cursor: pointer;
}
.check-row input {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin: 1px 0 0;
  flex: none;
  border-radius: 6px;
  border: 1.5px solid var(--line-strong);
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.check-row input:checked { background: var(--money); border-color: var(--money); }
.check-row input:checked::after { content: ""; width: 10px; height: 6px; border: 2px solid var(--bg); border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.check-row input:checked + span { color: var(--text-2); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.step .done-toggle { margin-top: 12px; }
.docs-list { list-style: none !important; padding: 0 !important; }

.plan-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 24px; }
@media (max-width: 420px) { .plan-actions { grid-template-columns: 1fr; } }

/* ---------- Ошибки и уведомления ---------- */

.alert {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 16px auto 0;
  max-width: 608px;
  padding: 12px 16px;
  border-radius: var(--r-card);
  border: 1px solid color-mix(in srgb, var(--danger) 50%, transparent);
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  font-size: 15px;
}
.alert p { flex: 1; min-width: 200px; }
.alert .btn { min-height: 40px; padding: 0 16px; font-size: 14px; }
.alert-wrap { padding: 0 16px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-b));
  z-index: 60;
  transform: translateX(-50%);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 15px;
  font-weight: 500;
  animation: enter .3s var(--ease) both;
}

.loading { display: grid; gap: 10px; margin-top: 24px; }
.loading span { height: 56px; border-radius: var(--r-card); background: var(--surface); animation: pulse 1.4s ease-in-out infinite; }
.loading span:nth-child(2) { animation-delay: .15s; }
.loading span:nth-child(3) { animation-delay: .3s; }
@keyframes pulse { 50% { opacity: .45; } }

/* ---------- Чат (боковая панель) ---------- */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--scrim);
  animation: fade .25s both;
}
@keyframes fade { from { opacity: 0; } }

.drawer {
  position: fixed;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--line);
  box-shadow: var(--highlight);
}
@media (min-width: 761px) {
  .drawer { top: 0; right: 0; bottom: 0; width: 420px; border-width: 0 0 0 1px; animation: slide-x .35s var(--ease) both; }
}
@media (max-width: 760px) {
  .drawer {
    left: 0; right: 0; bottom: 0;
    height: min(92dvh, 100%);
    border-radius: var(--r-hero) var(--r-hero) 0 0;
    border-width: 1px 0 0;
    animation: slide-y .35s var(--ease) both;
  }
}
@keyframes slide-x { from { transform: translateX(100%); } }
@keyframes slide-y { from { transform: translateY(100%); } }

.drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 10px 20px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h2 { flex: 1; font-size: 18px; letter-spacing: -.02em; }

.messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg {
  max-width: 88%;
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.msg p + p, .msg p + ul, .msg ul + p { margin-top: 8px; }
.msg ul { margin: 0; padding-left: 18px; }
.msg-bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg-user { align-self: flex-end; background: var(--surface-2); border-bottom-right-radius: 6px; }
.msg-error { border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.msg .msg-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.msg .msg-actions .btn { min-height: 40px; padding: 0 16px; font-size: 14px; }
.chat-intro { color: var(--text-2); font-size: 15px; }
.chat-intro h3 { color: var(--text); font-size: 17px; margin-bottom: 6px; letter-spacing: -.01em; }
.chat-intro .chips { margin-top: 12px; }
.chat-intro .chip { text-align: left; min-height: 44px; padding: 8px 14px; font-size: 14px; border-radius: 14px; }

.typing { display: inline-flex; gap: 4px; padding: 16px; }
.typing i { width: 6px; height: 6px; border-radius: 999px; background: var(--text-2); animation: pulse 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }

.quick { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 8px; }
.quick .chip { min-height: 40px; font-size: 14px; }

.composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 10px 10px calc(10px + var(--safe-b));
  border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 160px;
  padding: 10px 14px;
  border-radius: 22px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 16px; /* меньше 16px — iOS увеличивает страницу */
  line-height: 1.4;
  resize: none;
}
.composer textarea:focus { outline: none; border-color: var(--text); }
.send {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 999px;
  border: 0;
  background: var(--text);
  color: var(--bg);
}
.send:disabled { opacity: .4; }
.send .icon { width: 20px; height: 20px; }

/* ---------- Листы (согласие, подтверждение) ---------- */

dialog.sheet {
  width: min(480px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 24px;
  border-radius: var(--r-hero);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--highlight), 0 24px 64px rgba(0, 0, 0, .3);
}
dialog.sheet::backdrop { background: var(--scrim); }
dialog.sheet[open] { animation: enter .3s var(--ease) both; }
dialog.sheet h2 { font-size: 22px; line-height: 1.2; }
dialog.sheet p { margin-top: 10px; color: var(--text-2); font-size: 15px; }
dialog.sheet ul { margin: 12px 0 0; padding-left: 18px; color: var(--text-2); font-size: 15px; display: grid; gap: 4px; }
dialog.sheet .check-row { margin-top: 18px; }
dialog.sheet .sheet-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
dialog.sheet .sheet-actions .btn { flex: 1; min-width: 140px; }
@media (max-width: 520px) {
  dialog.sheet {
    margin: auto 0 0;
    width: 100%;
    max-width: 100%;
    border-radius: var(--r-hero) var(--r-hero) 0 0;
    padding-bottom: calc(24px + var(--safe-b));
  }
}

/* ---------- Меню ---------- */

.menu {
  position: absolute;
  right: 12px;
  top: calc(100% + 6px);
  z-index: 30;
  min-width: 240px;
  padding: 6px;
  border-radius: var(--r-card);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--highlight), 0 16px 40px rgba(0, 0, 0, .25);
  animation: enter .2s var(--ease) both;
}
.menu button,
.menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  font-size: 15px;
  text-align: left;
  text-decoration: none;
}
.menu button:hover,
.menu a:hover { background: var(--surface-2); }
.menu .danger { color: var(--danger); }

/* ---------- Движение ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- Печать плана ---------- */

@media print {
  :root, :root:not([data-theme="dark"]) {
    --bg: #fff; --surface: #fff; --surface-2: #f2f2f2; --text: #000; --text-2: #333;
    --line: #ccc; --line-strong: #999; --money: #1a6e44; --amber: #6b4b0f; --highlight: none; --shadow: none;
  }
  body { background: #fff; color: #000; font-size: 12pt; }
  .topbar, .footer, .alert-wrap, .drawer, .scrim, .no-print, .toast { display: none !important; }
  .screen { max-width: none; padding: 0; animation: none; }
  .step { break-inside: avoid; box-shadow: none; }
  .step a.ext::after { content: " (" attr(href) ")"; }
  .print-only { display: block !important; }
}
.print-only { display: none; }

/* --- Основание в чате и «Как посчитали» --- */
.sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.source-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--text-2); font-size: 12px; }
.source-chip .icon { width: 14px; height: 14px; }
.how { margin-top: 16px; }
.how-year { margin-top: 10px; }
.how-title { font-weight: 600; margin: 0 0 6px; }
.how ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.how li { display: grid; gap: 2px; color: var(--text-2); font-size: 14px; }
.how li b { color: var(--text); font-weight: 600; }
.how-note { color: var(--text-2); font-size: 13px; margin: 10px 0 0; }
