:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8ee;
  --text: #16212b;
  --muted: #6b7d8c;
  --accent: #0f7b6c;
  --accent-soft: #e6f4f1;
  --accent-text: #0b5f53;
  --new: #b4530a;
  --new-soft: #fdf1e3;
  --shadow: 0 1px 2px rgba(16, 33, 43, .06), 0 4px 12px rgba(16, 33, 43, .05);
  --shadow-hover: 0 2px 6px rgba(16, 33, 43, .09), 0 12px 28px rgba(16, 33, 43, .10);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10161c;
    --surface: #182028;
    --surface-2: #1e2831;
    --border: #2b3742;
    --text: #e6edf3;
    --muted: #93a4b3;
    --accent: #35b3a0;
    --accent-soft: #17302c;
    --accent-text: #6fd9c7;
    --new: #f0a35e;
    --new-soft: #33240f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 12px rgba(0, 0, 0, .25);
    --shadow-hover: 0 2px 6px rgba(0, 0, 0, .35), 0 12px 28px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }

/* ---------- Header ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 62px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 10px; margin-right: auto; }
.brand strong { font-size: 19px; letter-spacing: -.02em; }
.brand span { color: var(--muted); font-size: 13px; }
.header-nav { display: flex; gap: 6px; align-items: center; }
.header-nav a {
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--muted);
}
.header-nav a:hover { background: var(--surface-2); color: var(--text); }
.header-nav a.on { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }

/* ---------- Filters ---------- */
.filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 20px 0;
}
.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 12px;
}
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 600;
}
.field.wide { grid-column: span 2; }
.pair { display: flex; gap: 6px; align-items: center; }
.pair input { flex: 1 1 0; min-width: 0; }

input, select, button {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 0;
}
input:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  background: var(--surface);
}
select { appearance: none; padding-right: 26px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.filters-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
  flex-wrap: wrap;
}
.btn {
  cursor: pointer;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.btn:hover { border-color: var(--muted); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { filter: brightness(1.08); }
.result-count { margin-left: auto; color: var(--muted); font-size: 14px; }
.result-count b { color: var(--text); }

/* ---------- Card grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: transform .16s ease, box-shadow .16s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }

.card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
  overflow: hidden;
}
.card-media img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.card-media .no-photo {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  color: var(--muted); font-size: 13px;
}
.badges {
  position: absolute; top: 9px; left: 9px;
  display: flex; gap: 6px; flex-wrap: wrap;
}
.badge {
  font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  background: rgba(255, 255, 255, .94);
  color: #16212b;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
  letter-spacing: .02em;
}
.badge-new { background: var(--new); color: #fff; }
.badge-src { background: rgba(15, 30, 40, .82); color: #fff; }

.card-body { padding: 13px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.price { font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.price small { font-size: 12.5px; font-weight: 500; color: var(--muted); margin-left: 5px; }
.card-title {
  font-size: 14.5px; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.loc { font-size: 13px; color: var(--muted); display: flex; gap: 5px; }
.loc svg { flex: none; margin-top: 2px; opacity: .7; }
.specs {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: auto; padding-top: 4px;
}
.spec {
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  color: var(--muted);
}
.spec b { color: var(--text); font-weight: 600; }
.card-foot {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 9px;
}

/* ---------- Pagination ---------- */
.pager { display: flex; gap: 6px; justify-content: center; align-items: center; margin: 8px 0 40px; flex-wrap: wrap; }
.pager a, .pager span {
  min-width: 38px; text-align: center;
  padding: 8px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
}
.pager a:hover { border-color: var(--accent); color: var(--accent-text); }
.pager .cur { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.pager .gap { border: 0; background: none; min-width: 16px; padding: 8px 2px; color: var(--muted); }

/* ---------- Empty ---------- */
.empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 56px 24px;
  text-align: center;
  color: var(--muted);
  margin-bottom: 32px;
}
.empty h2 { color: var(--text); margin: 0 0 8px; font-size: 18px; }

/* ---------- Detail page ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr); gap: 22px; margin: 20px 0 40px; }
@media (max-width: 900px) { .detail { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.panel + .panel { margin-top: 18px; }
.panel h2 { margin: 0 0 14px; font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.gallery { display: grid; gap: 8px; grid-template-columns: repeat(4, 1fr); }
.gallery a:first-child { grid-column: span 4; }
.gallery img { width: 100%; border-radius: 8px; display: block; aspect-ratio: 4/3; object-fit: cover; background: var(--surface-2); }
.gallery a:first-child img { aspect-ratio: 16/10; }

.detail h1 { font-size: 23px; line-height: 1.28; margin: 0 0 10px; letter-spacing: -.02em; }
.detail-price { font-size: 30px; font-weight: 800; letter-spacing: -.03em; }
.detail-price small { display: block; font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-top: 2px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 9px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }

.desc { white-space: pre-wrap; font-size: 14.5px; line-height: 1.62; }

.cta {
  display: block; text-align: center;
  background: var(--accent); color: #fff;
  font-weight: 700; padding: 13px; border-radius: 9px;
  margin-top: 14px;
}
.cta:hover { filter: brightness(1.08); }
.cta-sub { text-align: center; font-size: 12px; color: var(--muted); margin-top: 8px; }

.also { display: flex; flex-direction: column; gap: 8px; }
.also a {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 12px; font-size: 13.5px;
}
.also a:hover { border-color: var(--accent); }

.backlink { display: inline-block; color: var(--muted); font-size: 14px; margin: 18px 0 0; }
.backlink:hover { color: var(--accent-text); }

/* ---------- Status page ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 20px 0; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
}
.stat .n { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat .l { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

table.runs { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.runs th {
  text-align: left; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); font-weight: 600;
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.runs td { padding: 9px 10px; border-bottom: 1px solid var(--border); }
table.runs tr:last-child td { border-bottom: 0; }
.ok { color: var(--accent-text); font-weight: 700; }
.fail { color: #c0392b; font-weight: 700; }
@media (prefers-color-scheme: dark) { .fail { color: #ff8a7a; } }
.tbl-scroll { overflow-x: auto; }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 22px 0 34px;
  color: var(--muted);
  font-size: 13px;
  background: var(--surface);
}
.site-footer .wrap { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.site-footer a { text-decoration: underline; }
