/* ==========================================================================
   buhgalteriya — «Амбарная книга». База: сброс, типографика, сетка, шапка, подвал.
   Порядок подключения: tokens.css → base.css → components.css → page-*.css
   Медиазапросы только min-width: 768px и min-width: 1200px.
   ========================================================================== */

/* ---------- Сброс ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bh-bg);
  color: var(--bh-text);
  font-family: var(--bh-font-body);
  font-size: var(--bh-fs-body);
  line-height: var(--bh-lh-body);
  font-weight: var(--bh-fw-regular);
  font-variant-numeric: lining-nums;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote, table { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
table { border-collapse: collapse; border-spacing: 0; }
th { font-weight: inherit; text-align: left; }
button, input, select, textarea { font: inherit; color: inherit; margin: 0; }
button { background: none; border: 0; padding: 0; cursor: pointer; border-radius: 0; text-align: inherit; }
a { color: inherit; text-decoration: none; }
summary { cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: var(--bh-focus); outline-offset: var(--bh-focus-offset); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* ---------- Типографика ---------- */
h1, h2, h3, h4, .bh-h1, .bh-h2, .bh-h3, .bh-h4 {
  font-family: var(--bh-font-heading);
  font-weight: var(--bh-fw-bold);
  color: var(--bh-text);
  text-wrap: balance;
}
h1, .bh-h1 { font-size: var(--bh-fs-h1); line-height: var(--bh-lh-h1); letter-spacing: var(--bh-ls-heading); }
h2, .bh-h2 { font-size: var(--bh-fs-h2); line-height: var(--bh-lh-h2); }
h3, .bh-h3 { font-size: var(--bh-fs-h3); line-height: var(--bh-lh-h3); }
h4, .bh-h4 { font-size: var(--bh-fs-h4); line-height: var(--bh-lh-h4); }
b, strong { font-weight: var(--bh-fw-bold); }

.bh-lead { font-size: var(--bh-fs-lead); line-height: var(--bh-lh-lead); max-width: var(--bh-measure); }
.bh-small { font-size: var(--bh-fs-small); line-height: var(--bh-lh-small); }
.bh-micro { font-size: var(--bh-fs-micro); line-height: var(--bh-lh-micro); }
.bh-muted { color: var(--bh-text-muted); }

/* Подпись графы: Anonymous Pro 700, прописные */
.bh-label {
  font-family: var(--bh-font-mono);
  font-weight: var(--bh-fw-bold);
  font-size: var(--bh-fs-label);
  line-height: var(--bh-lh-label);
  letter-spacing: var(--bh-ls-caps);
  text-transform: uppercase;
  color: var(--bh-text-muted);
}
/* Числа: моноширинные, пробел между разрядами сужен */
.bh-num {
  font-family: var(--bh-font-mono);
  font-weight: var(--bh-fw-bold);
  font-size: var(--bh-fs-num);
  line-height: var(--bh-lh-num);
  word-spacing: var(--bh-ws-num);
  white-space: nowrap;
}
.bh-num--s { font-weight: var(--bh-fw-regular); font-size: var(--bh-fs-num-s); line-height: var(--bh-lh-num-s); }
.bh-num--l { font-size: var(--bh-fs-num-l); line-height: var(--bh-lh-num-l); }
.bh-num--xl { font-size: var(--bh-fs-num-xl); line-height: var(--bh-lh-num-xl); }

/* Текстовая ссылка вне кнопок */
.bh-link {
  color: var(--bh-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color var(--bh-t);
}
.bh-link:hover { color: var(--bh-accent-deep); text-decoration-thickness: 2px; }

/* Иконки: линейные, прямые срезы */
.bh-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.bh-icon {
  width: var(--bh-icon); height: var(--bh-icon); flex: none;
  fill: none; stroke: currentColor; stroke-width: var(--bh-icon-stroke);
  stroke-linecap: square; stroke-linejoin: miter;
}
.bh-icon--s { width: var(--bh-icon-s); height: var(--bh-icon-s); stroke-width: var(--bh-icon-stroke-s); }
.bh-icon--l { width: var(--bh-icon-l); height: var(--bh-icon-l); }

/* Только для экранных читалок */
.bh-vh {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.bh-skip {
  position: absolute; left: var(--bh-gutter); top: -100px; z-index: var(--bh-z-popover);
  padding: 8px 12px; background: var(--bh-dark); color: var(--bh-on-dark);
  /* прямое начертание Old Standard TT 400: единственное место, где оно нужно, — строка-переход для клавиатуры */
  font-family: var(--bh-font-heading); font-weight: var(--bh-fw-regular); font-size: 18px; line-height: 24px;
}
.bh-skip:focus { top: 4px; outline: var(--bh-focus-on-dark); }

/* ---------- Сетка ---------- */
.bh-container {
  width: 100%;
  max-width: var(--bh-container);
  margin-inline: auto;
  padding-inline: var(--bh-gutter);
}
.bh-main { display: block; padding-bottom: var(--bh-section); }
.bh-section { margin-top: var(--bh-section); }
.bh-grid { display: grid; gap: var(--bh-gap); grid-template-columns: minmax(0, 1fr); }
.bh-grid > * { min-width: 0; }
.bh-is-locked { overflow: hidden; }

/* Заголовок блока: H2 слева, ссылка «Все …» справа, снизу линейка */
.bh-block__head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 4px 24px;
  padding-bottom: 8px; margin-bottom: var(--bh-block-gap);
  border-bottom: var(--bh-rule);
}
.bh-block__head > * { min-width: 0; }
.bh-block__sub { margin: calc(var(--bh-block-gap) * -1 + 12px) 0 var(--bh-block-gap); max-width: var(--bh-measure); color: var(--bh-text-muted); font-size: var(--bh-fs-small); line-height: var(--bh-lh-small); }
.bh-block__all { display: none; }
.bh-block__foot { margin-top: 16px; }
.bh-block__foot .bh-btn { width: 100%; }

/* ---------- Шапка ---------- */
.bh-header { background: var(--bh-bg); border-bottom: var(--bh-rule-double); }

/* колонтитул */
.bh-folio { background: var(--bh-bg-2); }
.bh-folio__in {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: var(--bh-folio-h);
  font-family: var(--bh-font-mono); font-size: var(--bh-fs-micro); line-height: var(--bh-lh-micro);
  color: var(--bh-text-muted);
}
.bh-folio__date { white-space: nowrap; }
.bh-folio__links { display: none; gap: 24px; }
.bh-folio__links a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; transition: color var(--bh-t); }
.bh-folio__links a:hover { color: var(--bh-text); }

/* строка названия */
.bh-mast { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: var(--bh-mast-h); }
.bh-brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.bh-mark { width: var(--bh-mark); height: var(--bh-mark); flex: none; }
.bh-brand__text { display: flex; flex-direction: column; min-width: 0; }
.bh-brand__name {
  font-family: var(--bh-font-heading); font-weight: var(--bh-fw-bold);
  font-size: var(--bh-fs-brand); line-height: 1.1; color: var(--bh-text);
}
.bh-brand__sub { display: none; margin-top: 2px; }
.bh-mast__actions { display: flex; align-items: center; gap: 8px; flex: none; }
.bh-mast .bh-mast__calc { display: none; }

/* строка разделов — от 1200px */
.bh-nav { display: none; border-top: var(--bh-border); }
.bh-nav__in { display: flex; align-items: stretch; justify-content: space-between; gap: 24px; min-height: var(--bh-nav-h); }
.bh-nav__list { display: flex; align-items: stretch; gap: 24px; }
.bh-nav__list--aux { padding-left: 24px; border-left: var(--bh-border-strong); }
.bh-nav__link {
  display: flex; align-items: center; height: 100%;
  font-size: var(--bh-fs-ui); line-height: var(--bh-lh-ui); font-weight: var(--bh-fw-semibold);
  border-bottom: 3px solid transparent; border-top: 3px solid transparent;
  white-space: nowrap; transition: border-color var(--bh-t), color var(--bh-t);
}
.bh-nav__link:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.bh-nav__link[aria-current="page"], .bh-nav__link.is-active { border-bottom-color: var(--bh-accent); }

/* меню до 1200px: лист на весь экран */
.bh-menu {
  position: fixed; inset: 0; z-index: var(--bh-z-menu);
  background: var(--bh-surface); overflow-y: auto; overscroll-behavior: contain;
  padding-bottom: 32px;
}
.bh-menu__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: var(--bh-mast-h); padding-inline: var(--bh-gutter);
  border-bottom: var(--bh-rule-double);
}
.bh-menu__group { padding: 20px var(--bh-gutter) 0; }
.bh-menu__title { margin-bottom: 8px; }
.bh-menu__list { border-top: var(--bh-rule); }
.bh-menu__link {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 48px; padding: 8px 0 8px var(--bh-margin-gap); margin-left: var(--bh-margin-w);
  border-left: var(--bh-margin-line); border-bottom: var(--bh-border);
  font-size: var(--bh-fs-body); line-height: 22px; font-weight: var(--bh-fw-semibold);
  transition: background-color var(--bh-t);
}
.bh-menu__link:hover { background: var(--bh-bg-2); }
.bh-menu__link .bh-icon { color: var(--bh-text-muted); }

/* ---------- Подвал: задняя обложка ---------- */
.bh-footer { background: var(--bh-dark); color: var(--bh-on-dark); padding-block: 40px 24px; }
.bh-footer :focus-visible { outline: var(--bh-focus-on-dark); }
.bh-footer__top { display: grid; gap: 12px; padding-bottom: 24px; border-bottom: 1px solid var(--bh-dark-line); }
.bh-footer .bh-brand__name { color: var(--bh-on-dark); }
.bh-footer__about { max-width: 60ch; font-size: var(--bh-fs-small); line-height: var(--bh-lh-small); color: var(--bh-on-dark-muted); }
.bh-footer__cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px var(--bh-gap); padding-block: 24px; }
.bh-footer__cols > * { min-width: 0; }
.bh-footer__title { color: var(--bh-on-dark); margin-bottom: 4px; }
.bh-footer__list a {
  display: flex; align-items: center; min-height: 44px;
  font-size: var(--bh-fs-small); line-height: var(--bh-lh-small); color: var(--bh-on-dark-muted);
  transition: color var(--bh-t);
}
.bh-footer__list a:hover { color: var(--bh-on-dark); text-decoration: underline; text-underline-offset: 3px; }
.bh-footer__bottom {
  display: grid; gap: 12px; padding-top: 20px; border-top: 1px solid var(--bh-dark-line);
  font-size: var(--bh-fs-micro); line-height: var(--bh-lh-micro); color: var(--bh-on-dark-muted);
}
.bh-footer__bottom p { max-width: 96ch; }
.bh-footer__legal { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.bh-footer__legal a { text-decoration: underline; text-underline-offset: 3px; transition: color var(--bh-t); }
.bh-footer__legal a:hover { color: var(--bh-on-dark); }
.bh-footer__year { font-family: var(--bh-font-mono); }

/* ---------- 768px ---------- */
@media (min-width: 768px) {
  .bh-folio__links { display: flex; }
  .bh-brand__sub { display: block; }
  .bh-mast .bh-mast__calc { display: inline-flex; }
  .bh-block__all { display: inline; }
  .bh-block__foot { display: none; }
  .bh-footer { padding-block: 48px 24px; }
  .bh-footer__cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bh-footer__list a { min-height: 32px; }
}

/* ---------- 1200px ---------- */
@media (min-width: 1200px) {
  .bh-nav { display: block; }
  .bh-mast .bh-mast__menu { display: none; }
  .bh-menu { display: none; }
  .bh-footer { padding-block: 64px 24px; }
  .bh-footer__top { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); align-items: center; }
  .bh-footer__cols { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
