:root {
  --bg: #ffffff;
  --surface: #fafafa;
  --ink: #18181b;
  --muted: #71717a;
  --line: #e4e4e7;
  --accent: #18181b;
  --accent-ink: #ffffff;

  --ok-bg: #dcfce7;   --ok-fg: #15803d;
  --low-bg: #fef9c3;  --low-fg: #a16207;
  --mid-bg: #ffedd5;  --mid-fg: #c2410c;
  --hi-bg: #fee2e2;   --hi-fg: #b91c1c;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(24, 24, 27, .06);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

main.container { flex: 1 0 auto; padding-bottom: 48px; }

h1, h2, h3 { line-height: 1.25; font-weight: 700; }
h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); margin: 28px 0 12px; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; margin: 0 0 8px; }

a { color: inherit; text-decoration: none; }
p a, .about-block a { text-decoration: underline; text-underline-offset: 3px; }

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

/* ---------- Шапка ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 60px;
}

.logo { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.logo-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 800; align-self: center;
}
.logo-text { font-size: 1.1rem; font-weight: 700; }
.logo-text b { color: var(--muted); font-weight: 700; }
.logo-sub { color: var(--muted); font-size: .8rem; }

.nav { display: flex; gap: 22px; }
.nav a {
  color: var(--muted);
  font-size: .95rem;
  padding: 6px 2px;
  border-bottom: 2px solid transparent;
}
.nav a:hover { color: var(--ink); }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 1rem;
  cursor: pointer;
}

/* ---------- Hero ---------- */

.hero { padding: 44px 0 8px; max-width: 720px; }
.hero .lead { color: var(--muted); font-size: 1.05rem; margin: 10px 0 20px; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.chip {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 600;
}
.chip-total { background: var(--surface); color: var(--muted); }
.chip-ok  { background: var(--ok-bg);  color: var(--ok-fg); }
.chip-low { background: var(--low-bg); color: var(--low-fg); }
.chip-mid { background: var(--mid-bg); color: var(--mid-fg); }
.chip-hi  { background: var(--hi-bg);  color: var(--hi-fg); }

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

.filters { padding: 18px 0 4px; }

.filters-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filters-form input[type="search"] { flex: 2 1 240px; }
.filters-form select { flex: 1 1 160px; }

input, select, textarea {
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(24, 24, 27, .08);
}
textarea { resize: vertical; width: 100%; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
  font-weight: 600;
  font-size: .92rem;
  cursor: pointer;
  transition: transform .06s, background .15s, border-color .15s;
}
.btn:hover { border-color: var(--ink); }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { opacity: .85; }

.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); }

.btn-danger { background: var(--hi-bg); color: var(--hi-fg); border-color: transparent; }
.btn-outline { background: transparent; }

.btn-small { padding: 5px 10px; font-size: .8rem; border-radius: 8px; }
.btn-block { width: 100%; }

/* ---------- Каталог ---------- */

.result-count { margin: 18px 0 10px; font-size: .88rem; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--ink); transform: translateY(-2px); }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-weight: 700;
  font-size: 1.02rem;
}
.card-title { margin: 2px 0 0; font-size: 1.02rem; }
.card-title a:hover { text-decoration: underline; text-underline-offset: 3px; }
.card-cat { margin: 0; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.card-desc { margin: 4px 0 8px; font-size: .9rem; color: #3f3f46; flex-grow: 1; }
.card-more { font-size: .85rem; font-weight: 600; align-self: flex-start; }
.card-more:hover { text-decoration: underline; text-underline-offset: 3px; }

.card-badge-link { display: block; border-radius: var(--radius); overflow: hidden; margin-bottom: 6px; }
.card-badge-img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-ok  { background: var(--ok-bg);  color: var(--ok-fg); }
.badge-low { background: var(--low-bg); color: var(--low-fg); }
.badge-mid { background: var(--mid-bg); color: var(--mid-fg); }
.badge-hi  { background: var(--hi-bg);  color: var(--hi-fg); }

.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* ---------- Страница добавки ---------- */

.breadcrumbs { margin-top: 20px; font-size: .9rem; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--ink); }

/* Верх страницы добавки: бейдж-картинка + заголовок + параметры */
.detail-top {
  display: flex;
  gap: 28px;
  align-items: flex-start;
  margin-top: 16px;
}
.detail-top .detail-badge {
  flex: 0 0 min(320px, 42%);
  max-width: 320px;
}
.detail-top .detail-badge img {
  width: 100%;
  height: auto;
  border-radius: var(--radius);
}
.detail-top .detail-head {
  display: block;
  flex: 1 1 auto;
  min-width: 260px;
}
.detail-top .detail-head h1 { margin: 4px 0 14px; }

.detail-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  margin: 0;
}
.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 1rem;
  color: var(--muted);
}
.meta-item strong { color: var(--ink); font-weight: 700; }
.meta-symbol { font-size: 1.35rem; line-height: 1; }
.meta-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: .95rem;
  font-weight: 800;
}

@media (max-width: 720px) {
  .detail-top { flex-direction: column; }
  .detail-top .detail-badge { flex-basis: auto; width: 100%; max-width: 320px; }
}

.detail-head {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.detail-code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -.03em;
}
.detail-head > div:nth-child(2) { flex: 1 1 260px; }
.detail-head h1 { margin: 0; }

.detail-section {
  padding: 20px;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.detail-section p { margin: 0; }

.danger-block {
  background: #fff1f2;
  border-color: #fecdd3;
}
.danger-block h2 { color: #be123c; }

.benefit-block {
  background: #f0fdf4;
  border-color: #bbf7d0;
}
.benefit-block h2 { color: #15803d; }

.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; }
.tag {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: .84rem;
}

.related { margin-top: 36px; }
.cards-compact { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 14px; }
.mini-card {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: .9rem;
  background: #fff;
  transition: border-color .15s;
}
.mini-card:hover { border-color: var(--ink); }
.mini-card b { font-family: ui-monospace, Consolas, monospace; }
.mini-card .badge { font-size: .68rem; padding: 2px 7px; vertical-align: middle; margin-left: 4px; }

/* ---------- Сортировка ---------- */

.sort-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0 4px;
  flex-wrap: wrap;
}
.sort-label {
  font-size: .88rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.sort-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sort-btn {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 600;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  transition: all .15s;
}
.sort-btn:hover { border-color: var(--ink); color: var(--ink); }
.sort-btn.is-active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

/* ---------- О классификации ---------- */

.about-block {
  margin: 56px 0 0;
  padding-top: 32px;
  border-top: 1px solid var(--line);
  max-width: 760px;
}
.range-list { padding-left: 20px; }
.range-list li { margin: 4px 0; }

/* ---------- Формы / админка ---------- */

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.admin-head h1 { margin: 24px 0 12px; }
.admin-head .btn { margin-top: 24px; }

.form-card {
  max-width: 720px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  margin-top: 16px;
}
.form-narrow { max-width: 440px; }

.form-card label {
  display: block;
  font-size: .88rem;
  font-weight: 600;
  margin-bottom: 14px;
}
.form-card input:not([type="hidden"]),
.form-card select,
.form-card textarea {
  width: 100%;
  margin-top: 5px;
  font-weight: 400;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

.form-actions { display: flex; gap: 10px; margin-top: 6px; }

.hint { font-size: .84rem; color: var(--muted); margin-top: 16px; }
.hint code { background: #f4f4f5; padding: 2px 6px; border-radius: 6px; }

.auth-card {
  max-width: 420px;
  margin: 64px auto;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-card h1 { margin: 0 0 4px; font-size: 1.4rem; }
.auth-card label { display: block; font-size: .88rem; font-weight: 600; margin: 14px 0; }
.auth-card input { width: 100%; margin-top: 5px; font-weight: 400; }

/* ---------- Таблица ---------- */

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

.table { width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 680px; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table thead th { background: var(--surface); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface); }
.ta-r { text-align: right !important; }

.actions-cell { white-space: nowrap; }
.actions-cell form { display: inline-block; margin-left: 4px; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  font-size: .9rem;
}

/* ---------- Flash и служебное ---------- */

.flashes { margin-top: 16px; }
.flash {
  padding: 11px 16px;
  border-radius: var(--radius);
  font-size: .92rem;
  margin-bottom: 8px;
}
.flash-ok  { background: var(--ok-bg);  color: var(--ok-fg); }
.flash-err { background: var(--hi-bg);  color: var(--hi-fg); }

/* ---------- Подвал ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 22px 0;
  font-size: .84rem;
  color: var(--muted);
}
.footer-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.site-footer p { margin: 2px 0; }

/* ---------- Адаптив ---------- */

@media (max-width: 720px) {
  .nav {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: 8px 20px 16px;
  }
  .nav.open { display: flex; }
  .nav a { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .nav-toggle { display: block; }

  .form-grid { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; }
  .detail-head { gap: 12px; }
}

/* ---------- SEO-блоки: FAQ и оценка опасности ---------- */

.seo-faq {
  margin-top: 40px;
  max-width: 760px;
}
.seo-faq h2 { margin-bottom: 14px; }

.faq-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px 18px;
  margin-bottom: 10px;
}
.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  font-size: .95rem;
  list-style-position: outside;
}
.faq-item[open] summary { margin-bottom: 6px; }
.faq-item p {
  margin: 8px 0 4px;
  color: #3f3f46;
  font-size: .92rem;
}

.assess-block {
  background: var(--surface);
}

.detail-faq { max-width: none; }

/* ---------- Рекламные блоки ---------- */

.ad-zone {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  align-items: center;
  margin: 36px auto;
  width: 100%;
}
/* Позиция без контента: зарезервированное пустое место на странице */
.ad-zone.is-empty {
  display: block;
  min-height: 110px;
}

.ad-banner {
  max-width: 100%;
  overflow-x: auto;
}
.ad-banner img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

.ad-zone[data-ad-position="footer"] { margin-top: 24px; margin-bottom: 0; }
.ad-zone[data-ad-position="index"]  { margin-top: 44px; }

/* ---------- Админка: реклама ---------- */

.thumb {
  display: block;
  width: 84px;
  height: 44px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.current-ad-img {
  display: block;
  max-width: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: -6px 0 14px;
}

.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 10px;
  font-weight: 400 !important;
}
.checkbox-row input[type="checkbox"] {
  width: 18px !important;
  height: 18px;
  margin: 0 !important;
  accent-color: var(--accent);
}
.checkbox-tall { align-self: end; padding-bottom: 18px; }

/* ---------- Статус по странам ---------- */

.countries-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.country-title {
  font-size: .95rem;
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--line);
}
.country-title.allowed { color: #15803d; border-color: #bbf7d0; }
.country-title.banned  { color: #b91c1c; border-color: #fecdd3; }

.country-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.country-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
  font-size: .9rem;
}
.country-list li:last-child { border-bottom: none; }
.country-list li.muted { justify-content: flex-start; font-size: .85rem; }
.ok-note { color: var(--ok-fg); }

.flag {
  width: 24px;
  height: 16px;
  flex-shrink: 0;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(24, 24, 27, .18), 0 1px 1px rgba(24, 24, 27, .08);
}

@media (max-width: 720px) {
  .countries-grid { grid-template-columns: 1fr; }
}
