/* ==========================================================================
   app.css — рабочие экраны клиента: мастер, кабинет, пакет, шпаргалка, Mini App
   ========================================================================== */

/* Шапка рабочих экранов ===================================================== */
.app-top .top__in { gap: 12px; }
.app-prog { flex: 1 1 auto; min-width: 0; max-width: 380px; margin-left: 8px; display: none; gap: 5px; }
.app-prog__meta { display: flex; justify-content: space-between; gap: 12px; font-size: .75rem; color: var(--ink-3); white-space: nowrap; font-variant-numeric: lining-nums tabular-nums; }
@media (min-width: 720px) { .app-prog { display: grid; margin-left: 24px; } }

/* Каркас мастера ============================================================ */
.app { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; padding-block: 16px 120px; }
@media (min-width: 1024px) { .app { grid-template-columns: 272px minmax(0, 1fr); gap: 56px; padding-block: 36px 96px; align-items: start; } }

/* Боковая колонка: страна, шаги, помощь */
.rail { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1024px) { .rail { position: sticky; top: calc(var(--top-h) + 28px); gap: 20px; } }
.rail__country { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--iris); position: relative; isolation: isolate; }
.rail__country::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: url("../img/mesh.svg") 0 0 / 160px 80px; z-index: -1; }
.rail__country b { font-family: var(--display); font-weight: 400; font-size: 1.125rem; line-height: 1.2; }
.rail__country small { display: block; font-size: .75rem; color: var(--ink-2); }

/* На телефоне список шагов свёрнут в одну строку */
.rail__toggle { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; padding: 10px 14px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--paper); text-align: left; }
.rail__toggle b { display: block; font-weight: 600; font-size: .9375rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail__toggle small { font-size: .75rem; color: var(--ink-3); }
.rail__toggle .bar { grid-column: 1 / -1; height: 4px; }
.rail__toggle[aria-expanded="true"] .ic-chevron-down { transform: rotate(180deg); }
.rail__list { display: none; }
.rail__list.is-open { display: block; }
.rail__help { display: none; }
@media (min-width: 1024px) {
  .rail__toggle { display: none; }
  .rail__list { display: block; }
  .rail__help { display: block; }
}

.steps { list-style: none; padding: 0; margin: 0; }
.steps li { position: relative; }
.steps li::before { content: ""; position: absolute; left: 13.5px; top: 34px; bottom: -4px; width: 1px; background: var(--line-2); }
.steps li:last-child::before { display: none; }
.steps button { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; align-items: center; width: 100%; padding: 7px 8px 7px 0; border: 0; background: none; text-align: left; border-radius: 8px; color: var(--ink-3); font-size: .9375rem; line-height: 1.3; }
.steps button:disabled { cursor: default; }
.steps button:not(:disabled):hover { color: var(--ink); }
.steps__n { position: relative; z-index: 1; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--paper); border: 1px solid var(--line-2); font-size: .8125rem; font-weight: 500; color: var(--ink-3); font-variant-numeric: lining-nums tabular-nums; transition: background var(--fast), border-color var(--fast), color var(--fast); }
.steps__n .ic { width: 14px; height: 14px; }
.steps small { display: block; font-size: .75rem; color: var(--warn); }
.steps li.is-done .steps__n { background: var(--ok); border-color: var(--ok); color: #fff; }
.steps li.is-done button { color: var(--ink-2); }
.steps li.is-now .steps__n { background: var(--violet); border-color: var(--violet); color: #fff; box-shadow: 0 0 0 4px var(--violet-t); }
.steps li.is-now button { color: var(--ink); font-weight: 600; }
.steps li.is-lock button { opacity: .55; }

/* Экран шага ================================================================ */
.stage { min-width: 0; max-width: 820px; }
.stage__head { display: grid; gap: 10px; margin-bottom: 24px; }
.stage__kicker { font-size: .875rem; font-weight: 500; color: var(--violet); font-variant-numeric: lining-nums tabular-nums; }
.stage__head h1 { font-size: clamp(1.625rem, 1.3rem + 1.6vw, 2.25rem); line-height: 1.15; }
.stage__body { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
.stage.is-in > *:not(.dock) { animation: stage 300ms var(--ease) both; }
@keyframes stage { from { opacity: 0; transform: translateY(6px); } }

.block { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-content: start; }
.block > h2 { font: 600 1.1875rem/1.3 var(--text); letter-spacing: -.012em; }
.block__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.block__head h2, .block__head h3 { font: 600 1.1875rem/1.3 var(--text); letter-spacing: -.012em; }
.q { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); padding: 22px 0; border-top: 1px solid var(--line); }
.q:first-child { border-top: 0; padding-top: 0; }
.q__t { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; align-items: baseline; }
.q__n { font-weight: 600; color: var(--violet); font-variant-numeric: lining-nums tabular-nums; }
.q__t h3 { font-size: 1.0625rem; }
.q__t p { grid-column: 2; color: var(--ink-3); font-size: .875rem; margin-top: 2px; }
.q__a { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px) { .q__a { padding-left: 40px; } }
.q--done .q__a { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }

/* Кнопки шага: на телефоне прижаты к низу экрана */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; display: flex; gap: 10px; padding: 10px var(--pad) calc(10px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .94); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
.dock .btn { min-height: 48px; }
.dock .btn--primary { flex: 1 1 auto; }
@media (min-width: 1024px) {
  .dock { position: static; padding: 28px 0 0; margin-top: 12px; border-top: 1px solid var(--line); background: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .dock .btn--primary { flex: 0 0 auto; min-width: 220px; }
}

/* Блокирующая зависимость (ТЗ 4) */
.blocker { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 12px; padding: 14px 16px; border-radius: 12px; border: 1px dashed var(--warn); background: var(--warn-t); color: var(--warn); font-size: .9375rem; }
.blocker b { color: var(--ink); }
.blocker .ic { margin-top: 2px; }

/* Сводка оплаты */
.sum { display: grid; gap: 10px; }
.sum div { display: flex; justify-content: space-between; gap: 16px; font-size: .9375rem; }
.sum div span:first-child { color: var(--ink-3); }
.sum .sum__total { padding-top: 12px; border-top: 1px solid var(--line); align-items: baseline; }
.sum .sum__total span:first-child { color: var(--ink); font-weight: 600; }

/* Способ оплаты */
.pay { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pay .choice { grid-template-columns: 20px minmax(0, 1fr); align-items: center; }
.pay .choice__mark { grid-row: auto; margin-top: 0; }

/* Результат проверки ИИ */
.verdict { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; align-items: center; }
.checks { list-style: none; padding: 0; display: grid; }
.checks li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px 0; border-top: 1px solid var(--line); }
.checks li:first-child { border-top: 0; }
.checks li > .ic { margin-top: 2px; color: var(--ok); }
.checks li.is-warn > .ic { color: var(--warn); }
.checks li.is-bad > .ic { color: var(--bad); }
.checks li small { display: block; color: var(--ink-3); font-size: .8125rem; }
.finding { display: grid; gap: 10px; padding: 16px; border-radius: 12px; border: 1px solid var(--warn); background: var(--warn-t); }
.finding.is-fixed { border-color: var(--line); background: var(--ok-t); }
.finding__cmp { display: grid; gap: 6px; font-size: .875rem; }
.finding__cmp div { display: grid; grid-template-columns: minmax(0, 9em) minmax(0, 1fr); gap: 10px; }
.finding__cmp span:first-child { color: var(--ink-3); }

/* Анкета: поля и источники */
.ftable { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.ftable th { text-align: left; padding: 14px 0 6px; font-size: .8125rem; font-weight: 600; color: var(--ink); border-bottom: 1px solid var(--line-2); }
.ftable td { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.ftable td:first-child { color: var(--ink-3); width: 38%; }
.ftable td:last-child { padding-right: 0; text-align: right; white-space: nowrap; width: 1%; }
.ftable tr.is-wait td:nth-child(2) { color: var(--warn); font-style: italic; }
@media (max-width: 599px) {
  .ftable, .ftable tbody, .ftable tr, .ftable td, .ftable th { display: block; width: 100% !important; }
  .ftable tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  .ftable td { padding: 1px 0; border: 0; text-align: left !important; white-space: normal !important; }
  .ftable td:first-child { font-size: .8125rem; }
  .ftable td:last-child { margin-top: 4px; }
  .ftable tr:has(th) { border-bottom: 0; padding: 14px 0 0; }
}

/* Данные по порядку полей — запасной вариант для онлайн-анкет (ТЗ 8) */
.copyrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.copyrow:first-child { border-top: 0; }
.copyrow small { display: block; color: var(--ink-3); font-size: .8125rem; }
.copyrow b { font-family: var(--code); font-weight: 500; font-size: .9375rem; word-break: break-word; }

/* Да / нет без варианта по умолчанию */
.yn { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 14px 0; border-top: 1px solid var(--line); }
.yn:first-child { border-top: 0; }
@media (min-width: 720px) { .yn { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 20px; } }
.yn.is-bad p { color: var(--bad); }
.yn .seg button { min-width: 64px; }

/* Документ: письмо, план, памятка */
.paper { background: #fff; border: 1px solid var(--line-2); border-radius: var(--r-doc); padding: 24px 20px; font-size: .9375rem; line-height: 1.55; box-shadow: var(--sh-1); overflow-x: auto; }
@media (min-width: 720px) { .paper { padding: 36px 40px; } }
.paper h3 { font-family: var(--display); font-weight: 400; font-size: 1.25rem; margin-bottom: 12px; }
.paper p + p { margin-top: 10px; }
.paper table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: .875rem; min-width: 480px; }
.paper th, .paper td { border: 1px solid var(--line-2); padding: 7px 10px; text-align: left; vertical-align: top; }
.paper th { background: var(--wash); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label { position: relative; }
.chips input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chips span { display: inline-flex; align-items: center; min-height: 36px; padding: 6px 14px; border: 1px solid var(--line-2); border-radius: 18px; font-size: .875rem; font-weight: 500; color: var(--ink-2); cursor: pointer; transition: all var(--fast); }
.chips input:checked + span { border-color: var(--violet); background: var(--violet-t); color: var(--violet-d); }
.chips input:focus-visible + span { outline: 2px solid var(--violet); outline-offset: 2px; }

/* Фото: правильно и неправильно */
.photos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; max-width: 420px; }
.photo { display: grid; gap: 8px; justify-items: center; align-content: start; padding: 16px 12px 12px; border-radius: 12px; background: var(--wash); text-align: center; font-size: .8125rem; color: var(--ink-2); }
.photo__img { position: relative; width: 70px; height: 90px; border-radius: 3px; background: #EEF1F8; border: 1px solid var(--line-2); overflow: hidden; }
.photo__img::before { content: ""; position: absolute; left: 50%; top: 20px; width: 28px; height: 32px; margin-left: -14px; border-radius: 50%; background: var(--ink-4); }
.photo__img::after { content: ""; position: absolute; left: 50%; bottom: -22px; width: 58px; height: 52px; margin-left: -29px; border-radius: 50% 50% 0 0; background: var(--ink-4); }
.photo--bad .photo__img { background: linear-gradient(100deg, #8791AE 0 45%, #EEF1F8 45%); }
.photo--bad .photo__img::before { top: 28px; margin-left: -4px; transform: rotate(14deg); }
.photo--bad .photo__img::after { margin-left: -19px; }
.photo b { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.photo--ok b { color: var(--ok); } .photo--bad b { color: var(--bad); }

/* Экран «оплачено», «у менеджера» и другие состояния */
.state { display: grid; gap: 12px; justify-items: start; padding: 24px; border-radius: var(--r-box); background: var(--wash); }
.state h2 { font-size: 1.5rem; }
.state--ok { background: var(--ok-t); }
.state--wait { background: var(--violet-t); }

/* Кабинет =================================================================== */
.page { padding-block: 28px 88px; }
.page__head { display: grid; gap: 10px; margin-bottom: 28px; }
.page__head h1 { font-size: clamp(1.75rem, 1.4rem + 1.8vw, 2.5rem); }
.case { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 20px; border: 1px solid var(--line); border-radius: var(--r-box); background: var(--paper); }
@media (min-width: 720px) { .case { grid-template-columns: minmax(0, 1fr) auto; align-items: center; padding: 24px 28px; } }
.case__t { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.case__t h3 { font-family: var(--display); font-weight: 400; font-size: 1.375rem; }
.case__m { color: var(--ink-3); font-size: .875rem; margin-top: 4px; }
.case__p { display: grid; gap: 6px; margin-top: 14px; max-width: 420px; }
.case__a { display: flex; flex-wrap: wrap; gap: 8px; }
.case--now { border-color: transparent; box-shadow: var(--sh-2); }
.feed { list-style: none; padding: 0; display: grid; }
.feed li { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.feed li:first-child { border-top: 0; }
.feed li > span:first-child { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--violet-t); color: var(--violet); }
.feed li.is-warn > span:first-child { background: var(--warn-t); color: var(--warn); }
.feed b { font-weight: 500; display: block; }
.feed small { color: var(--ink-3); font-size: .8125rem; display: block; margin-top: 1px; }

/* Шпаргалка ================================================================= */
.qa { list-style: none; padding: 0; counter-reset: qa; display: grid; }
.qa li { counter-increment: qa; display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 4px 12px; padding: 16px 0; border-top: 1px solid var(--line); break-inside: avoid; }
.qa li:first-child { border-top: 0; }
.qa li::before { content: counter(qa); grid-row: 1 / span 2; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--violet-t); color: var(--violet-d); font-weight: 600; font-size: .8125rem; font-variant-numeric: lining-nums tabular-nums; }
.qa b { font-weight: 600; }
.qa p { grid-column: 2; color: var(--ink-2); }
.daymemo { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.daymemo td { padding: 10px 12px 10px 0; border-top: 1px solid var(--line); vertical-align: top; }
.daymemo tr:first-child td { border-top: 0; }
.daymemo td:first-child { white-space: nowrap; font-weight: 600; width: 1%; font-variant-numeric: lining-nums tabular-nums; }

/* Telegram Mini App ========================================================= */
.tg { max-width: 480px; margin-inline: auto; min-height: 100dvh; padding-bottom: 96px; background: var(--paper); }
.tg__head { position: sticky; top: 0; z-index: 30; padding: 12px 16px; background: rgba(255, 255, 255, .94); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
.tg__tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; padding: 3px; background: var(--wash-2); border-radius: 12px; }
.tg__tabs button { min-height: 38px; border: 0; border-radius: 9px; background: transparent; font-size: .8125rem; font-weight: 500; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }
.tg__tabs button[aria-selected="true"] { background: var(--paper); color: var(--ink); box-shadow: var(--sh-1); }
.tg__body { padding: 18px 16px; display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
.tg__body h1 { font-size: 1.625rem; }
.tg__main { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .94); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
.tg__main .btn { width: min(100%, 448px); margin-inline: auto; display: flex; }
body.tg-page { background: var(--wash-2); }

@media print {
  .dock, .rail, .app-prog, .tg__main, .tg__head { display: none !important; }
  .app { display: block; padding: 0; }
  .stage { max-width: none; }
  .paper { border: 0; box-shadow: none; padding: 0; }
}

/* Состав семьи (тариф Family) */
.members { display: grid; gap: 12px; margin-top: 16px; }
.member { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-box); background: var(--paper); }
.member.is-bad { border-color: var(--bad); }
.member .err { grid-column: 1 / -1; color: var(--bad); font-size: .875rem; margin: 0; }
@media (min-width: 720px) { .member { grid-template-columns: minmax(0, 14rem) minmax(0, 1fr) minmax(0, 11rem); } }

/* Робот заполняет анкету на сайте посольства */
.robot__cap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: end; }
@media (min-width: 560px) { .robot__cap { grid-template-columns: 176px minmax(0, 1fr); } }
.captcha { width: 176px; height: 60px; border-radius: 6px; border: 1px solid var(--line-2); }
.captcha rect { fill: var(--wash); }
.captcha path { fill: none; stroke: var(--ink-4); stroke-width: 1.5; }
.captcha text { font: 600 26px var(--code); fill: var(--ink); text-anchor: middle; letter-spacing: 0; }
.robot__list { margin-top: 14px; }
.robot__list li.is-wait { color: var(--ink-4); }
.robot__list li.is-now .ic { color: var(--violet); animation: spin 1s linear infinite; }
.tag .ic-spinner { animation: spin 1s linear infinite; }
.fallback { border: 1px solid var(--line); border-radius: var(--r-box); background: var(--paper); padding: 4px 18px; }
.fallback > summary { display: grid; grid-template-columns: 20px minmax(0, 1fr) 16px; gap: 12px; align-items: center; padding: 12px 0; cursor: pointer; list-style: none; }
.fallback > summary::-webkit-details-marker { display: none; }
.fallback > summary b { font-weight: 500; display: block; }
.fallback > summary small { color: var(--ink-3); font-size: .8125rem; }
.fallback[open] > summary .ic-chevron-down { transform: rotate(180deg); }
.fallback[open] { padding-bottom: 18px; }
