/* «Домовая книга» — лист расчёта рядом с квитанцией. Замысел: бизнес/стандарты/идентичность/dom.md
   Бумага, зелёные линии граф, как у бланков ЖКУ и домовых книг; цифры — моноширинным; просрочка и итог — красный штамп. */
@font-face { font-family: "Golos Text"; font-weight: 400; font-display: swap; src: url(/assets/fonts/golos-text-cyrillic-400-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Golos Text"; font-weight: 400; font-display: swap; src: url(/assets/fonts/golos-text-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+20BD, U+2212; }
@font-face { font-family: "Golos Text"; font-weight: 500; font-display: swap; src: url(/assets/fonts/golos-text-cyrillic-500-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Golos Text"; font-weight: 500; font-display: swap; src: url(/assets/fonts/golos-text-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+20BD, U+2212; }
@font-face { font-family: "PT Mono"; font-weight: 400; font-display: swap; src: url(/assets/fonts/pt-mono-cyrillic-400-normal.woff2) format("woff2"); unicode-range: U+0400-045F, U+2116; }
@font-face { font-family: "PT Mono"; font-weight: 400; font-display: swap; src: url(/assets/fonts/pt-mono-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2010-2027, U+20BD, U+2212; }

:root {
  --paper: #f4f1e6;
  --sheet: #fbfaf5;
  --ink: #1d211f;
  --ink-2: #3f4541;
  --line: #2f5d4e;
  --line-2: rgba(47, 93, 78, 0.28);
  --stamp: #b3261e;
  --text: "Golos Text", "Helvetica Neue", Arial, sans-serif;
  --mono: "PT Mono", ui-monospace, Menlo, Consolas, monospace;
  --pad: clamp(18px, 4vw, 48px);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 17px/1.55 var(--text); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, ul, ol, table, fieldset, legend { margin: 0; padding: 0; }
ul, ol { list-style: none; }
fieldset { border: 0; min-width: 0; }
a { color: var(--line); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--line); outline-offset: 2px; }
.sr, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip:focus { position: absolute; top: 8px; left: 8px; z-index: 10; background: var(--sheet); padding: 8px 12px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.r { text-align: right; }
.muted { color: var(--ink-2); }
main { max-width: 1120px; margin: 0 auto; padding: 0 var(--pad) 72px; }

/* Шапка: знак листа учёта и подпись. Двойная линия снизу — как у бланка. */
.top { width: calc(100% - 2 * var(--pad)); max-width: calc(1120px - 2 * var(--pad)); margin: 0 auto; padding: 18px 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px 24px; flex-wrap: wrap; border-bottom: 3px double var(--line); }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; font: 500 20px/1 var(--text); letter-spacing: -0.01em; min-height: 44px; }
.brand__mark { width: 34px; height: 34px; color: var(--line); flex: none; }
.top__what { font-size: 14px; color: var(--ink-2); }

/* Заголовок листа. */
.head { padding: clamp(36px, 7vw, 88px) 0 clamp(24px, 4vw, 40px); max-width: 52rem; }
.head__kicker { font: 500 15px/1.3 var(--text); color: var(--line); margin-bottom: 14px; }
.head h1, .text h2, .index__name { text-wrap: balance; }
.head h1 { font: 500 clamp(36px, 6.2vw, 72px)/1.02 var(--text); letter-spacing: -0.035em; text-wrap: balance; }
.head__lead { margin-top: 20px; font-size: clamp(17px, 1.6vw, 20px); line-height: 1.5; color: var(--ink-2); max-width: 40em; text-wrap: pretty; }

/* Лист: графы с номерами, тонкие зелёные линии. */
.sheet { background: var(--sheet); border: 1px solid var(--line); }
.sheet__cols { display: grid; grid-template-columns: 1.25fr 1fr 1fr; }
.cell { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px 20px; border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line); min-width: 0; }
.cell:last-child { border-right: 0; }
.cell small, .ledger small { font-size: 14px; line-height: 1.4; color: var(--ink-2); }
.label, legend { display: flex; align-items: baseline; gap: 10px; font: 400 14px/1.3 var(--text); letter-spacing: 0.02em; color: var(--ink-2); }
legend { float: left; width: 100%; margin-bottom: 10px; }
legend + * { clear: both; }
.no { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 4px; border: 1px solid var(--line); color: var(--line); font: 400 12px/1 var(--mono); }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; cursor: pointer; min-height: 44px; line-height: 1.35; }
.choice small { display: block; font: 400 13px/1.4 var(--mono); color: var(--line); margin-top: 2px; }
.choice input { appearance: none; -webkit-appearance: none; flex: none; width: 20px; height: 20px; margin: 1px 0 0; border: 1.5px solid var(--line); border-radius: 50%; background: #fff; display: grid; place-content: center; cursor: pointer; }
.choice input::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--line); transform: scale(0); transition: transform 0.18s var(--ease); }
.choice input:checked::after { transform: scale(1); }
input { font: inherit; color: inherit; }
input[type="number"], input[type="date"], input[type="month"], .ledger input, .fill input { min-height: 44px; padding: 8px 10px; border: 0; border-bottom: 1.5px solid var(--line); background: transparent; border-radius: 0; width: 100%; font-family: var(--mono); font-size: 17px; }
input:focus, select:focus { outline: 0; border-bottom-color: var(--ink); box-shadow: 0 2px 0 var(--ink); }
input:focus-visible, select:focus-visible, .btn:focus-visible, .del:focus-visible { outline: 3px solid var(--line); outline-offset: 3px; box-shadow: none; }
.inline { display: flex; align-items: baseline; gap: 10px; }
.inline input { width: 4.2em; flex: none; text-align: center; }
.inline span { font-size: 15px; color: var(--ink-2); }

/* Долг по месяцам — строки книги. */
.ledger { padding: 18px 20px 20px; }
.months { width: 100%; border-collapse: collapse; margin-top: 10px; }
.months th { font: 400 13px/1.3 var(--text); color: var(--ink-2); text-align: left; padding: 0 12px 8px 0; border-bottom: 1px solid var(--line); }
.months th.r { text-align: right; }
.months td { padding: 2px 12px 2px 0; border-bottom: 1px solid var(--line-2); }
.months td:first-child { width: 55%; }
.months tr { transition: opacity 0.35s var(--ease), transform 0.35s var(--ease); }
.months tr.is-new { opacity: 0; transform: translateY(-6px); }
.c-del { width: 44px; padding-right: 0 !important; }
.del { width: 44px; height: 44px; border: 0; background: none; color: var(--ink-2); font-size: 24px; line-height: 1; cursor: pointer; }
.del:hover { color: var(--stamp); }
.ledger__tools { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-start; margin-top: 16px; }
.btn { min-height: 44px; padding: 0 18px; border: 1.5px solid var(--line); background: transparent; color: var(--line); font: 500 15px/1 var(--text); cursor: pointer; transition: background 0.2s var(--ease), color 0.2s var(--ease); }
.btn:hover { background: var(--line); color: #fff; }
.btn--ink { background: var(--line); color: #fff; }
.btn--ink:hover { background: var(--ink); border-color: var(--ink); }
.fill summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--line); text-decoration: underline; text-underline-offset: 0.18em; list-style: none; }
.fill summary::-webkit-details-marker { display: none; }
.fill__in { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: flex-end; margin-top: 8px; }
.fill__in label { display: flex; align-items: baseline; gap: 8px; font-size: 15px; color: var(--ink-2); }
.fill__in input { width: 11em; }
.fill__in input.num { width: 7em; }

/* Результат: итог как строка «К оплате» квитанции, затем расчёт по месяцам. */
.result { margin-top: 40px; }
.result__empty { padding: 28px 0; color: var(--ink-2); border-top: 1px dashed var(--line); }
.result__warn, .result__note { margin-top: 14px; padding: 12px 16px; border-left: 4px solid var(--stamp); background: #fff; max-width: 62em; font-size: 15px; }
.result__note { border-left-color: var(--line); }
.total { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 3px double var(--line); border-bottom: 1px solid var(--line); }
.total__item { padding: 16px 20px 18px 0; display: flex; flex-direction: column; gap: 6px; }
.total__item b { font: 500 clamp(26px, 3.4vw, 42px)/1.1 var(--text); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; white-space: nowrap; }
.total__item--due b { color: var(--stamp); }
.total__item--due { position: relative; }
.result__rate { margin-top: 18px; max-width: 62em; }
.scroll { overflow-x: auto; margin-top: 22px; }
.calc { width: 100%; border-collapse: collapse; font-size: 15px; }
.calc th, .calc td { padding: 10px 14px 10px 0; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: top; white-space: nowrap; }
.calc thead th { font: 400 13px/1.3 var(--text); color: var(--ink-2); border-bottom: 1px solid var(--line); }
.calc tbody th { font-weight: 500; }
.calc .r { text-align: right; padding-right: 24px; }
.calc th:last-child, .calc td:last-child { padding-right: 0; }
.calc small { display: block; font-size: 13px; color: var(--ink-2); }
.calc .strong { font-weight: 400; color: var(--ink); }
.result__formula { margin-top: 18px; display: flex; flex-direction: column; gap: 4px; font-size: 15px; }
.result__formula .num { white-space: normal; overflow-wrap: anywhere; }
.result__base { margin-top: 14px; font-size: 14px; color: var(--ink-2); }
.btns { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }

/* Текст под расчётом. */
.text { margin-top: clamp(56px, 8vw, 96px); max-width: 46rem; }
.text h2 { font: 500 clamp(24px, 2.6vw, 30px)/1.2 var(--text); letter-spacing: -0.02em; margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--line); }
.text h2:first-child { margin-top: 0; }
.text h3 { font: 500 18px/1.35 var(--text); margin-top: 26px; }
.text p { margin-top: 12px; text-wrap: pretty; }
.text ul { margin-top: 12px; display: grid; gap: 10px; }
.text li { padding-left: 22px; position: relative; text-wrap: pretty; }
.text li::before { content: "—"; position: absolute; left: 0; color: var(--line); }

/* Главная: оглавление книги. */
.index { border-top: 3px double var(--line); }
.index__row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; grid-template-areas: "no name law" "no what law"; gap: 6px 20px; padding: 22px 0 24px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.index__row .no { grid-area: no; width: 44px; height: 44px; font-size: 15px; }
.index__name { grid-area: name; font: 500 clamp(22px, 2.6vw, 30px)/1.2 var(--text); letter-spacing: -0.02em; }
.index__what { grid-area: what; color: var(--ink-2); max-width: 40em; }
.index__law { grid-area: law; font: 400 13px/1.3 var(--mono); color: var(--line); align-self: start; padding-top: 6px; }
.index__row:hover .index__name { text-decoration: underline; text-underline-offset: 0.18em; }

/* Подвал и плашка проектной группы. */
.foot { width: calc(100% - 2 * var(--pad)); max-width: calc(1120px - 2 * var(--pad)); margin: 0 auto; border-top: 3px double var(--line); }
.foot__in { padding: 22px 0 32px; display: grid; gap: 14px; font-size: 14px; color: var(--ink-2); }
.foot__in p { max-width: 62em; }
.foot__made a { white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin: -10px 0; color: var(--ink); text-decoration: none; font: 400 13px/1 var(--mono); letter-spacing: 0.02em; }
.foot__made a:hover { text-decoration: underline; }
.foot__made svg { width: 16px; height: 16px; }

@media (max-width: 860px) {
  .sheet__cols { grid-template-columns: 1fr 1fr; }
  .cell--kind { grid-column: 1 / -1; border-right: 0; }
  .total { grid-template-columns: 1fr 1fr; }
  .total__item--due { order: -1; grid-column: 1 / -1; border-bottom: 1px solid var(--line-2); }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .sheet__cols { grid-template-columns: 1fr; }
  .cell { border-right: 0; padding: 16px; }
  .ledger { padding: 16px; }
  .months td:first-child { width: auto; }
  .index__row { grid-template-columns: 52px minmax(0, 1fr); grid-template-areas: "no name" "no what" "no law"; }
  .top__what { width: 100%; }
}

/* Печать: только лист результата и основание. */
@media print {
  body { background: #fff; font-size: 12pt; }
  .top, .foot, .head__lead, .sheet, .text, .btns, .skip { display: none !important; }
  .head { padding: 0 0 12pt; }
  .head h1 { font-size: 20pt; }
  main { padding: 0; max-width: none; }
  .result { margin-top: 0; }
  .calc th, .calc td { padding: 4pt 8pt 4pt 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Месяц — два списка. */
.when { display: flex; gap: 8px; }
.when select { min-height: 44px; padding: 8px 26px 8px 6px; border: 0; border-bottom: 1.5px solid var(--line); border-radius: 0; background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%232f5d4e' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 8px center; -webkit-appearance: none; appearance: none; font: 400 17px/1.2 var(--text); color: var(--ink); cursor: pointer; }
.when select:first-child { flex: 1 1 auto; min-width: 0; }
.when select.num { font-family: var(--mono); flex: 0 0 5.6em; }

/* Под расчётом: слева — оглавление листа (закреплено), справа — текст. */
.below { display: grid; grid-template-columns: 220px minmax(0, 46rem); gap: 56px; margin-top: clamp(56px, 8vw, 96px); align-items: start; }
.below .text { margin-top: 0; }
.toc { position: sticky; top: 24px; display: grid; gap: 4px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 15px; }
.toc p { font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.toc a { padding: 6px 0; text-decoration: none; color: var(--ink); line-height: 1.35; }
.toc a:hover { color: var(--line); text-decoration: underline; }

/* Расчёт по месяцам — карточками уже с ширины планшета: виден столбец «Пени» и периоды целиком. */
@media (max-width: 900px) {
  .below { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .toc { display: none; }
}
/* Расчёт по месяцам — карточками только на узком экране; на планшете таблица помещается без строк периодов. */
@media (max-width: 700px) {
  .below { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .toc { display: none; }
  .scroll { overflow: visible; }
  .calc thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .calc, .calc tbody, .calc tr, .calc th, .calc td { display: block; width: 100%; }
  .calc tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .calc tbody th { padding: 0 0 6px; border: 0; font-size: 16px; }
  .calc td, .calc td.r { display: grid; grid-template-columns: 9.5em minmax(0, 1fr); gap: 10px; padding: 3px 0; border: 0; text-align: left !important; white-space: normal; }
  .calc td::before { content: attr(data-label); font: 400 13px/1.6 var(--text); color: var(--ink-2); }
  .calc td.strong { margin-top: 4px; font-size: 16px; color: var(--stamp); }
}
@media (min-width: 701px) and (max-width: 1000px) {
  .calc { font-size: 14px; }
  .calc small { display: none; }
  .calc th, .calc td { padding-right: 10px; }
  .calc .r { padding-right: 14px; }
}
/* Телефон: месяц во всю ширину, сумма — строкой ниже. */
@media (max-width: 560px) {
  .months thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .months, .months tbody { display: block; }
  .months tr { display: grid; grid-template-columns: minmax(0, 1fr) 44px; grid-template-areas: "when del" "sum sum"; border-bottom: 1px solid var(--line-2); padding: 6px 0 10px; }
  .months td { display: block; border: 0; padding: 0 !important; width: auto !important; }
  .months td:first-child { grid-area: when; }
  .months td.r { grid-area: sum; }
  .months td.c-del { grid-area: del; align-self: center; }
  .months input { text-align: left; }
  .months td.r { display: grid !important; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; gap: 12px; }
  .months td.r::before { content: "Сумма, ₽"; font-size: 14px; color: var(--ink-2); }
  .when select.num { flex-basis: 5.2em; }
  .when select { padding-right: 22px; background-position: right 6px center; }
  .total__item b { font-size: 24px; }
  .calc td { grid-template-columns: 8em minmax(0, 1fr); }
  .fill__in input { width: 8em; }
}
@media (max-width: 380px) {
  .total { grid-template-columns: 1fr; }
  .total__item { padding-right: 0; }
}
@media (max-width: 360px) {
  .foot__made a { font-size: 11.5px; letter-spacing: 0; gap: 6px; }
}

/* После третьей проверки: явная ссылка в оглавлении, кнопки не ниже 44 px, ₽ одним начертанием. */
.index__go { display: block; margin-top: 10px; font: 500 15px/1.3 var(--text); color: var(--line); }
.index__row:hover .index__go { text-decoration: underline; }
.btn { min-height: 44px; }
.calc .num .rub, .rub { font-family: var(--text); }
@media (max-width: 560px) {
  .index__row { grid-template-columns: minmax(0, 1fr); grid-template-areas: "no" "name" "what" "law"; }
}
