@font-face { font-family: Manrope; font-weight: 400; font-display: swap; src: url(fonts/manrope-cyrillic-400.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Manrope; font-weight: 400; font-display: swap; src: url(fonts/manrope-latin-400.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20BD, U+2212; }
@font-face { font-family: Manrope; font-weight: 500; font-display: swap; src: url(fonts/manrope-cyrillic-500.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Manrope; font-weight: 500; font-display: swap; src: url(fonts/manrope-latin-500.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20BD, U+2212; }
@font-face { font-family: Manrope; font-weight: 600; font-display: swap; src: url(fonts/manrope-cyrillic-600.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Manrope; font-weight: 600; font-display: swap; src: url(fonts/manrope-latin-600.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20BD, U+2212; }
@font-face { font-family: Manrope; font-weight: 700; font-display: swap; src: url(fonts/manrope-cyrillic-700.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Manrope; font-weight: 700; font-display: swap; src: url(fonts/manrope-latin-700.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20BD, U+2212; }

:root {
  --green: #123E32;
  --green-2: #1F5A49;
  --green-soft: #E6EEEA;
  --gold: #B89A63;
  --gold-soft: #F1E9DA;
  --gold-text: #7A6237;
  --bg: #F7F5EF;
  --surface: #FFFFFF;
  --ink: #202622;
  --muted: #5F6862;
  --line: #E3DFD4;
  --danger: #A3322A;
  --danger-soft: #FBEDEB;
  --radius: 16px;
  --radius-sm: 12px;
  --focus: 0 0 0 3px #F7F5EF, 0 0 0 5px var(--green);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-bottom: 40vh; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.45 Manrope, "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-variant-numeric: tabular-nums lining-nums;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.wrap {
  max-width: 560px; margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
}

/* Шапка */
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 2px 18px; }
.brand-mark { width: 44px; height: 44px; flex: none; }
.brand-name { font-size: 20px; letter-spacing: .14em; color: var(--green); line-height: 1.1; font-weight: 500; }
.brand-name b { font-weight: 700; }
.brand-name .dash { color: var(--gold); }
.brand-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }

/* Ввод */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; }
.field { margin-bottom: 16px; }
label, .label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 7px; }
.input-wrap { position: relative; flex: 1; min-width: 0; }
input[type=text] {
  width: 100%; height: 56px; padding: 0 40px 0 14px;
  font-size: 22px; font-weight: 600; letter-spacing: .01em;
  background: var(--bg); border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  outline: none; -webkit-appearance: none; appearance: none;
}
input[type=text]::placeholder { color: #A7ABA5; font-weight: 500; font-size: 18px; }
input[type=text]:focus { border-color: var(--green); background: #fff; }
input[aria-invalid=true] { border-color: var(--danger); background: var(--danger-soft); }
.suffix { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; font-size: 18px; pointer-events: none; }
.input-row { display: flex; gap: 8px; align-items: stretch; }
.input-row input { padding-right: 14px; }
.msg { margin: 6px 2px 0; font-size: 14px; color: var(--danger); font-weight: 500; }
.msg:empty, .hint:empty { display: none; }
.msg.ok { color: var(--green-2); }
.hint { margin: 6px 2px 0; font-size: 13px; color: var(--muted); }

.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px; gap: 3px; }
.seg button {
  flex: 1; min-height: 46px; border: 0; border-radius: 9px; background: transparent;
  font-weight: 600; font-size: 15px; color: var(--muted); padding: 0 10px;
}
.seg button[aria-checked=true] { background: var(--green); color: #fff; }
.seg-unit { flex: none; width: 112px; }

.rate-line {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  margin: 2px 0 14px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--green-soft); color: var(--green); font-size: 15px;
}
.rate-line:empty { display: none; }
.rate-line strong { font-size: 17px; }
.rate-why { color: var(--muted); font-size: 14px; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .02em; padding: 3px 9px; border-radius: 999px; background: var(--gold-soft); color: var(--gold-text); border: 1px solid #E2D3B5; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 52px; padding: 0 18px; border-radius: var(--radius-sm);
  font-weight: 700; font-size: 16px; border: 1.5px solid transparent;
}
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:disabled { background: #C9CEC9; color: #fff; cursor: not-allowed; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--green); }
.btn-small { min-height: 44px; font-size: 15px; }

.settings { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 4px; }
.settings summary {
  min-height: 48px; display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; color: var(--muted); cursor: pointer; list-style: none; border-radius: 8px;
}
.settings summary::-webkit-details-marker { display: none; }
.settings summary::after { content: ""; width: 9px; height: 9px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-3px); margin-right: 6px; }
.settings[open] summary::after { transform: rotate(-135deg) translateX(-3px); }
.settings-body { padding: 4px 0 6px; }
.settings-body .seg { margin-bottom: 12px; }
#custom-field { margin-bottom: 8px; }
#reset-tariff { margin-top: 12px; }

/* Результаты */
.results { margin-top: 18px; }
.empty { text-align: center; padding: 36px 20px; color: var(--muted); border: 1.5px dashed var(--line); border-radius: var(--radius); }
.empty strong { display: block; color: var(--ink); font-size: 17px; margin-bottom: 4px; }
.paid { text-align: center; padding: 28px 18px; border-radius: var(--radius); background: var(--green-soft); color: var(--green); }
.paid strong { display: block; font-size: 18px; margin-bottom: 4px; }
.note { font-size: 14px; color: var(--muted); padding: 0 2px 12px; margin: 0; }
.note b { color: var(--ink); font-weight: 600; }

.cards { display: grid; gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card-top { padding: 14px 16px 4px; }
.first-box {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px;
  margin: 8px 0 6px; padding: 10px 12px; border-radius: 10px; background: var(--gold-soft); border: 1px solid #E2D3B5;
}
.first-label { font-size: 14px; font-weight: 600; color: var(--gold-text); }
.first-sum { font-size: 24px; font-weight: 700; color: var(--ink); line-height: 1.2; }
.facts { padding: 6px 16px 10px; font-size: 14px; color: var(--ink); }
.facts p { margin: 0; padding: 5px 0; border-top: 1px solid var(--line); }
.facts p:first-child { border-top: 0; }
.facts .fl { color: var(--muted); }
.card-toggle {
  display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 48px;
  padding: 0 16px; background: none; border: 0; border-top: 1px solid var(--line);
  font-weight: 600; font-size: 15px; color: var(--green); text-align: left;
}
.card-toggle::after {
  content: ""; width: 9px; height: 9px; margin-right: 4px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-3px);
}
.card-toggle[aria-expanded=true]::after { transform: rotate(-135deg) translateX(-3px); }
.sched td small { color: var(--muted); font-weight: 500; }
.term { display: block; font-size: 14px; font-weight: 700; color: var(--green); letter-spacing: .02em; }
.pay { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 8px; margin-top: 2px; }
.pay-sum { font-size: 28px; font-weight: 700; letter-spacing: -.01em; color: var(--ink); line-height: 1.2; }
.pay-per { font-size: 14px; color: var(--muted); }
.markup { display: block; font-size: 14px; color: var(--muted); margin-top: 4px; }
.markup b { color: var(--gold-text); font-weight: 700; }
.last-note { display: inline-block; margin-top: 6px; font-size: 13px; color: var(--ink); background: var(--gold-soft); padding: 2px 8px; border-radius: 6px; }
.card.off { background: transparent; border-style: dashed; padding: 14px 16px; }
.card.off .why { font-size: 14px; color: var(--muted); margin-top: 2px; }

.details { border-top: 1px solid var(--line); padding: 12px 16px 16px; }
.kv { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; }
.kv .strong { color: var(--ink); font-weight: 700; }
.sched-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 16px 0 6px; }
.sched { width: 100%; border-collapse: collapse; font-size: 14px; }
.sched th, .sched td { padding: 7px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.sched th { font-weight: 600; color: var(--muted); font-size: 13px; }
.sched td:last-child, .sched th:last-child { text-align: right; }
.sched tr.diff td { font-weight: 700; }
.sched tfoot td { font-weight: 700; border-bottom: 0; }
.details .btn { margin-top: 14px; }

.compare { display: none; }

.bottom { margin-top: 20px; }
.foot { font-size: 12px; color: var(--muted); text-align: center; margin: 14px 0 0; }

/* Окно с текстом */
dialog {
  border: 0; padding: 0; background: transparent; width: 100%; max-width: 560px;
  margin: auto auto 0; max-height: 100dvh;
}
dialog::backdrop { background: rgba(18, 30, 25, .45); }
.sheet {
  background: var(--surface); border-radius: 20px 20px 0 0; padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
}
.sheet h2 { margin: 0 0 4px; font-size: 18px; }
.sheet textarea {
  width: 100%; margin-top: 10px; padding: 12px; font-size: 14px; line-height: 1.45;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--bg);
  resize: vertical; max-height: 50dvh;
}
.sheet-actions { display: grid; gap: 8px; margin-top: 12px; }

/* Фокус */
button:focus-visible, summary:focus-visible, textarea:focus-visible { outline: none; box-shadow: var(--focus); }
input[type=text]:focus-visible { box-shadow: 0 0 0 3px rgba(18, 62, 50, .18); }

/* Компьютер: две колонки и таблица сравнения */
@media (min-width: 960px) {
  .wrap { max-width: 1120px; padding-top: 28px; }
  .layout { display: grid; grid-template-columns: 380px 1fr; gap: 24px; align-items: start; }
  .inputs { position: sticky; top: 20px; }
  .results { margin-top: 0; }
  .compare { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 16px 10px; margin-bottom: 16px; }
  .compare table { width: 100%; border-collapse: collapse; font-size: 14px; }
  .compare th, .compare td { padding: 9px 6px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
  .compare th:first-child, .compare td:first-child { text-align: left; }
  .compare th { color: var(--muted); font-weight: 600; font-size: 13px; }
  .compare tr:last-child td { border-bottom: 0; }
  .compare td.big { font-weight: 700; font-size: 15px; }
  .cards { grid-template-columns: 1fr 1fr; align-items: start; }
  .bottom { max-width: 380px; }
  dialog { margin: auto; }
  .sheet { border-radius: 20px; }
}

@media (max-width: 359px) {
  .pay-sum { font-size: 24px; }
  input[type=text] { font-size: 20px; }
  .seg-unit { width: 96px; }
  .brand-name { font-size: 18px; }
}

@media (prefers-reduced-motion: no-preference) {
  .seg button, .btn, input[type=text] { transition: background-color .15s, border-color .15s, color .15s; }
}
