:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --accent: #0ea5e9;
  --radius: 12px;
}

* { box-sizing: border-box; }

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

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.header-contact { color: var(--accent); text-decoration: none; font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 16px; }
.messengers { display: flex; gap: 8px; }
.msg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #fff;
  text-decoration: none;
}
.msg svg { width: 18px; height: 18px; }
.msg-whatsapp { background: #25d366; }
.msg-telegram { background: #2aabee; }
.msg-max { background: #7b3ff2; }

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

.filters {
  align-self: start;
  position: sticky;
  top: 76px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.filters-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.filters-head h3 { margin: 0; font-size: 14px; }
.link { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 12px; }

.filter-group { margin-bottom: 12px; }
.filter-title { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.filter-options { display: flex; flex-direction: column; gap: 3px; }
.filter-options label { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.filter-options input { accent-color: var(--accent); }

.select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--card);
  color: var(--text);
}

.price-range { display: flex; gap: 8px; }
.price-range input, .search {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.count { color: var(--muted); font-size: 14px; }
.sort-wrap { display: flex; align-items: center; gap: 8px; }
.sort-label { color: var(--muted); font-size: 12px; }
.sort { padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; background: var(--card); color: var(--text); }

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

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow .15s;
}
.card:hover { box-shadow: 0 8px 24px rgba(0,0,0,.08); }

.card-photo { aspect-ratio: 4/3; background: #eef0f3; display: flex; align-items: center; justify-content: center; position: relative; }
.card-photo img { width: 100%; height: 100%; object-fit: cover; }
.card-photo .no-photo { color: var(--muted); font-size: 13px; }

.cond-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}
.cond-new { background: #059669; }
.cond-used { background: #6b7280; }
.cond-mt { background: #d97706; }

.card-body { padding: 12px; }
.card-price { font-size: 18px; font-weight: 700; }
.card-meta { color: var(--muted); font-size: 13px; margin-top: 6px; display: flex; flex-direction: column; gap: 2px; }

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

.footer { border-top: 1px solid var(--border); margin-top: 32px; }
.footer-inner { max-width: 1280px; margin: 0 auto; padding: 20px 24px; display: flex; justify-content: space-between; }
.footer-brand { font-weight: 700; }
.muted { color: var(--muted); font-size: 13px; }

/* Модалка */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}
.modal {
  background: var(--card);
  border-radius: var(--radius);
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 20px;
  cursor: pointer;
  z-index: 2;
}
.modal-body { display: grid; grid-template-columns: 7fr 3fr; gap: 20px; }
.m-gallery { display: flex; flex-direction: column; gap: 8px; }
.m-gallery .main { aspect-ratio: 4/3; background: #eef0f3; border-radius: 12px 0 0 12px; overflow: hidden; position: relative; }
.m-gallery .main img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.m-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.m-thumbs img { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; cursor: pointer; border: 2px solid transparent; }
.m-thumbs img.active { border-color: var(--accent); }

.nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,.4);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav:hover { background: rgba(0,0,0,.6); }
.nav-prev { left: 8px; }
.nav-next { right: 8px; }

/* Полноэкранный просмотр */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.lightbox img { max-width: 90vw; max-height: 90vh; object-fit: contain; }
.lb-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  color: #fff;
  font-size: 28px;
  cursor: pointer;
}
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  color: #fff;
  font-size: 32px;
  cursor: pointer;
}
.lb-nav:hover { background: rgba(255,255,255,.3); }
.lb-prev { left: 16px; }
.lb-next { right: 16px; }
.lb-count {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 14px;
  background: rgba(0,0,0,.4);
  padding: 4px 12px;
  border-radius: 12px;
}
.m-info { padding: 20px 20px 20px 0; }
.m-no { margin: 0 0 8px; font-size: 20px; }
.m-price { font-size: 24px; font-weight: 700; margin-bottom: 16px; }
.m-spec { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.m-spec th, .m-spec td { text-align: left; padding: 8px 0; border-bottom: 1px solid var(--border); }
.m-spec th { color: var(--muted); font-weight: 500; width: 40%; }

.lead-form { display: flex; flex-direction: column; gap: 10px; }
.lead-title { font-weight: 700; }
.lead-form input, .lead-form textarea {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.lead-submit {
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.lead-msg { font-size: 14px; min-height: 18px; }
.lead-msg.ok { color: #059669; }
.lead-msg.err { color: #dc2626; }

@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
  .filters { position: static; }
  .modal-body { grid-template-columns: 1fr; }
  .m-info { padding: 20px; }
}
