/* ==========================================================================
   KREK Portal — главная таблица стилей
   Подключается на всех страницах. Постраничные стили лежат в css/pages/
   и подключаются через {% block page_css %} в layouts/base.html.

   Порядок: токены → сброс → типографика → раскладка → шапка → подвал →
   компоненты → утилиты → печать.
   Метод — mobile-first: базовые правила для узкого экрана,
   расширения через min-width.
   ========================================================================== */

@import url("fonts.css");

/* ==========================================================================
   1. ТОКЕНЫ
   Палитра снята с логотипа АО «КРЭК» и адаптирована под веб:
   контраст доведён до AA, добавлены оттенки для состояний.
   ========================================================================== */

:root {
  /* Фирменные — с логотипа */
  --brand: #0b4ea2;           /* глубокий синий, основа знака */
  --brand-dark: #07376f;      /* нажатие, тёмный фон */
  --brand-darker: #052748;    /* подвал */
  --brand-light: #2aa3e0;     /* голубой из «волны» */
  --brand-lighter: #e8f4fc;   /* заливки, ховеры */
  --accent: #f5c518;          /* жёлтый из «солнца» */
  --accent-dark: #d9a800;
  --danger: #d2231e;          /* красный из знака — только алерты */
  --danger-bg: #fdecec;
  --success: #17864a;
  --success-bg: #e8f5ee;

  /* Нейтральные */
  --text: #16202b;
  --text-muted: #5a6472;
  --text-inverse: #ffffff;
  --surface: #ffffff;
  --surface-alt: #f4f7fa;     /* секции-подложки */
  --surface-sunk: #eaeff5;
  --line: #dbe2ea;
  --line-strong: #c3ccd8;

  /* Типографика.
     Нижняя ступень шкалы — 15px: мельче на сайте текста нет нигде,
     включая подписи, мету и служебные строки. */
  --font: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --fs-xs: 0.9375rem;   /* 15px — минимум */
  --fs-sm: 1rem;        /* 16px */
  --fs-base: 1.0625rem; /* 17px */
  --fs-lg: 1.25rem;     /* 20px */
  --fs-xl: 1.5rem;      /* 24px */
  --fs-2xl: 1.875rem;
  --fs-3xl: 2.25rem;
  --fs-4xl: 3rem;
  --lh-tight: 1.2;
  --lh-base: 1.6;

  /* Раскладка */
  --container: 1240px;
  --container-wide: 100%;   /* шапка идёт во всю ширину экрана */
  --gutter: 1rem;
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 16px;

  /* Тени — мягкие, без «залипания» */
  --shadow-sm: 0 1px 2px rgba(22, 32, 43, 0.06);
  --shadow: 0 2px 12px rgba(22, 32, 43, 0.08);
  --shadow-lg: 0 12px 32px rgba(22, 32, 43, 0.12);

  /* Прочее */
  --header-h: 64px;
  --transition: 160ms ease;
}

@media (min-width: 768px) {
  :root {
    --gutter: 1.5rem;
    --header-h: 84px;
  }
}

@media (min-width: 1024px) {
  :root {
    --gutter: 2rem;
    --fs-3xl: 2.75rem;
    --fs-4xl: 3.75rem;
  }
}

/* ==========================================================================
   2. СБРОС
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text);
  background: var(--surface);
  /* Длинные казахские и русские слова не должны рвать раскладку */
  overflow-wrap: break-word;
}

img,
picture,
svg,
video {
  display: block;
  max-width: 100%;
  height: auto;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

a {
  color: var(--brand);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--brand-light);
  text-decoration: underline;
}

ul,
ol {
  margin: 0;
  padding: 0;
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote {
  margin: 0;
}

table {
  border-collapse: collapse;
  width: 100%;
}

/* Видимый фокус — обязателен для доступности */
:focus-visible {
  outline: 3px solid var(--brand-light);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   3. ТИПОГРАФИКА
   ========================================================================== */

h1, .h1 {
  font-size: var(--fs-3xl);
  line-height: var(--lh-tight);
  font-weight: 800;
  letter-spacing: -0.02em;
}

h2, .h2 {
  font-size: var(--fs-2xl);
  line-height: var(--lh-tight);
  font-weight: 700;
  letter-spacing: -0.01em;
}

h3, .h3 {
  font-size: var(--fs-xl);
  line-height: 1.3;
  font-weight: 700;
}

h4, .h4 {
  font-size: var(--fs-lg);
  font-weight: 600;
}

.text-muted {
  color: var(--text-muted);
}

.text-sm {
  font-size: var(--fs-sm);
}

/* Заголовок секции: подпись сверху + линия-акцент снизу */
.section-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.section-title h2 {
  position: relative;
  padding-bottom: 0.6rem;
  text-transform: uppercase;
  /* Флекс-элемент не сжимается ниже min-content, а заголовки набраны
     в верхнем регистре длинными словами. На самом узком экране такое
     слово выпирало за край контейнера. */
  min-width: 0;
  overflow-wrap: anywhere;
}

.section-title h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 56px;
  height: 4px;
  background: var(--accent);
  border-radius: 2px;
}

/* Ссылка «Все …» рядом с заголовком секции — такая же кнопка,
   как везде на сайте: прозрачная с рамкой, при наведении заливается.
   Голым текстом она терялась и подчёркивалась при наведении. */
.section-title > a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  min-height: 40px;
  padding: 0.4rem 1rem;
  border: 2px solid currentColor;
  border-radius: var(--radius-sm);
  color: var(--brand);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.section-title > a::after {
  content: "→";
  font-size: 1.1em;
  line-height: 1;
}

.section-title > a:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--text-inverse);
  text-decoration: none;
}

/* Текст статьи — стили для контента из админки */
.prose {
  max-width: 72ch;
}

.prose > * + * {
  margin-top: 1rem;
}

.prose h2 {
  margin-top: 2rem;
}

.prose h3 {
  margin-top: 1.5rem;
}

.prose ul,
.prose ol {
  padding-left: 1.25rem;
}

.prose li + li {
  margin-top: 0.4rem;
}

.prose img {
  border-radius: var(--radius);
}

.prose table {
  display: block;
  overflow-x: auto;      /* широкие таблицы скроллятся внутри себя */
  white-space: nowrap;
}

@media (min-width: 768px) {
  .prose table {
    display: table;
    white-space: normal;
  }
}

.prose th,
.prose td {
  border: 1px solid var(--line);
  padding: 0.6rem 0.75rem;
  text-align: left;
}

.prose th {
  background: var(--surface-alt);
  font-weight: 600;
}

/* ==========================================================================
   4. РАСКЛАДКА
   ========================================================================== */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Широкий контейнер — для шапки: логотип уходит к самому левому краю,
   а навигации хватает места на полные названия разделов. */
.container--wide {
  max-width: var(--container-wide);
}

.section {
  padding-block: 2.5rem;
}

.section--alt {
  background: var(--surface-alt);
}

.section--tight {
  padding-block: 1.5rem;
}

@media (min-width: 768px) {
  .section {
    padding-block: 4rem;
  }
}

/* Внутренняя страница: контент + сайдбар раздела */
.layout-sidebar {
  display: grid;
  /* Без явной колонки неявная растягивается по содержимому: широкая
     таблица внутри статьи раздвигала страницу на узком экране. */
  grid-template-columns: minmax(0, 1fr);
  gap: 2rem;
}

@media (min-width: 1024px) {
  .layout-sidebar {
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 3rem;
  }
}

.grid {
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 640px) {
  .grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 900px) {
  .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1280px) {
  .grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Пропуск к контенту — первый таб на странице */
.skip-link {
  position: absolute;
  left: -9999px;
  z-index: 999;
  padding: 0.75rem 1.25rem;
  background: var(--brand);
  color: var(--text-inverse);
  border-radius: 0 0 var(--radius) 0;
}

.skip-link:focus {
  left: 0;
  top: 0;
}

/* ==========================================================================
   5. ШАПКА
   Два яруса: утилиты (языки, соцсети, поиск) и основная навигация.
   До 1024px основная навигация уезжает в выдвижную панель.
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

/* --- ярус 1: утилиты --- */

.topbar {
  background: var(--brand-darker);
  color: rgba(255, 255, 255, 0.85);
  font-size: var(--fs-xs);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 36px;
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  list-style: none;
}

.lang-switch a {
  display: block;
  padding: 0.35rem 0.55rem;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.04em;
  border-radius: var(--radius-sm);
}

.lang-switch a:hover {
  color: var(--text-inverse);
  background: rgba(255, 255, 255, 0.1);
  text-decoration: none;
}

.lang-switch a[aria-current="true"] {
  color: var(--accent);
}

.topbar__meta {
  display: none;
  align-items: center;
  gap: 1.25rem;
}

.topbar__meta a {
  color: rgba(255, 255, 255, 0.85);
}

.topbar__meta a:hover {
  color: var(--text-inverse);
  text-decoration: none;
}

@media (min-width: 768px) {
  .topbar__meta {
    display: flex;
  }
}

/* --- ярус 2: бренд + навигация --- */

.navbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  min-height: var(--header-h);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-right: auto;
  color: var(--text);
  /* Бренд не сжимаем: рядом стоит навигация с nowrap, и без этого
     флекс ужимает логотип в ноль, а название рассыпается по буквам */
  flex-shrink: 0;
}

.brand:hover {
  text-decoration: none;
}

/* Во флекс-контейнере ужимается <picture>, а не <img> внутри него */
.brand picture {
  display: block;
  flex-shrink: 0;
}

.brand img {
  width: 44px;
  height: auto;
  flex-shrink: 0;
}

.brand__text {
  display: none;
  min-width: 0;
  /* Без ограничения длинный слоган разваливается на шесть строк
     и растягивает всю шапку по высоте */
  max-width: 220px;
}

.brand__name {
  display: block;
  font-weight: 800;
  font-size: var(--fs-base);
  line-height: 1.15;
  color: var(--brand);
  letter-spacing: -0.01em;
}

.brand__tagline {
  /* Не больше двух строк — иначе слоган раздувает высоту всей шапки */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  line-height: 1.3;
}

@media (min-width: 480px) {
  .brand__text { display: block; }
}

@media (min-width: 768px) {
  .brand img { width: 56px; }
}

/* На средних экранах слоган только мешает навигации — прячем,
   название компании остаётся */


/* Основное меню — горизонтальное с 1280px */
.main-nav {
  display: none;
}

@media (min-width: 1280px) {
  /* Шапка в одну строку: логотип, навигация и кнопки на одном уровне.
     Слоган на десктопе прячем — он съедает ~200px, которых
     не хватает полным названиям разделов. */
  .brand__tagline {
    display: none;
  }

  .main-nav {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0;
  }

  .main-nav > li {
    position: relative;
    list-style: none;
  }

  .main-nav > li > a {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.7rem 0.55rem;
    font-size: var(--fs-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.01em;
    color: var(--text);
    border-radius: var(--radius-sm);
    /* Пункт не должен рваться на две строки — от этого шапка скачет по высоте */
    white-space: nowrap;
  }

  /* По умолчанию показываем полное название раздела */
  .nav-label-short { display: none; }
  .nav-label-full { display: inline; }

  .main-nav > li > a:hover,
  .main-nav > li[data-open="true"] > a {
    color: var(--brand);
    background: var(--brand-lighter);
    text-decoration: none;
  }

  .main-nav > li > a[aria-current="page"] {
    color: var(--brand);
  }

  /* Выпадающее подменю */
  .submenu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 260px;
    padding: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    list-style: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
  }

  /* У правых пунктов подменю раскрывается влево: иначе оно выходит
     за край экрана и на странице появляется горизонтальная прокрутка. */
  .main-nav > li:nth-last-child(-n + 3) .submenu {
    left: auto;
    right: 0;
  }

  .main-nav > li:hover .submenu,
  .main-nav > li:focus-within .submenu,
  .main-nav > li[data-open="true"] .submenu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .submenu a {
    display: block;
    padding: 0.55rem 0.75rem;
    font-size: var(--fs-sm);
    color: var(--text);
    border-radius: var(--radius-sm);
  }

  .submenu a:hover {
    background: var(--brand-lighter);
    color: var(--brand);
    text-decoration: none;
  }
}

/* 1280–1519px: семь полных заголовков в строку не помещаются даже во всю
   ширину экрана, поэтому здесь показываем короткие подписи из админки. */
@media (min-width: 1280px) and (max-width: 1799px) {
  .nav-label-full { display: none; }
  .nav-label-short { display: inline; }
}

/* На широких экранах пунктам меню можно дать больше воздуха */
@media (min-width: 1800px) {
  .main-nav > li > a {
    padding: 0.7rem 0.85rem;
    letter-spacing: 0.02em;
  }
}

/* Кнопки в шапке */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;             /* 44px — минимальная зона нажатия */
  height: 44px;
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: background var(--transition), color var(--transition);
}

.icon-btn:hover {
  background: var(--surface-alt);
  color: var(--brand);
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

/* --- поиск в шапке --- */

.header-search {
  display: none;
  align-items: center;
  gap: 0.4rem;
}

.header-search input {
  width: 160px;
  padding: 0.4rem 0.6rem;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  color: var(--text-inverse);
  font-size: var(--fs-xs);
}

.header-search input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.header-search input:focus {
  background: rgba(255, 255, 255, 0.2);
  outline-color: var(--accent);
}

.header-search button {
  color: rgba(255, 255, 255, 0.85);
  display: grid;
  place-items: center;
  padding: 0.25rem;
}

.header-search svg {
  width: 18px;
  height: 18px;
}

@media (min-width: 768px) {
  .header-search { display: flex; }
}

/* --- мобильная панель навигации --- */

.nav-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(88vw, 380px);
  z-index: 200;
  padding: 1rem var(--gutter) 3rem;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  overscroll-behavior: contain;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 240ms ease, visibility 240ms ease;
}

.nav-drawer[data-open="true"] {
  transform: translateX(0);
  visibility: visible;
}

.nav-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}

.nav-drawer ul {
  list-style: none;
}

.nav-drawer > ul > li {
  border-bottom: 1px solid var(--line);
}

.nav-drawer a {
  display: block;
  padding: 0.85rem 0;
  color: var(--text);
  font-weight: 600;
}

.nav-drawer .submenu a {
  padding: 0.6rem 0 0.6rem 1rem;
  font-weight: 400;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

/* Раскрывашка подменю на мобильном */
.nav-drawer__group > button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.85rem 0;
  font-weight: 600;
  text-align: left;
}

.nav-drawer__group > button svg {
  width: 18px;
  height: 18px;
  transition: transform var(--transition);
  flex-shrink: 0;
}

.nav-drawer__group[data-open="true"] > button svg {
  transform: rotate(180deg);
}

.nav-drawer__group > .submenu {
  display: none;
  padding-bottom: 0.5rem;
}

.nav-drawer__group[data-open="true"] > .submenu {
  display: block;
}

.nav-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(5, 39, 72, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}

.nav-overlay[data-open="true"] {
  opacity: 1;
  visibility: visible;
}

@media (min-width: 1280px) {
  .nav-toggle { display: none; }
}

/* Мега-меню — только на широких экранах.
   Ниже 1024px прячем и саму панель, и кнопку: иначе в шапке
   оказываются два одинаковых бургера. */
.megamenu {
  display: none;
}

[data-megamenu-toggle] {
  display: none;
}

@media (min-width: 1280px) {
  [data-megamenu-toggle] {
    display: grid;
  }

  .megamenu {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: block;
    padding: 2rem 0;
    background: var(--surface);
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition), visibility var(--transition);
  }

  .megamenu[data-open="true"] {
    opacity: 1;
    visibility: visible;
  }

  .megamenu__grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2.5rem 2rem;
    margin-top: 2rem;
  }

  .megamenu__col h3 {
    display: flex;
    align-items: flex-start;
    /* Два заголовка переносятся на вторую строку («Корпоративное управление»,
       «Акционерам и инвесторам»), и линии под ними разъезжались по высоте.
       Резервируем две строки во всех колонках — подчёркивания встают в ряд. */
    min-height: calc(2 * 1.3em);
    padding-bottom: 0.6rem;
    margin-bottom: 0.9rem;
    border-bottom: 2px solid var(--line);
    font-size: var(--fs-sm);
    line-height: 1.3;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .megamenu__col ul {
    list-style: none;
  }

  .megamenu__col li + li {
    margin-top: 0.5rem;
  }

  .megamenu__col a {
    font-size: var(--fs-sm);
    color: var(--text-muted);
  }

  .megamenu__col a:hover {
    color: var(--brand);
  }
}

/* ==========================================================================
   6. ПОДВАЛ
   ========================================================================== */

.site-footer {
  background: var(--brand-darker);
  color: rgba(255, 255, 255, 0.75);
  font-size: var(--fs-sm);
  padding-block: 2.5rem 0;
}

.footer-grid {
  display: grid;
  gap: 2rem;
}

@media (min-width: 640px) {
  .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .footer-grid {
    grid-template-columns: 1.4fr repeat(4, minmax(0, 1fr));
    gap: 2.5rem;
  }
}

.footer-brand img {
  width: 64px;
  margin-bottom: 1rem;
}

.footer-brand p + p {
  margin-top: 0.6rem;
}

.footer-col h3 {
  margin-bottom: 1rem;
  color: var(--text-inverse);
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.footer-col ul {
  list-style: none;
}

.footer-col li + li {
  margin-top: 0.55rem;
}

.site-footer a {
  color: rgba(255, 255, 255, 0.75);
}

.site-footer a:hover {
  color: var(--accent);
  text-decoration: none;
}

.footer-social {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.footer-social a {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
}

.footer-social a:hover {
  background: var(--brand-light);
  border-color: var(--brand-light);
  color: var(--text-inverse);
}

.footer-social svg {
  width: 18px;
  height: 18px;
}

.footer-bottom {
  margin-top: 2.5rem;
  padding-block: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  font-size: var(--fs-xs);
}

.footer-bottom__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

/* ==========================================================================
   7. КОМПОНЕНТЫ
   ========================================================================== */

/* --- кнопки --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.btn:hover {
  text-decoration: none;
}

/* Все кнопки на сайте выглядят одинаково: прозрачные, с рамкой в 2px,
   при наведении заливаются. Отличается только направление заливки —
   оно зависит от того, на светлой подложке кнопка или на тёмной.
   Никаких «главная сплошная / второстепенная контурная»: рядом стоящие
   кнопки должны быть неотличимы друг от друга. */
.btn--primary,
.btn--ghost,
.btn--white,
.btn--on-dark,
.btn--accent {
  background: transparent;
  border: 2px solid currentColor;
}

/* --- на светлой подложке: синяя рамка, при наведении синяя заливка --- */
.btn--primary,
.btn--ghost {
  color: var(--brand);
}

.btn--primary:hover,
.btn--ghost:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--text-inverse);
}

/* --- на тёмной подложке: белая рамка, при наведении белая заливка --- */
.btn--white,
.btn--on-dark {
  color: var(--text-inverse);
}

.btn--white:hover,
.btn--on-dark:hover {
  background: var(--surface);
  border-color: var(--surface);
  color: var(--brand);
}

/* --- на жёлтой подложке белая рамка не читается: берём тёмно-синий --- */
.btn--accent {
  color: var(--brand-darker);
}

.btn--accent:hover {
  background: var(--brand-darker);
  border-color: var(--brand-darker);
  color: var(--text-inverse);
}

.btn--block {
  width: 100%;
}

/* --- карточки --- */

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
}

.card:hover {
  border-color: var(--brand-light);
  box-shadow: var(--shadow);
}

.card__media {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--surface-sunk);
}

.card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 400ms ease;
}

.card:hover .card__media img {
  transform: scale(1.04);
}

.card__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 0.5rem;
  padding: 1.1rem;
}

.card__date {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.card__title {
  font-size: var(--fs-base);
  font-weight: 600;
  line-height: 1.4;
}

.card__title a {
  color: var(--text);
}

.card__title a:hover {
  color: var(--brand);
  text-decoration: none;
}

.card__footer {
  margin-top: auto;
  padding-top: 0.75rem;
}

/* --- хлебные крошки --- */






/* --- заголовок страницы --- */

.page-head {
  padding-block: 1.5rem 2rem;
  border-bottom: 1px solid var(--line);
}

.page-head h1 {
  margin-bottom: 0.5rem;
}

.page-head p {
  max-width: 70ch;
  color: var(--text-muted);
}

/* --- боковая навигация раздела --- */

.side-nav {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
}

.side-nav h3 {
  margin-bottom: 0.75rem;
  font-size: var(--fs-base);
  color: var(--brand);
}

.side-nav ul {
  list-style: none;
}

.side-nav li + li {
  margin-top: 0.2rem;
}

.side-nav a {
  display: block;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  color: var(--text);
}

.side-nav a:hover {
  background: var(--brand-lighter);
  color: var(--brand);
  text-decoration: none;
}

.side-nav a[aria-current="page"] {
  background: var(--brand);
  color: var(--text-inverse);
}

/* --- вложения (PDF и прочее) --- */

.attachment {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color var(--transition), background var(--transition);
}

.attachment:hover {
  border-color: var(--brand-light);
  background: var(--brand-lighter);
  text-decoration: none;
}

.attachment__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: var(--fs-xs);
  font-weight: 700;
}

.attachment__name {
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.attachment__meta {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.attachment-list {
  display: grid;
  gap: 0.6rem;
  list-style: none;
}

/* --- бейджи --- */

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 600;
  background: var(--surface-sunk);
  color: var(--text-muted);
}

.badge--active { background: var(--success-bg); color: var(--success); }
.badge--alert { background: var(--danger-bg); color: var(--danger); }
.badge--accent { background: #fdf3d0; color: #7a5c00; }

/* --- формы --- */

.field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.field label {
  font-size: var(--fs-sm);
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.6rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.field textarea {
  min-height: 120px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-lighter);
}

.field__error {
  font-size: var(--fs-xs);
  color: var(--danger);
}

/* Ханипот — прячем от людей, но не от ботов */
.field--honey {
  position: absolute;
  left: -9999px;
}

/* --- таблицы-реестры --- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.table {
  min-width: 640px;
  font-size: var(--fs-sm);
}

.table th,
.table td {
  padding: 0.8rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.table th {
  background: var(--surface-alt);
  font-weight: 600;
  white-space: nowrap;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: var(--brand-lighter);
}

/* --- пагинация --- */

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 2rem;
  list-style: none;
}

.pagination a,
.pagination span {
  display: grid;
  place-items: center;
  min-width: 44px;
  height: 44px;
  padding-inline: 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  color: var(--text);
}

.pagination a:hover {
  border-color: var(--brand);
  color: var(--brand);
  text-decoration: none;
}

.pagination .is-current {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--text-inverse);
  font-weight: 600;
}

/* --- уведомления и пустые состояния --- */

.alert {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  border-left: 4px solid var(--brand);
  background: var(--brand-lighter);
  font-size: var(--fs-sm);
}

.alert--danger {
  border-left-color: var(--danger);
  background: var(--danger-bg);
}

.alert--success {
  border-left-color: var(--success);
  background: var(--success-bg);
}

.empty-state {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-muted);
}

/* --- фильтры --- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.filters select,
.filters input {
  min-height: 44px;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

/* Табы-чипсы (периоды, разделы) */
.chips {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  list-style: none;
  scrollbar-width: thin;
}

.chips a {
  display: block;
  padding: 0.5rem 1rem;
  white-space: nowrap;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: var(--fs-sm);
  color: var(--text);
}

.chips a:hover {
  border-color: var(--brand);
  color: var(--brand);
  text-decoration: none;
}

.chips a[aria-current="true"] {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--text-inverse);
}

/* ==========================================================================
   8. УТИЛИТЫ
   ========================================================================== */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.no-scroll {
  overflow: hidden;
}

.stack > * + * {
  margin-top: 1rem;
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

/* Обрезка длинных заголовков в карточках */
.clamp-2,
.clamp-3 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.clamp-2 { -webkit-line-clamp: 2; line-clamp: 2; }
.clamp-3 { -webkit-line-clamp: 3; line-clamp: 3; }

/* ==========================================================================
   9. ПЕЧАТЬ
   ========================================================================== */

@media print {
  .site-header,
  .site-footer,
  .nav-drawer,
  .nav-overlay,
  .megamenu,
  .breadcrumbs {
    display: none !important;
  }

  body {
    font-size: 11pt;
    color: #000;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
  }
}
