/* Под рукой — общие стили. «Тетрадь в клетку»: бумага с сеткой, синие чернила, красная линия полей.
   Шрифты: Dela Gothic One (заголовки), Onest (текст), Caveat (рукописные цифры). */
@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@500;700&family=Dela+Gothic+One&family=Onest:wght@400;500;600;700&display=swap');
:root {
  --bg: #f6f7f3;
  --grid: rgba(43, 57, 201, .095);
  --surface: #ffffff;
  --surface-2: #eef0f8;
  --text: #191b33;
  --muted: #5a5f7c;
  --border: #d9dcea;
  --accent: #2b39c9;
  --accent-ink: #ffffff;
  --accent-soft: #e6e9fb;
  --margin: #ff5a4a;
  --marker: #ffe45c;
  --good: #137a3d;
  --bad: #c62f22;
  --warn-bg: #fff4c7;
  --warn-ink: #5e4700;
  --radius: 10px;
  --shadow: 3px 3px 0 var(--border);
  --cell: 24px;
  --f-display: "Dela Gothic One", "Arial Black", system-ui, sans-serif;
  --f-text: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --f-hand: "Caveat", "Segoe Print", cursive;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14162a;
    --grid: rgba(140, 155, 255, .07);
    --surface: #1c1f38;
    --surface-2: #252946;
    --text: #e9eaf6;
    --muted: #a3a8c8;
    --border: #343960;
    --accent: #9aa6ff;
    --accent-ink: #14162a;
    --accent-soft: #2a2f57;
    --margin: #ff7466;
    --marker: #ffe45c;
    --good: #5fd08f;
    --bad: #ff8577;
    --warn-bg: #3a3218;
    --warn-ink: #f3d98c;
    --shadow: 3px 3px 0 #0c0d1c;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; } /* иначе .grid { display: grid } перебивает атрибут hidden */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
  background-position: -1px -1px;
  font: 17px/1.6 var(--f-text);
  overflow-wrap: break-word;
}
img, svg { max-width: 100%; height: auto; }
a { color: var(--accent); text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 60; background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 8px; }
.skip:focus { top: 12px; }

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

/* Шапка */
.site-header { background: var(--surface); border-bottom: 2px solid var(--text); position: relative; z-index: 5; }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 22px; padding-top: 12px; padding-bottom: 12px; }
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font: 20px/1 var(--f-display); letter-spacing: -.01em; }
.logo svg { width: 30px; height: 30px; flex: none; }
.nav { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 15px; font-weight: 500; }
.nav a { color: var(--muted); text-decoration: none; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--accent); text-decoration: underline; text-decoration-thickness: 2px; }

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

h1, h2 { font-family: var(--f-display); font-weight: 400; letter-spacing: -.01em; text-wrap: balance; }
h1 { font-size: clamp(28px, 4.4vw, 38px); line-height: 1.12; margin: 14px 0 10px; }
h2 { font-size: clamp(22px, 3vw, 26px); line-height: 1.2; margin: 36px 0 12px; }
h3 { font-size: 18px; font-weight: 700; margin: 22px 0 8px; }
.lead { color: var(--muted); margin: 0 0 18px; max-width: 64ch; }

/* Карточка калькулятора — лист бумаги на тетрадной сетке */
.card {
  background: var(--surface);
  border: 1.5px solid var(--text);
  border-radius: var(--radius);
  box-shadow: 5px 5px 0 var(--accent-soft);
  padding: 18px;
  margin: 18px 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; }

/* Отпускные по месяцам и таблица ставок для пеней */
.months { display: grid; gap: 6px; }
.mrow { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.2fr) 64px; gap: 8px; align-items: center; font-size: 15px; }
.mrow.mhead { font-size: 13px; color: var(--muted); font-weight: 600; }
.mrow label { font-weight: 500; }
.calc .mrow input[type="text"] { min-height: 40px; padding: 7px 10px; font-size: 16px; }
.calc textarea {
  width: 100%; font: inherit; font-size: 16px; line-height: 1.5; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text);
  font-variant-numeric: tabular-nums; resize: vertical;
}
.calc textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

.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-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--accent-ink);
  text-decoration: none; font: 600 15px/1.2 var(--f-text);
  padding: 10px 16px; min-height: 42px; border-radius: 8px; border: 1.5px solid var(--accent); cursor: pointer;
  box-shadow: 3px 3px 0 var(--text); transition: transform .12s, box-shadow .12s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--text); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--text); }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--text); }
@media (prefers-reduced-motion: reduce) { .btn { transition: none; } .btn:hover, .btn:active { transform: none; } }
.product .old { font-weight: 400; font-size: 14px; color: var(--muted); }
.product .off { font-size: 13px; font-weight: 700; color: var(--accent-ink); background: var(--accent); border-radius: 999px; padding: 1px 7px; vertical-align: 2px; }
.bundle-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-top: 12px; font-size: 15px; }

/* Блок «Что выбрать ИП» (партнёрки) */
.partners-box .sub { color: var(--muted); font-size: 15px; margin: -4px 0 12px; }
.partner-group h3 { margin: 14px 0 6px; font-size: 18px; }
.partner-group .crit-t { margin: 0 0 4px; font-size: 14px; color: var(--muted); }
.partner-group .crit { margin: 0 0 10px; padding-left: 20px; font-size: 15px; }
.partners { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 640px) { .partners { grid-template-columns: 1fr 1fr; } }
.partner { display: flex; flex-direction: column; gap: 4px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); min-width: 0; }
.partner .ad-mark { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.partner .t { font-weight: 700; line-height: 1.3; }
.partner .d { font-size: 14px; color: var(--muted); flex: 1; }
.partner .btn { align-self: flex-start; margin-top: 6px; }
.partners-box .note { font-size: 14px; color: var(--muted); margin: 12px 0 0; }

/* Текст */
.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: 1.5px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.hub a:hover { border-color: var(--text); box-shadow: 4px 4px 0 var(--accent-soft); }
.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: 56px; border-top: 2px solid var(--text); 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, .partners-box, .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; }

/* Сравнение режимов и график аренды */
.label-like { display: block; font-size: 15px; font-weight: 600; margin-bottom: 6px; }
tr.off td { color: var(--muted); }
:root { --s1: #2b39c9; --s2: #e0493b; }
@media (prefers-color-scheme: dark) { :root { --s1: #9aa6ff; --s2: #ff7466; } }
.chart { margin-top: 10px; }
.chart svg { display: block; width: 100%; height: auto; font-size: 12px; font-variant-numeric: tabular-nums; }
.chart text { fill: var(--muted); }
.chart line.grid { stroke: var(--border); stroke-width: 1; }
.chart line.axis { stroke: var(--muted); stroke-width: 1; }
.chart polyline { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart polyline.s1 { stroke: var(--s1); }
.chart polyline.s2 { stroke: var(--s2); stroke-dasharray: 6 4; }
.chart circle.s1 { fill: var(--s1); stroke: var(--surface); stroke-width: 2; }
.chart circle.s2 { fill: var(--s2); stroke: var(--surface); stroke-width: 2; }
.chart rect.hit { fill: transparent; }
.chart rect.hit:hover { fill: var(--accent-soft); fill-opacity: .5; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 14px; color: var(--muted); margin-top: 4px; }
.legend i { display: inline-block; width: 18px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.legend i.s1 { background: var(--s1); }
.legend i.s2 { background: repeating-linear-gradient(90deg, var(--s2) 0 6px, transparent 6px 10px); }

/* Лендинг «Бот-магазин для авторов» (bot-magazin.html) */
.cta-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 4px; }
.cta-row .btn { font-size: 16px; padding: 11px 18px; }
.cta-note { font-size: 14px; color: var(--muted); margin: 6px 0 0; }
.shots { display: grid; grid-auto-flow: column; grid-auto-columns: 220px; gap: 12px; overflow-x: auto;
  padding: 4px 2px 12px; margin: 12px 0 0; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
.shots figure { margin: 0; scroll-snap-align: start; }
.shots img { display: block; width: 220px; height: auto; aspect-ratio: 390 / 760; border-radius: 16px;
  border: 1px solid var(--border); background: var(--surface-2); }
.shots figcaption { font-size: 14px; color: var(--muted); margin-top: 6px; line-height: 1.35; }
.features, .article ul.features { display: grid; grid-template-columns: 1fr; gap: 10px; padding: 0; margin-left: 0; list-style: none; }
@media (min-width: 640px) { .features, .article ul.features { grid-template-columns: 1fr 1fr; } }
.features li { padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.features b { display: block; margin-bottom: 2px; }
.plans { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .plans { grid-template-columns: 1fr 1fr; } }
.plan { display: flex; flex-direction: column; gap: 6px; padding: 16px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); min-width: 0; }
.plan.featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.plan h3 { margin: 0; }
.plan .price { font-size: 28px; font-weight: 800; }
.plan ul { margin: 4px 0 8px; padding-left: 20px; flex: 1; }
.plan .btn { align-self: flex-start; }
.steps { padding-left: 22px; }
.steps li { margin-bottom: 6px; }

/* Бесплатный материал в Telegram-боте (лид-магнит) */
.lead-cta { border-color: var(--accent); background: var(--accent-soft); }
.lead-cta h2 { margin: 0 0 6px; font-size: 20px; }
.lead-cta p { margin: 0 0 8px; }

/* «Это развод?» (razvod.html) */
.rz-form textarea { min-height: 150px; }
.rz-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-top: 12px; }
.rz-submit { font-size: 17px; padding: 12px 28px; min-height: 48px; }
.rz-submit[aria-busy="true"] { opacity: .75; cursor: progress; }
.rz-sample { color: var(--accent); min-height: 44px; }
.rz-privacy { font-size: 14px; color: var(--muted); margin: 10px 0 0; }
.rz-error { color: var(--bad); font-size: 15px; margin: 6px 0 0; }
.rz-result h2 { font-size: 18px; margin: 20px 0 6px; }
.rz-result ul, .rz-result ol { margin: 0; padding-left: 22px; }
.rz-result li { margin: 4px 0; }
.rz-level { display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 18px; background: var(--surface-2); }
.rz-level[data-level="scam"] { background: var(--bad); color: #fff; }
.rz-level[data-level="suspicious"] { background: var(--warn-bg); color: var(--warn-ink); }
.rz-level[data-level="ordinary"] { background: var(--accent-soft); color: var(--text); }
.rz-headline { font-size: 18px; font-weight: 600; margin: 12px 0 0; }
.rz-signs q { display: block; color: var(--muted); font-size: 15px; quotes: "«" "»"; }
.rz-report li { font-size: 15px; }
.rz-rule { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin: 18px 0 0; font-size: 15px; }
.rz-share { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.rz-share .btn { min-height: 44px; padding: 10px 16px; }
.rz-note { font-size: 14px; color: var(--muted); margin: 12px 0 0; }
.rz-disclaimer { margin-top: 0; }
@media (prefers-color-scheme: dark) { .rz-level[data-level="scam"] { color: #12161c; } }

/* Вердикт калькулятора «Маржа до акции» */
.verdict { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; font-weight: 700; font-size: 17px; border-left: 4px solid var(--good); background: var(--surface-2); }
.verdict.ok { border-left-color: var(--good); }
.verdict.warn { border-left-color: #b7791f; background: var(--warn-bg); color: var(--warn-ink); }
.verdict.bad { border-left-color: var(--bad); color: var(--bad); }
.cmp td.neg, .cmp .neg { color: var(--bad); font-weight: 700; }
.cmp td.pos { color: var(--good); }
.sale-dates { padding-left: 20px; }

/* Главный результат калькулятора — «от руки», как ответ в тетради */
.kpi.main .v { font: 700 38px/1.1 var(--f-hand); }
.kpi { border: 1px solid var(--border); }
