:root {
  --accent: #0b6efd;
  --text: #1a1a1a;
  --muted: #6b7280;
  --border: #e6e8eb;
  --bg: #f5f6f8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

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

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.logo { font-size: 20px; font-weight: 700; color: var(--accent); }
.count { color: var(--muted); font-size: 14px; }
.back { color: var(--accent); font-size: 14px; }

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  padding-top: 20px;
  padding-bottom: 40px;
  align-items: start;
}

.filters {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  position: sticky;
  top: 80px;
}

.f-group { margin-bottom: 14px; }
.f-group label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.f-group select, .f-group input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
}
.f-range { display: flex; gap: 8px; }
.f-range input { width: 50%; }

.btn-apply {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}
.btn-reset {
  display: block;
  text-align: center;
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

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

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: block;
  transition: box-shadow 0.15s, transform 0.15s;
}
.card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); transform: translateY(-2px); }

.card-photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #eee;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.card-photo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #eee;
}
.no-photo { color: var(--muted); font-size: 13px; }

.card-body { padding: 12px; }
.card-title { font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.card-specs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.card-specs span {
  background: var(--bg);
  border-radius: 6px;
  padding: 2px 7px;
}
.card-price { font-size: 17px; font-weight: 700; }
.card-city { font-size: 12px; color: var(--muted); margin-top: 4px; }
.card-date { font-size: 12px; color: var(--muted); }

.empty { color: var(--muted); padding: 40px 0; grid-column: 1 / -1; text-align: center; }

/* detail page */
.detail {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 28px;
  padding-top: 24px;
  padding-bottom: 60px;
}

.gallery-main {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #eee;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-main img { width: 100%; height: 100%; object-fit: contain; }

.gallery-thumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.gallery-thumbs img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid var(--border);
}

.detail-info {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  align-self: start;
}
.detail-info h1 { font-size: 22px; margin: 0 0 4px; }
.detail-city { color: var(--muted); font-size: 13px; margin-bottom: 16px; }

.specs-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.specs-table td { padding: 6px 0; font-size: 14px; border-bottom: 1px solid var(--bg); }
.specs-table td:first-child { color: var(--muted); width: 50%; }
.specs-table td:last-child { font-weight: 600; text-align: right; }

.detail-price { font-size: 26px; font-weight: 800; margin-bottom: 10px; }
.detail-phone { font-size: 16px; font-weight: 600; margin-bottom: 14px; }

.phone-gate {
  background: var(--bg);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
}
.phone-gate p { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.gate-btn { display: inline-block; width: auto; padding: 8px 16px; margin-right: 10px; }
.gate-recheck { display: inline-block; margin-top: 0; font-size: 13px; }

.autoteka-link {
  display: inline-block;
  margin-bottom: 16px;
  padding: 8px 14px;
  background: #eef4ff;
  color: var(--accent);
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
}

.detail-text {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.login-wrap { display: flex; justify-content: center; padding-top: 60px; }
.login-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 30px;
  max-width: 420px;
  text-align: center;
}
.login-card h1 { font-size: 20px; margin: 0 0 12px; }
.login-card p { color: var(--muted); font-size: 14px; line-height: 1.5; }
.login-btn { display: inline-block; width: auto; padding: 10px 24px; margin: 14px 0; }
.login-status { font-size: 13px; }

@media (max-width: 800px) {
  .layout, .detail { grid-template-columns: 1fr; }
  .filters { position: static; }
}
