/* Арифметика дома — тетрадь в клетку, синяя паста, красная ручка */
:root {
  --paper: #f7f9f6;
  --sheet: #fdfefc;
  --grid: #dfe8ef;
  --margin: #e8a3a8;
  --text: #24272c;
  --muted: #5e6672;
  --ink: #2340a6;
  --red: #c42a3a;
  --line: #cfd6dd;
  --ok: #2e7a4c;
  --focus: #2340a6;
  --cell: 24px;
  --radius: 6px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14171c;
    --sheet: #181c22;
    --grid: #232a33;
    --margin: #6b2f36;
    --text: #e7e9ec;
    --muted: #a0a8b3;
    --ink: #9cb0ff;
    --red: #ff7884;
    --line: #333b46;
    --ok: #6cc690;
    --focus: #9cb0ff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--text);
  font: 17px/1.6 var(--font); font-variant-numeric: tabular-nums;
}
img, svg { max-width: 100%; }
a { color: var(--ink); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; background: var(--sheet); padding: 8px 12px; z-index: 10; }

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

/* Шапка */
.site-head { border-bottom: 1px solid var(--line); }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; padding-top: 14px; padding-bottom: 14px; }
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.logo-mark { width: 30px; height: 30px; color: var(--ink); }
.nav { display: flex; gap: 4px 18px; flex-wrap: wrap; font-size: 15px; }
.nav a { color: var(--muted); text-decoration: none; padding: 4px 0; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--text); box-shadow: inset 0 -2px 0 var(--red); }

/* Текст */
main { padding-top: 32px; padding-bottom: 48px; }
h1 { font-size: clamp(30px, 6vw, 44px); line-height: 1.12; letter-spacing: -0.025em; margin: 0 0 16px; font-weight: 750; }
h2 { font-size: 25px; line-height: 1.25; letter-spacing: -0.015em; margin: 44px 0 12px; }
h3 { font-size: 19px; margin: 28px 0 8px; }
p, ul, ol { margin: 0 0 14px; }
.lead { font-size: 20px; line-height: 1.5; color: var(--muted); max-width: 38rem; }
.note { font-size: 15px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; margin: 8px 0 20px; font-size: 15.5px; }
th, td { text-align: left; padding: 9px 10px 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 650; }
td.num, th.num { text-align: right; white-space: nowrap; }
.table-scroll { overflow-x: auto; }

/* Лист тетради — главный элемент сайта */
.sheet {
  position: relative; margin: 28px 0 8px; padding: 22px 20px 24px 64px;
  background-color: var(--sheet);
  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;
  border: 1px solid var(--line); border-radius: var(--radius);
}
.sheet::before { content: ""; position: absolute; top: 0; bottom: 0; left: 46px; border-left: 2px solid var(--margin); }
.sheet h2 { margin-top: 0; font-size: 22px; }
.sheet-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 24px 36px; align-items: start; }
.sheet-cols > * { min-width: 0; }
@media (min-width: 1040px) {
  section.sheet { margin-left: -7rem; margin-right: -7rem; padding-right: 32px; }
}
@media (max-width: 680px) {
  .sheet { padding: 18px 14px 20px 34px; }
  .sheet::before { left: 22px; }
  .sheet-cols { grid-template-columns: 1fr; }
}

/* Поля */
.field { margin: 0 0 14px; }
.field > label, .field > .legend { display: block; font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.field .hint { display: block; font-size: 13.5px; color: var(--muted); margin-top: 3px; }
input[type=number], input[type=text], select {
  width: 100%; font: inherit; font-size: 17px; color: var(--text);
  background: var(--sheet); border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 9px 11px; min-height: 44px;
}
input[type=number]:focus, select:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 25%, transparent); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; border: 0; padding: 0; margin: 0; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: inline-block; padding: 7px 12px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--sheet); font-size: 15px; cursor: pointer; min-height: 40px; }
.seg input:checked + span { border-color: var(--ink); color: var(--ink); font-weight: 600; box-shadow: inset 0 0 0 1px var(--ink); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 6px 0; font-size: 15.5px; }
.check input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--ink); }

/* Счёт столбиком */
.column { font-size: 18px; line-height: var(--cell); margin: 0; }
.column .row { display: grid; grid-template-columns: 1.2em 1fr auto; gap: 8px; padding: 0; min-height: var(--cell); align-items: start; }
.column .op { color: var(--muted); text-align: center; }
.column .what { color: var(--text); }
.column .what small { color: var(--muted); font-size: 13.5px; }
.column .val { color: var(--ink); text-align: right; white-space: nowrap; font-weight: 600; }
.column .total { margin-top: 6px; padding-top: 6px; border-top: 2px solid var(--text); }
.column .total .what { font-weight: 700; }
.column .total .val { color: var(--red); font-size: 24px; line-height: 1.2; padding-bottom: 2px; border-bottom: 4px double var(--red); }
.result-note { font-size: 14.5px; color: var(--muted); margin-top: 14px; }
.warn { color: var(--red); font-weight: 600; }
.ok { color: var(--ok); font-weight: 600; }

/* Блок партнёров (реклама) */
.offer { border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 20px 0; font-size: 15px; }
.offer .ad { font-size: 12.5px; color: var(--muted); display: block; margin-bottom: 6px; }

/* Кнопки */
button, .btn { font: inherit; font-size: 16px; font-weight: 600; border-radius: var(--radius); padding: 10px 16px; min-height: 44px; border: 1.5px solid var(--ink); background: var(--ink); color: var(--sheet); cursor: pointer; text-decoration: none; display: inline-block; }
button.ghost { background: transparent; color: var(--ink); }

/* Главная */
.home-hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 28px; align-items: center; margin-bottom: 8px; }
@media (max-width: 680px) { .home-hero { grid-template-columns: 1fr; } }
.tools { list-style: none; padding: 0; margin: 24px 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.tools li { border-bottom: 1px solid var(--line); }
.tools a { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 16px 0; text-decoration: none; color: var(--text); }
.tools strong { font-size: 19px; }
.tools span { color: var(--muted); font-size: 15px; grid-column: 1; }
.tools em { font-style: normal; color: var(--ink); grid-row: 1 / span 2; grid-column: 2; align-self: center; font-weight: 600; }
.tools a:hover strong { box-shadow: inset 0 -2px 0 var(--red); }

/* FAQ, источники, подвал */
.faq details { border-bottom: 1px solid var(--line); padding: 12px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq-a { margin-top: 8px; color: var(--text); }
.sources ol { font-size: 14.5px; color: var(--muted); padding-left: 20px; }
.updated { font-size: 14px; color: var(--muted); margin-top: 32px; }
.site-foot { border-top: 1px solid var(--line); padding: 24px 0 40px; font-size: 14px; color: var(--muted); }

/* Согласие на cookie */
.consent { position: fixed; left: 16px; right: 16px; bottom: 16px; max-width: 34rem; margin: 0 auto; background: var(--sheet); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: 0 6px 24px rgba(0,0,0,.12); z-index: 20; font-size: 15px; }
.consent p { margin: 0 0 10px; }
.consent-btns { display: flex; gap: 8px; flex-wrap: wrap; }

@media (prefers-reduced-motion: no-preference) {
  .column .val { transition: color .2s; }
}
