:root {
  --bg: #f4f4f5;
  --card: #fff;
  --text: #18181b;
  --muted: #71717a;
  --line: #e4e4e7;
  --accent: #e3262f;
  --accent-2: #ff5a36;
  --accent-soft: #fde8e8;
  --good: #15803d;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f11; --card: #1a1a1d; --text: #f4f4f5; --muted: #a1a1aa; --line: #2a2a2e;
    --accent-soft: #3a1416; --good: #4ade80; --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: inherit; }
button, select, input { font: inherit; color: inherit; }

.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

/* ---------- кнопки */
.btn {
  border: 0; border-radius: 10px; padding: 10px 14px; cursor: pointer;
  background: var(--card); text-decoration: none; display: inline-flex; align-items: center;
  justify-content: center; gap: 6px; transition: transform .1s ease, background-color .15s ease;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #c81e26; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.wide { width: 100%; padding: 14px; }
.btn.chip { border: 1px solid var(--line); padding: 8px 12px; font-size: 14px; white-space: nowrap; }
.btn.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font-weight: 600; }

/* ---------- вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 440px; background: var(--card); border-radius: 20px; padding: 28px;
  box-shadow: var(--shadow);
}
.brand-big { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.brand-big span, .brand span { color: var(--accent); }
.lead { color: var(--muted); margin: 8px 0 22px; }
.login h2 { font-size: 16px; margin: 0 0 12px; }
.group-list { display: grid; gap: 10px; }
.group-list .btn { justify-content: flex-start; border: 1px solid var(--line); padding: 14px; text-align: left; }
.group-list .btn:hover { border-color: var(--accent); }
.code-box { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--accent-soft); border-radius: 14px; padding: 14px 18px; margin-bottom: 14px; }
.code { font-size: 38px; font-weight: 800; letter-spacing: .18em; font-variant-numeric: tabular-nums; }
.steps { color: var(--muted); padding-left: 20px; margin: 16px 0; }
.steps li { margin: 4px 0; }
.status { padding: 10px 12px; border-radius: 10px; background: var(--bg); margin-bottom: 12px; font-size: 14px; }
.status.ok { color: var(--good); }
.error { margin-top: 14px; color: var(--accent); font-size: 14px; }

/* ---------- шапка и фильтры */
.top {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 16px; max-width: 1280px; margin: 0 auto;
}
.brand { font-weight: 800; font-size: 18px; letter-spacing: -.01em; }
.user { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.user img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; background: var(--line); }
@media (max-width: 520px) { #me-name { display: none; } .brand span { display: none; } }

.controls {
  position: sticky; top: 0; z-index: 500; background: var(--bg);
  max-width: 1280px; margin: 0 auto; padding: 8px 16px 10px; display: grid; gap: 8px;
  border-bottom: 1px solid var(--line);
}
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); outline: none;
}
.search:focus { border-color: var(--accent); }
.radius { font-size: 14px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
select { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); }
.seg button { border: 0; background: none; padding: 7px 10px; cursor: pointer; font-size: 14px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: #fff; }
.formats { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.formats .btn.chip { padding: 6px 10px; font-size: 13px; }
.filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }

.city-wrap { position: relative; }
.pop {
  position: absolute; top: calc(100% + 6px); left: 0; width: 300px; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 8px; box-shadow: var(--shadow); z-index: 1000;
}
.pop input { width: 100%; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }
#city-results button {
  display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px; border-radius: 8px; cursor: pointer;
}
#city-results button:hover { background: var(--bg); }
#city-results small { color: var(--muted); }

#map-wrap { max-width: 1280px; margin: 10px auto 0; padding: 0 16px; }
#map { height: 360px; border-radius: var(--radius); overflow: hidden; }
.store-pin {
  background: var(--accent); color: #fff; border-radius: 12px; font: 600 11px/22px system-ui;
  text-align: center; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.store-pin.me { background: #2563eb; }

.summary { max-width: 1280px; margin: 0 auto; padding: 12px 16px 4px; color: var(--muted); font-size: 14px;
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.store-filter { background: var(--accent-soft); color: var(--text); border-radius: 8px; padding: 3px 8px; }
.store-filter button { border: 0; background: none; cursor: pointer; margin-left: 4px; }
.note { max-width: 1248px; margin: 8px auto 0; background: var(--card); border-radius: 12px; padding: 10px 14px;
  font-size: 13px; color: var(--muted); border: 1px solid var(--line); }
@media (max-width: 1280px) { .note { margin: 8px 16px 0; } }

/* ---------- карточки */
.grid {
  max-width: 1280px; margin: 0 auto; padding: 10px 16px 16px;
  display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
@media (max-width: 520px) { .grid { grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 8px; } }
.card {
  background: var(--card); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.pic { position: relative; aspect-ratio: 1; background: #fff; overflow: hidden; }
.pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.badge {
  position: absolute; top: 8px; left: 8px; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 800; border-radius: 8px; padding: 3px 7px; font-size: 14px;
}
.tag { position: absolute; bottom: 8px; left: 8px; right: 8px; background: rgba(0,0,0,.66); color: #fff;
  font-size: 11px; border-radius: 6px; padding: 2px 6px; width: fit-content; max-width: calc(100% - 16px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.prices { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.price { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.old { color: var(--muted); text-decoration: line-through; font-size: 13px; }
.save { color: var(--good); font-size: 12px; font-weight: 600; }
.name { font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.meta { font-size: 12px; color: var(--muted); display: grid; gap: 2px; margin-top: auto; }
.meta b { color: var(--text); font-weight: 600; }
.go { font-size: 12px; color: var(--accent); text-decoration: none; font-weight: 600; margin-top: 4px; }
.store-link { background: none; border: 0; padding: 0; color: inherit; cursor: pointer; text-align: left;
  text-decoration: underline dotted; font-size: 12px; }

.more { text-align: center; padding: 8px 16px 40px; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px 80px; max-width: 520px; margin: 0 auto; }
.skeleton { aspect-ratio: .62; border-radius: var(--radius); background: linear-gradient(90deg, var(--card), var(--line), var(--card));
  background-size: 200% 100%; animation: sh 1.2s infinite linear; }
@keyframes sh { to { background-position: -200% 0; } }
