/* ПРО Скидки: сайт. Тот же Worker и данные, что у карты мини-приложения (../style.css — её стили). */
:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #eef0f5;
  --text: #12161c;
  --muted: #667085;
  --line: rgba(16, 24, 40, 0.09);
  --brand: #ff4d2e;
  --brand-2: #ff8a3d;
  --brand-ink: #ffffff;
  --link: #1f6feb;
  --good: #12a150;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06);
  --shadow-up: 0 12px 40px rgba(16, 24, 40, 0.18);
  --r: 16px;
  --top: 124px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141b; --surface: #171e27; --surface-2: #202a35; --text: #eef1f5; --muted: #98a2b3;
    --line: rgba(255, 255, 255, 0.09); --brand: #ff6a4d; --brand-2: #ff9c5b; --link: #6aa8ff; --good: #3ccf7d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.25); --shadow-up: 0 12px 40px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141b; --surface: #171e27; --surface-2: #202a35; --text: #eef1f5; --muted: #98a2b3;
  --line: rgba(255, 255, 255, 0.09); --brand: #ff6a4d; --brand-2: #ff9c5b; --link: #6aa8ff; --good: #3ccf7d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.25); --shadow-up: 0 12px 40px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }

/* ---------- шапка ---------- */
.top {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.bar { display: flex; align-items: center; gap: 12px; padding-top: 12px; padding-bottom: 10px; }
.logo { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 19px; letter-spacing: -0.2px; white-space: nowrap; }
.logo:hover { text-decoration: none; }
.logo svg { width: 34px; height: 34px; flex: none; }
.logo .tag { fill: var(--brand); }
.logo .hole { fill: var(--bg); }
.logo text { fill: #fff; font: 800 15px/1 Arial, sans-serif; }
.logo b, .brand b { color: var(--brand); font-weight: 800; }
.place { display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 8px; height: 42px; }
.place select { border: 0; background: transparent; height: 40px; font-weight: 600; max-width: 150px; cursor: pointer; }
.search { flex: 1; display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.search svg { width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2; flex: none; }
.search input { flex: 1; border: 0; background: transparent; outline: none; min-width: 0; height: 40px; font-size: 16px; }
.search input::-webkit-search-cancel-button { display: none; }
.clear { border: 0; background: var(--surface-2); width: 26px; height: 26px; border-radius: 50%; line-height: 1; font-size: 18px; color: var(--muted); }
.tg { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 14px; border-radius: 12px; background: #229ed9; color: #fff; font-weight: 600; white-space: nowrap; }
.tg:hover { text-decoration: none; filter: brightness(1.05); }
.tg svg { width: 18px; height: 18px; fill: #fff; }
.tabs { display: flex; gap: 4px; padding-bottom: 8px; }
.tabs a, .dock a { color: var(--muted); font-weight: 600; border-radius: 10px; }
.tabs a { padding: 7px 12px; }
.tabs a:hover { text-decoration: none; background: var(--surface); color: var(--text); }
.tabs a.on { background: var(--text); color: var(--bg); }
.tabs .n:not(:empty), .dock .n:not(:empty) { margin-left: 2px; font-size: 12px; opacity: 0.8; }

/* нижнее меню на телефоне */
.dock { display: none; }
@media (max-width: 760px) {
  :root { --top: 112px; }
  .bar { flex-wrap: wrap; gap: 8px; padding-top: 10px; }
  .logo { font-size: 17px; }
  .logo svg { width: 30px; height: 30px; }
  .place { margin-left: auto; height: 38px; padding: 0 6px; }
  .place select { height: 36px; max-width: 104px; }
  .logo svg { width: 28px; height: 28px; }
  .hero { padding: 14px 16px; border-radius: 16px; gap: 10px; }
  .hero h1 { font-size: 19px; }
  .hero p { font-size: 13px; }
  .hero .stats { gap: 14px; }
  .hero .stats b { font-size: 18px; }
  .search { order: 5; flex-basis: 100%; height: 42px; }
  .tg { width: 38px; height: 38px; padding: 0; justify-content: center; border-radius: 10px; }
  .tg span { display: none; }
  .tabs { display: none; }
  .dock {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .dock a { display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 11px; padding: 4px 0; }
  .dock a span { font-size: 19px; line-height: 1.1; }
  .dock a:hover { text-decoration: none; }
  .dock a.on { color: var(--brand); }
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
}

/* ---------- главная полоса ---------- */
main { padding-top: 16px; padding-bottom: 32px; min-height: 60vh; }
.loading, .empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.empty b { color: var(--text); }
.hero {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 18px 20px; border-radius: 20px; margin-bottom: 14px;
  background: linear-gradient(120deg, var(--brand), var(--brand-2)); color: #fff;
}
.hero h1 { margin: 0 0 4px; font-size: clamp(20px, 3vw, 28px); line-height: 1.15; letter-spacing: -0.3px; }
.hero p { margin: 0; opacity: 0.95; }
.hero .stats { display: flex; gap: 18px; flex-wrap: wrap; }
.hero .stats div { line-height: 1.1; }
.hero .stats b { display: block; font-size: 22px; }
.hero .stats span { font-size: 12px; opacity: 0.9; }
.title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 10px; }
.title h1, .title h2 { margin: 0; font-size: 22px; letter-spacing: -0.2px; }
.title .sub { color: var(--muted); }

/* фильтры */
.filters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.row { display: flex; gap: 8px; align-items: center; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; height: 36px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 14px;
}
.chip:hover { border-color: color-mix(in srgb, var(--text) 25%, transparent); }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .n { font-weight: 500; opacity: 0.6; font-size: 12px; }
.chip.small { height: 32px; font-size: 13px; }
.tools { display: flex; gap: 8px; margin-left: auto; flex: none; }
.tools select { height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 0 8px; font-weight: 600; font-size: 14px; }
.notice { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px dashed var(--line); color: var(--muted); margin-bottom: 12px; }
.notice button, .link { border: 0; background: none; color: var(--link); font-weight: 600; padding: 0; }
@media (max-width: 760px) {
  .row.wrapm { flex-wrap: wrap; }
  .tools { margin-left: 0; width: 100%; }
  .tools select { flex: 1; }
}

/* ---------- карточки ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(208px, 1fr)); gap: 12px; }
@media (max-width: 520px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } }
.card {
  position: relative; display: flex; flex-direction: column; text-align: left; padding: 0; border: 1px solid var(--line);
  background: var(--surface); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-up); }
.pic { position: relative; aspect-ratio: 4 / 3; background: #fff; display: grid; place-items: center; overflow: hidden; }
.pic img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.pic.tile { background: var(--tint); }
.pic.tile .em { font-size: 44px; filter: saturate(1.1); }
.pic.tile .cl { position: absolute; bottom: 8px; left: 10px; right: 10px; font-size: 12px; font-weight: 600; color: rgba(0, 0, 0, 0.55); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { position: absolute; top: 8px; left: 8px; background: var(--brand); color: var(--brand-ink); font-weight: 800; font-size: 13px; padding: 3px 8px; border-radius: 999px; }
.badge.best { background: var(--good); font-weight: 700; font-size: 11px; }
.fav { position: absolute; top: 6px; right: 6px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.9); color: #98a2b3; font-size: 17px; line-height: 1; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); }
.fav.on { color: #e5383b; }
.body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.store { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: none; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, #999); flex: none; }
.name { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.6em; }
.meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.price { display: flex; align-items: baseline; gap: 8px; margin-top: auto; padding-top: 4px; }
.price b { font-size: 19px; letter-spacing: -0.3px; }
.price s { color: var(--muted); font-size: 13px; }
.more { display: block; margin: 16px auto 0; height: 44px; padding: 0 22px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; }

/* витрина на главной: ряды карточек, листаются вбок */
.shelf { margin: 6px 0 18px; }
.shelf .title { margin-bottom: 8px; }
.shelfrow { display: grid; grid-auto-flow: column; grid-auto-columns: 208px; gap: 12px; overflow-x: auto; padding: 2px 2px 10px; scroll-snap-type: x proximity; scrollbar-width: thin; }
.shelfrow .card { scroll-snap-align: start; }
@media (max-width: 520px) { .shelfrow { grid-auto-columns: 46%; gap: 8px; } }
.flag svg { width: 22px; height: 15px; display: block; border-radius: 2px; box-shadow: 0 0 0 1px var(--line); }

/* ---------- окно товара ---------- */
dialog.sheet { border: 0; padding: 0; border-radius: 20px; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); background: var(--surface); color: var(--text); box-shadow: var(--shadow-up); }
dialog.sheet::backdrop { background: rgba(10, 14, 20, 0.5); }
@media (max-width: 600px) {
  dialog.sheet { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 20px 20px 0 0; max-height: 88vh; }
}
.dlg { position: relative; }
.dlg .pic { aspect-ratio: 16 / 10; }
.dlg .pic.tile { aspect-ratio: 3 / 1; } /* у техники фото нет — плашка пониже */
.dlg .x { position: absolute; top: 10px; right: 10px; z-index: 2; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 20px; }
.dlg .in { padding: 14px 18px 18px; display: flex; flex-direction: column; gap: 8px; }
.dlg h2 { margin: 0; font-size: 19px; line-height: 1.3; }
.dlg .price b { font-size: 26px; }
.dlg .facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.dlg .facts dt { color: var(--muted); }
.dlg .facts dd { margin: 0; }
.acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 42px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-weight: 700; white-space: nowrap; }
.btn:hover { text-decoration: none; filter: brightness(0.98); }
.btn.main { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.tgb { background: #229ed9; border-color: #229ed9; color: #fff; }
.also { margin-top: 6px; }
.also h3 { margin: 6px 0; font-size: 14px; color: var(--muted); }
.mini { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.mini .card { min-width: 150px; max-width: 150px; box-shadow: none; }
.mini .pic { aspect-ratio: 1 / 1; }
.mini .name { font-size: 12px; }
.mini .price b { font-size: 15px; }

/* ---------- карта ---------- */
.mapview { display: grid; grid-template-columns: 340px 1fr; gap: 12px; height: calc(100vh - var(--top) - 32px); min-height: 460px; }
.mapview .side { overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.mapbox { border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); min-height: 300px; position: relative; }
#map { position: absolute; inset: 0; background: var(--surface-2); }
.side h2 { margin: 0 0 4px; font-size: 18px; }
.side .sub { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.shop { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: none; padding: 9px 6px; border-radius: 10px; }
.shop:hover { background: var(--surface-2); }
.shop .info { flex: 1; min-width: 0; }
.shop .nm { font-weight: 700; display: block; }
.shop .ad { color: var(--muted); font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shop .km { font-size: 12px; color: var(--muted); white-space: nowrap; }
.locate { width: 100%; margin-bottom: 8px; }
.leaflet-popup-content { font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }
.leaflet-popup-content b { display: block; font-size: 15px; }
.leaflet-popup-content .pa { display: flex; gap: 10px; margin-top: 6px; }
:root[data-theme="dark"] .leaflet-tile-pane, :root:not([data-theme="light"]) .dark-tiles .leaflet-tile-pane { filter: brightness(0.75) invert(1) contrast(0.9) hue-rotate(200deg) saturate(0.4); }
@media (max-width: 760px) {
  .mapview { grid-template-columns: 1fr; grid-template-rows: 55vh auto; height: auto; }
  .mapview .mapbox { order: -1; }
  .mapview .side { max-height: none; }
}

/* ---------- магазины ---------- */
.stores { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.st { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); }
.st .info { flex: 1; min-width: 0; }
.st .nm { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.st .ds { color: var(--muted); font-size: 12px; }
.st.off { opacity: 0.55; }
.sw { position: relative; width: 46px; height: 28px; flex: none; }
.sw input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.sw span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); transition: background 0.15s; }
.sw span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.15s; }
.sw input:checked + span { background: var(--good); border-color: var(--good); }
.sw input:checked + span::after { transform: translateX(18px); }
.sw input:focus-visible + span { outline: 2px solid var(--link); outline-offset: 2px; }
.sect { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); font-weight: 700; }

/* ---------- подвал ---------- */
.foot { border-top: 1px solid var(--line); background: var(--surface); padding: 24px 0; color: var(--muted); font-size: 14px; }
.foot .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.foot b { color: var(--text); }
.foot p { margin: 6px 0 0; }
.foot .small { font-size: 12px; margin-top: 18px; }
.brand { font-size: 17px; }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 60; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow-up); max-width: calc(100vw - 32px); }
