:root {
  --bg: #0e1116;
  --panel: #161b23;
  --panel-2: #1d2430;
  --line: #262e3a;
  --text: #e7ecf3;
  --muted: #8b97a8;
  --accent: #4ade80;
  --accent-dim: #16351f;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -200px, #1a2431 0%, var(--bg) 60%) no-repeat, var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 18px; }

/* ---------- шапка ---------- */
.top {
  border-bottom: 1px solid var(--line);
  background: rgba(14, 17, 22, .78);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 20;
}
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 18px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, #1f2b3a, #131922);
  border: 1px solid var(--line);
  color: var(--accent); font-size: 20px;
}
h1 { font-size: 17px; margin: 0; letter-spacing: .2px; font-weight: 650; }
.sub { margin: 1px 0 0; color: var(--muted); font-size: 12.5px; }
.live { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(74, 222, 128, .12); animation: pulse 2.4s infinite; }
@keyframes pulse { 50% { opacity: .45; } }

/* ---------- статистика ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 18px 0 14px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 2px;
}
.stat b { font-size: 21px; font-weight: 650; letter-spacing: -.2px; }
.stat span { color: var(--muted); font-size: 12px; }
.stat.accent b { color: var(--accent); }

/* ---------- фильтры ---------- */
.filters {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px;
}
.filters input[type="search"], .filters select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px; font: inherit; font-size: 13.5px; outline: none;
}
.filters input[type="search"] { flex: 1 1 240px; min-width: 180px; }
.filters input[type="search"]:focus, .filters select:focus { border-color: #3b4a5f; }
.check { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; padding: 0 4px; cursor: pointer; }
.check input { accent-color: var(--accent); }
.btn {
  background: var(--accent); color: #08130b; border: 0; border-radius: 10px;
  padding: 9px 16px; font: inherit; font-size: 13.5px; font-weight: 650; cursor: pointer;
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .5; cursor: default; }
.reset { color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }

.result-line { display: flex; justify-content: space-between; align-items: baseline; margin: 16px 2px 10px; color: var(--muted); font-size: 13px; }
.result-line b { color: var(--text); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- карточки ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: #3a4a60; transform: translateY(-1px); }
.card.is-new { border-color: #2c5138; box-shadow: inset 0 0 0 1px rgba(74, 222, 128, .10); }
.card-link { display: flex; flex-direction: column; flex: 1; }
.thumb { position: relative; aspect-ratio: 4 / 3; background: var(--panel-2); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.noimg { width: 100%; height: 100%; display: grid; place-items: center; color: #3d4a5c; font-size: 13px; letter-spacing: .5px; }
.badge {
  position: absolute; top: 8px; left: 8px; font-size: 11px; font-weight: 650;
  padding: 3px 8px; border-radius: 8px; backdrop-filter: blur(6px);
}
.badge.new { background: rgba(74, 222, 128, .16); color: var(--accent); border: 1px solid rgba(74, 222, 128, .35); }
.badge.drop { left: auto; right: 8px; background: rgba(251, 191, 36, .14); color: var(--warn); border: 1px solid rgba(251, 191, 36, .3); }

.body { padding: 11px 12px 8px; flex: 1; }
.price { font-size: 19px; font-weight: 700; letter-spacing: -.3px; display: flex; align-items: baseline; gap: 8px; }
.model { font-size: 11px; font-weight: 650; color: #9fb0c4; background: var(--panel-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; letter-spacing: .3px; }
.card h2 {
  font-size: 13.5px; font-weight: 450; line-height: 1.35; margin: 6px 0 8px; color: #c9d5e4;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; min-height: 54px;
}
.meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 11.5px; color: var(--muted); }
.meta .city { color: #a8b6c8; }
.spec { background: var(--panel-2); border-radius: 6px; padding: 1px 6px; }

.card-foot {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-top: 1px solid var(--line); font-size: 11.5px; color: var(--muted);
}
.src { text-transform: uppercase; letter-spacing: .6px; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 5px; }
.src-youla { background: #2a1d3d; color: #c4a7ff; }
.src-avito { background: #1d2f3d; color: #7dd3fc; }
.src-other { background: var(--panel-2); color: var(--muted); }
.score { margin-left: auto; font-weight: 700; color: #9fb0c4; }
.score::after { content: " /100"; font-weight: 400; color: #55637a; font-size: 10px; }

/* ---------- пусто / пагинация ---------- */
.empty {
  background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 40px 24px; text-align: center; color: var(--muted);
}
.empty .big { color: var(--text); font-size: 19px; font-weight: 650; margin: 0 0 6px; }
.empty .btn { margin-top: 14px; }

.pager { display: flex; gap: 16px; justify-content: center; align-items: center; margin: 22px 0; font-size: 13px; color: var(--muted); }
.pager a { border: 1px solid var(--line); padding: 7px 14px; border-radius: 10px; background: var(--panel); }

/* ---------- источники ---------- */
.health { margin: 34px 0 10px; border-top: 1px solid var(--line); padding-top: 16px; }
.health h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 650; margin: 0 0 10px; }
.health-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.health-item {
  display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 7px 11px; font-size: 12px;
}
.health-item b { font-size: 12px; }
.health-item.error { border-color: #5b2b2b; }
.health-item.error .err { color: var(--danger); }
.health-item .err { flex-basis: 100%; color: var(--danger); font-size: 11.5px; }

.foot { color: #5b6678; font-size: 11.5px; padding: 18px 0 40px; max-width: 760px; }

@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 9px; }
  .card h2 { font-size: 12.5px; min-height: 48px; }
  .price { font-size: 16px; }
  .top-inner { padding: 11px 14px; }
  .live { display: none; }
}

/* ---------- «почти подошли» ---------- */
.near { margin-top: 22px; }
.near h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 650; margin: 0 0 10px; }
.near-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.near-item { display: flex; gap: 12px; align-items: baseline; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.near-item:last-child { border-bottom: 0; }
.near-item:hover { background: var(--panel-2); }
.near-item .np { color: var(--warn); font-weight: 650; min-width: 92px; }
.near-item .nt { flex: 1; color: #c9d5e4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.near-item .nc { color: var(--muted); font-size: 11.5px; white-space: nowrap; }

.quick { margin-top: 30px; border-top: 1px solid var(--line); padding-top: 16px; }
.quick h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 650; margin: 0 0 10px; }
.quick-links { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-links a {
  border: 1px solid var(--line); background: var(--panel); border-radius: 10px;
  padding: 8px 12px; font-size: 12.5px; color: #b9c7d8;
}
.quick-links a:hover { border-color: #3a4a60; color: var(--accent); }

.callout {
  margin: 26px 0 0; padding: 14px 16px; border-radius: var(--radius);
  border: 1px solid #4a3a1c; background: rgba(251, 191, 36, .07);
  color: #d9c9a3; font-size: 12.5px; line-height: 1.5;
}
.callout b { color: #f2d08a; }
.callout code { background: rgba(0,0,0,.35); padding: 1px 6px; border-radius: 5px; font-size: 11.5px; color: #e7d7b0; }
