/* ==========================================================================
   1. Переменные и базовый сброс
   ========================================================================== */

:root {
  --accent: #00CF91;
  --accent-dark: #00A572;
  --bg-light: #f9f9f9;
  --text-main: #333;
}

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

body {
  font-family: "Segoe UI", Arial, sans-serif;
  margin: 0;
  padding: 0;
  line-height: 1.6;
  background-color: var(--bg-light);
  color: var(--text-main);
}

/* Общие заголовки и списки */

h1, h2, h3, h4 {
  margin: 0;
}

ul {
  list-style: none;
  padding-left: 20px;
  margin: 0;
}

/* ==========================================================================
   2. Каркас страницы (header, main, section)
   ========================================================================== */

header {
  background: var(--accent);
  color: #fff;
  padding: 4px 20px 10px;
  text-align: center;
}

header h1 {
  font-size: 24px;
  font-weight: 600;
  margin: 6px 0;
}

.header-link {
  color: #fff;
  text-decoration: none;
}

.header-link:hover {
  color: #e0fdf4;
  text-decoration: none;
}

.subtitle {
  max-width: 800px;
  margin: 6px auto 0;
  font-size: 15px;
}

.top-nav {
  margin-top: 4px;
}

.nav-link {
  color: #ffffff;
  text-decoration: none;
  font-size: 15px;
}

.nav-link:hover {
  color: #e0fdf4;
  text-decoration: none;
}

main {
  padding: 16px 24px 24px;
  max-width: 1200px;
  margin: 0 auto;
}

section {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 0 10px rgba(0, 0, 0, .1);
  margin-bottom: 25px;
}

h2 {
  color: #000;
  text-align: center;
  margin-bottom: 15px;
}

h3 {
  color: var(--accent-dark);
}

/* ==========================================================================
   3. Кнопки и ссылки-кнопки
   ========================================================================== */

button {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  transition: background .2s ease;
}

button:hover {
  background: var(--accent-dark);
}

.back-button {
  text-align: center;
  margin-top: 30px;
}

.button-link {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 10px 20px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 15px;
}

.button-link:hover {
  background: var(--accent-dark);
}

/* Кнопки для скачивания (узкие по умолчанию) */

.download-btn {
  text-align: right;
  margin-top: 10px;
}

.download-btn button {
  width: auto;
  padding: 8px 16px;
  font-size: 15px;
}

.download-top-form {
  margin: 0;
}

.download-top-btn {
  width: auto;
  padding: 8px 16px;
  font-size: 15px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.download-top-btn:hover {
  background: var(--accent-dark);
}

/* ==========================================================================
   4. Результаты поиска (списком и таблицей)
   ========================================================================== */

.results {
  margin-top: 10px;
}

.result-group {
  margin-bottom: 15px;
}

.source {
  color: #333;
  font-weight: 600;
}

/* Для списков результатов по слову */

.status-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.status-list li {
  background: #f9f9f9;
  margin-bottom: 6px;
  padding: 6px 10px;
  border-radius: 6px;
}

.status-label {
  font-weight: 600;
}

.note-line {
  font-style: italic;
  color: #777;
}

/* Общие li, не относящиеся к about */

li {
  background: #f2f2f2;
  margin-bottom: 8px;
  padding: 8px;
  border-radius: 6px;
}

/* Заголовок и таблица результатов фильтров */

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1px;
}

.table-wrapper {
  overflow-x: auto;
  margin-top: 4px;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-top: 1px;
  background: #fff;
  border: 1px solid #ccc;
}

.result-table th,
.result-table td {
  border: 1px solid #ccc;
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}

.result-table th {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-align: center;
}

.result-table tbody tr:nth-child(even) {
  background: #f9f9f9;
}

/* ==========================================================================
   5. Фильтры и формы
   ========================================================================== */

.search-section,
.filter-section {
  margin-bottom: 20px;
}

.search-form {
  position: relative;
}

.filter-card {
  border: 1px solid #E6E6E6;
  border-radius: 8px;
  padding: 1px 2px 2px 16px;
  margin-bottom: 4px;
  background: #fff;
}

.filter-legend {
  font-size: 18px;
  font-weight: 600;
  color: #222;
  margin: 0 0 2px;
  padding: 0 4px;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-column-gap: 12px;
  grid-row-gap: 1px;
}

.option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  line-height: 1.4;
}

.option.disabled {
  opacity: .55;
  cursor: not-allowed;
}

.option.disabled span {
  color: #999;
}

.option input[type="checkbox"] {
  position: relative;
  top: 1px;
  margin: 0;
}

.option span {
  display: inline-block;
  line-height: 1.4;
}

.option:hover {
  background: #FAFAFA;
}

.filter-card input[type="text"],
.search-form input[type="text"] {
  width: 100%;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 15px;
}

/* Последняя карточка — поле "Содержит" */

.filter-card:last-of-type {
  border: none;
  background: transparent;
  padding: 0;
  margin-top: 8px;
}

.filter-card:last-of-type .filter-legend {
  margin-bottom: 6px;
  padding-left: 21px;
}

/* Режимы фильтров (радиокнопки и чекбоксы в строку) */

.mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 3px 4px 2px 4px;
  margin-top: 3px;
  font-size: 14px;
  color: #444;
}

.mode-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
  cursor: pointer;
}

.mode-row input[type="radio"],
.mode-row input[type="checkbox"] {
  position: relative;
  top: 1px;
  margin: 0;
}

.ab-grid {
  margin-top: 6px;
}

/* Блок исключаемых источников */

#exclude-block {
  display: none;
  margin-top: 6px;
}

#exclude-block[hidden] {
  display: none !important;
}

/* Сообщение об ошибке в фильтрах */

.inline-error {
  color: #c0392b;
  margin: 8px 0 12px;
  font-size: 14px;
}

/* ==========================================================================
   6. Автодополнение
   ========================================================================== */

#autocomplete-list {
  position: absolute;
  left: 0;
  right: 0;
  width: 100%;
  background: #fff;
  border: 1px solid #ccc;
  border-top: 0;
  border-radius: 0 0 6px 6px;
  z-index: 10;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .1);
  padding: 0;
  margin-top: 2px;
  max-height: 240px;
  overflow-y: auto;
}

#autocomplete-list:empty {
  display: none;
}

.suggestion {
  list-style: none;
  padding: 6px 12px;
  margin: 0;
  cursor: pointer;
  border: none;
  background: transparent;
  transition: background 0.15s ease;
}

.suggestion + .suggestion {
  border-top: 1px solid #eee;
}

.suggestion:hover {
  background: var(--accent);
  color: #fff;
}

/* ==========================================================================
   7. Подсказки (иконки "?")
   ========================================================================== */

.help-wrapper {
  display: inline-block;
  position: relative;
  margin-left: 6px;
}

.help-icon {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  font-size: 11px;
  line-height: 1;
  cursor: help;
  background: #fff;
  color: var(--accent);
  font-weight: 600;
}

.help-icon:focus {
  outline: none;
}

.help-text {
  position: absolute;
  left: 0;
  top: 140%;
  min-width: 220px;
  max-width: 280px;
  padding: 8px 10px;
  background: #333;
  color: #fff;
  font-size: 13px;
  line-height: 1.4;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
  z-index: 20;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity .15s ease, transform .15s ease, visibility .15s ease;
}

.help-text::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 10px;
  border-width: 0 6px 6px 6px;
  border-style: solid;
  border-color: transparent transparent #333 transparent;
}

.help-wrapper:hover .help-text,
.help-wrapper:focus-within .help-text {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* ==========================================================================
   8. Страница "О базе" (about)
   ========================================================================== */

.about-text p {
  margin: 0 0 8px;
}

.about-text ul {
  list-style: disc;
  padding-left: 24px;
  margin: 4px 0 8px;
}

.about-text li {
  background: transparent;
  padding: 0;
  margin-bottom: 4px;
  border-radius: 0;
}

.about-nav {
  margin: 12px 0 20px;
  padding-left: 4px;
  border-left: 3px solid var(--accent);
}

.about-nav ul {
  list-style: none;
  padding-left: 12px;
  margin: 0;
}

.about-nav li {
  background: transparent;
  padding: 0;
  margin: 2px 0;
  border-radius: 0;
}

.about-nav a,
.about-nav a:visited {
  text-decoration: none;
  color: #333;
  font-size: 15px;
}

.about-nav a:hover {
  color: var(--accent-dark);
}

/* ==========================================================================
   9. Адаптивность
   ========================================================================== */

/* --- До 768px: планшеты и крупные телефоны --- */

@media (max-width: 768px) {
  main {
    padding: 12px 12px 16px;
  }

  section {
    padding: 16px;
    margin-bottom: 20px;
  }

  header {
    padding: 4px 12px 10px;
  }

  header h1 {
    font-size: 20px;
  }

  .subtitle {
    padding: 0 8px;
    font-size: 14px;
  }

  .options-grid {
    grid-template-columns: 1fr;
  }

  .about-nav a,
  .about-nav a:visited {
    font-size: 14px;
  }

  .about-text {
    font-size: 15px;
    line-height: 1.5;
  }

  .about-text p {
    margin: 0 0 6px;
  }

  .about-text ul {
    margin: 2px 0 6px;
    padding-left: 20px;
  }
}

/* --- До 600px: телефоны (узкие экраны) --- */

@media (max-width: 600px) {
  .results-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .download-top-btn {
    width: 100%;
  }

  .button-link {
    width: 100%;
    text-align: center;
  }

  .about-nav {
    padding-left: 0;
    border-left: none;
    border-top: 1px solid #e5e5e5;
    padding-top: 8px;
  }

  .about-nav ul {
    padding-left: 0;
  }

  .about-nav li {
    margin: 3px 0;
  }

  header h1 {
    font-size: 18px;
  }
}
