/* Под рукой — общие стили. Без фреймворков, системные шрифты. */
:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --text: #1c2430;
  --muted: #5b6676;
  --border: #dde3ea;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --accent-soft: #e7f0fe;
  --good: #137a3d;
  --bad: #c0392b;
  --warn-bg: #fff6dc;
  --warn-ink: #6b4e00;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --surface: #1a2029;
    --surface-2: #222a35;
    --text: #e6e9ee;
    --muted: #9aa5b4;
    --border: #2e3846;
    --accent: #5b9dff;
    --accent-ink: #0b1220;
    --accent-soft: #1d2b42;
    --good: #4cc27c;
    --bad: #ff7a6b;
    --warn-bg: #3a3118;
    --warn-ink: #f1d58a;
    --shadow: none;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-wrap: break-word;
}
img, svg { max-width: 100%; height: auto; }
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px; }

/* Шапка */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding-top: 10px; padding-bottom: 10px; }
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; font-size: 18px; }
.logo svg { width: 28px; height: 28px; flex: none; }
.nav { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 15px; }
.nav a { color: var(--muted); text-decoration: none; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--accent); }

.crumbs { font-size: 14px; color: var(--muted); margin: 14px 0 0; }
.crumbs a { color: var(--muted); }

h1 { font-size: 28px; line-height: 1.2; margin: 12px 0 8px; }
h2 { font-size: 22px; line-height: 1.3; margin: 32px 0 10px; }
h3 { font-size: 18px; margin: 22px 0 8px; }
.lead { color: var(--muted); margin: 0 0 18px; }

/* Карточка калькулятора */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 16px 0;
}
.calc fieldset { border: 0; padding: 0; margin: 0 0 8px; min-width: 0; }
.calc legend { font-weight: 600; padding: 0; margin-bottom: 6px; }
.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 560px) { .grid.two { grid-template-columns: 1fr 1fr; } }
@media (min-width: 720px) { .grid.three { grid-template-columns: 1fr 1fr 1fr; } }

.field label { display: block; font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.field .hint { display: block; font-size: 13px; color: var(--muted); font-weight: 400; margin-top: 3px; }
.input-wrap { position: relative; }
.calc input[type="text"], .calc input[type="date"], .calc select {
  width: 100%;
  font: inherit;
  font-size: 17px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  min-height: 46px;
}
.calc input[data-unit] { padding-right: 40px; }
.input-wrap .unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; font-size: 15px; }
.calc input:focus, .calc select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-2); cursor: pointer; font-size: 15px; font-weight: 500;
}
.seg input { accent-color: var(--accent); margin: 0; }
.seg label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 15px; cursor: pointer; }
.check input { margin-top: 5px; accent-color: var(--accent); width: 18px; height: 18px; flex: none; }

details.more { margin-top: 12px; }
details.more > summary { cursor: pointer; color: var(--accent); font-size: 15px; font-weight: 600; }
details.more[open] > summary { margin-bottom: 10px; }

/* Результаты */
.results { margin-top: 16px; border-top: 1px dashed var(--border); padding-top: 14px; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
.kpi { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.kpi .k { display: block; font-size: 13px; color: var(--muted); line-height: 1.3; }
.kpi .v { display: block; font-size: 20px; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; }
.kpi.main { grid-column: 1 / -1; background: var(--accent-soft); }
.kpi.main .v { font-size: 26px; color: var(--accent); }
.v.neg { color: var(--bad) !important; }
.v.pos { color: var(--good); }
.explain { font-size: 15px; color: var(--muted); margin: 10px 0 0; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 15px; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; white-space: normal; }
td small { display: block; }
thead th { font-size: 13px; color: var(--muted); font-weight: 600; }
.article table th, .article table td { white-space: normal; }
/* Таблица авансов на телефоне — карточками */
@media (max-width: 560px) {
  table.stack thead { display: none; }
  table.stack tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--border); }
  table.stack td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 2px 0; text-align: right; }
  table.stack td:first-child { display: block; font-weight: 700; text-align: left; }
  table.stack td:first-child small { font-weight: 400; color: var(--muted); }
  table.stack td[data-label]::before { content: attr(data-label); color: var(--muted); text-align: left; }
  table.stack td small { display: block; }
}

/* Кредитный калькулятор: строки досрочных погашений и компактные графики */
.hint-text { font-size: 14px; color: var(--muted); margin: 0 0 8px; }
.extra { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: var(--surface); }
.extra-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 15px; }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--bad); font: inherit; font-size: 14px; cursor: pointer; text-decoration: underline; }
.extra .grid.three { grid-template-columns: 1fr 1fr; }
.extra .grid.three .field:last-child { grid-column: 1 / -1; }
@media (min-width: 720px) { .extra .grid.three { grid-template-columns: 1fr 1fr 1fr; } .extra .grid.three .field:last-child { grid-column: auto; } }
table.compact { font-size: 14px; }
table.compact th, table.compact td { padding: 6px 6px; }
@media (max-width: 420px) { table.compact { font-size: 13px; } table.compact th, table.compact td { padding: 6px 3px; } table.compact thead th { white-space: normal; } }
.results h3 { margin: 18px 0 0; font-size: 17px; }

.rates-note {
  display: block;
  background: var(--warn-bg); color: var(--warn-ink);
  border-radius: 10px; padding: 8px 12px; font-size: 14px; margin: 12px 0 0;
}
.rates-note a { color: inherit; font-weight: 600; }

/* Реклама */
.ad-slot { margin: 20px 0; min-height: 0; }
.ad-slot:empty { display: none; }
.ad-slot .ad-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }

/* Готовые таблицы */
.shop h2 { margin-top: 0; font-size: 20px; }
.shop .sub { color: var(--muted); font-size: 15px; margin: -4px 0 12px; }
.products { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 640px) { .products { grid-template-columns: 1fr 1fr; } }
.product { display: flex; flex-direction: column; gap: 4px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.product.featured { border-color: var(--accent); background: var(--accent-soft); grid-column: 1 / -1; }
.product .t { font-weight: 700; line-height: 1.3; }
.product .d { font-size: 14px; color: var(--muted); flex: 1; }
.product .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.product .price { font-weight: 700; font-size: 18px; }
.btn {
  display: inline-block; background: var(--accent); color: var(--accent-ink);
  text-decoration: none; font-weight: 600; font-size: 15px;
  padding: 8px 14px; border-radius: 999px; border: 0; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.bundle-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-top: 12px; font-size: 15px; }

/* Текст */
.article p, .article li { max-width: 70ch; }
.article ul, .article ol { padding-left: 22px; }
.article li { margin: 4px 0; }
.formula { background: var(--surface-2); border-left: 3px solid var(--accent); padding: 8px 12px; border-radius: 0 8px 8px 0; font-size: 16px; overflow-x: auto; }

.faq details { border-bottom: 1px solid var(--border); padding: 10px 0; }
.faq summary { cursor: pointer; font-weight: 600; list-style-position: outside; }
.faq details > div { margin-top: 8px; }
.faq details > div p { margin: 0 0 8px; }

/* Хаб */
.hub { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 16px 0; }
@media (min-width: 600px) { .hub { grid-template-columns: 1fr 1fr; } }
.hub a { display: block; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.hub a:hover { border-color: var(--accent); }
.hub .t { display: block; font-weight: 700; font-size: 18px; color: var(--accent); margin-bottom: 2px; }
.hub .d { display: block; font-size: 15px; color: var(--muted); }

.related { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; list-style: none; }
.related a { display: inline-block; padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; text-decoration: none; font-size: 15px; background: var(--surface); }

.site-footer { margin-top: 40px; border-top: 1px solid var(--border); background: var(--surface); font-size: 14px; color: var(--muted); }
.site-footer .wrap { padding-top: 18px; padding-bottom: 24px; }
.site-footer a { color: var(--muted); }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 8px; }

@media print {
  .site-header, .site-footer, .ad-slot, .shop, .related { display: none !important; }
  body { background: #fff; color: #000; }
}

/* Плашка cookies */
.cookie-bar {
  position: fixed; left: 8px; right: 8px; bottom: 8px; z-index: 50;
  max-width: 720px; margin: 0 auto;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
  padding: 12px 14px; font-size: 14px;
  display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between;
}
.cookie-bar p { margin: 0; flex: 1 1 260px; }
