@font-face {
  font-family: Manrope;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/manrope-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: Manrope;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/manrope-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: Manrope;
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/manrope-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: Manrope;
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/manrope-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: Manrope;
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/manrope-cyrillic-600-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: Manrope;
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/manrope-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: Manrope;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/manrope-cyrillic-700-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: Manrope;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/manrope-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: Literata;
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/literata-cyrillic-600-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: Literata;
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/literata-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #f5f6f7;
  --surface: #fff;
  --ink: #16191d;
  --muted: #444b53;
  --faint: #69717a;
  --line: #dde0e4;
  --accent: #0e6b56;
  --accent-strong: #084838;
  --accent-soft: #e5f3ed;
  --danger: #a3302a;
  --danger-soft: #fbeceb;
  --shadow: none;
  --radius: 8px;
  --sans: Manrope, "Segoe UI", sans-serif;
  --serif: var(--sans);
  --content: 1120px;
  --header: 60px;
  color-scheme: light;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.skip {
  position: absolute;
  left: 16px;
  top: -80px;
  background: var(--ink);
  color: white;
  padding: 8px 12px;
  z-index: 20;
}
.skip:focus { top: 12px; }

.wrap {
  width: min(var(--content), calc(100% - 32px));
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.header-bar {
  min-height: var(--header);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex: none;
}
.logo img { width: 32px; height: 32px; }
.logo-name {
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.02em;
  line-height: 1;
}

.nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 6px;
  white-space: nowrap;
  font-size: 14.5px;
  font-weight: 600;
}
.nav a:hover,
.nav a[aria-current="page"] {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
}

.header-search { position: relative; flex: none; width: min(320px, 40vw); margin-left: auto; }
.header-search input,
.search-field input,
.field input,
.field select,
.field textarea,
.admin-card input,
.admin-card select,
.admin-card textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 44px;
}
.header-search input { min-height: 44px; padding-right: 14px; }
.field textarea { min-height: 140px; resize: vertical; }
.suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: none;
}
.suggest.is-open { display: block; }
.suggest a {
  display: block;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
}
.suggest a:hover,
.suggest a[aria-selected="true"] { background: var(--accent-soft); }
.suggest small { display: block; color: var(--faint); }

.hero { padding: 36px 0 12px; }
.hero h1,
.page-title,
.readout-value {
  font-weight: 700;
  letter-spacing: -0.02em;
}
.hero h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.15;
}
.lede {
  margin: 16px 0 0;
  max-width: 46ch;
  color: var(--muted);
  font-size: 16px;
}
.search-field {
  margin-top: 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  position: relative;
}
.search-field input {
  min-height: 52px;
  font-size: 16px;
  padding-inline: 16px;
}
.search-field .suggest { top: 58px; right: 148px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--accent);
  color: white;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}
.button:hover { background: var(--accent-strong); }
.button.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.button.secondary:hover { background: white; }
.search-field .button { min-height: 52px; padding-inline: 22px; }

.section { padding: 24px 0 4px; }
.section h2, .block h2 {
  margin: 0 0 12px;
  font-size: 22px;
  letter-spacing: -0.02em;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
}
.section-head a:not(.button) { color: var(--accent-strong); font-weight: 700; }

.cards, .tool-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
}
.card:hover { border-color: var(--accent); }
.card-kicker {
  color: var(--faint);
  font-size: 13px;
  font-weight: 500;
}
.card strong { font-size: 16px; line-height: 1.3; }
.card span { color: var(--muted); font-size: 14px; }

.category-list { display: grid; gap: 8px; }
.category-row {
  position: relative;
  display: grid;
  grid-template-columns: 1.2fr 2fr auto;
  gap: 8px 16px;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.category-row:hover { border-color: var(--accent); }
.category-name { text-decoration: none; }
.category-name::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.category-row strong { font-size: 18px; }
.chips { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; position: relative; z-index: 1; }
.chips a {
  padding: 3px 10px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
}
.chips a:hover { background: #d3ebe1; }
.category-row p { margin: 0; color: var(--muted); }
.category-row em {
  font-style: normal;
  color: var(--faint);
  font-weight: 700;
}

.collections { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.collection {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}
.collection h3 { margin: 0 0 6px; font-size: 18px; }
.collection p { margin: 0 0 14px; color: var(--muted); }
.collection a { display: block; padding: 6px 0; font-weight: 700; text-underline-offset: 3px; }

.note {
  margin: 36px 0 12px;
  padding: 20px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  max-width: 68ch;
}

.crumbs { display: flex; flex-wrap: wrap; gap: 6px; color: var(--faint); font-size: 14px; padding-top: 22px; }
.crumbs a { color: var(--muted); }

.page-title { margin: 8px 0 6px; font-size: clamp(24px, 3.4vw, 34px); line-height: 1.15; }
.page-lead { margin: 0 0 18px; max-width: 62ch; color: var(--muted); font-size: 16px; }

.tool-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 24px;
  align-items: start;
  padding-bottom: 28px;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
}
.instrument {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.is-wide { grid-column: 1 / -1; }
.field-label { font-size: 14px; font-weight: 700; }
.field-hint { color: var(--faint); font-size: 13px; }
.field-control { position: relative; }
.field-control input { padding-right: 64px; }
.field-unit {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  font-weight: 700;
  pointer-events: none;
}
.check { flex-direction: row; align-items: center; gap: 10px; grid-column: 1 / -1; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.readout {
  background: var(--bg);
  border-radius: 8px;
  padding: 16px 16px 12px;
  border: 1px solid var(--line);
}
.readout-label { margin: 0; color: var(--muted); font-size: 14px; font-weight: 600; }
.readout-value {
  margin: 6px 0 0;
  font-size: clamp(30px, 4vw, 42px);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.readout-value.is-long {
  font-family: var(--sans);
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.35;
  letter-spacing: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.readout-unit { font-size: 0.42em; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.readout-rule { height: 1px; background: var(--line); margin: 14px 0 10px; }
.details { margin: 0; display: grid; gap: 8px; }
.details div { display: flex; justify-content: space-between; gap: 12px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 700; text-align: right; }
.form-error {
  margin: 12px 0 0;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: 10px;
  padding: 10px 12px;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.actions .button { min-height: 44px; }

.prose { max-width: 68ch; }
.prose p, .block p { margin: 0 0 12px; }
.block { padding: 8px 0 18px; }
.formula {
  font-variant-numeric: tabular-nums;
  background: var(--surface);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
}

.faq details {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}
.faq summary { cursor: pointer; font-weight: 700; }
.faq p { color: var(--muted); }

.side-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.side-list a { text-decoration: none; font-weight: 700; }
.side-card { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.side-card h2 { font-size: 16px; margin: 0 0 10px; }
.pager { display: flex; gap: 12px; align-items: center; padding: 18px 0 28px; }
.pager a, .pager span { min-height: 44px; display: inline-flex; align-items: center; }

.ad { margin: 16px 0; }
.ad-label { margin: 0 0 6px; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.ad-code { overflow: auto; max-width: 100%; }
.ad-code [id^="yandex_rtb_"] { min-height: 100px; }
.ad-code img, .ad-code iframe { max-width: 100%; }

.site-footer {
  margin-top: 28px;
  border-top: 1px solid var(--line);
  padding: 28px 0 40px;
}
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 24px; }
.site-footer a { text-decoration: none; }
.site-footer li { margin: 6px 0; }
.site-footer ul { margin: 0; padding: 0; list-style: none; }
.fine { color: var(--faint); font-size: 14px; }

.missing { padding: 48px 0 24px; }
.missing h1 { font-size: clamp(28px, 4vw, 40px); margin: 0 0 12px; letter-spacing: -0.02em; }

.admin-body { background: var(--bg); }
.admin-top { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 16px 0; }
.admin-nav { display: flex; gap: 14px; flex-wrap: wrap; font-weight: 700; }
.admin-nav a { text-decoration: none; }
.admin-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
}
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat strong { display: block; font-size: 30px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters select, .filters input { min-height: 44px; border-radius: 10px; border: 1px solid var(--line); padding: 0 10px; background: white; }
.form-grid { display: grid; gap: 12px; }
.flash { background: var(--accent-soft); padding: 10px 12px; border-radius: 10px; }

@media (max-width: 980px) {
  .cards, .tool-grid, .collections, .stats { grid-template-columns: 1fr 1fr; }
  .tool-layout, .instrument, .footer-grid, .category-row { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .cards, .tool-grid, .collections, .fields, .stats { grid-template-columns: 1fr; }
  .search-field { grid-template-columns: 1fr; }
  .search-field .suggest { right: 0; }
  .hero { padding-top: 32px; }
  .wrap { width: min(var(--content), calc(100% - 24px)); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

/* Каталог в шапке */
.catalog { flex: none; }
.catalog-button {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  user-select: none;
}
.catalog-button::-webkit-details-marker { display: none; }
.catalog-button svg { width: 18px; height: 18px; }
.catalog-button:hover,
.catalog[open] .catalog-button { background: var(--accent-strong); }
.catalog-panel {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
  max-height: calc(100vh - var(--header));
  overflow: auto;
}
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 22px 28px;
  padding: 22px 0 26px;
}
.catalog-col { display: flex; flex-direction: column; gap: 2px; }
.catalog-root { font-weight: 700; font-size: 16px; padding: 4px 0; text-decoration: none; }
.catalog-child { color: var(--muted); font-size: 14.5px; padding: 3px 0; text-decoration: none; }
.catalog-panel a:hover { color: var(--accent-strong); text-decoration: underline; }

/* Разделы категории */
.sections { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 6px; }
.sections a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  font-size: 14.5px;
  font-weight: 700;
  text-decoration: none;
}
.sections a small { color: var(--faint); font-size: 13px; }
.sections a:hover { border-color: var(--accent); }
.sections a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: white; }
.tool-group { margin-bottom: 22px; }
.tool-group h3 { margin: 18px 0 4px; font-size: 18px; letter-spacing: -0.01em; scroll-margin-top: 90px; }
.tool-group h3 a { text-decoration: none; }
.tool-group h3 a:hover { text-decoration: underline; }
.group-lead { margin: 0 0 12px; color: var(--muted); }

/* Инструменты с текстом и отчётами */
.fields-heading {
  grid-column: 1 / -1;
  margin: 8px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 15px;
  color: var(--muted);
}
.fields-heading:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.field input.field-color { width: 88px; padding: 4px; }
.field input[type="file"] { padding: 10px 12px; }
.field textarea { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 14.5px; line-height: 1.5; }
.instrument.is-wide { grid-template-columns: 1fr; }
.instrument.is-wide .readout { position: static; }
.instrument.is-wide .details div { display: grid; grid-template-columns: minmax(130px, 230px) 1fr; gap: 4px 16px; }
.instrument.is-wide .details dd { text-align: left; overflow-wrap: anywhere; }
.readout-text {
  margin: 10px 0 0;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  font: 14.5px/1.55 ui-monospace, "Cascadia Mono", Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 440px;
  overflow: auto;
}
.readout-preview {
  margin-top: 10px;
  max-width: 100%;
  max-height: 180px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: repeating-conic-gradient(#ece8dc 0% 25%, white 0% 50%) 50% / 16px 16px;
  object-fit: contain;
}
.readout-frame {
  width: 100%;
  height: 460px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
}
.readout-frame[hidden], .readout-preview[hidden], .readout-text[hidden], .readout-value[hidden] { display: none; }
.readout-hint { margin: 0; color: var(--muted); }
.readout[data-empty] .readout-label,
.readout[data-empty] .readout-value,
.readout[data-empty] .readout-rule,
.readout[data-empty] .details,
.readout[data-empty] .actions { display: none; }
.details .is-ok dt::before,
.details .is-warn dt::before,
.details .is-fail dt::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.details .is-warn dt::before { background: #c58a13; }
.details .is-fail dt::before { background: var(--danger); }
.button[disabled] { opacity: 0.6; cursor: progress; }

@media (max-width: 640px) {
  .catalog-button { padding: 0 12px; }
  .instrument.is-wide .details div { grid-template-columns: 1fr; }
  .readout-frame { height: 380px; }
}

/* Проверка адаптива */
.rsp-form .actions { align-items: center; }
.rsp-switch { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14.5px; cursor: pointer; }
.rsp-switch input { width: 18px; height: 18px; accent-color: var(--accent); }
.rsp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 18px; margin-top: 18px; align-items: start; }
.rsp-item { margin: 0; min-width: 0; }
.rsp-item figcaption { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 8px; }
.rsp-item figcaption span, .rsp-item figcaption em { color: var(--faint); font-size: 13.5px; font-style: normal; }
.rsp-open { margin-left: auto; padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 13px; font-weight: 700; cursor: pointer; }
.rsp-open:hover { background: white; }
.rsp-view { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: white; max-width: 100%; }
.rsp-view iframe { position: absolute; left: 0; top: 0; border: 0; transform-origin: 0 0; background: white; }
.rsp-note { margin: 16px 0 0; color: var(--muted); font-size: 14px; max-width: 70ch; }

/* Флажки в широких формах идут в две колонки */
.instrument.is-wide .check { grid-column: auto; }
.instrument.is-wide .check span { line-height: 1.35; }

/* Скрытые условные поля не должны перебиваться display у .field */
[hidden] { display: none !important; }

/* Каталог на узких экранах */
.catalog-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); }
@media (max-width: 640px) {
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 16px; padding: 16px 0 20px; }
  .catalog-root, .catalog-child { overflow-wrap: anywhere; }
}

/* Флажки: одинаковый размер и выравнивание по первой строке подписи */
.field.check { align-items: flex-start; cursor: pointer; }
.field.check input { flex: none; width: 20px; height: 20px; min-height: 0; padding: 0; margin: 2px 0 0; }
.field.check span { line-height: 1.4; }

.panel { margin-bottom: 20px; }

/* Виджеты вроде проверки адаптива занимают всю ширину, боковая колонка уходит вниз */
.tool-layout.is-full { grid-template-columns: minmax(0, 1fr); }
.tool-layout.is-full .rsp-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }

/* Одна колонка не должна распирать страницу содержимым: длинные списки в select, подписи */
@media (max-width: 980px) {
  .tool-layout, .instrument, .footer-grid, .category-row { grid-template-columns: minmax(0, 1fr); }
}
.tool-layout > *, .instrument > *, .fields > * { min-width: 0; }
.field select { max-width: 100%; text-overflow: ellipsis; }

/* Длинные слова в заголовках («конфиденциальности») не должны выходить за экран */
.page-title, .hero h1, .section h2, .block h2, .card strong { overflow-wrap: break-word; hyphens: manual; }
@media (max-width: 640px) { .page-title { font-size: clamp(22px, 6.4vw, 28px); } }

/* Отклик интерфейса: короткие переходы, без вычурности */
:root { --ease: cubic-bezier(0.2, 0.7, 0.2, 1); --t: 160ms; }

a, .button, .card, .category-row, .chips a, .sections a, .nav a, .collection, .side-card,
.catalog-button, .field input, .field select, .field textarea, .header-search input, .search-field input {
  transition: color var(--t) var(--ease), background-color var(--t) var(--ease), border-color var(--t) var(--ease),
    box-shadow var(--t) var(--ease), transform var(--t) var(--ease);
}

.card, .category-row, .collection { will-change: transform; }
.card:hover, .category-row:hover, .collection:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(28, 33, 28, 0.08);
}
.card:active, .category-row:active { transform: translateY(0); box-shadow: none; }

.button:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(14, 107, 86, 0.25); }
.button:active { transform: translateY(0); box-shadow: none; }
.button.secondary:hover { box-shadow: none; border-color: var(--accent); }
.catalog-button:active { transform: scale(0.98); }

.logo img { transition: transform 260ms var(--ease); }
.logo:hover img { transform: translateY(-2px) rotate(-4deg); }

.nav a:hover, .side-list a:hover, .crumbs a:hover, .site-footer a:hover, .section-head a:not(.button):hover { color: var(--accent); }
.side-list a, .site-footer a { transition: color var(--t) var(--ease), padding-left var(--t) var(--ease); }
.side-list a:hover, .site-footer li a:hover { padding-left: 4px; }

.chips a:hover, .sections a:hover { transform: translateY(-1px); }

.field input:hover, .field select:hover, .field textarea:hover,
.header-search input:hover, .search-field input:hover { border-color: #b9c2bd; }
.field input:focus, .field select:focus, .field textarea:focus,
.header-search input:focus, .search-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 107, 86, 0.16);
}

/* Каталог в шапке: панель выезжает, а не появляется рывком */
.catalog[open] .catalog-panel { animation: panel-in 200ms var(--ease); }
.catalog-button svg { transition: transform 200ms var(--ease); }
.catalog[open] .catalog-button svg { transform: rotate(90deg); }
.suggest.is-open { animation: panel-in 140ms var(--ease); }

/* Ответы в FAQ */
.faq summary { transition: color var(--t) var(--ease); }
.faq summary:hover { color: var(--accent); }
.faq details[open] p { animation: fade-in 220ms var(--ease); }

/* Появление страницы и карточек */
main, .site-footer { animation: fade-in 260ms var(--ease) both; }
.cards .card, .tool-grid .card, .category-row, .collection { animation: rise-in 360ms var(--ease) both; }
.cards .card:nth-child(2), .tool-grid .card:nth-child(2) { animation-delay: 40ms; }
.cards .card:nth-child(3), .tool-grid .card:nth-child(3) { animation-delay: 80ms; }
.cards .card:nth-child(4), .tool-grid .card:nth-child(4) { animation-delay: 120ms; }
.cards .card:nth-child(n+5), .tool-grid .card:nth-child(n+5) { animation-delay: 160ms; }

/* Результат расчёта и ошибка появляются мягко */
.readout.is-fresh { animation: rise-in 280ms var(--ease); }
.readout.is-fresh .readout-value { animation: pop-in 320ms var(--ease); }
.form-error:not([hidden]) { animation: shake-in 300ms var(--ease); }
.details div { transition: background-color var(--t) var(--ease); }
.details div:hover { background: rgba(14, 107, 86, 0.05); }
.button[disabled] { position: relative; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes panel-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0.4; transform: scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes shake-in {
  0% { opacity: 0; transform: translateX(-6px); }
  40% { opacity: 1; transform: translateX(4px); }
  70% { transform: translateX(-2px); }
  100% { transform: none; }
}

@media (hover: none) {
  .card:hover, .category-row:hover, .collection:hover, .button:hover, .chips a:hover, .sections a:hover { transform: none; box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .card:hover, .category-row:hover, .collection:hover, .button:hover { transform: none; }
}

/* Админка на узких экранах */
.admin-card { overflow-x: auto; }
.admin-card table { min-width: 0; }
.admin-top { flex-wrap: wrap; }
.admin-nav { align-items: center; row-gap: 6px; }
.admin-nav form { margin: 0; }
.admin-nav .button { min-height: 36px; padding: 0 14px; }
.stats .admin-card { display: flex; flex-direction: column; gap: 4px; margin-bottom: 0; }
.stats .admin-card span { color: var(--muted); font-size: 14px; }
.stats .admin-card strong { font-size: 26px; line-height: 1.1; }
.section-head { flex-wrap: wrap; align-items: center; }
.section-head h1 { margin: 0; }
@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .admin-top { gap: 8px; padding: 12px 0 8px; }
  .admin-nav { gap: 6px 14px; font-size: 15px; }
  .admin-card { padding: 12px 10px; }
  th, td { padding: 8px 3px; overflow-wrap: break-word; }
  td:last-child, td:nth-last-child(2):not(:first-child) { white-space: nowrap; }
  .admin-card table { font-size: 13px; }
  .admin-card small { font-size: 12px; }
  .filters select, .filters input, .filters .button { flex: 1 1 140px; }
}

/* Флажки в формах админки */
.admin-card label.check { display: flex; align-items: center; gap: 10px; margin: 8px 0; cursor: pointer; }
.admin-card input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; padding: 0; flex: none; accent-color: var(--accent); }

/* Второстепенный столбец таблицы (модуль, слаг) на телефоне скрыт: действие «Править» должно быть на виду */
@media (max-width: 640px) {
  .hide-col-2 th:nth-child(2), .hide-col-2 td:nth-child(2) { display: none; }
}

/* Блог и статьи */
.posts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.posts.is-compact { margin-top: 0; }
.post {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color var(--t) var(--ease), transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.post:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 18px rgba(28, 33, 28, 0.08); }
.post.is-featured { grid-column: 1 / -1; padding: 24px; background: var(--accent-soft); border-color: #cfe6dc; }
.post.is-featured .post-title { font-size: clamp(22px, 3vw, 30px); max-width: 30ch; }
.post.is-featured .post-text { font-size: 17px; max-width: 62ch; }
.post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 0; color: var(--faint); font-size: 13.5px; }
.post-tag { padding: 2px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.post.is-featured .post-tag { background: var(--surface); }
.post-title { margin: 0; font-size: 19px; line-height: 1.3; letter-spacing: -0.01em; }
.post-title a { text-decoration: none; }
.post-title a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.post-text { margin: 0; color: var(--muted); }
.post-more { margin-top: auto; padding-top: 4px; color: var(--accent-strong); font-weight: 700; text-decoration: none; position: relative; z-index: 1; }
.post-more span { display: inline-block; transition: transform var(--t) var(--ease); }
.post:hover .post-more span { transform: translateX(4px); }

.article-head { max-width: 760px; }
.article-head .page-lead { font-size: 18px; }
.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 720px) 240px;
  gap: 48px;
  align-items: start;
  padding: 8px 0 24px;
}
.article-body { font-size: 17.5px; line-height: 1.7; }
.article-body > p, .article-body > ul, .article-body > ol { margin: 0 0 18px; }
.article-body h2 { margin: 36px 0 12px; font-size: 25px; line-height: 1.25; letter-spacing: -0.02em; scroll-margin-top: 80px; }
.article-body h3 { margin: 26px 0 8px; font-size: 20px; scroll-margin-top: 80px; }
.article-body ul, .article-body ol { padding-left: 1.3em; }
.article-body li { margin: 6px 0; padding-left: 4px; }
.article-body li::marker { color: var(--accent); font-weight: 700; }
.article-body a { color: var(--accent-strong); text-underline-offset: 3px; text-decoration-thickness: 1px; }
.article-body a:hover { color: var(--accent); }
.callout {
  margin: 22px 0;
  padding: 14px 18px;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--accent-soft);
  font-size: 16.5px;
  line-height: 1.6;
}
.article-tools, .article-body .faq { margin-top: 40px; padding-top: 8px; border-top: 1px solid var(--line); }
.article-tools h2 { margin-top: 24px; }
.article-tools .tool-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }

.toc-wrap { position: sticky; top: 84px; }
.toc { border-left: 2px solid var(--line); padding-left: 16px; }
.toc summary { cursor: pointer; font-weight: 700; margin-bottom: 8px; list-style: none; }
.toc summary::-webkit-details-marker { display: none; }
.toc ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.toc a { display: block; padding: 4px 0; color: var(--muted); font-size: 14.5px; line-height: 1.4; text-decoration: none; transition: color var(--t) var(--ease); }
.toc a:hover { color: var(--accent); }
.toc a[aria-current="true"] { color: var(--accent-strong); font-weight: 700; }

.read-progress { position: fixed; left: 0; right: 0; top: 0; height: 3px; z-index: 30; pointer-events: none; }
.read-progress span { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: 0 50%; }

@media (max-width: 980px) {
  .posts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .article-layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .toc-wrap { position: static; order: -1; margin-bottom: 20px; }
  .toc { border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; background: var(--surface); }
}
@media (max-width: 640px) {
  .posts { grid-template-columns: minmax(0, 1fr); }
  .post.is-featured { padding: 18px; }
  .article-body { font-size: 17px; }
  .article-body h2 { font-size: 22px; margin-top: 30px; }
}
.article-head { margin-top: 14px; }

/* Футер: всегда внизу окна, даже если контента мало */
body { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
main { flex: 1 0 auto; }
.site-footer { flex: none; margin-top: 32px; padding: 0; background: var(--surface); border-top: 1px solid var(--line); }
.footer-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.6fr) minmax(0, 0.8fr); gap: 32px; padding: 28px 0 24px; align-items: start; }
.footer-about .logo { display: inline-flex; margin-bottom: 10px; }
.footer-about .fine { margin: 0; max-width: 34ch; }
.footer-col strong { display: block; margin-bottom: 10px; font-size: 15px; }
.footer-cats { columns: 2; column-gap: 24px; }
.footer-cats li { break-inside: avoid; }
.site-footer li { margin: 0; }
.site-footer li a { display: inline-block; padding: 4px 0; color: var(--muted); font-size: 14.5px; }
.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 24px;
  padding: 14px 0 20px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 13.5px;
}
@media (max-width: 980px) {
  .footer-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .footer-about { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .footer-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 22px 0 18px; }
  .footer-cats { columns: 2; }
  .footer-bottom { flex-direction: column; }
}

/* Зоны нажатия на телефоне: не меньше 32 px по высоте */
@media (max-width: 640px) {
  .crumbs { gap: 0 6px; padding-top: 12px; }
  .crumbs a, .crumbs span { padding: 5px 0; }
  .site-footer li a { padding: 6px 0; }
  .footer-col strong { margin-bottom: 6px; }
  .chips a { padding: 6px 10px; }
  .faq summary, .toc summary { padding: 8px 0; }
  .toc a { padding: 6px 0; }
  .side-list a { display: inline-block; padding: 4px 0; }
}

/* Поиск уходит на вторую строку шапки только на узких экранах; такая шапка не залипает: она съедала бы пятую часть экрана */
@media (max-width: 720px) {
  .header-bar { flex-wrap: wrap; gap: 12px; padding: 10px 0; min-height: 0; }
  .header-search { width: 100%; order: 3; }
  .site-header { position: relative; }
}
@media (max-width: 640px) {
  .catalog-panel { max-height: calc(100vh - 140px); }
  .article-body h2, .article-body h3, .tool-group h3 { scroll-margin-top: 16px; }
}

/* Число в строке отчёта не переносится посреди суммы: переносится подпись слева */
.details dd { flex: 0 0 auto; max-width: 62%; }
.instrument.is-wide .details dd { max-width: none; }
.catalog[open] .catalog-button svg { transform: none; }

/* Планшет: карточки в три столбца, а не в два */
@media (min-width: 641px) and (max-width: 980px) {
  .cards, .tool-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Нижний закреплённый рекламный блок: только мобильные */
.sticky-ad { display: none; }
@media (max-width: 640px) {
  .sticky-ad:not([hidden]) {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
    padding: 4px 8px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--line);
  }
  .sticky-ad .ad-label { margin: 0 0 2px; padding-right: 48px; }
  .sticky-ad-code { max-height: 110px; overflow: hidden; }
  .sticky-ad-code img, .sticky-ad-code iframe { max-width: 100%; }
  .sticky-ad-close {
    position: absolute;
    top: -40px;
    right: 8px;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 8px 8px 0 0;
    border-bottom: 0;
    background: var(--surface);
    color: var(--ink);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
  }
}
