/* ===== ClinReky — страница клинической рекомендации =====
   Структура и классы — порт из cervical_cancer_guidelines (3).html
   Цветовая палитра согласована с patkast/ClinReky (--accent #1a4a7a).
   Mobile-first: брейкпойнты на 360 / 640 / 900. */

:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --surface: #ffffff;
  --surface2: #f0f4fa;
  --border: #d0d7e3;
  --border2: #b8c4d8;
  --accent: #1a4a7a;
  --accent2: #2e7bc4;
  --accent-soft: rgba(46, 123, 196, 0.10);
  --accent-glow: rgba(46, 123, 196, 0.05);
  --red: #c0392b;
  --red-soft: rgba(192, 57, 43, 0.08);
  --green: #1e7e34;
  --green-soft: rgba(30, 126, 52, 0.10);
  --blue: #2e7bc4;
  --blue-soft: rgba(46, 123, 196, 0.10);
  --orange: #f5a623;
  --orange-soft: rgba(245, 166, 35, 0.12);
  --gold: #c8952a;
  --text: #1e2535;
  --text2: #5a6680;
  --text3: #8a97b0;
  --muted: #5a6680;
  --label: #344060;
  --highlight: #e8f0fb;
  --tag-bg: #eaf3ff;
  --warn: #f5a623;
  --section-head: #1a3a60;
  --radius: 6px;
  --radius-sm: 4px;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.09);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --header-h: 60px;
  --tabs-h: 46px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Geologica', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { color: var(--accent); }
button { font-family: inherit; cursor: pointer; }

/* ===== HEADER (sticky тёмно-синий) ===== */
.kr-header {
  background: var(--accent);
  border-bottom: 1px solid var(--accent);
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--header-h);
  box-shadow: 0 2px 8px rgba(26, 74, 122, 0.25);
}
@media (min-width: 640px) { .kr-header { padding: 0 24px; gap: 16px; } }
@media (min-width: 900px) { .kr-header { padding: 0 32px; } }

.kr-logo-link {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none;
  flex-shrink: 0;
  padding-right: 12px;
  border-right: 1px solid rgba(255, 255, 255, 0.25);
  min-width: 0;
}
@media (min-width: 640px) { .kr-logo-link { padding-right: 16px; gap: 10px; } }

.kr-logo-link img {
  width: 32px; height: 32px;
  border-radius: 5px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}

.kr-logo-link span {
  font-size: 13px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
  letter-spacing: -0.1px;
}
.kr-logo-link span em {
  font-style: normal;
  color: #4a9ede;
}

.kr-icon {
  width: 34px; height: 34px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
@media (max-width: 480px) { .kr-icon { display: none; } }

.kr-title {
  min-width: 0;
  overflow: hidden;
  flex: 1;
}
.kr-title h1 {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (min-width: 640px) { .kr-title h1 { font-size: 15px; } }

.kr-title .subtitle {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.65);
  letter-spacing: 0.3px;
  text-transform: uppercase;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (min-width: 640px) { .kr-title .subtitle { font-size: 10.5px; } }
.kr-title .kr-edition { color: #fff; font-weight: 600; text-transform: none; }
.kr-title .kr-age { color: #fff; font-weight: 700; }
/* Телефон: название КР есть только в шапке — даём ему две строки, место берём у надписи логотипа */
@media (max-width: 480px) {
  .kr-header { padding: 0 12px; gap: 10px; }
  .kr-logo-link { padding-right: 10px; }
  .kr-logo-link span { display: none; }
  .kr-title h1 {
    font-size: 13px;
    line-height: 1.2;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
}

.kr-badge {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  white-space: nowrap;
  flex-shrink: 0;
}
@media (max-width: 480px) { .kr-badge { display: none; } }

/* ===== SUMMARY TOGGLE (✨ Кратко / 📄 Полный) ===== */
.summary-toggle {
  display: inline-flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 20px;
  padding: 2px;
  gap: 0;
  flex-shrink: 0;
}
.summary-toggle .st-btn {
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.78);
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 18px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}
.summary-toggle .st-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.summary-toggle .st-btn--active {
  background: var(--gold, #c8952a);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
@media (max-width: 640px) {
  .summary-toggle .st-btn { padding: 4px 8px; font-size: 11px; }
}

/* Полный текст — менее плотный шрифт + serif для отличия от выжимки */
.rec-text-full {
  display: block;
  font-family: 'PT Serif', Georgia, serif;
  line-height: 1.55;
  color: var(--text, #1a2433);
}
/* Перебиваем display:block для скрытых через hidden-атрибут JS-тогглом.
   Иначе наше display:block выигрывает по специфичности у браузерного
   [hidden]{display:none} и оба варианта показываются одновременно. */
.rec-text-ai[hidden],
.rec-text-full[hidden] { display: none; }

/* ===== MAIN TABS (sticky под header) ===== */
.main-tabs {
  display: flex;
  background:
    /* fade-индикатор слева — появляется при скролле */
    linear-gradient(to right, var(--panel) 30%, rgba(255,255,255,0)) left center / 28px 100% no-repeat local,
    /* fade-индикатор справа — появляется при скролле */
    linear-gradient(to left, var(--panel) 30%, rgba(255,255,255,0)) right center / 28px 100% no-repeat local,
    /* теневой shadow слева — статичный, не скроллится */
    radial-gradient(farthest-side at 0 50%, rgba(0,0,0,0.12), rgba(0,0,0,0)) left center / 14px 100% no-repeat scroll,
    /* теневой shadow справа — статичный */
    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,0.12), rgba(0,0,0,0)) right center / 14px 100% no-repeat scroll,
    var(--panel);
  border-bottom: 2px solid var(--border);
  padding: 0 8px;
  gap: 0;
  position: sticky;
  top: var(--header-h);
  z-index: 99;
  box-shadow: var(--shadow);
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x mandatory;
}
.main-tabs::-webkit-scrollbar { display: none; }
@media (min-width: 640px) { .main-tabs { padding: 0 24px; } }
@media (min-width: 900px) { .main-tabs { padding: 0 32px; } }

.main-tab {
  padding: 12px 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
  scroll-snap-align: start;
  min-height: 44px;
  background: transparent;
  border-top: none; border-left: none; border-right: none;
  display: inline-flex; align-items: center; gap: 4px;
}
@media (min-width: 480px) { .main-tab { padding: 12px 14px; } }
@media (min-width: 640px) { .main-tab { padding: 11px 20px; } }

/* На узких ≤719 — короткий лейбл «Лечение», на ≥720 — полный «Лечение по стадиям» */
.mt-lbl-short { display: inline; }
.mt-lbl-full  { display: none;   }
@media (min-width: 720px) {
  .mt-lbl-short { display: none;   }
  .mt-lbl-full  { display: inline; }
}

.main-tab:hover { color: var(--accent); background: var(--highlight); }
.main-tab.active { color: var(--accent); border-bottom-color: var(--accent2); }

/* ===== CONTENT ===== */
.kr-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 12px 60px;
}
@media (min-width: 640px) { .kr-content { padding: 20px 20px 60px; } }
@media (min-width: 900px) { .kr-content { padding: 24px 32px 80px; } }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* SECTION TITLES */
.section-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--section-head);
}
@media (min-width: 640px) { .section-title { font-size: 20px; } }

.section-desc {
  color: var(--text2);
  margin-bottom: 18px;
  font-size: 13px;
  line-height: 1.55;
}
@media (min-width: 640px) {
  .section-desc { font-size: 13.5px; margin-bottom: 24px; }
}

/* ===== CARDS ===== */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s;
}
@media (min-width: 640px) { .card { padding: 18px 20px; margin-bottom: 14px; } }
.card:hover { box-shadow: 0 3px 10px rgba(26, 74, 122, 0.10); }

.card-title {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--section-head);
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
@media (min-width: 640px) {
  .card-title { font-size: 12.5px; margin-bottom: 12px; }
}
.card-title .icon {
  width: 24px; height: 24px;
  background: var(--highlight);
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

/* DIAGNOSIS GRID */
.diag-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
@media (min-width: 768px) {
  .diag-grid { grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
}

/* ===== REC ITEM ===== */
.rec-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 7px;
  position: relative;
  transition: all 0.15s;
  display: flex;
  align-items: flex-start;
  gap: 9px;
}
@media (min-width: 640px) { .rec-item { padding: 11px 13px; gap: 10px; } }

.rec-item:hover {
  border-left-color: var(--accent2);
  background: var(--highlight);
  box-shadow: var(--shadow);
}

.rec-content { flex: 1; min-width: 0; }

/* ID-бейдж рекомендации в правом нижнем углу. Мелкий, ненавязчивый, но
   доступен глазу — чтобы можно было сослаться на конкретную карточку
   («посмотри t48»). Клик копирует ID в буфер обмена. */
.rec-item { padding-bottom: 22px; } /* запас под бейдж снизу */
.rec-id-badge {
  position: absolute;
  right: 8px;
  bottom: 4px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 500;
  color: #999;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 1px 5px;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: color 0.1s, border-color 0.1s, background 0.1s;
  user-select: all;
}
.rec-id-badge:hover {
  color: var(--accent2);
  border-color: var(--border);
  background: var(--surface);
}
.rec-id-badge.copied {
  color: #2e7d32;
  border-color: #2e7d32;
  background: #e8f5e9;
}
.rec-id-badge.copied::after {
  content: ' ✓';
}

.rec-text {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  word-wrap: break-word;
}
@media (min-width: 640px) { .rec-text { font-size: 13.5px; } }
.rec-text strong { color: var(--text); }

.rec-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  flex-wrap: wrap;
}

.ev-badge {
  font-family: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
  letter-spacing: 0.3px;
}
.ev-A { background: #e6f4ee; color: #155724; border: 1px solid #a8d5b5; }
.ev-B { background: var(--tag-bg); color: var(--accent); border: 1px solid #a8c8ec; }
.ev-C { background: #f0f2f5; color: var(--text2); border: 1px solid var(--border); }

.ref-link {
  font-size: 11px;
  color: var(--text3);
  font-family: 'JetBrains Mono', monospace;
}
.ref-link a { color: var(--blue); text-decoration: none; }
.ref-link a:hover { text-decoration: underline; }

/* Дополнительные кнопки в meta */
.ref-btn {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--tag-bg);
  border: 1px solid #a8c8ec;
  padding: 2px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.ref-btn:hover { background: #d4e6f7; border-color: var(--accent2); }

/* ===== TOOLTIP ===== */
.tooltip-trigger {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}

.tooltip-icon {
  width: 18px; height: 18px;
  background: var(--tag-bg);
  border: 1px solid #a8c8ec;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 1px;
  cursor: help;
  font-weight: 700;
  user-select: none;
}

.tooltip-box {
  display: none;
  position: absolute;
  left: 24px;
  top: -4px;
  z-index: 200;
  width: 360px;
  max-width: calc(100vw - 40px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent2);
  border-radius: var(--radius);
  padding: 13px 15px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.58;
  box-shadow: 0 6px 20px rgba(26, 74, 122, 0.15);
}

/* Desktop: hover; Mobile: tap (через class .open) */
@media (hover: hover) {
  .tooltip-trigger:hover .tooltip-box { display: block; }
}
.tooltip-trigger.open .tooltip-box { display: block; }

@media (max-width: 600px) {
  .tooltip-box { width: calc(100vw - 60px); left: -16px; }
}

.tooltip-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent2);
  font-weight: 700;
  margin-bottom: 6px;
}

/* ===== STAGE NAVIGATION ===== */
.stage-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.stage-btn {
  padding: 6px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--label);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  min-height: 32px;
  display: inline-flex; align-items: center; gap: 5px;
}
@media (min-width: 640px) {
  .stage-btn { padding: 8px 13px; font-size: 12.5px; min-height: 36px; }
}
/* Подстадии (IA, IB, IIA, IIB, ...) — двухбуквенные после римской цифры —
   рендерятся чуть менее контрастно, как «детали» родительской стадии. */
.stage-btn.is-substage {
  background: var(--bg);
  font-weight: 500;
}
/* Псевдо-стадии («Рецидив», «Паллиативное лечение») — клинические ситуации,
   а не TNM-стадии. Отделяем их визуально от анатомических кнопок. */
.stage-btn.is-special {
  border-color: var(--accent2);
  background: linear-gradient(to bottom, var(--panel), var(--highlight));
  color: var(--accent);
}
.stage-btn.is-special.active {
  background: var(--accent2);
  border-color: var(--accent2);
  color: #fff;
}
.stage-btn:hover {
  border-color: var(--accent2);
  color: var(--accent);
  background: var(--tag-bg);
}
.stage-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.stage-btn small {
  font-size: 10px; opacity: 0.85;
  background: rgba(200, 149, 42, 0.22);
  color: var(--gold);
  padding: 1px 5px; border-radius: 3px;
}
.stage-btn.active small {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* STAGE PANEL */
.stage-panel { display: none; }
.stage-panel.active { display: block; }

.stage-header {
  background: var(--highlight);
  border: 1px solid #b8cfe8;
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
@media (min-width: 640px) { .stage-header { padding: 16px 20px; margin-bottom: 16px; } }

.stage-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--section-head);
  margin-bottom: 4px;
}
@media (min-width: 640px) { .stage-header h3 { font-size: 16px; } }

.stage-header p {
  font-size: 12.5px;
  color: var(--text2);
  line-height: 1.5;
}

/* Placeholder когда ничего не выбрано */
.stage-placeholder {
  text-align: center;
  padding: 32px 16px;
  background: var(--highlight);
  border: 1px dashed var(--border2);
  border-radius: var(--radius);
  color: var(--muted);
}
.stage-placeholder-icon {
  font-size: 36px;
  margin-bottom: 12px;
}
@media (min-width: 640px) { .stage-placeholder { padding: 40px 20px; } .stage-placeholder-icon { font-size: 44px; } }

/* TREATMENT TABS */
.treatment-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 14px;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x mandatory;
}
.treatment-tabs::-webkit-scrollbar { display: none; }

.treatment-tab {
  padding: 8px 13px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text2);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
  scroll-snap-align: start;
  min-height: 40px;
  background: transparent;
  border-top: none; border-left: none; border-right: none;
  display: inline-flex; align-items: center; gap: 4px;
}
@media (min-width: 640px) { .treatment-tab { padding: 8px 15px; } }

.treatment-tab:hover { color: var(--accent); background: var(--highlight); }
.treatment-tab.active { color: var(--accent); border-bottom-color: var(--accent2); }

.treatment-content { display: none; }
.treatment-content.active { display: block; }

/* ===== DIVIDER ===== */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}

/* ===== TABLE ===== */
.rec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  margin: 12px 0;
}
@media (min-width: 640px) { .rec-table { font-size: 13px; } }

.rec-table th {
  background: var(--highlight);
  padding: 8px 10px;
  text-align: left;
  font-weight: 700;
  color: var(--section-head);
  border: 1px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
@media (min-width: 640px) {
  .rec-table th { padding: 9px 12px; font-size: 11.5px; }
}

.rec-table td {
  padding: 8px 10px;
  border: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.45;
}
@media (min-width: 640px) { .rec-table td { padding: 9px 12px; } }

.rec-table tr:hover td { background: var(--highlight); }

/* ===== DRUG BOX ===== */
.drug-box {
  background: var(--tag-bg);
  border: 1px solid #b8cfe8;
  border-left: 3px solid var(--accent2);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 8px 0;
  font-family: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.75;
  color: var(--accent);
  word-wrap: break-word;
  overflow-x: auto;
}
@media (min-width: 640px) {
  .drug-box { padding: 11px 14px; font-size: 12px; }
}
.drug-box .drug-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--accent2);
  margin-bottom: 6px;
  font-family: 'Inter', 'Geologica', sans-serif;
  font-weight: 700;
}

/* ===== ALERTS ===== */
.alert {
  border-radius: var(--radius);
  padding: 9px 12px;
  margin: 8px 0;
  font-size: 12.5px;
  display: flex;
  gap: 9px;
  line-height: 1.5;
}
@media (min-width: 640px) { .alert { padding: 10px 13px; font-size: 13px; gap: 10px; } }

.alert-warn {
  background: #fffaf0;
  border: 1px solid #f0d08a;
  border-left: 3px solid var(--warn);
  color: #6b4500;
}
.alert-info {
  background: var(--highlight);
  border: 1px solid #b8cfe8;
  border-left: 3px solid var(--accent2);
  color: var(--accent);
}
.alert-note {
  background: #f0f6e8;
  border: 1px solid #b8d8a0;
  border-left: 3px solid #3a8f3a;
  color: #2a5c1a;
}
.alert-icon { flex-shrink: 0; font-size: 14px; margin-top: 1px; }

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26, 74, 122, 0.45);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
body.modal-open { overflow: hidden; }

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 18px 18px 24px;
  position: relative;
  box-shadow: 0 16px 48px rgba(26, 74, 122, 0.18);
}
@media (min-width: 640px) { .modal { padding: 22px; max-height: 85vh; } }

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--section-head);
  margin-bottom: 14px;
  padding-right: 32px;
}
@media (min-width: 640px) { .modal-title { font-size: 16px; } }

/* Текстовые блоки внутри модалок «Справочников» (Определение/Этиология/…)
   — PDF-извлечение с переносами строк, читаем без шумной типографики. */
.info-block {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.info-block br { content: " "; }

.modal-close {
  position: absolute;
  top: 8px; right: 8px;
  width: 40px; height: 40px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 50%;
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  line-height: 1;
}
@media (min-width: 640px) { .modal-close { width: 36px; height: 36px; font-size: 18px; } }
.modal-close:hover { background: var(--border); color: var(--text); }

/* ===== APPENDIX (Справочники) ===== */
.appendix-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.appendix-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--label);
  padding: 8px 13px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.15s;
  box-shadow: var(--shadow);
  min-height: 36px;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: inherit;
}
.appendix-btn:hover {
  border-color: var(--accent2);
  color: var(--accent);
  background: var(--highlight);
}
@media (min-width: 640px) { .appendix-btn { font-size: 13px; padding: 7px 13px; } }

/* ===== APPENDIX-IMAGES (Приложения Б — алгоритмы) ===== */
.appendix-img-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 768px) {
  .appendix-img-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
}
.appendix-img-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: var(--shadow);
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.appendix-img-item a {
  display: block;
  cursor: zoom-in;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
}
.appendix-img-item img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.18s;
}
.appendix-img-item a:hover img { transform: scale(1.02); }
.appendix-img-item figcaption {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.4;
  padding: 0 4px;
}

.modal-hint {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text2);
  margin: 0 0 12px;
  padding: 6px 10px;
  background: var(--highlight);
  border-left: 3px solid var(--accent2);
  border-radius: var(--radius-sm);
}

/* ===== APPENDIX-TEXT (Приложения А/В/Г — текст + таблицы) ===== */
.appendix-text-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.appendix-text-item > summary {
  font-weight: 600;
  font-size: 13px;
  color: var(--section-head);
  cursor: pointer;
  padding: 4px 0;
}
.appendix-text-item[open] > summary { margin-bottom: 8px; }
.appendix-body {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 50vh;
  overflow-y: auto;
  padding: 6px 8px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin: 6px 0;
}

/* ===== APPENDIX-TABLE (общая таблица для приложений и критериев) ===== */
.appendix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  line-height: 1.45;
  margin: 8px 0;
  background: var(--bg);
}
.appendix-table th,
.appendix-table td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
  word-break: break-word;
}
.appendix-table thead th {
  background: var(--highlight);
  font-weight: 700;
  color: var(--section-head);
  position: sticky;
  top: 0;
  z-index: 1;
}
.appendix-table tbody tr:nth-child(even) { background: var(--panel); }
.appendix-table--quality td:first-child { width: 36px; text-align: center; font-weight: 600; }
.appendix-table--quality td:last-child  { width: 80px; text-align: center; }
/* «Тактики наблюдения»: первая колонка — название параметра, выделяем */
.appendix-table--surveillance td:first-child {
  font-weight: 600;
  background: var(--bg);
  color: var(--section-head);
  width: 38%;
}

/* ===== REC-VALIDATION-FLAG (красный флаг для unmatched) =====
   `.admin-only` определён в admin-toggle.css — обычный пользователь
   видит рекомендацию без флага, админ — с флагом. */
.rec-content--needs-validation { position: relative; }
.rec-validation-flag {
  background: #fff5f5;
  border-left: 4px solid #e53935;
  color: #b71c1c;
  padding: 8px 12px;
  margin: 0 0 10px;
  font-size: 12.5px;
  line-height: 1.45;
  border-radius: var(--radius-sm);
}
.rec-validation-flag strong { color: #b71c1c; font-weight: 700; }
/* Бейдж и ссылка admin-режима — в admin-toggle.css (общий для всех страниц). */

/* ===== REC-STAGES (chips «также применима к…») ===== */
.rec-stages {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text2);
}
.rec-stages-label {
  font-size: 10.5px;
  font-weight: 500;
  text-transform: lowercase;
  letter-spacing: 0.02em;
  color: var(--text2);
  white-space: nowrap;
  opacity: 0.85;
}
.rec-stage-chip {
  font-family: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--highlight);
  color: var(--accent);
  border: 1px solid var(--border);
}
@media (min-width: 640px) {
  .appendix-table { font-size: 13px; }
}

/* ===== SCALES (УДД диагностика / УДД лечение / УУР) ===== */
.scale-block {
  margin: 0 0 18px;
}
.scale-block:last-child { margin-bottom: 0; }
.scale-block h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--section-head);
  margin: 0 0 8px;
  line-height: 1.45;
}
@media (min-width: 640px) { .scale-block h3 { font-size: 14px; } }
.scale-source {
  font-size: 11px;
  font-style: italic;
  color: var(--text2);
  margin: 0 0 8px;
  line-height: 1.5;
}
.appendix-table--scale td.cell-num,
.appendix-table--scale th.cell-num {
  width: 56px;
  text-align: center;
  font-weight: 700;
  vertical-align: middle;
}

/* ===== REFERENCES list (модалка литературы) ===== */
.ref-list {
  font-size: 12px;
  line-height: 1.85;
  color: var(--text2);
  max-height: 55vh;
  overflow-y: auto;
  padding-right: 8px;
}
.ref-list li {
  list-style: none;
  padding: 3px 0;
  border-bottom: 1px dotted var(--border);
}
.ref-list li:target {
  background: #fff7d6;
  animation: refFlash 1.5s ease-out;
}
@keyframes refFlash {
  0% { background: var(--gold); }
  100% { background: transparent; }
}

/* ===== TYPOGRAPHY UTILITIES ===== */
.text-muted { color: var(--muted); font-size: 13px; }
.text-accent { color: var(--accent2); }
.mono { font-family: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace; }
.mb-4 { margin-bottom: 16px; }
.mb-2 { margin-bottom: 8px; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #b8cfe8; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent2); }

/* ===== CLASSIFICATION BOX ===== */
.class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.class-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 12.5px;
  box-shadow: var(--shadow);
}
.class-item .stage-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent2);
  display: block;
  margin-bottom: 4px;
}

/* ===== FOOTER (минимальный для КР-страницы) ===== */
.kr-footer {
  background: #060f1c;
  color: rgba(255, 255, 255, 0.55);
  padding: 24px 16px 18px;
  margin-top: 40px;
  font-size: 12px;
  text-align: center;
}
.kr-footer a { color: rgba(74, 158, 222, 0.9); }
.kr-footer a:hover { color: #fff; }
.kr-footer-disclaimer {
  font-style: italic;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  margin-top: 10px;
  max-width: 720px;
  margin-left: auto; margin-right: auto;
  line-height: 1.55;
}

/* ===== PRINT ===== */
@media print {
  .kr-header, .main-tabs { position: static; }
  .tooltip-box { display: none !important; }
  .modal-overlay { display: none !important; }
  .tab-panel { display: block !important; }
  .stage-panel { display: block !important; }
  .treatment-content { display: block !important; }
}
