@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@500;700;800&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;600&display=swap');

/* -------------------------------------------------------------------------
   1. Переменные дизайн-системы
   ------------------------------------------------------------------------- */
:root {
  /* Цвета */
  --color-bg: #f6f7f9;
  --color-surface: #ffffff;
  --color-text: #1f2937;
  --color-text-muted: #64748b;
  --color-accent: #2563eb;
  --color-accent-dark: #1d4ed8;
  --color-accent-soft: #e8f0fe;
  --color-border: #e2e6ec;
  --color-old-name: #94a3b8;

  /* Рекламные блоки — нейтральные, но заметные */
  --color-ad-bg: #f0f2f5;
  --color-ad-border: #d3d9e2;
  --color-ad-label: #8892a0;

  /* Бейджи типов организаций */
  --color-tszh: #2563eb;
  --color-zhsk: #7c3aed;
  --color-tsn: #0891b2;
  --color-snt: #16a34a;
  --color-dnp: #ea580c;
  --color-gsk: #be123c;

  /* Типографика */
  --font-display: 'Manrope', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Прочее */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 8px rgba(15, 23, 42, 0.04);
  --shadow-hover: 0 4px 16px rgba(15, 23, 42, 0.08);
  --header-height: 68px;
  --content-max: 1280px;
}

/* -------------------------------------------------------------------------
   2. Base reset
   ------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }
button { font-family: inherit; cursor: pointer; }
table { border-collapse: collapse; width: 100%; }

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* -------------------------------------------------------------------------
   3. Типографика
   ------------------------------------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--color-text);
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0;
}

h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); font-weight: 800; }
h2 { font-size: 1.4rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 700; }

p { margin: 0 0 1em; color: var(--color-text); }

.eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: 8px;
}

.mono { font-family: var(--font-mono); }

/* -------------------------------------------------------------------------
   4. Layout: header / nav / footer
   ------------------------------------------------------------------------- */
.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 20px;
}

/* --- Header --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border);
}

.site-header .container {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--color-text);
  white-space: nowrap;
}
.logo span { color: var(--color-accent); }

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.main-nav a {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-text-muted);
  transition: background 0.15s ease, color 0.15s ease;
}

.main-nav a:hover,
.main-nav a.active {
  color: var(--color-accent-dark);
  background: var(--color-accent-soft);
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  width: 40px;
  height: 40px;
  padding: 8px;
}
.nav-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--color-text);
  margin: 5px 0;
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* --- Footer --- */
.site-footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  margin-top: 56px;
  padding: 36px 0 24px;
}

.footer-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 20px;
}

.footer-links {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.footer-links a { color: var(--color-text-muted); font-size: 0.9rem; }
.footer-links a:hover { color: var(--color-accent-dark); }

.footer-copy {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  padding-top: 16px;
}

/* -------------------------------------------------------------------------
   5. Компоненты
   ------------------------------------------------------------------------- */

/* --- Hero --- */
.hero {
  padding: 48px 0 32px;
}

/* .hero-inner намеренно не переопределяет max-width — использует те же
   границы, что и класс .container (var(--content-max)) */

.hero p.lead {
  font-size: 1.1rem;
  color: var(--color-text-muted);
}

.hero-search {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  max-width: 560px;
}

/* --- Хлебные крошки --- */
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 14px 0 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.breadcrumbs a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.breadcrumbs a:hover {
  color: var(--color-accent-dark);
  text-decoration: underline;
}

.breadcrumbs [aria-current="page"] {
  color: var(--color-text);
  font-weight: 500;
}

.breadcrumbs-sep {
  color: var(--color-border);
}

.hero-search input {
  flex: 1;
  padding: 14px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-family: var(--font-body);
  background: var(--color-surface);
}
.hero-search input:focus { border-color: var(--color-accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 22px;
  border-radius: var(--radius-md);
  border: none;
  font-weight: 600;
  font-size: 0.98rem;
  background: var(--color-accent);
  color: #fff;
  transition: background 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--color-accent-dark); }
.btn:active { transform: translateY(1px); }

.btn-outline {
  background: transparent;
  color: var(--color-accent-dark);
  border: 1px solid var(--color-border);
}
.btn-outline:hover { background: var(--color-accent-soft); border-color: var(--color-accent); }

/* --- Двухколоночный layout: контент + рекламная колонка --- */
.page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  padding: 0 0 40px;
}

.feed-section h2 { margin-bottom: 4px; }
.section-sub {
  color: var(--color-text-muted);
  font-size: 0.92rem;
  margin-bottom: 20px;
}

/* --- Группы фильтров (регион / тип организации) --- */
.filters {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 22px;
}
.filter-group { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.filter-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

/* --- Фильтр-табы --- */
.filter-tabs {
  display: flex;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  padding-bottom: 4px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.filter-tabs::-webkit-scrollbar { display: none; }

.filter-tabs a,
.filter-tabs button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}
.filter-tabs a.active,
.filter-tabs button.active,
.filter-tabs a:hover,
.filter-tabs button:hover {
  border-color: var(--color-accent);
  color: var(--color-accent-dark);
  background: var(--color-accent-soft);
}

/* --- Карточка изменения (лента) --- */
.change-list { display: flex; flex-direction: column; gap: 12px; }

.change-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.change-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: #d3dcec;
}

.change-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.org-name { font-weight: 700; font-size: 1.02rem; }
.org-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* Бейдж типа организации — цвет зависит от типа */
.org-type {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
}
.org-type.tszh { background: var(--color-tszh); }
.org-type.zhsk { background: var(--color-zhsk); }
.org-type.tsn  { background: var(--color-tsn); }
.org-type.snt  { background: var(--color-snt); }
.org-type.dnp  { background: var(--color-dnp); }
.org-type.gsk  { background: var(--color-gsk); }

.detected-date {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  font-family: var(--font-mono);
}

/* Фирменный элемент: чип "было → стало" */
.change-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
}
.change-chip .old-name {
  color: var(--color-old-name);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}
.change-chip .arrow {
  color: var(--color-accent);
  font-weight: 700;
}
.change-chip .new-name {
  font-weight: 700;
  color: var(--color-text);
}

.change-card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}

.link-more {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-accent-dark);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.link-more:hover { text-decoration: underline; }

/* --- Пагинация-заглушка --- */
.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  row-gap: 10px;
  margin-top: 24px;
}
.pagination a,
.pagination button,
.pagination .disabled {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 0.9rem;
  color: var(--color-text-muted);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}
.pagination a:hover {
  border-color: var(--color-accent);
  color: var(--color-accent-dark);
  background: var(--color-accent-soft);
}
.pagination a.active,
.pagination button.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}
.pagination .disabled {
  color: var(--color-border);
  cursor: not-allowed;
  pointer-events: none;
}
.pagination .ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 38px;
  color: var(--color-text-muted);
  user-select: none;
}

/* --- Поисковая форма (search.html) --- */
.search-hero {
  padding: 56px 0 8px;
  text-align: center;
}
.search-hero .container { max-width: 720px; }
.search-hero p.lead { margin: 0 auto 28px; }

.search-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  text-align: left;
}

.search-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: var(--font-body);
}
.field input:focus { border-color: var(--color-accent); }

.search-box .btn { width: 100%; margin-top: 14px; }

.search-examples {
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.search-examples button {
  background: none;
  border: none;
  color: var(--color-accent-dark);
  font-weight: 600;
  padding: 0;
  margin-right: 4px;
}
.search-examples button:hover { text-decoration: underline; }

.results-heading {
  margin: 40px 0 16px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

/* --- Страница организации --- */
.org-header {
  padding: 40px 0 8px;
}
.org-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.org-inn-line {
  margin-top: 6px;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}
.org-inn-line .mono { color: var(--color-text); }

.info-strip {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  margin: 22px 0 30px;
  padding: 16px 20px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.info-item { display: flex; flex-direction: column; gap: 3px; }
.info-item .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  font-weight: 600;
}
.info-item .value { font-weight: 700; font-size: 0.98rem; }

/* --- Таблица истории изменений --- */
.history-table-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.history-table th {
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  font-weight: 600;
  padding: 14px 18px;
  background: #fafbfc;
  border-bottom: 1px solid var(--color-border);
}
.history-table td {
  padding: 16px 18px;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.95rem;
  vertical-align: top;
}
.history-table tr:last-child td { border-bottom: none; }
.history-table td.date-cell { font-family: var(--font-mono); color: var(--color-text-muted); white-space: nowrap; }
.history-table td .source-note { display: block; font-size: 0.8rem; color: var(--color-text-muted); margin-top: 4px; }

/* Мобильное представление таблицы (карточки) — активируется в media query */
.history-table td[data-label]::before {
  content: attr(data-label);
  display: none;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

/* -------------------------------------------------------------------------
   6. Рекламные блоки РСЯ
   ------------------------------------------------------------------------- */
.ad-block {
  background: var(--color-ad-bg);
  border: 1px dashed var(--color-ad-border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--color-ad-label);
  padding: 16px;
}

.ad-block .ad-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
  color: var(--color-ad-label);
}

.ad-block .ad-caption {
  font-size: 0.82rem;
  line-height: 1.4;
}

/* Вертикальный баннер: 300×600, адаптивный по высоте */
.ad-vertical {
  width: 100%;
  max-width: 300px;
  min-height: 250px;
  margin: 0 auto;
}
@media (min-width: 1025px) {
  .ad-vertical { min-height: 600px; position: sticky; top: calc(var(--header-height) + 20px); }
}

/* Горизонтальный баннер: 728×90, адаптивный */
.ad-horizontal {
  width: 100%;
  min-height: 90px;
  max-width: 728px;
  margin: 24px auto;
}

/* Встроенный в контент блок (между карточками ленты / строками таблицы) */
.ad-inline {
  width: 100%;
  min-height: 100px;
  margin: 4px 0;
}

/* Рекламная колонка сайта (обёртка над .ad-vertical) */
.ad-rail { display: none; }

/* Небольшой рекламный блок в футере */
.footer-ad {
  max-width: 480px;
  min-height: 70px;
  margin: 0 auto 20px;
}

/* -------------------------------------------------------------------------
   7. Утилиты
   ------------------------------------------------------------------------- */
.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;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* -------------------------------------------------------------------------
   8. Медиа-запросы
   ------------------------------------------------------------------------- */

/* ≤768px — мобильные: одна колонка, реклама встроена между блоками */
@media (max-width: 768px) {
  .main-nav {
    position: fixed;
    top: var(--header-height);
    left: 0; right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    flex-direction: column;
    align-items: stretch;
    padding: 10px 20px 16px;
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
  }
  .main-nav.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
  .main-nav a { padding: 12px 10px; }
  .nav-toggle { display: block; }

  .hero-search { flex-direction: column; }

  .search-fields { grid-template-columns: 1fr; }

  /* Таблица истории -> карточки */
  .history-table, .history-table thead, .history-table tbody, .history-table th, .history-table td, .history-table tr {
    display: block;
  }
  .history-table thead { display: none; }
  .history-table tr {
    border-bottom: 1px solid var(--color-border);
    padding: 14px 18px;
  }
  .history-table tr:last-child { border-bottom: none; }
  .history-table td {
    border-bottom: none;
    padding: 4px 0;
  }
  .history-table td[data-label]::before { display: block; }

  .change-card-top { flex-direction: column; }
  .detected-date { order: -1; }
}

/* 769–1024px — планшет: две колонки (контент + реклама) */
@media (min-width: 769px) and (max-width: 1024px) {
  .page-grid.with-rail {
    grid-template-columns: 1fr 240px;
  }
  .ad-rail { display: block; }
}

/* >1024px — десктоп: классическая раскладка */
@media (min-width: 1025px) {
  .page-grid.with-rail {
    grid-template-columns: 1fr 300px;
  }
  .ad-rail { display: block; }

  .search-fields { grid-template-columns: 1fr 1fr; }
}

/* Кликабельные название организации и ИНН в таблице ленты */
.history-table a.org-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dashed var(--color-border);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.history-table a.org-link:hover {
  color: var(--color-accent-dark);
  border-bottom-color: var(--color-accent);
}
