/* ===========================================================================
   EMAN — единая дизайн-система (Apple-подобная: минимализм, плавность,
   непрерывность). Один бренд-цвет #0a496a + комплементарный амбер для выбора.
   =========================================================================== */

:root {
  /* — Бренд — */
  --brand:      #0a496a;   /* основной петроль */
  --brand-600:  #0e6390;   /* светлее (верх градиента/hover) */
  --brand-700:  #063a54;   /* темнее (нажатие) */
  --brand-tint: #e9f1f5;   /* очень светлый холодный фон */

  /* — Комплементарный акцент (тёплое дерево/дуб) — только для «выбрано» — */
  --accent:      #c8a96e;   /* древесный, контраст к петролю */
  --accent-600:  #a8863f;   /* темнее */
  --accent-tint: #f1e8d4;   /* светлый древесный тон (кольцо/мягкий фон) */
  --accent-ink:  #3d2f12;   /* тёмный текст на акценте */

  /* — Нейтрали (холодный петролевый ряд) — */
  --bg:      #f3f6f8;
  --surface: #ffffff;
  --text:    #102a39;
  --muted:   #5e7180;
  --line:    #e5ebef;      /* hairline */

  /* — Статусы — */
  --ok:     #1c8a4e;
  --danger: #d6453d;

  /* — Алиасы под существующую разметку — */
  --card: var(--surface);
  --border: var(--line);
  --primary: var(--brand);
  --primary-dark: var(--brand-700);
  --primary-soft: var(--brand-tint);

  /* — Скругления (одно семейство) — */
  --r-lg: 22px;
  --r-md: 15px;
  --r-sm: 12px;
  --radius: var(--r-lg);

  /* — Тени (мягкие, многослойные) — */
  --shadow-sm: 0 1px 2px rgba(6,58,84,.05), 0 2px 6px rgba(6,58,84,.04);
  --shadow-md: 0 6px 22px rgba(6,58,84,.09);
  --shadow-lg: 0 16px 46px rgba(6,58,84,.16);

  /* — Движение (одна кривая, единый ритм) — */
  --ease: cubic-bezier(.22, 1, .36, 1);
  --t-fast: .18s;
  --t: .32s;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; width: 100%; overflow-x: hidden; }
img { max-width: 100%; }
body {
  font-family: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* Первый экран (развилка) — без прогресса и навигации. Топбар оставляем, но
   прозрачным и только с переключателем языка (логотип прячем — есть в hero). */
.app.welcome-mode .progress,
.app.welcome-mode .navbar { display: none; }
.app.welcome-mode .topbar {
  background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none;
  justify-content: flex-end;
}
.app.welcome-mode .brand { display: none; }
/* На развилке панели навигации нет — убираем лишний нижний отступ. */
.app.welcome-mode .screen { padding: 6vh 18px 28px; }

/* ── Переключатель языка (RU/UZ) — сегмент-пилюля в шапке ───────────────── */
.lang-switch {
  display: inline-flex; background: var(--brand-tint);
  border-radius: 999px; padding: 3px;
}
.lang-switch button {
  border: none; background: transparent; color: var(--brand);
  font-family: inherit; font-size: 13px; font-weight: 700; letter-spacing: .02em;
  padding: 5px 13px; border-radius: 999px; cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
}
.lang-switch button.on { background: var(--surface); box-shadow: var(--shadow-sm); }

/* ── Топбар + прогресс ─────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px 10px;
  background: rgba(243, 246, 248, .8);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .mark {
  flex: 0 0 auto;
  width: 44px; height: 44px; border-radius: 13px;
  background: linear-gradient(160deg, var(--brand-600), var(--brand) 70%, var(--brand-700));
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}
.brand .mark img { height: 32px; width: auto; display: block; }

.rate {
  font-size: 13px; color: var(--muted); background: var(--surface);
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.progress { height: 4px; background: var(--line); margin: 0 18px; border-radius: 999px; overflow: hidden; }
.progress-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--brand-600), var(--brand));
  border-radius: 999px;
  transition: width .45s var(--ease);
}

/* ── Экран ─────────────────────────────────────────────────────────────── */
/* Нижний отступ оставляет место под закреплённую панель навигации. */
.screen {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 22px 18px calc(98px + env(safe-area-inset-bottom));
}
.screen.anim { animation: screenIn .42s var(--ease) both; }
.screen h1 { font-size: 25px; line-height: 1.2; letter-spacing: -.02em; margin: 4px 0 6px; font-weight: 800; }
.screen .hint { color: var(--muted); font-size: 15px; margin: 0 0 22px; }
.center { text-align: center; }

/* ── Карточка-секция ───────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--r-lg); padding: 18px; margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

/* ── Большой степпер (конструкторы) — белые круглые кнопки, Apple-стиль ─── */
.stepper { display: flex; align-items: center; justify-content: center; gap: 26px; margin: 14px 0 6px; }
.stepper .val {
  font-size: 46px; font-weight: 700; letter-spacing: -.03em;
  min-width: 72px; text-align: center; font-variant-numeric: tabular-nums;
}
.round-btn {
  width: 58px; height: 58px; border-radius: 50%; border: none;
  background: var(--surface); color: var(--brand);
  font-size: 27px; font-weight: 400; cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
}
.round-btn:hover { background: var(--brand-tint); }
.round-btn:active { transform: scale(.9); background: var(--brand-tint); box-shadow: none; }
.round-btn:disabled { opacity: .35; box-shadow: none; }

/* ── Карточки оборудования ─────────────────────────────────────────────── */
.cat-title {
  font-weight: 700; margin: 22px 4px 10px; color: var(--muted);
  text-transform: uppercase; font-size: 12px; letter-spacing: .08em;
}
.equip {
  background: var(--surface);
  border-radius: var(--r-lg); margin-bottom: 14px; overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t) var(--ease), transform var(--t) var(--ease);
}
.equip:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.equip.active { box-shadow: 0 0 0 2px var(--accent), var(--shadow-md); }
.equip .photo {
  position: relative; width: 100%; height: 184px;
  background: var(--brand-tint); overflow: hidden;
}
.equip .photo img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .6s var(--ease);
}
.equip.active .photo img { transform: scale(1.04); }
.equip .photo .ph {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 68px; opacity: .8;
}
.equip .photo .count-badge {
  position: absolute; top: 12px; right: 12px;
  background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 15px;
  padding: 6px 13px; border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.equip .photo .count-badge.pop { animation: badgePop .42s var(--ease); }
.equip .body {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 16px;
}
.equip .info { flex: 1; min-width: 0; }
.equip .info .name { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }

/* ── Мини-степпер (оборудование / комплект) — связный pill в стиле iOS ──── */
.mini-stepper {
  display: inline-flex; align-items: center;
  background: var(--brand-tint); border-radius: 999px; padding: 3px;
}
.mini-stepper button {
  width: 38px; height: 38px; border-radius: 50%; border: none;
  background: transparent; color: var(--brand);
  font-size: 23px; font-weight: 400; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
}
.mini-stepper button:active { transform: scale(.88); background: var(--surface); box-shadow: var(--shadow-sm); }
.mini-stepper .val {
  min-width: 30px; text-align: center; font-weight: 700; font-size: 17px;
  color: var(--text); font-variant-numeric: tabular-nums;
}

/* ── Сегмент-контролы (Да/Нет, дни) — iOS-стиль ────────────────────────── */
.yesno, .days {
  display: flex; gap: 6px; margin-top: 12px;
  background: var(--brand-tint); border-radius: 14px; padding: 5px;
}
.yesno button, .days button {
  flex: 1; padding: 12px 0; border-radius: 10px; border: none;
  background: transparent; color: var(--muted);
  font-size: 16px; font-weight: 700; cursor: pointer;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.yesno button:active, .days button:active { transform: scale(.97); }
.yesno button.on, .days button.on {
  background: var(--surface); color: var(--brand);
  box-shadow: var(--shadow-sm);
}
.q-label { font-weight: 700; margin-bottom: 3px; letter-spacing: -.01em; }
.q-hint { color: var(--muted); font-size: 14px; }

/* ── Итог ──────────────────────────────────────────────────────────────── */
.summary-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 13px 0; border-bottom: 1px solid var(--line);
}
.summary-row:last-child { border-bottom: none; }
.summary-row .nm { flex: 1; }
.summary-row .pr { white-space: nowrap; font-weight: 700; }
.summary-row .badge {
  font-size: 11px; color: var(--ok); font-weight: 800;
  background: rgba(28,138,78,.1); padding: 2px 7px; border-radius: 999px; margin-left: 6px;
}
.total-box {
  background: linear-gradient(160deg, var(--brand-600), var(--brand) 65%, var(--brand-700));
  color: #fff; border-radius: var(--r-lg);
  padding: 24px; text-align: center; margin-top: 18px;
  box-shadow: var(--shadow-lg);
}
.total-box .lbl { opacity: .8; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }
.total-box .amount { font-size: 38px; font-weight: 800; letter-spacing: -.02em; margin-top: 6px; }
.total-box .sub { opacity: .8; font-size: 12px; margin-top: 8px; }

/* ── Форма ─────────────────────────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 700; margin-bottom: 7px; font-size: 15px; letter-spacing: -.01em; }
.field input, .field textarea {
  width: 100%; padding: 14px; border-radius: var(--r-md); border: 1px solid var(--line);
  font-size: 16px; font-family: inherit; background: var(--surface); color: var(--text);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.field input:focus, .field textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-tint);
}
.field textarea { resize: vertical; min-height: 72px; }
.field .err { color: var(--danger); font-size: 13px; margin-top: 5px; display: none; }
.field.invalid input, .field.invalid textarea { border-color: var(--danger); }
.field.invalid input:focus, .field.invalid textarea:focus { box-shadow: 0 0 0 4px rgba(214,69,61,.12); }
.field.invalid .err { display: block; }

/* ── Навигация: закреплённая снизу панель (видна без прокрутки) ─────────── */
.navbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  width: 100%; max-width: 520px; margin: 0 auto;
  display: flex; gap: 10px; padding: 12px 18px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  background: rgba(243, 246, 248, .82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 -10px 28px rgba(6, 58, 84, .07);
  z-index: 50;
}
.btn {
  flex: 1 1 0; min-width: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 15px 18px; border-radius: 16px; border: none;
  font-size: 17px; font-weight: 700; letter-spacing: -.01em; cursor: pointer;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease),
              filter var(--t-fast) var(--ease), background var(--t-fast) var(--ease),
              opacity var(--t-fast) var(--ease);
}
.btn-primary {
  background: linear-gradient(180deg, var(--brand-600), var(--brand));
  color: #fff; box-shadow: 0 8px 20px rgba(10, 73, 106, .28);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:active { transform: scale(.97); filter: brightness(.93); }
.btn-primary:disabled { opacity: .55; box-shadow: none; }
/* Назад — равный по площади вторичный (тёплая подложка бренда, не белый). */
.btn-ghost {
  background: var(--brand-tint); color: var(--brand); font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.btn-ghost::before { content: "‹"; font-size: 21px; line-height: 1; margin-top: -2px; }
.btn-ghost:hover { background: #dfeaf1; }
.btn-ghost:active { transform: scale(.97); }
.navbar.hide-back .btn-ghost { display: none; }

/* ── Welcome-герой ─────────────────────────────────────────────────────── */
.hero {
  margin: 4px 0 22px; padding: 34px 24px;
  border-radius: 26px; text-align: center;
  background: linear-gradient(160deg, var(--brand-600), var(--brand) 60%, var(--brand-700));
  box-shadow: var(--shadow-lg);
  animation: rise .6s var(--ease) both;
}
.hero img { height: 118px; width: auto; filter: drop-shadow(0 8px 22px rgba(0,0,0,.28)); }
/* На развилке герой компактнее — чтобы поместились две карточки выбора. */
.app.welcome-mode .hero { padding: 24px; margin: 0 0 18px; }
.app.welcome-mode .hero img { height: 88px; }

/* ── Развилка: выбор калькулятора ──────────────────────────────────────── */
.fork { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.fork-card {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  text-align: left; width: 100%;
  background: var(--surface); border: none; border-radius: var(--r-lg);
  padding: 20px 22px; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.fork-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.fork-card:active { transform: scale(.985); box-shadow: 0 0 0 2px var(--accent), var(--shadow-md); }
.fork-card .fc-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fork-card .fc-title {
  font-weight: 800; font-size: 21px; letter-spacing: .01em; color: var(--brand);
}
.fork-card .fc-sub { color: var(--muted); font-size: 14px; }
.fork-card .fc-go {
  flex: 0 0 auto; color: var(--accent); font-size: 28px; line-height: 1;
  transition: transform var(--t) var(--ease);
}
.fork-card .fc-go::before { content: "\203A"; }   /* › */
.fork-card:hover .fc-go { transform: translateX(3px); }

/* ── Экран «Подтверждение комплекта» ───────────────────────────────────── */
.kit-locked { padding: 6px 18px; }
.kit-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.kit-row:last-child { border-bottom: none; }
.kit-row .kit-nm { flex: 1; font-weight: 600; font-size: 15px; }
.kit-empty { color: var(--muted); font-size: 14px; padding: 6px 0; }

.kit-devices { padding: 6px 18px; }
.kit-dev { padding: 14px 0; border-bottom: 1px solid var(--line); }
.kit-dev:last-child { border-bottom: none; }
.kit-dev-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.kit-dev .kit-nm { flex: 1; font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.kit-dev .kit-hint { color: var(--muted); font-size: 13px; margin-top: 7px; line-height: 1.4; }

/* Компактный итог (предварительный) на экране комплекта. */
.total-box.compact { padding: 16px 20px; margin-top: 16px; }
.total-box.compact .amount { font-size: 28px; margin-top: 2px; }

/* ── Модули Базиса (степперы количества) ───────────────────────────────── */
.modules { display: flex; flex-direction: column; gap: 12px; }
.module {
  width: 100%; text-align: left;
  background: var(--surface); border: none; border-radius: var(--r-lg);
  padding: 16px; box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t) var(--ease);
}
.module.on { box-shadow: 0 0 0 2px var(--accent), var(--shadow-md); }
.module .mod-body { display: flex; flex-direction: column; align-items: stretch; min-width: 0; }
.module .mod-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.module .mod-name { font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.module .mod-price { white-space: nowrap; font-weight: 700; color: var(--brand); }
.module .mod-desc { display: block; color: var(--muted); font-size: 13px; margin-top: 5px; line-height: 1.4; }
/* Степпер — по содержимому (inline-flex из базы), прижат влево, не растягивается. */
.module .mini-stepper { align-self: flex-start; margin-top: 14px; }

/* ── Прочее ────────────────────────────────────────────────────────────── */
.spinner { text-align: center; color: var(--muted); padding: 48px 0; }
.success-wrap { text-align: center; padding-top: 12vh; animation: rise .6s var(--ease) both; }
.success-emoji {
  width: 96px; height: 96px; margin: 0 auto 18px;
  border-radius: 50%; background: linear-gradient(160deg, var(--brand-600), var(--brand));
  display: flex; align-items: center; justify-content: center;
  font-size: 50px; color: #fff; box-shadow: var(--shadow-lg);
  animation: badgePop .5s var(--ease) both;
}
.order-id {
  display: inline-block; font-size: 20px; font-weight: 800; letter-spacing: .06em;
  color: var(--brand); background: var(--brand-tint);
  padding: 8px 18px; border-radius: 999px; margin: 10px 0;
}
.banner {
  background: #fbeae8; color: var(--danger);
  padding: 12px 14px; border-radius: var(--r-md); font-size: 14px; margin-bottom: 14px;
}

/* ── Анимации ──────────────────────────────────────────────────────────── */
@keyframes screenIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes badgePop {
  0%   { transform: scale(.4); opacity: 0; }
  60%  { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); }
}

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