:root {
  --bg: #070707;
  --surface: #111;
  --surface-2: #191919;
  --line: #2d2d2d;
  --line-soft: #202020;
  --text: #f6f2e9;
  --muted: #99958d;
  --accent: #ffad00;
  --accent-2: #ffc329;
  --accent-soft: rgba(255, 173, 0, .12);
  --green: #77c56d;
  --radius: 15px;
  --shadow: 0 18px 60px rgba(0, 0, 0, .44);
}

body[data-mode="discount"] {
  --accent: #e83732;
  --accent-2: #ff625c;
  --accent-soft: rgba(232, 55, 50, .14);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(circle at 50% -20%, var(--accent-soft), transparent 36rem), var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }
button { color: inherit; }
.page { width: min(1500px, calc(100% - 36px)); margin: 0 auto; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 17px 0 14px;
  background: linear-gradient(to bottom, rgba(7,7,7,.98) 78%, rgba(7,7,7,0));
  backdrop-filter: blur(14px);
}
.brandline { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 780; }
.brandmark {
  width: 31px; height: 31px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent); color: #111; font-size: 13px; font-weight: 950; transform: rotate(-3deg);
}
.discount-toggle {
  min-height: 38px; padding: 0 17px; border: 1px solid #ff625c; border-radius: 11px;
  background: #bd211d; color: #fff; font-weight: 820; cursor: pointer;
  box-shadow: 0 0 22px rgba(232,55,50,.32), inset 0 1px rgba(255,255,255,.12);
}
.discount-toggle:hover { background: #d52b26; box-shadow: 0 0 28px rgba(232,55,50,.46); }

.searchline { display: grid; grid-template-columns: minmax(280px, 1fr) auto auto; gap: 10px; align-items: stretch; }
.searchbox {
  position: relative; min-height: 62px; overflow: hidden; border: 1px solid #393939;
  border-radius: var(--radius); background: #f7f5ef; color: #161616; box-shadow: var(--shadow);
}
.searchbox label { position: absolute; left: 18px; top: 9px; color: #776f62; font-size: 11px; letter-spacing: .03em; }
.searchbox input { width: 100%; height: 100%; padding: 25px 62px 8px 18px; border: 0; outline: 0; background: transparent; color: #111; font-size: 19px; font-weight: 650; }
.searchbox:focus-within { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.search-submit { position: absolute; right: 9px; top: 9px; width: 44px; height: 44px; border: 0; border-radius: 11px; background: #181818; color: var(--accent); cursor: pointer; font-size: 20px; }

.control {
  min-height: 62px; padding: 0 18px; border: 1px solid #3a3a3a; border-radius: var(--radius);
  background: var(--surface-2); display: flex; align-items: center; gap: 10px; cursor: pointer;
  font-weight: 720; white-space: nowrap;
}
.control:hover { border-color: #555; }
.control.active, .store-control { background: var(--accent); color: #15120a; border-color: var(--accent); }
.filter-count { min-width: 21px; height: 21px; display: grid; place-items: center; border-radius: 99px; background: #111; color: var(--accent); font-size: 11px; }
.store-shell { position: relative; }
.store-control { width: 100%; min-width: 228px; height: 100%; justify-content: space-between; box-shadow: 0 9px 35px var(--accent-soft); }
.store-control span, .store-control small { display: block; }
.store-control small { margin-top: 2px; font-weight: 550; opacity: .68; }
.store-menu {
  position: absolute; right: 0; top: calc(100% + 8px); width: 310px; display: none;
  padding: 7px; border: 1px solid #3b3b3b; border-radius: 14px; background: #171717; box-shadow: var(--shadow);
}
.store-menu.open { display: block; }
.store-option { width: 100%; padding: 12px; border: 0; border-radius: 10px; background: transparent; text-align: left; cursor: pointer; }
.store-option:hover, .store-option.selected { background: var(--accent-soft); color: var(--accent-2); }
.store-option small { display: block; margin-top: 3px; color: var(--muted); }

.content-grid { display: grid; grid-template-columns: 260px minmax(0,1fr); gap: 14px; padding: 7px 0 44px; }
.content-grid.filters-hidden, body[data-mode="discount"] .content-grid { grid-template-columns: 1fr; }
.filters { position: sticky; top: 112px; align-self: start; padding: 19px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.filters.hidden, body[data-mode="discount"] .search-only { display: none; }
.filter-title { margin-bottom: 13px; color: var(--muted); font-size: 12px; }
.filter-option { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 14px; cursor: pointer; }
.filter-option input { width: 17px; height: 17px; accent-color: var(--accent); }
.divider { height: 1px; margin: 15px 0; background: var(--line); }
.reset, .load-more { border: 0; border-radius: 10px; background: var(--accent); color: #16120a; font-weight: 780; cursor: pointer; }
.reset { width: 100%; padding: 11px; }

.results-panel { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.results-panel[aria-busy="true"] { opacity: .76; }
.result-meta { min-height: 58px; padding: 17px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.result-meta strong { font-size: 16px; }
.mode-caption { color: var(--muted); font-size: 12px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; min-width: 1020px; border-collapse: collapse; }
th { padding: 11px 12px; border-right: 1px solid rgba(0,0,0,.15); background: var(--accent); color: #18130a; text-align: left; vertical-align: bottom; font-size: 11px; font-weight: 850; line-height: 1.15; }
th.num, td.num { text-align: right; }
td { padding: 13px 12px; border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); vertical-align: middle; font-size: 13px; }
tbody tr { transition: background .16s ease; }
tbody tr:hover { background: #1a1a1a; }
tbody tr.best { background: linear-gradient(90deg, var(--accent-soft), transparent 54%); }
.code { color: #aaa69e; font-variant-numeric: tabular-nums; }
.product-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.product-copy { flex: 1 1 auto; min-width: 0; }
.product-name { font-size: 14px; font-weight: 740; line-height: 1.3; }
.why { margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.match { display: inline-block; margin-left: 7px; padding: 3px 6px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-2); font-size: 9px; letter-spacing: .05em; text-transform: uppercase; vertical-align: 1px; }
.product-image-button { flex: 0 0 52px; width: 52px; height: 52px; padding: 0; border: 0; border-radius: 9px; background: transparent; cursor: zoom-in; }
.product-image-button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.product-thumb { width: 52px; height: 52px; padding: 4px; border: 1px solid #303030; border-radius: 9px; background: #f4f2ed; object-fit: contain; }
.unit { color: var(--muted); }
.price { font-weight: 820; white-space: nowrap; }
.old-price { color: var(--muted); text-decoration: line-through; white-space: nowrap; }
.drop { color: #ff7771; font-weight: 850; }
.stock { font-variant-numeric: tabular-nums; font-weight: 690; }
.stock.good { color: var(--green); }
.stock.zero { color: #666; }
.stock.remote { color: var(--accent-2); }
.cities-toggle { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: #181818; color: var(--muted); cursor: pointer; font-size: 11px; }
.city-details td { padding: 0; background: #0d0d0d; }
.city-list { display: grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); gap: 8px; padding: 12px 18px; }
.city-price { padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); font-size: 12px; }
.city-price b { color: var(--text); }
.panel-state { padding: 52px 20px; color: var(--muted); text-align: center; }
.panel-state.error { color: #ff8a84; }
.load-more { display: block; margin: 18px auto; padding: 11px 18px; }
.load-more[hidden] { display: none; }

.footer { padding: 42px 0 48px; border-top: 1px solid var(--line); color: #a5a098; font-size: 14px; line-height: 1.66; }
.footer-inner { max-width: 780px; }
.footer strong { color: var(--text); }
.footer p { margin: 3px 0 0; }
.footer .smile { color: var(--accent); font-weight: 780; }
.footer .ps { margin-top: 15px; color: #77736d; }

.gallery { position: fixed; inset: 0; z-index: 1000; display: grid; grid-template-rows: auto 1fr; background: rgba(0,0,0,.94); backdrop-filter: blur(8px); }
.gallery[hidden] { display: none; }
.gallery-head { display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 18px; padding: 16px 20px; border-bottom: 1px solid #292929; }
.gallery-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 760; }
.gallery-counter { color: #aaa69e; font-size: 13px; }
.gallery-close, .gallery-arrow { display: grid; place-items: center; border: 1px solid #3a3a3a; background: #171717; color: #fff; cursor: pointer; }
.gallery-close { width: 42px; height: 42px; border-radius: 12px; font-size: 25px; }
.gallery-stage { position: relative; min-height: 0; display: grid; place-items: center; padding: 28px 88px; }
.gallery-image { display: block; max-width: min(100%,1100px); max-height: calc(100vh - 126px); border-radius: 14px; background: #f5f3ee; object-fit: contain; box-shadow: 0 22px 80px rgba(0,0,0,.45); }
.gallery-arrow { position: absolute; top: 50%; width: 52px; height: 72px; border-radius: 14px; transform: translateY(-50%); font-size: 34px; }
.gallery-arrow:hover, .gallery-close:hover { border-color: var(--accent); color: var(--accent); }
.gallery-prev { left: 20px; }
.gallery-next { right: 20px; }

.refresh-notice { position: fixed; left: 50%; top: 50%; z-index: 900; width: min(440px,calc(100% - 32px)); padding: 19px 48px 19px 20px; border: 1px solid var(--accent); border-radius: 14px; background: #171717; box-shadow: var(--shadow), 0 0 30px var(--accent-soft); transform: translate(-50%,-50%); }
.refresh-notice[hidden] { display: none; }
.refresh-notice strong, .refresh-notice span { display: block; }
.refresh-notice span { margin-top: 5px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.refresh-notice button { position: absolute; right: 10px; top: 9px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 24px; }

@media (max-width: 900px) {
  .page { width: min(100% - 20px,760px); }
  .searchline { grid-template-columns: 1fr auto; }
  .searchbox { grid-column: 1 / -1; }
  body[data-mode="discount"] .searchbox { grid-column: 1 / -1; }
  .store-control { min-width: 0; }
  .content-grid { grid-template-columns: 1fr; }
  .filters { position: static; display: none; }
  .filters.open { display: block; }
}
@media (max-width: 560px) {
  .page { width: calc(100% - 20px); }
  .control { min-height: 54px; padding: 0 13px; }
  .store-control { min-width: 185px; }
  .result-meta { align-items: flex-start; flex-direction: column; }
  .footer { padding-top: 30px; }
  .gallery-head { gap: 10px; padding: 10px; }
  .gallery-stage { padding: 18px 52px; }
  .gallery-image { max-height: calc(100vh - 92px); }
  .gallery-arrow { width: 40px; height: 58px; border-radius: 11px; font-size: 27px; }
  .gallery-prev { left: 6px; }
  .gallery-next { right: 6px; }
}
