:root {
  /* фирменный синий из логотипа Sayf Pay — #0C1E60 */
  --navy-900: #0a1850;
  --navy-800: #0c1e60;
  --navy-700: #1b2f85;
  --navy-100: #e4e8f5;
  --navy-50: #f3f5fb;
  --accent-600: #3352c9;
  --accent-500: #4766e0;
  --accent-400: #8da2ee;
  --accent-100: #e5eafc;
  --ink: #111a3a;
  --text: #3a4566;
  --muted: #66708a;
  --line: #dfe3ee;
  --bg: #f6f7fb;
  --card: #ffffff;
  --danger: #b4412f;
  --radius-lg: 24px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(10, 24, 80, .04), 0 18px 40px -24px rgba(10, 24, 80, .22);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Onest', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button { font: inherit; color: inherit; }

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 max(20px, env(safe-area-inset-right)) 40px max(20px, env(safe-area-inset-left));
}

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
}

/* ---------- header ---------- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 4px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { display: block; height: auto; }
.brand-mark { width: 34px; }
.brand-name { width: 118px; margin-bottom: -2px; }
.header-contacts { display: flex; align-items: center; gap: 22px; font-weight: 500; font-size: 15px; }
.header-contacts a { text-decoration: none; white-space: nowrap; color: var(--text); transition: color .15s, background .15s, border-color .15s; }
.header-contacts a:hover { color: var(--navy-800); }
.header-contacts .phone {
  font-weight: 700; color: var(--navy-800);
  padding: 10px 16px;
  border: 1.5px solid var(--navy-100);
  border-radius: var(--radius-sm);
  background: var(--card);
}
.header-contacts .phone:hover { border-color: var(--navy-800); }
.header-contacts .phone + .wa-round { margin-left: -12px; }
.wa-round {
  flex: none;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--navy-800);
}
.header-contacts .wa-round, .header-contacts .wa-round:hover { color: #fff; }
.wa-round:hover { background: var(--navy-700); }
.wa-round .wa-icon { width: 20px; height: 20px; }
.wa-icon { flex: none; width: 20px; height: 20px; display: block; }

/* ---------- hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: 52px 56px 44px;
  border-radius: var(--radius-lg);
  color: #fff;
  background:
    radial-gradient(700px 420px at 100% 0%, rgba(71, 102, 224, .55), transparent 65%),
    linear-gradient(135deg, var(--navy-800), var(--navy-900));
  margin-bottom: 20px;
}
.hero > * { position: relative; }
.hero .hero-mark {
  position: absolute;
  right: 56px; top: 50%;
  width: 230px; height: auto;
  transform: translateY(-50%) rotate(-6deg);
  opacity: .1;
  pointer-events: none;
}
.eyebrow {
  margin: 0 0 14px;
  font-size: 13px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent-400);
}
.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: -.02em;
  max-width: 16em;
}
.lead { margin: 0 0 32px; font-size: 18px; color: rgba(255, 255, 255, .78); max-width: 34em; }
.perks {
  list-style: none; padding: 22px 0 0; margin: 0;
  display: flex; flex-wrap: wrap; gap: 12px 32px;
  border-top: 1px solid rgba(255, 255, 255, .16);
}
.perks li {
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; color: rgba(255, 255, 255, .88);
}
.perks li::before {
  content: '';
  flex: none; width: 20px; height: 20px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Ccircle cx='10' cy='10' r='10' fill='%23fff' fill-opacity='.16'/%3E%3Cpath d='M6 10.4l2.6 2.6L14 7.6' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 56px; padding: 0 28px;
  border: 0; border-radius: var(--radius);
  font-size: 16px; font-weight: 600;
  gap: 10px;
  text-decoration: none; cursor: pointer;
  transition: background .15s, transform .1s, border-color .15s, color .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy-800); color: #fff; }
.btn-primary:hover { background: var(--navy-700); }
.btn-wide { width: 100%; }
.btn:focus-visible, .tab:focus-visible, .threshold:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid rgba(71, 102, 224, .55);
  outline-offset: 2px;
}

/* ---------- calculator ---------- */
.calc {
  padding: 32px 36px;
  box-shadow: var(--shadow);
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr);
  gap: 36px;
  align-items: start;
}
.calc-form { min-width: 0; }
.calc-form .field:last-child { margin-bottom: 0; }
.calc h2 {
  margin: 0 0 22px;
  font-size: 24px; font-weight: 700;
  letter-spacing: -.01em;
  color: var(--navy-900);
}
.tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  background: var(--navy-50);
  padding: 4px; border-radius: var(--radius);
  margin-bottom: 26px;
}
.tab {
  height: 46px; border: 0; border-radius: var(--radius-sm);
  background: transparent; cursor: pointer;
  font-size: 15px; font-weight: 600; color: var(--muted);
  transition: background .2s, color .2s, box-shadow .2s;
  white-space: nowrap; padding: 0 8px;
}
.tab:hover { color: var(--navy-800); }
.tab.is-active {
  background: #fff; color: var(--navy-800);
  box-shadow: 0 1px 2px rgba(10, 24, 80, .08), 0 4px 12px -4px rgba(10, 24, 80, .18);
}

.field { margin-bottom: 24px; }
.field-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 0 2px 8px;
}
.field-head label, .field-head .label { font-size: 14px; color: var(--text); font-weight: 600; }
.hint { font-size: 13px; color: var(--muted); text-align: right; }

.input-wrap {
  display: flex; align-items: center; gap: 8px;
  height: 58px; padding: 0 18px;
  background: #fff;
  border-radius: var(--radius);
  border: 1.5px solid var(--line);
  transition: border-color .15s, box-shadow .15s;
}
.input-wrap:focus-within { border-color: var(--accent-500); box-shadow: 0 0 0 4px rgba(71, 102, 224, .14); }
.input-wrap input {
  flex: 1; min-width: 0;
  border: 0; background: transparent; outline: none;
  font: inherit; font-size: 21px; font-weight: 700; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.input-wrap input:focus-visible { outline: none; }
.suffix { font-size: 18px; color: var(--muted); font-weight: 500; }
.badge {
  flex: none;
  font-size: 13px; font-weight: 700;
  padding: 5px 9px; border-radius: 8px;
  background: var(--accent-100); color: var(--accent-600);
}
.badge:empty { display: none; }

.range {
  -webkit-appearance: none; appearance: none;
  width: calc(100% - 8px); margin: 16px 4px 0;
  height: 4px; border-radius: 999px;
  background: linear-gradient(to right, var(--navy-800) var(--p, 0%), var(--line) var(--p, 0%));
  outline: none; cursor: pointer;
}
/* ползунок с отметкой порога «выгоднее» */
.range-wrap { position: relative; margin: 16px 4px 0; --thumb: 22px; }
.range-wrap .range {
  display: block; width: 100%; margin: 0;
  /* --t — позиция порога с учётом ширины бегунка; правее неё зона подсвечена */
  background:
    linear-gradient(to right, var(--navy-800) var(--p, 0%), transparent var(--p, 0%)),
    linear-gradient(to right, var(--line) var(--t, 100%), var(--accent-400) var(--t, 100%));
}
.range-wrap.has-threshold { padding-bottom: 30px; }
.threshold {
  position: absolute;
  top: 2px;
  left: var(--t);
  transform: translateX(-1px);
  border: 0; background: none; padding: 0; cursor: pointer;
  font: inherit;
}
.threshold::before { /* засечка под дорожкой */
  content: '';
  position: absolute; left: 0; top: 0;
  width: 2px; height: 12px; border-radius: 2px;
  background: var(--accent-600);
  opacity: .6;
}
.threshold-label {
  position: absolute; top: 14px; left: 0;
  white-space: nowrap;
  font-size: 12.5px; font-weight: 600;
  color: var(--accent-600);
  padding: 2px 0;
}
.threshold:hover .threshold-label { text-decoration: underline; text-underline-offset: 3px; }
.threshold.is-reached::before { opacity: 1; }
.threshold.is-reached .threshold-label { color: var(--navy-800); cursor: default; text-decoration: none; }
.threshold.is-reached .threshold-label::before {
  content: '✓'; margin-right: 5px;
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--navy-800); border: 4px solid #fff;
  box-shadow: 0 0 0 1px var(--line), 0 2px 6px rgba(10, 24, 80, .25);
  transition: transform .1s;
}
.range::-webkit-slider-thumb:active { transform: scale(1.12); }
.range::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--navy-800); border: 4px solid #fff;
  box-shadow: 0 0 0 1px var(--line), 0 2px 6px rgba(10, 24, 80, .25);
}

/* срок: значение + ползунок */
.input-static { gap: 10px; }
.static-value { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; }
.input-static .suffix { font-size: 17px; }

.result {
  min-width: 0; padding: 24px;
  background: var(--navy-50);
  border-radius: var(--radius-lg);
  container-type: inline-size;
}
.result .field-head { padding-bottom: 12px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0;
}
.tile span { font-size: 13px; color: var(--muted); }
.tile em { font-style: normal; color: var(--accent-600); font-weight: 700; }
.tile strong {
  /* размер подстраивается под ширину блока расчёта, чтобы суммы не обрезались на телефоне */
  font-size: clamp(15px, 5.5cqi, 19px); font-weight: 700; color: var(--navy-900);
  font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* платёж — главная цифра: на всю ширину и в полтора раза крупнее остальных */
.tile-main { grid-column: 1 / -1; background: var(--navy-800); padding: 18px 20px; }
.tile-main span { color: rgba(255, 255, 255, .72); font-size: 14px; }
.tile-main strong { color: #fff; font-size: 30px; line-height: 1.15; letter-spacing: -.01em; }

/* совсем узкий экран: «Наценка» и «Всего» друг под другом */
@container (max-width: 270px) {
  .tiles { grid-template-columns: 1fr; }
  .tile-main { grid-column: auto; }
}

/* разбивка расчёта — под раскрывающейся ссылкой */
.more { margin: 14px 2px 18px; }
.more summary {
  display: inline-flex; align-items: center; gap: 6px;
  list-style: none; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--accent-600);
  border-radius: 6px;
}
.more summary::-webkit-details-marker { display: none; }
.more summary::after {
  content: '';
  width: 7px; height: 7px;
  border-right: 1.8px solid currentColor; border-bottom: 1.8px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform .15s;
}
.more[open] summary::after { transform: translateY(2px) rotate(-135deg); }
.more summary:hover { color: var(--navy-800); }
.more summary:focus-visible { outline: 3px solid rgba(71, 102, 224, .55); outline-offset: 3px; }

.breakdown {
  margin: 8px 0 0; padding: 0;
  display: grid; grid-template-columns: 1fr; gap: 0;
}
.breakdown div { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.breakdown div:last-child { border-bottom: 0; }
.breakdown dt { color: var(--muted); }
.breakdown dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.error {
  background: #fbeeea; color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 12px 16px; font-size: 14px; font-weight: 600;
  margin-bottom: 10px;
}
.is-invalid .tiles, .is-invalid .more { opacity: .35; }

.note { margin: 14px 2px 0; font-size: 13px; color: var(--muted); }

/* ---------- footer ---------- */
.footer {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px 32px;
  margin-top: 32px; padding: 22px 4px 0;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 14px;
}
.footer-links { display: flex; gap: 28px; flex-wrap: wrap; }
.footer-links a { color: var(--text); text-decoration: none; }
.footer-links a:hover { color: var(--navy-800); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- полоска внизу экрана (только телефон) ---------- */
.sticky-bar { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1020px) {
  .hero .hero-mark { width: 190px; right: 32px; }
}
@media (max-width: 900px) {
  .calc { grid-template-columns: minmax(0, 1fr); gap: 26px; }
}
@media (max-width: 760px) {
  .header-contacts a[data-bind="email"] { display: none; }
  .hero .hero-mark { top: 28px; right: 20px; width: 120px; transform: rotate(-6deg); }
}
@media (max-width: 640px) {
  /* снизу — запас под закреплённую полоску, чтобы она не перекрывала подвал */
  .page {
    padding: 0 max(12px, env(safe-area-inset-right)) calc(104px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }
  .header { padding: 14px 2px; gap: 8px; }
  .header-contacts { font-size: 14px; gap: 8px; }
  .header-contacts .phone { padding: 8px 10px; }
  .header-contacts .phone + .wa-round { margin-left: 0; }
  .wa-round { width: 38px; height: 38px; }
  .wa-round .wa-icon { width: 18px; height: 18px; }
  .brand { gap: 10px; }
  .brand-mark { width: 26px; }
  .brand-name { width: 94px; }
  .hero { padding: 30px 22px 26px; margin-bottom: 12px; }
  .lead { font-size: 16px; margin-bottom: 24px; }
  .perks { flex-direction: column; gap: 10px; padding-top: 20px; }
  .perks li { font-size: 14px; }
  .calc { padding: 24px 18px; }
  .calc h2 { font-size: 22px; margin-bottom: 18px; }
  .tab { font-size: 13px; white-space: normal; line-height: 1.1; padding: 0 4px; }
  .field-head { flex-wrap: wrap; }
  .result { padding: 16px; border-radius: 18px; }
  .tile { padding: 12px 12px; }
  .tile-main { padding: 16px 16px; }
  .tile-main strong { font-size: 28px; }
  .input-wrap input { font-size: 19px; }

  .sticky-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px max(14px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    background: rgba(255, 255, 255, .96);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    box-shadow: 0 -10px 30px -18px rgba(10, 24, 80, .35);
    transition: transform .25s ease, visibility 0s;
  }
  .sticky-bar.is-hidden { transform: translateY(110%); visibility: hidden; transition: transform .25s ease, visibility 0s .25s; }
  .sticky-sum { min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
  .sticky-sum strong {
    font-size: 19px; font-weight: 700; color: var(--navy-900);
    font-variant-numeric: tabular-nums; white-space: nowrap;
  }
  .sticky-sum span { font-size: 12px; color: var(--muted); }
  .sticky-bar .btn { flex: none; height: 48px; padding: 0 16px; font-size: 15px; gap: 8px; }
  .sticky-bar .wa-icon { width: 18px; height: 18px; }
  .footer { flex-direction: column; align-items: flex-start; }
  .footer-links { gap: 8px 20px; }
}

/* узкие телефоны */
@media (max-width: 400px) {
  .brand { gap: 8px; }
  .brand-mark { width: 24px; }
  .brand-name { width: 84px; }
  .header-contacts { font-size: 13px; gap: 6px; }
  .header-contacts .phone { padding: 8px 8px; }
  .wa-round { width: 36px; height: 36px; }
  .sticky-sum strong { font-size: 17px; }
  .sticky-bar .btn { padding: 0 12px; font-size: 14px; }
}
@media (max-width: 350px) {
  .header { flex-wrap: wrap; }
  .sticky-bar .wa-long { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sticky-bar, .sticky-bar.is-hidden, .more summary::after, .btn, .tab { transition: none; }
}
