:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #1d2129;
  --muted: #6b7280;
  --border: #e3e5e9;
  --accent: #c0392b;
  --accent-soft: #fbeceb;
  --head: #1f2430;
  --head-text: #f5f6f8;
  --row-alt: #fafbfc;
  --row-hover: #fff6e5;
  --link: #1b5fb4;
  --raw: #2e7d32;
  --wraps: #00838f;
  --single: #6a1b9a;
  --multi: #ad1457;
  --unl: #5d4037;
  --female: #d6336c;
  --male: #1c7ed6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141a;
    --panel: #1b1e26;
    --text: #e6e8ec;
    --muted: #9aa1ad;
    --border: #2c303b;
    --accent: #e0584a;
    --accent-soft: #3a2220;
    --head: #0c0e12;
    --row-alt: #1f222b;
    --row-hover: #2e2a20;
    --link: #74a9ff;
    --raw: #66bb6a;
    --wraps: #4dd0e1;
    --single: #ce93d8;
    --multi: #f48fb1;
    --unl: #bcaaa4;
    --female: #f783ac;
    --male: #74c0fc;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- шапка ---------- */
.top {
  background: var(--head);
  color: var(--head-text);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 20px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.logo { color: var(--head-text); font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.logo:hover { text-decoration: none; }
.logo-mark { width: 28px; height: 28px; display: block; flex: none; }
.logo-tld { color: #9aa1ad; font-weight: 500; }
.top nav { display: flex; gap: 2px; }
.top nav a { color: #c9ced8; padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
.top nav a:hover { background: #2c3240; text-decoration: none; color: #fff; }
.top nav a.active { background: var(--accent); color: #fff; }
.search { margin: 0 0 0 auto; position: relative; width: min(340px, 100%); }
.search input {
  width: 100%; padding: 7px 10px; border-radius: 6px; border: 1px solid #3a4050;
  background: #2a2f3b; color: #fff; font-size: 16px;
}
.search input::placeholder { color: #8b92a0; }
.search-results {
  position: absolute; right: 0; top: calc(100% + 4px); width: 100%; min-width: 300px;
  background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); max-height: 70vh; overflow: auto; z-index: 30;
}
.search-results .group { padding: 6px 12px; font-size: 11px; text-transform: uppercase; color: var(--muted); background: var(--row-alt); }
.search-results a { display: block; padding: 7px 12px; color: var(--text); }
.search-results a:hover, .search-results a.sel { background: var(--row-hover); text-decoration: none; }
.search-results .sub { color: var(--muted); font-size: 12px; }

/* ---------- основное ---------- */
main { flex: 1; padding: 16px 20px 30px; width: 100%; max-width: 1600px; margin: 0 auto; transition: opacity .15s; }
main.loading { opacity: .45; pointer-events: none; }
h1 { font-size: 24px; margin: 4px 0 8px; line-height: 1.25; }
h2 { font-size: 17px; margin: 22px 0 8px; }
.lead { color: var(--muted); max-width: 900px; margin: 0 0 14px; }
.subtitle { color: var(--muted); margin-bottom: 14px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.crumbs a { color: var(--muted); }
.prose { max-width: 900px; }
.prose p, .prose li { line-height: 1.6; }
blockquote { margin: 8px 0; padding: 8px 14px; border-left: 3px solid var(--accent); background: var(--panel); font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

/* ---------- фильтры ---------- */
.filters {
  display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: flex-end;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 12px;
}
.filters label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.filters select, .filters input[type=text], .filters input[type=search] {
  font-size: 14px; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); min-width: 110px; max-width: 240px; height: 34px;
}
.filters input[type=search] { min-width: 200px; }
.filters .check { flex-direction: row; align-items: center; gap: 6px; text-transform: none; font-size: 14px; color: var(--text); padding-bottom: 7px; letter-spacing: 0; }
.filters .spacer { flex: 1; }
.filters-toggle { display: none; }

.toolbar { display: flex; align-items: center; gap: 10px; margin: 6px 0 8px; flex-wrap: wrap; }
.toolbar .count { color: var(--muted); }
.pager { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.pageinfo { color: var(--muted); padding: 0 4px; white-space: nowrap; }
button, .btn {
  font: inherit; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); cursor: pointer; display: inline-block; line-height: 1.45; white-space: nowrap;
}
.btn:hover, button:hover { border-color: var(--accent); text-decoration: none; }
.btn.disabled { opacity: .4; cursor: default; pointer-events: none; }
.btn.active { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; -webkit-overflow-scrolling: touch; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 9px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--border); background: var(--panel); }
th { background: var(--row-alt); font-size: 12px; color: var(--muted); font-weight: 600; }
tbody tr:nth-child(even) td { background: var(--row-alt); }
tbody tr:hover td { background: var(--row-hover); }
td.num, th.num { text-align: right; }
td.rank { color: var(--muted); text-align: right; }
.strong { font-weight: 700; }
td.sorted { font-weight: 700; color: var(--accent); }
td.name a { font-weight: 600; }
td.meet { max-width: 380px; overflow: hidden; text-overflow: ellipsis; }
tr.group-head td { background: var(--accent-soft) !important; font-weight: 700; color: var(--text); padding-top: 9px; }
table.records td { vertical-align: top; white-space: normal; min-width: 130px; }
@media (max-width: 760px) { table.records td { min-width: 112px; font-size: 13px; } }
.eq { font-size: 12px; font-weight: 600; }
.eq-Raw { color: var(--raw); }
.eq-Wraps { color: var(--wraps); }
.eq-Single-ply { color: var(--single); }
.eq-Multi-ply { color: var(--multi); }
.eq-Unlimited { color: var(--unl); }
.sex-F { color: var(--female); }
.sex-M { color: var(--male); }
.muted { color: var(--muted); }
.dq td { color: var(--muted); }
.dq td.num { text-decoration: line-through; }
ul.results { padding-left: 18px; columns: 2 280px; }
ul.results li { margin: 3px 0; break-inside: avoid; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 10px 0 4px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.card .k { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: .3px; }
.card .v { font-size: 22px; font-weight: 700; margin-top: 2px; }
.card .v.small { font-size: 16px; }
.empty { color: var(--muted); padding: 30px; text-align: center; }
.empty h1 { color: var(--text); }

/* ---------- подвал ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--panel); color: var(--muted); font-size: 12.5px; }
.footer-inner { max-width: 1600px; margin: 0 auto; padding: 16px 20px 20px; display: grid; grid-template-columns: 2fr 1fr; gap: 10px 40px; }
.footer-inner p { margin: 0 0 8px; line-height: 1.55; }

/* ---------- мобильная версия ---------- */
@media (max-width: 760px) {
  .top { flex-wrap: wrap; padding: 8px 12px; gap: 6px 10px; }
  .logo { font-size: 16px; }
  .top nav { order: 3; width: 100%; overflow-x: auto; margin: 0 -4px; scrollbar-width: none; }
  .top nav::-webkit-scrollbar { display: none; }
  .top nav a { padding: 5px 9px; }
  .search { order: 2; width: auto; flex: 1; min-width: 150px; }
  .search-results { position: fixed; left: 8px; right: 8px; top: auto; width: auto; min-width: 0; }
  main { padding: 10px 10px 24px; }
  h1 { font-size: 20px; }
  .filters-toggle {
    display: block; width: 100%; text-align: left; margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis;
    background: var(--panel); position: relative; padding-right: 30px;
  }
  .filters-toggle::after { content: "▾"; position: absolute; right: 12px; }
  .filters-toggle[aria-expanded="true"]::after { content: "▴"; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; padding: 10px; }
  .filters-toggle + .filters { display: none; }
  .filters-toggle[aria-expanded="true"] + .filters { display: grid; }
  .filters button, .filters .btn { align-self: end; text-align: center; }
  .filters label { min-width: 0; }
  .filters select, .filters input[type=search] { max-width: none; width: 100%; min-width: 0; font-size: 16px; }
  .filters .check, .filters .spacer, .filters label:has(input[type=search]) { grid-column: 1 / -1; }
  .filters .spacer { display: none; }
  .pager { margin-left: 0; width: 100%; justify-content: space-between; }
  .hm { display: none; }
  th, td { padding: 6px 6px; }
  td.name { position: sticky; left: 0; z-index: 1; max-width: 140px; overflow: hidden; text-overflow: ellipsis; box-shadow: 1px 0 0 var(--border); }
  thead th:nth-child(2) { position: sticky; left: 0; z-index: 2; }
  .rank-table td.rank { padding-right: 4px; }
  td.meet { max-width: 200px; }
  .footer-inner { grid-template-columns: 1fr; padding: 14px 12px; }
}

/* якорные ссылки не прячутся под закреплённой шапкой */
[id] { scroll-margin-top: 70px; }
@media (max-width: 760px) { [id] { scroll-margin-top: 120px; } blockquote { white-space: normal; word-break: break-word; } }

/* блок «Поддержать проект» */
.support { background: var(--accent-soft); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; }
.support p { margin: 0 0 8px; }
.support p:last-child { margin-bottom: 0; }
.support-btn { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.support-btn:hover { color: #fff; filter: brightness(1.08); }
.prose .support { max-width: 560px; }
.footer-copy { margin-top: 4px !important; }

/* кнопка «Показать»: без JS видна всегда; с JS — только на телефоне (там фильтры применяются по кнопке) */
.apply-btn { font-weight: 600; }
.js .apply-btn { display: none; }
@media (max-width: 760px) {
  .js .apply-btn { display: block; grid-column: 1 / -1; background: var(--accent); border-color: var(--accent); color: #fff; padding: 10px; font-size: 16px; }
  .filters .btn { text-align: center; }
}
