:root {
  --green: #2f6b3a; --green-dark: #234f2b; --green-light: #eaf3ea;
  --text: #1f2421; --muted: #66706a; --border: #dde3dd; --bg: #f7f8f6;
  --red: #b3261e; --radius: 8px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.55 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--green); }
.container { max-width: 1040px; margin: 0 auto; padding: 0 16px; }

.header { background: var(--green); color: #fff; }
.header .container { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 20px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.nav a, .nav button { color: #fff; text-decoration: none; padding: 6px 10px; border-radius: 6px; background: none; border: 0; font: inherit; cursor: pointer; }
.nav a:hover, .nav button:hover, .nav a.active { background: var(--green-dark); }
.nav form { margin: 0; }

/* Подвал всегда внизу: на коротких страницах main растягивается на всю свободную высоту */
body { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
main { padding: 24px 0 48px; flex: 1 0 auto; }
h1 { font-size: 28px; margin: 0 0 16px; }
h2 { font-size: 21px; margin: 28px 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.layout { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; }
@media (max-width: 760px) { .layout { grid-template-columns: 1fr; } }

.sidenav { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; }
.sidenav a { display: block; padding: 8px 12px; border-radius: 6px; text-decoration: none; color: var(--text); }
.sidenav a.active, .sidenav a:hover { background: var(--green-light); color: var(--green-dark); }
.sidenav .plot-label { padding: 8px 12px; font-weight: 700; border-bottom: 1px solid var(--border); margin-bottom: 6px; }

.news-item { border-bottom: 1px solid var(--border); padding: 14px 0; }
.news-item:last-child { border-bottom: 0; }
.news-item h3 { margin: 0 0 4px; font-size: 18px; }
.news-item h3 a { text-decoration: none; color: var(--text); }
.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--green-light); color: var(--green-dark); vertical-align: middle; }
.badge.warn { background: #fff1d6; color: #7a4b00; }
.badge.gray { background: #eee; color: #555; }

.big { font-size: 26px; font-weight: 700; }
.debt { color: var(--red); }
.ok { color: var(--green); }

table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 14px; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.date, th.date { text-align: center; white-space: nowrap; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }

form p, .field { margin: 0 0 14px; }
label { display: block; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], select, textarea {
  width: 100%; max-width: 480px; padding: 9px 11px; border: 1px solid #c5ccc5; border-radius: 6px; font: inherit; background: #fff;
}
textarea { max-width: 100%; }
ul.radio, .field ul { list-style: none; padding: 0; margin: 4px 0; display: flex; gap: 16px; flex-wrap: wrap; }
.field ul label, ul.radio label { font-weight: 400; display: inline-flex; gap: 6px; align-items: center; }
.helptext, .help { font-size: 13px; color: var(--muted); }
.helptext ul { margin: 4px 0; padding-left: 18px; display: block; }
.errorlist { color: var(--red); margin: 4px 0; padding-left: 18px; font-size: 14px; }
.btn { display: inline-block; background: var(--green); color: #fff; border: 0; border-radius: 6px; padding: 10px 18px; font: inherit; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--green-dark); }
/* Отклик на нажатия: кнопка «вдавливается», занятая — полупрозрачная с крутящимся индикатором */
.btn, button { transition: transform .06s ease, opacity .15s ease; }
.btn:active, button:active { transform: scale(.97); }
.is-busy { opacity: .75; cursor: progress !important; position: relative; }
.btn.is-busy::after { content: ""; display: inline-block; width: 12px; height: 12px; margin-left: 8px; vertical-align: -1px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.page-progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 1000; background: #f2c94c;
  box-shadow: 0 0 6px rgba(242, 201, 76, .8); pointer-events: none; }
.page-progress.run { width: 85%; transition: width 8s cubic-bezier(.1, .7, .2, 1); }
.page-progress.done { width: 100%; opacity: 0; transition: width .2s, opacity .4s .2s; }

.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { padding: 10px 14px; border-radius: 6px; margin-bottom: 8px; background: var(--green-light); }
.messages li.error { background: #fde7e5; color: var(--red); }
.messages li.warning { background: #fff1d6; }

.doc { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.doc:last-child { border-bottom: 0; }
.bar { height: 8px; background: var(--green-light); border-radius: 4px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--green); }
.pre { white-space: pre-line; }
/* Длинные тексты — по ширине; переносы слов (язык страницы — ru), чтобы не было «дыр» между словами */
.justify, .prose p, .prose li { text-align: justify; -webkit-hyphens: auto; hyphens: auto; }

.footer { border-top: 1px solid var(--border); padding: 20px 0; color: var(--muted); font-size: 14px; }

.row-actions { white-space: nowrap; }
.row-actions form { display: inline; margin: 0 0 0 10px; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--green); text-decoration: underline; cursor: pointer; }
.link-button.danger { color: var(--red); }

/* ---------- Счётчики ---------- */
.page-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.page-head h1 { margin-bottom: 12px; }
/* Сетки карточек: auto-fit растягивает карточки, когда их меньше, чем колонок */
.meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; align-items: start; }
.card.meter { margin-bottom: 0; }
.meter h3 { margin: 0 0 6px; font-size: 19px; }
.meter h3 a { color: var(--text); text-decoration: none; }
.meter.inactive { opacity: .7; }
.btn-small { padding: 7px 14px; font-size: 15px; }
label.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
label.check input { width: 18px; height: 18px; accent-color: var(--green); }
.danger-zone { margin-top: 24px; padding-top: 12px; border-top: 1px solid var(--border); }

/* ---------- Чаты ---------- */
.chat-page { max-width: 1040px; }
.chat-layout { display: grid; grid-template-columns: 240px 1fr; gap: 16px; align-items: start; }
.chat-layout > * { min-width: 0; }
.chat-nav > summary { display: none; }
.chat-switch { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-align: left; cursor: default; }
.chat-switch-caret, .chat-switch .count { display: none; }
.chat-rooms { display: flex; flex-direction: column; gap: 2px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 6px; }
.chat-rooms a { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 6px; color: var(--text); text-decoration: none; }
.chat-rooms a:hover { background: var(--green-light); }
.chat-rooms a.active { background: var(--green-light); color: var(--green-dark); font-weight: 600; }
.chat-rooms a.archived { color: var(--muted); }
.chat-nav-section { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 10px 4px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.chat-nav-section:not(:first-child) { border-top: 1px solid var(--border); margin-top: 6px; }
.chat-rooms a.chat-new { display: inline; padding: 0; font-size: 13px; text-transform: none; letter-spacing: 0; color: var(--green); }
.chat-nav-empty { padding: 4px 10px; margin: 0; }
.room-name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-rooms .count { flex: 0 0 auto; }
.chat-room-head { display: flex; align-items: center; gap: 4px 12px; flex-wrap: wrap; margin-bottom: 8px; }
.chat-room-head h2 { margin: 0; font-size: 20px; }
.chat-room-info { flex: 1 1 200px; margin: 0; }
.chat-tools { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.chat-tools form { margin: 0; }
/* Значки-переключатели в шапке чата: 🔔/🔕 — звук, 🚫 — блокировка собеседника (ярко, когда включена) */
.chat-icon { background: none; border: 1px solid transparent; border-radius: 8px; padding: 2px 6px; font-size: 18px; line-height: 1.3; cursor: pointer; }
.chat-icon:hover { background: var(--green-light); }
.chat-block { opacity: .4; filter: grayscale(1); }
.chat-block:hover { opacity: .8; }
.chat-block.on { opacity: 1; filter: none; border-color: var(--red); background: #fdecec; }
.chat-nav .nav-mute { font-size: 11px; opacity: .6; margin-left: 4px; flex: none; }
/* Компьютер: заголовок «Чаты» не нужен (пункт меню подсвечен), переписка — на всю высоту окна */
.page-chat h1 { display: none; }
.page-chat main { padding-top: 14px; }
.page-chat .chat-messages { height: calc(100vh - 260px); }
.chat { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; }
.chat-messages { height: 60vh; min-height: 300px; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 80%; align-self: flex-start; background: #f2f4f1; border-radius: 10px; padding: 6px 12px 8px; }
.msg.own { align-self: flex-end; background: var(--green-light); }
.msg.staff .msg-author { color: var(--green-dark); }
.msg.staff { border-left: 3px solid var(--green); }
.msg.deleted { opacity: .6; }
.msg-head { display: flex; gap: 10px; justify-content: space-between; font-size: 13px; }
.msg-author { font-weight: 600; }
.msg-time { color: var(--muted); white-space: nowrap; }
.receipt { font-size: 12px; letter-spacing: -3px; padding-right: 3px; color: var(--muted); }
.receipt-read { color: var(--green); font-weight: 700; }
.msg-text { overflow-wrap: anywhere; margin-top: 2px; }
.msg-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: baseline; margin-top: 2px; }
.msg-actions:empty { display: none; }
.msg-actions .small, .msg .link-button.small { font-size: 12px; }
.msg-actions a { color: var(--muted); }
.msg-delete { display: inline; margin: 0 0 0 auto; order: 99; }   /* «удалить» — справа внизу сообщения */
.msg-quote { display: block; margin: 4px 0 2px; padding: 4px 8px; border-left: 3px solid var(--green); background: rgba(255, 255, 255, .6);
  border-radius: 4px; font-size: 13px; color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.msg-quote b { display: block; font-size: 12px; color: var(--green-dark); }
.msg.flash { box-shadow: 0 0 0 3px #f2c94c; transition: box-shadow .3s; }
.chat-reply { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--border);
  background: var(--green-light); font-size: 14px; }
.chat-reply[hidden] { display: none; }
.chat-reply > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; border-top: 1px solid var(--border); padding: 10px; margin: 0; }
.chat-form textarea { flex: 1; max-width: none; resize: vertical; min-height: 44px; }
.chat-form .btn { width: auto; }
.chat-older { text-align: center; margin: 0 0 8px; font-size: 14px; }
.chat-error { padding: 0 12px 8px; margin: 0; }
.chat-closed { border-top: 1px solid var(--border); padding: 12px 14px; margin: 0; }
.chat-search { display: flex; gap: 8px; margin: 8px 0 12px; }
.chat-search input { flex: 1; max-width: none; }
.chat-search .btn { width: auto; }
.people { padding: 4px 16px; }
.person { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.person:last-child { border-bottom: 0; }
.person:hover .small { text-decoration: underline; }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--red); color: #fff; font-size: 12px; line-height: 20px; text-align: center; }
.count[hidden] { display: none; }
@media (max-width: 760px) {
  /* Страница чата — ровно по высоте экрана: поле ввода всегда внизу, подвал скрыт */
  .page-chat main { padding: 8px 0 0; }
  .page-chat main > .container > .messages { margin-bottom: 8px; }
  .page-chat .chat-room-head h2 { font-size: 17px; }
  .page-chat .chat-room-info { display: none; }
  .page-chat .chat { border-radius: var(--radius) var(--radius) 0 0; }
  .page-chat .chat-messages { min-height: 120px; }
  .chat-layout { grid-template-columns: 1fr; gap: 10px; }
  .chat-layout:has(.chat-nav:not([open])) { gap: 0; }
  /* Название чата — кнопка выбора другого чата */
  .chat-switch { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
  .chat-switch-caret { display: inline; font-size: 14px; color: var(--muted); }
  .chat-switch .count:not([hidden]) { display: inline-block; }
  .chat-nav[open] ~ div .chat-switch-caret { transform: rotate(180deg); }
  .chat-messages { height: 58vh; padding: 10px; }
  .msg { max-width: 92%; }
  .chat-form { padding: 8px; }
  .chat-form .btn, .chat-search .btn { display: inline-block; width: auto; padding: 11px 14px; }
}

/* ---------- Отделы на странице «Контакты» ---------- */
/* Отделы — столбцом на всю ширину, сверху вниз по полю «порядок» */
.departments { display: flex; flex-direction: column; gap: 16px; }
.card.department { margin-bottom: 0; }
.department h3 { margin: 0 0 8px; font-size: 19px; }
.department p { margin: 6px 0; }
.schedule { background: var(--green-light); border-radius: 6px; padding: 8px 12px; margin: 4px 0 8px; }
.members { list-style: none; padding: 0; margin: 4px 0 0; }
.members li { padding: 8px 0; border-top: 1px solid var(--border); }
.members li:first-child { border-top: 0; padding-top: 2px; }

/* ---------- Проекты ---------- */
.projects { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.card.project { margin-bottom: 0; }
.project h3 { margin: 0 0 6px; font-size: 19px; }
.project h3 a { color: var(--text); text-decoration: none; }
.project h3 a:hover { color: var(--green); text-decoration: underline; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge.danger { background: #fde7e5; color: var(--red); }
.badge.kind { background: #fff; color: var(--text); border: 1px solid var(--border); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: -4px 0 8px; }
.chips a { padding: 6px 12px; border: 1px solid var(--border); border-radius: 16px; background: #fff; color: var(--text); text-decoration: none; font-size: 15px; }
.chips a.active { background: var(--green); border-color: var(--green); color: #fff; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 15px; }
.kv > span:last-child { text-align: right; }
.bar { margin: 2px 0 8px; }
.bar.over span { background: var(--red); }
.stages { list-style: none; padding: 0; margin: 0; }
.stages li { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); align-items: baseline; }
.stages li:first-child { border-top: 0; }
.stage-mark { color: var(--muted); font-weight: 700; text-align: center; }
.stages li.done .stage-mark { color: var(--green); }
.stages li.done .stage-title { color: var(--muted); }
.stages li.overdue .stage-mark, .stages li.overdue .stage-date { color: var(--red); }
.stage-date { color: var(--muted); white-space: nowrap; }
@media (max-width: 760px) {
  .stages li { grid-template-columns: 22px 1fr; }
  .stage-date { grid-column: 2; white-space: normal; }
}

/* ---------- Объявления ---------- */
.ads { display: flex; flex-direction: column; gap: 16px; }
/* Каждое объявление — на всю ширину: фото слева целиком (без обрезки), текст справа */
.card.ad { padding: 0; overflow: hidden; margin-bottom: 0; }
.card.ad.with-image { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); align-items: start; }
.ad-image-link { display: block; background: #fff; border-right: 1px solid var(--border); cursor: zoom-in; }
.ad-image { display: block; width: 100%; max-height: 460px; object-fit: contain; }
.ad-body { padding: 16px 20px 4px; }
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .85); display: flex; align-items: center;
  justify-content: center; padding: 16px; cursor: zoom-out; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
.lightbox-close { position: absolute; top: 12px; right: 16px; background: none; border: 0; color: #fff; font-size: 28px; cursor: pointer; }
@media (max-width: 760px) {
  .card.ad.with-image { grid-template-columns: 1fr; }
  .ad-image-link { border-right: 0; border-bottom: 1px solid var(--border); }
  .ad-image { max-height: 360px; }
}
.ad-body h2 { margin: 0 0 8px; font-size: 19px; }
.ad-body p { overflow-wrap: anywhere; }
.ad-contacts { list-style: none; padding: 0; margin: 4px 0 14px; }
.ad-contacts li { padding: 6px 0; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.ad-contacts li:first-child { border-top: 0; }
.ad-contact-kind { display: inline-block; min-width: 80px; color: var(--muted); font-size: 14px; }

/* ---------- Голосование: крупные варианты ответа ---------- */
fieldset.question { border: 0; border-bottom: 1px solid var(--border); margin: 0 0 14px; padding: 0 0 14px; }
fieldset.question legend { font-weight: 600; padding: 0; margin-bottom: 10px; }
.choices { display: flex; gap: 8px; flex-wrap: wrap; }
.choice { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; margin: 0;
  padding: 10px 16px; border: 1px solid #c5ccc5; border-radius: 6px; background: #fff; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--green); background: var(--green-light); color: var(--green-dark); font-weight: 600; }
.choice input { margin: 0; width: 18px; height: 18px; accent-color: var(--green); }

/* ---------- Кнопка меню (видна только на телефоне) ---------- */
.nav-toggle { display: none; align-items: center; gap: 8px; background: none; border: 1px solid rgba(255,255,255,.5);
  color: #fff; border-radius: 6px; padding: 7px 12px; font: inherit; cursor: pointer; }
.nav-toggle-icon, .nav-toggle-icon::before, .nav-toggle-icon::after {
  display: block; width: 18px; height: 2px; background: #fff; border-radius: 1px; position: relative; }
.nav-toggle-icon::before, .nav-toggle-icon::after { content: ""; position: absolute; left: 0; }
.nav-toggle-icon::before { top: -6px; }
.nav-toggle-icon::after { top: 6px; }
.nav-toggle[aria-expanded="true"] .nav-toggle-icon { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle-icon::before { top: 0; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-icon::after { top: 0; transform: rotate(-45deg); }

.layout-aside { grid-template-columns: 1fr 300px; }
td.num.ok { color: var(--green); }

/* ---------- Телефон ---------- */
@media (max-width: 760px) {
  body { font-size: 16px; }
  main { padding: 16px 0 32px; }
  h1 { font-size: 23px; line-height: 1.3; }
  h2 { font-size: 19px; }
  .card { padding: 14px 16px; }
  .big { font-size: 22px; }

  .header .container { flex-wrap: wrap; gap: 0; padding-top: 10px; padding-bottom: 10px; }
  .brand { font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 12px; }
  .nav-toggle { display: inline-flex; }
  .nav { display: none; width: 100%; flex-direction: column; align-items: stretch; gap: 2px; padding-top: 10px; }
  .nav.open { display: flex; }
  .nav a, .nav button { display: block; width: 100%; text-align: left; padding: 11px 12px; }

  .layout, .layout-aside { grid-template-columns: 1fr; gap: 16px; }
  .layout-aside aside { order: -1; }   /* на главной сначала «Войти в кабинет», потом новости */
  .grid { grid-template-columns: 1fr; gap: 12px; }

  /* Вкладки кабинета — одна строка с прокруткой вбок */
  .sidenav { display: flex; gap: 6px; overflow-x: auto; padding: 6px; margin: 0 -16px; border-radius: 0;
    border-left: 0; border-right: 0; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .sidenav::-webkit-scrollbar { display: none; }
  .sidenav .plot-label { display: none; }
  .sidenav a { flex: 0 0 auto; white-space: nowrap; padding: 8px 12px; border: 1px solid var(--border); }
  .sidenav a.active { border-color: var(--green); }

  input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], select, textarea {
    max-width: 100%; font-size: 16px; padding: 11px 12px; }   /* 16px — чтобы iOS не увеличивал страницу */
  .btn { display: block; width: 100%; text-align: center; padding: 13px 18px; }
  .choices { display: grid; grid-template-columns: 1fr; }
  .choice { padding: 13px 16px; }

  .doc { flex-direction: column; gap: 2px; }
  .doc > div:last-child { white-space: normal !important; }

  /* Таблицы → карточки: каждая строка — блок, у ячейки подпись из data-label */
  .table-wrap { border: 0; overflow: visible; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack { background: none; }
  table.stack thead { display: none; }
  table.stack tr { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 14px; margin-bottom: 10px; }
  table.stack td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.stack td::before { content: attr(data-label); color: var(--muted); text-align: left; font-size: 14px; }
  table.stack td:not([data-label])::before { content: none; }
  table.stack td:not([data-label]) { text-align: left; }
  table.stack td.empty { display: none; }
  table.stack td.title { font-weight: 600; display: block; text-align: left; }

  .footer { display: none; }  /* на телефоне подвал не показываем — экономим место */
}

/* ---------- Инструкция ---------- */
.instruction { grid-template-columns: 250px 1fr; }
.layout > * { min-width: 0; }   /* иначе широкая таблица распирает колонку */
.toc { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; padding: 12px 14px; font-size: 14px; }
.toc summary { font-weight: 700; cursor: pointer; }
.toc ul { list-style: none; margin: 6px 0 0; padding-left: 0; }
.toc ul ul { padding-left: 12px; }
.toc li { margin: 4px 0; }
.toc a { text-decoration: none; }
.prose { padding: 20px 28px; }
.prose h1 { margin-top: 0; }
.prose h2 { margin-top: 36px; padding-top: 12px; border-top: 1px solid var(--border); }
.prose h3 { font-size: 17px; margin: 22px 0 8px; }
.prose h2, .prose h3 { scroll-margin-top: 12px; }
.prose hr { display: none; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin: 4px 0; }
.prose code { background: #f0f2ef; padding: 1px 5px; border-radius: 4px; font-size: 14px; }
.prose blockquote { margin: 14px 0; padding: 10px 14px; background: #fff8e6; border-left: 3px solid #e0a800; border-radius: 4px; }
.prose blockquote p { margin: 0; }
.prose table { display: block; overflow-x: auto; margin: 12px 0; border: 1px solid var(--border); border-radius: var(--radius); }
.prose th, .prose td { font-size: 14px; }
@media (max-width: 760px) {
  .instruction { grid-template-columns: 1fr; }
  .toc { position: static; max-height: none; }
  .prose { padding: 14px 16px; }
}
