:root {
  --navy: #14213d;
  --navy-2: #1f3a68;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --good: #0f7a4a;
  --good-bg: #e8f6ef;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --warn-bg: #fff4e0;
  --warn-border: #f5a524;
  --text: #14213d;
  --muted: #5b6474;
  --line: #d9dee8;
  --bg: #f4f6fa;
  --card: #ffffff;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.5 var(--font); min-height: 100vh;
  padding-top: 52px;
}
body.has-nav { padding-bottom: 96px; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
strong { font-weight: 700; }

/* ---------- Прогресс ---------- */
.progress {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  background: rgba(244, 246, 250, .96); backdrop-filter: saturate(1.5) blur(6px);
  padding: 10px 16px 8px; border-bottom: 1px solid var(--line);
}
.progress__track { height: 6px; background: #e3e8f1; border-radius: 99px; overflow: hidden; max-width: 760px; margin: 0 auto; }
.progress__bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--navy-2)); border-radius: 99px; transition: width .5s cubic-bezier(.2, .8, .2, 1); }
.progress__label { max-width: 760px; margin: 5px auto 0; font-size: 13px; color: var(--muted); }

/* ---------- Каркас ---------- */
.app { max-width: 760px; margin: 0 auto; padding: 20px 16px 32px; }
.step { animation: none; }
.step--in { animation: stepIn .3s ease both; }
@keyframes stepIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.step__title { font-size: 24px; line-height: 1.25; margin: 4px 0 20px; outline: none; }

.loader { display: flex; gap: 8px; justify-content: center; padding: 60px 0; }
.loader span { width: 10px; height: 10px; border-radius: 50%; background: var(--navy-2); animation: dot 1s infinite ease-in-out; }
.loader span:nth-child(2) { animation-delay: .15s; } .loader span:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .2; transform: scale(.8); } 40% { opacity: 1; transform: none; } }
.notice { background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; }

/* ---------- Введение ---------- */
.step--intro { text-align: center; padding-top: 24px; }
.intro__title { font-size: clamp(28px, 7vw, 42px); line-height: 1.15; margin: 0 0 14px; letter-spacing: -.01em; }
.intro__subtitle { font-size: 19px; color: var(--muted); margin: 0 auto 24px; max-width: 560px; }
.intro__points { list-style: none; padding: 0; margin: 0 auto 32px; display: inline-flex; flex-direction: column; gap: 10px; text-align: left; }
.intro__points li { position: relative; padding-left: 30px; }
.intro__points li::before {
  content: ""; position: absolute; left: 0; top: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--good-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5 10.5l3 3 7-7' fill='none' stroke='%230f7a4a' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/16px no-repeat;
}

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 10px 20px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 600; cursor: pointer; text-decoration: none; transition: background .2s, opacity .2s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn--primary:disabled, .btn--primary.btn--off, .btn--primary.btn--off:hover { background: #b8c3d6; color: #f1f4f9; cursor: not-allowed; box-shadow: none; }

/* Незаполненные поля после нажатия на неактивную «Далее» */
.is-missing { animation: shake .35s ease; }
.money.is-missing, select.is-missing, .combo__input.is-missing { border-color: var(--bad) !important; background-color: var(--bad-bg) !important; box-shadow: 0 0 0 3px rgba(180, 35, 24, .15); }
.money.is-missing input { background: transparent; }
.yn.is-missing .yn__btn { border-color: var(--bad); background: var(--bad-bg); }
@keyframes shake { 0%, 100% { transform: none; } 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--navy-2); }
.btn--ghost:hover { background: #fff; }
.btn--big { min-height: 58px; padding: 14px 40px; font-size: 19px; box-shadow: 0 8px 24px rgba(37, 99, 235, .25); }
:focus-visible { outline: 3px solid rgba(37, 99, 235, .45); outline-offset: 2px; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  display: flex; justify-content: center; gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(244, 246, 250, .96); backdrop-filter: blur(6px); border-top: 1px solid var(--line);
}
.nav .btn { flex: 0 1 220px; }
.nav #btn-next { flex-basis: 280px; }

/* ---------- Поля ---------- */
.field { margin: 0 0 22px; }
.field__label { display: flex; align-items: flex-start; gap: 8px; font-weight: 600; margin-bottom: 8px; }
.field__label label { cursor: pointer; }
.field__error { min-height: 0; color: var(--bad); font-size: 14px; margin-top: 4px; }
.field__error:empty { display: none; }

.money {
  position: relative; display: flex; align-items: center;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; transition: border-color .2s, box-shadow .2s;
}
.money:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.money--error { border-color: var(--bad); }
.money input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 12px 8px 12px 14px; font-size: 18px; outline: none; }
.money__unit { flex: none; padding-right: 14px; color: var(--muted); font-size: 15px; white-space: nowrap; }

/* Строки дохода */
.incomes { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.income {
  display: grid; grid-template-columns: minmax(0, 1fr) 48px; grid-template-areas: "type help" "sum remove";
  gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px;
}
.income__type { grid-area: type; }
.income__help { grid-area: help; justify-self: center; align-self: center; }
.income .money { grid-area: sum; }
.income__remove { grid-area: remove; }
.income__type select {
  width: 100%; min-height: 48px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; padding: 10px 36px 10px 12px;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235b6474' stroke-width='1.8'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px;
}
.income__type select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.income__remove {
  width: 48px; height: 48px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted);
}
.income__remove:hover { color: var(--bad); border-color: var(--bad); }
@media (min-width: 600px) {
  .income { grid-template-columns: 220px minmax(0, 1fr) 48px 48px; grid-template-areas: "type sum help remove"; align-items: center; }
}

/* Выбор региона */
.combo { position: relative; }
.combo__input {
  width: 100%; min-height: 50px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; padding: 12px 44px 12px 14px; font-size: 17px; outline: none;
}
.combo__input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.combo--error .combo__input { border-color: var(--bad); }
.combo__toggle {
  position: absolute; right: 4px; top: 4px; width: 42px; height: 42px; border: 0; background: transparent; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235b6474' stroke-width='1.8'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center; background-size: 12px; transition: transform .2s;
}
.combo--open .combo__toggle { transform: rotate(180deg); }
.combo__list {
  position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none;
  max-height: 260px; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 30px rgba(20, 33, 61, .15);
}
.combo__list li { padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.combo__list li.active, .combo__list li:hover { background: #edf2fd; }
.combo__list li[aria-selected="true"] { font-weight: 600; }
.combo__empty { color: var(--muted); cursor: default !important; }

/* Да / Нет */
.yn { display: flex; gap: 10px; }
.yn__btn {
  flex: 1 1 0; max-width: 180px; min-height: 50px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; font-weight: 600; cursor: pointer;
  transition: background .2s, border-color .2s, color .2s;
}
.yn__btn:hover { border-color: var(--accent); }
.yn__btn[aria-pressed="true"] { background: var(--navy-2); border-color: var(--navy-2); color: #fff; }

/* Счётчик */
.counter { display: inline-flex; align-items: center; gap: 8px; }
.counter__btn {
  width: 56px; height: 56px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff; font-size: 28px; line-height: 1; cursor: pointer; color: var(--navy-2);
}
.counter__btn:hover:not(:disabled) { border-color: var(--accent); }
.counter__btn:disabled { opacity: .35; cursor: not-allowed; }
.counter__value { min-width: 84px; text-align: center; font-size: 22px; font-weight: 700; }

/* Подсказки (?) */
.help { position: relative; display: inline-flex; flex: none; }
.help__btn {
  width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid #b7c1d3; background: #fff; color: var(--muted);
  font-size: 13px; font-weight: 700; line-height: 1; cursor: pointer; padding: 0;
}
.help__pop {
  display: none; position: absolute; z-index: 30; top: calc(100% + 8px); right: -8px; width: min(300px, calc(100vw - 32px));
  background: var(--navy); color: #fff; font-size: 14px; font-weight: 400; line-height: 1.45; padding: 10px 12px; border-radius: 10px;
  box-shadow: 0 10px 30px rgba(20, 33, 61, .3);
}
.field__label .help__pop { left: auto; right: auto; }
.field__label .help { position: static; }
.field__label { position: relative; }
.field__label .help__pop { left: 0; right: 0; width: auto; max-width: 420px; }
.help.open .help__pop { display: block; }
@media (hover: hover) { .help:hover .help__pop { display: block; } }

/* Плавное появление */
.reveal { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows .25s ease, opacity .25s ease; }
.reveal__inner { overflow: hidden; min-height: 0; }
.reveal--open { grid-template-rows: 1fr; opacity: 1; }
.reveal--open > .reveal__inner { overflow: visible; animation: unclip .25s step-end; }
@keyframes unclip { from { overflow: hidden; } to { overflow: visible; } }

/* ---------- Результат ---------- */
.res__title { font-size: 22px; margin: 4px 0 12px; color: var(--muted); font-weight: 600; outline: none; }
.res__main { font-size: clamp(22px, 5.5vw, 30px); line-height: 1.3; margin: 0 0 10px; }
.res__main strong { color: var(--good); white-space: nowrap; }
.res__now { margin: 0 0 18px; color: var(--muted); }
.res__now strong { color: var(--text); white-space: nowrap; }
.res__now--neg strong { color: var(--bad); }

.contrast { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 0 0 22px; }
.contrast__item { border-radius: var(--radius); padding: 14px 16px; font-size: 16px; }
.contrast__item strong { display: block; font-size: 24px; margin-top: 2px; }
.contrast__item--bad { background: var(--bad-bg); }
.contrast__item--bad strong { color: var(--bad); }
.contrast__item--good { background: var(--good-bg); }
.contrast__item--good strong { color: var(--good); }

.chart-link { display: inline-block; margin-top: 8px; color: var(--good); font-weight: 600; font-size: 15px; text-decoration: underline; text-underline-offset: 3px; }
.chart-link:hover { text-decoration-thickness: 2px; }
.cols { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 18px; }
.col { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px; }
.col--me { border: 2px solid var(--good); box-shadow: 0 10px 30px rgba(15, 122, 74, .12); }
.col__badge { position: absolute; top: -12px; right: 16px; background: var(--good); color: #fff; font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 99px; }
.col__title { font-size: 19px; margin: 0 0 8px; }
.col__sum { margin: 0 0 12px; }
.col__sum strong { white-space: nowrap; }
.col__sum--big { font-size: 20px; }
.col__sum--big strong { font-size: 28px; color: var(--good); }
.col__sub { margin: 0 0 6px; font-size: 14px; color: var(--muted); font-weight: 600; }
.col__parts { margin: 0 0 12px; padding-left: 20px; font-size: 15px; }
.col__parts li { margin-bottom: 6px; }
.col__note { display: block; color: var(--muted); font-size: 13px; }
.col__court { margin: 0; font-size: 15px; background: #f7f8fb; border-left: 3px solid #b7c1d3; padding: 10px 12px; border-radius: 0 10px 10px 0; }
.col__outcome { margin: 0; font-size: 15px; background: var(--good-bg); padding: 10px 12px; border-radius: 10px; }
.col__outcome strong { color: var(--good); }

.warn { background: var(--warn-bg); border: 1.5px solid var(--warn-border); border-radius: var(--radius); padding: 14px 16px 14px 48px; margin: 0 0 18px; position: relative; font-size: 15px; }
.warn::before { content: "!"; position: absolute; left: 14px; top: 13px; width: 24px; height: 24px; border-radius: 50%; background: var(--warn-border); color: #fff; font-weight: 800; text-align: center; line-height: 24px; }

.share { margin: 0 0 20px; }
.share__label { font-weight: 600; margin-bottom: 6px; font-size: 15px; }
.share__row { display: flex; flex-wrap: wrap; gap: 8px; }
.share__link { flex: 1 1 220px; min-width: 0; min-height: 48px; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; font-size: 14px; color: var(--muted); }

.cta { background: var(--navy); color: #e8edf7; border-radius: 18px; padding: 18px; margin-bottom: 16px; }
.cta__text { margin: 0 0 14px; font-size: 14px; line-height: 1.5; }
.cta__btns { display: grid; grid-template-columns: 1fr; gap: 10px; }
.btn--msg { color: #fff; min-height: 54px; font-size: 17px; }
.btn--tg { background: #229ed9; } .btn--tg:hover { background: #1b8bc0; }
.btn--vk { background: #0077ff; } .btn--vk:hover { background: #0066db; }
.btn--max { background: #7b4dff; } .btn--max:hover { background: #6a3cf0; }
.inputs { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.inputs summary { cursor: pointer; padding: 6px 0; width: fit-content; }
.inputs summary:hover { color: var(--text); }
.inputs__list { list-style: none; margin: 6px 0 0; padding: 0 0 0 2px; display: flex; flex-direction: column; gap: 4px; }
.inputs__list span { color: var(--text); }
.res__nav { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.res__nav .btn { width: 100%; white-space: nowrap; padding-left: 12px; padding-right: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 50; max-width: calc(100vw - 32px);
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 15px; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; box-shadow: 0 10px 30px rgba(20, 33, 61, .3);
}
.toast--on { opacity: 1; transform: translate(-50%, 0); }
body.has-nav .toast { bottom: 100px; }

@media (min-width: 720px) {
  body { font-size: 18px; }
  .app { padding-top: 32px; }
  .step__title { font-size: 28px; }
  .contrast { grid-template-columns: 1fr 1fr; }
  .cols { grid-template-columns: 1fr 1fr; align-items: start; }
  .cta__btns { grid-template-columns: repeat(3, 1fr); }
}

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