/* ============================================================
   Tehnobonus Catalog Mirror — editorial deal-hunter UI
   ------------------------------------------------------------
   Palette: warm cream paper, deep ink, coral accent.
   No default Bootstrap-y boxes; thin hairlines, generous space.
   ============================================================ */

:root {
  --paper:      #f4efe2;   /* warm cream background  */
  --paper-2:    #fbf8ee;   /* slightly lighter for layered surfaces */
  --panel:      #ffffff;   /* card / popover surface */
  --ink:        #18160f;   /* near-black, warm        */
  --ink-2:      #3a362c;   /* secondary text          */
  --muted:      #7a7367;   /* muted captions          */
  --line:       #e3dcc7;   /* hairline                */
  --line-2:     #d4cbb1;   /* stronger hairline       */
  --accent:     #d83a1f;   /* coral – deals/discounts */
  --accent-ink: #a31a04;   /* coral text on cream     */
  --new:        #1f5d3a;   /* forest – new/in-stock   */
  --new-bg:     #e3eee2;
  --gone-bg:    #efe9d6;
  --gone-fg:    #6c6655;

  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 16px;

  --shadow-pop: 0 6px 24px -8px rgba(24, 22, 15, .18),
                0 2px 6px  -2px rgba(24, 22, 15, .10);
  --shadow-card: 0 1px 0 rgba(24, 22, 15, .04);

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino", "Palatino Linotype", "Georgia", serif;
}

@media (prefers-color-scheme: dark) {
  /* Stay in cream/ink mode — design is intentionally light. */
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: var(--font-sans);
  margin: 0;
  padding: 0;
  background: var(--paper);
  background-image:
    radial-gradient(circle at 0% 0%, rgba(216, 58, 31, .04), transparent 40%),
    radial-gradient(circle at 100% 100%, rgba(31, 93, 58, .04), transparent 50%);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}

a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--accent-ink); }

button { font-family: inherit; font-size: inherit; color: inherit; }

::selection { background: var(--ink); color: var(--paper-2); }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 22px; margin: 28px 0 16px; }
h3 { font-size: 14px; line-height: 1.3; }

.small { font-size: 12.5px; color: var(--muted); }
.eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ----------------------------------------------------------
   Top bar
   ---------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 22px;
  background: transparent;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.topbar .brand {
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  flex-shrink: 0;
}
.topbar .brand:hover { color: var(--ink); }
.topbar .brand h1 {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.topbar .brand::before {
  content: "◆";
  color: var(--accent);
  font-size: 11px;
  transform: translateY(-2px);
}
.brand-suffix { /* shown on desktop, hidden on phones */ }

.topnav { display: flex; gap: 4px; margin-left: 4px; }
.topnav a {
  padding: 6px 10px;
  border-radius: var(--radius-s);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  position: relative;
}
.topnav a:hover { color: var(--ink); }
.topnav a.active {
  color: var(--ink);
}
.topnav a.active::after {
  content: "";
  position: absolute;
  left: 10px; right: 10px; bottom: 1px;
  height: 2px;
  background: var(--accent);
}

#stats {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  display: flex;
  gap: 0;
  flex-wrap: wrap;
}
#stats .stat-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 2px 10px;
  border-right: 1px solid var(--line);
}
#stats .stat-pill:last-child { border-right: none; }
#stats .stat-pill b {
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ----------------------------------------------------------
   Layout
   ---------------------------------------------------------- */

main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 18px 18px 80px;
}

.footer {
  text-align: center;
  padding: 36px 16px 48px;
  color: var(--muted);
  font-size: 12px;
}

/* ----------------------------------------------------------
   Toolbar (search + filters) — compact, single strip
   ---------------------------------------------------------- */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(244, 239, 226, .94);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  margin: 0 -18px 18px;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}
.search-wrap .search-icon {
  position: absolute;
  left: 14px;
  pointer-events: none;
  color: var(--muted);
  font-size: 16px;
}
.search-wrap input {
  flex: 1;
  height: 42px;
  padding: 0 14px 0 40px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.search-wrap input::placeholder { color: var(--muted); }
.search-wrap input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(24, 22, 15, .06);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  align-items: center;
}

/* compact filter button */
.fbtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .12s, color .12s, background .12s;
  font-variant-numeric: tabular-nums;
}
.fbtn:hover { border-color: var(--ink); color: var(--ink); }
.fbtn:disabled, .fbtn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
.fbtn:disabled:hover { border-color: var(--line); color: var(--ink-2); }
.fbtn .chevron {
  font-size: 9px;
  color: var(--muted);
  transform: translateY(-1px);
}
.fbtn .count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper-2);
  font-size: 11px;
  font-weight: 600;
}
.fbtn.is-active {
  background: var(--ink);
  color: var(--paper-2);
  border-color: var(--ink);
}
.fbtn.is-active .chevron { color: var(--paper-2); }
.fbtn.is-active .count { background: var(--accent); color: #fff; }

.fbtn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.fbtn.ghost:hover { color: var(--accent-ink); }

/* Sort button has the value visible inline */
.fbtn .label-pre {
  color: var(--muted);
  font-weight: 400;
}

/* ----------------------------------------------------------
   Popover
   ---------------------------------------------------------- */

.popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 260px;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-pop);
  padding: 10px;
  z-index: 60;
}
.popover[hidden] { display: none; }
.popover.is-sheet {
  position: fixed;
  left: 12px;
  right: 12px;
  top: auto;
  bottom: calc(12px + env(safe-area-inset-bottom));
  max-width: none;
  max-height: min(70vh, 430px);
  max-height: min(70svh, 430px);
  display: flex;
  flex-direction: column;
}
.popover.is-sheet .pop-list {
  flex: 1 1 auto;
  min-height: 0;
}
.popover .pop-search {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--paper-2);
  font-size: 13px;
  font-family: inherit;
  margin-bottom: 8px;
  outline: none;
}
.popover .pop-search:focus { border-color: var(--ink); }

.popover .pop-list {
  max-height: 280px;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
  scrollbar-width: thin;
}
.popover .pop-list li {
  padding: 0;
}
.popover .pop-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-s);
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-2);
}
.popover .pop-list label:hover { background: var(--paper); color: var(--ink); }
.popover .pop-list input[type=checkbox] {
  appearance: none;
  width: 14px; height: 14px;
  border: 1px solid var(--line-2);
  border-radius: 3px;
  background: var(--panel);
  display: inline-grid;
  place-content: center;
  cursor: pointer;
}
.popover .pop-list input[type=checkbox]:checked {
  background: var(--ink);
  border-color: var(--ink);
}
.popover .pop-list input[type=checkbox]:checked::after {
  content: "";
  width: 6px; height: 3px;
  border-left: 2px solid var(--paper-2);
  border-bottom: 2px solid var(--paper-2);
  transform: rotate(-45deg) translate(0, -1px);
}
.popover .pop-list .count {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.popover .pop-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}
.popover .pop-actions button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 4px;
}
.popover .pop-actions button:hover { color: var(--ink); }
.popover .pop-actions .apply { color: var(--accent-ink); font-weight: 600; }

/* Range popover */
.popover .range-row {
  display: flex;
  gap: 8px;
}
.popover .range-row input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--paper-2);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}
.popover .range-row input:focus { border-color: var(--ink); }

/* Menu list (single-select popovers) */
.popover .pop-list.menu {
  max-height: 320px;
}
.popover .menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: 7px 8px;
  border-radius: var(--radius-s);
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  color: var(--ink-2);
}
.popover .menu-item:hover { background: var(--paper); color: var(--ink); }
.popover .menu-item .check {
  margin-left: auto;
  color: var(--accent);
  font-weight: 700;
  width: 14px;
  text-align: right;
}
.popover .menu-item.selected {
  color: var(--ink);
  font-weight: 600;
}

/* ----------------------------------------------------------
   Result meta
   ---------------------------------------------------------- */

.result-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 4px 2px 14px;
  flex-wrap: wrap;
  gap: 8px;
}
.result-meta .count-big {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.result-meta .count-big em {
  font-style: italic;
  color: var(--accent-ink);
}

/* ----------------------------------------------------------
   Product grid + cards
   ---------------------------------------------------------- */

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

.product {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: transparent;
  /* helps the browser skip layout for offscreen cards */
  content-visibility: auto;
  contain-intrinsic-size: 360px;
}

.product .img-wrap {
  display: block;
  aspect-ratio: 1 / 1;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  overflow: hidden;
  position: relative;
  transition: transform .25s ease, border-color .15s ease;
}
.product:hover .img-wrap {
  transform: translateY(-2px);
  border-color: var(--line-2);
}
.product img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 14px;
  transition: transform .35s ease;
}
.product:hover img { transform: scale(1.03); }

.product .badges {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
  pointer-events: none;
}
.product .badges-left,
.product .badges-right {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.badge.discount {
  padding: 5px 8px;
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  box-shadow: 0 1px 0 rgba(0,0,0,.08);
}
.badge.new {
  padding: 5px 8px;
  background: var(--paper-2);
  color: var(--new);
  border: 1px solid var(--new);
  border-radius: 4px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.badge.gone {
  padding: 5px 8px;
  background: var(--gone-bg);
  color: var(--gone-fg);
  border-radius: 4px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.product .meta-top {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product .meta-top .meta-link { cursor: pointer; }
.product .meta-top .meta-link:hover { color: var(--accent-ink); }

.product .title-link {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--ink);
  font-weight: 500;
  font-size: 14.5px;
  line-height: 1.3;
  min-height: 2.6em;
}
.product .title-link:hover { color: var(--accent-ink); }

.price-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
  margin-top: 2px;
}
.price {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.price.has-discount { color: var(--accent-ink); }
.old-price {
  text-decoration: line-through;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.savings {
  margin-left: auto;
  color: var(--new);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dates {
  display: flex;
  gap: 7px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--muted);
  margin-top: auto;
  padding-top: 4px;
}
.dates span + span::before {
  content: "·";
  margin-right: 7px;
  color: var(--line-2);
}
.dates .sold-date { color: var(--gone-fg); }

/* ----------------------------------------------------------
   Skeleton placeholders
   ---------------------------------------------------------- */

@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skel {
  background: linear-gradient(90deg, #ece5d2 0%, #f4ede0 50%, #ece5d2 100%);
  background-size: 800px 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: var(--radius-m);
}
.skel-card {
  display: flex; flex-direction: column; gap: 8px;
}
.skel-card .skel-img { aspect-ratio: 1 / 1; }
.skel-card .skel-line {
  height: 11px;
  border-radius: 4px;
}
.skel-card .skel-line.short { width: 50%; }

/* ----------------------------------------------------------
   Placeholders / empty
   ---------------------------------------------------------- */

.placeholder {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 14px;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-l);
  background: var(--paper-2);
}

/* ----------------------------------------------------------
   Detail view
   ---------------------------------------------------------- */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 14px;
}
.back-link:hover { color: var(--ink); }

.detail-grid {
  display: grid;
  grid-template-columns: minmax(280px, 480px) 1fr;
  gap: 36px;
  margin-top: 4px;
}
.detail-grid .img-wrap {
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-l);
  border: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
  padding: 24px;
}
.detail-grid img { width: 100%; height: 100%; object-fit: contain; }
.detail-info h2 {
  margin-top: 0;
  font-family: var(--font-serif);
  font-size: 30px;
  letter-spacing: -0.01em;
  font-weight: 600;
  line-height: 1.15;
}
.detail-info .badges {
  position: static;
  margin-bottom: 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.detail-meta {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px 18px;
  margin: 18px 0;
  font-size: 13.5px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}
.detail-meta dt {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  padding-top: 2px;
}
.detail-meta dd { margin: 0; color: var(--ink-2); }
.detail-prices {
  display: flex;
  gap: 16px;
  align-items: baseline;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.detail-prices .price { font-size: 36px; }
.detail-prices .old-price { font-size: 18px; }

.description {
  margin-top: 20px;
  background: var(--paper-2);
  border-radius: var(--radius-m);
  padding: 16px 20px;
  border: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.action-row {
  display: flex;
  gap: 12px;
  font-size: 13.5px;
  margin-top: 8px;
}
.action-row a {
  color: var(--accent-ink);
  font-weight: 500;
  border-bottom: 1px solid currentColor;
  padding-bottom: 1px;
}
.action-row a:hover { color: var(--ink); }

.chart-card {
  margin-top: 28px;
  background:
    linear-gradient(180deg, rgba(251, 248, 238, .88), rgba(255, 255, 255, .96));
  border: 1px solid var(--line-2);
  border-radius: var(--radius-m);
  padding: 16px;
  box-shadow: var(--shadow-card);
}
.chart-card h3 {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 600;
  font-size: 19px;
  margin-bottom: 14px;
}
.chart-panel {
  display: grid;
  gap: 14px;
}
.chart-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  overflow: hidden;
  background: rgba(255, 255, 255, .68);
}
.chart-stat {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-right: 1px solid var(--line);
  min-width: 0;
}
.chart-stat:last-child { border-right: none; }
.chart-stat span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.chart-stat strong {
  color: var(--ink);
  font-size: 19px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.chart-stat.primary strong { color: var(--accent-ink); }
.chart-stat strong.good { color: var(--new); }
.chart-stat strong.bad { color: var(--accent-ink); }
.chart-plot {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 8px 8px 2px;
  overflow: hidden;
}
.chart-card svg {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 900 / 280;
}
.chart-gridline {
  stroke: var(--line);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.chart-area { opacity: .96; }
.chart-dot {
  fill: var(--panel);
  stroke: var(--accent);
  stroke-width: 2.4;
  vector-effect: non-scaling-stroke;
}
.chart-dot.current {
  fill: var(--accent);
  stroke: var(--panel);
  stroke-width: 2;
}
.chart-axis,
.chart-date {
  fill: var(--muted);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.chart-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 18px;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-s);
  background: var(--paper-2);
}

/* ----------------------------------------------------------
   Admin tables
   ---------------------------------------------------------- */

table.admin {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.admin th, table.admin td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
table.admin th {
  background: var(--paper-2);
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.06em;
}
.status-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.status-pill.success { background: var(--new-bg); color: var(--new); }
.status-pill.failed,
.status-pill.aborted_suspicious_count { background: #fbe4df; color: var(--accent-ink); }
.status-pill.running { background: #e2e8f3; color: #1a3a8a; }
.status-pill.partial { background: #fbf0c9; color: #7a5b00; }

.admin-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  overflow-x: auto;
  box-shadow: var(--shadow-card);
}

/* ----------------------------------------------------------
   Mobile
   ---------------------------------------------------------- */

@media (max-width: 720px) {
  .topbar {
    padding: 10px 14px;
    gap: 10px 12px;
    align-items: center;
  }
  .topbar .brand h1 { font-size: 17px; }
  .brand-suffix { display: none; }
  .topnav {
    gap: 0;
    margin-left: 0;
    flex: 0 0 auto;
  }
  .topnav a { padding: 5px 8px; font-size: 12px; }
  #stats {
    width: 100%;
    margin-left: 0;
    order: 3;
    font-size: 11px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-top: 4px;
    border-top: 1px dashed var(--line);
  }
  #stats::-webkit-scrollbar { display: none; }
  #stats .stat-pill { padding: 0 8px 0 0; border-right: none; gap: 3px; }
  #stats .stat-pill::after {
    content: "·";
    margin-left: 6px;
    color: var(--line-2);
  }
  #stats .stat-pill:last-child::after { content: ""; }

  .toolbar { padding: 12px 14px 10px; margin: 0 -14px 14px; }
  main { padding: 12px 14px 60px; }

  .search-wrap input { height: 40px; font-size: 14px; }

  .filter-row {
    overflow-x: auto;
    flex-wrap: nowrap;
    margin-left: -14px;
    margin-right: -14px;
    padding: 0 14px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .filter-row::-webkit-scrollbar { display: none; }
  .fbtn { flex-shrink: 0; }

  .grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .product {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    grid-template-rows: auto auto 1fr;
    gap: 4px 12px;
    align-items: start;
    min-width: 0;
    padding: 9px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-m);
    contain-intrinsic-size: 136px;
  }
  .product .img-wrap {
    grid-row: 1 / span 3;
    width: 112px;
    border-radius: var(--radius-s);
    align-self: stretch;
  }
  .product:hover .img-wrap {
    transform: none;
    border-color: var(--line);
  }
  .product img { padding: 7px; }
  .product:hover img { transform: none; }
  .product .badges {
    top: 6px;
    left: 6px;
    right: 6px;
    gap: 4px;
  }
  .product .badges-left,
  .product .badges-right { gap: 4px; }
  .product .badge.discount,
  .product .badge.new,
  .product .badge.gone {
    padding: 4px 6px;
    font-size: 9px;
  }
  .product .meta-top {
    margin-top: 0;
    font-size: 9px;
    line-height: 1.25;
  }
  .product .title-link {
    font-size: 13px;
    line-height: 1.28;
    min-height: 0;
    -webkit-line-clamp: 3;
  }
  .price-row {
    align-self: end;
    gap: 6px;
    margin-top: 2px;
  }
  .price { font-size: 15px; }
  .old-price { font-size: 12px; }
  .savings { display: none; } /* keep card tight on mobile */

  .result-meta .count-big { font-size: 18px; }

  .detail-grid { grid-template-columns: 1fr; gap: 22px; }
  .detail-meta { grid-template-columns: 1fr; gap: 2px 0; }
  .detail-meta dt { padding-top: 8px; }
  .detail-info h2 { font-size: 24px; }
  .detail-prices .price { font-size: 28px; }
  .chart-card {
    margin-top: 20px;
    padding: 12px;
  }
  .chart-card h3 {
    font-size: 18px;
    margin-bottom: 10px;
  }
  .chart-summary {
    grid-template-columns: 1fr 1fr;
  }
  .chart-stat {
    padding: 9px 10px;
  }
  .chart-stat.primary {
    grid-column: 1 / -1;
    border-bottom: 1px solid var(--line);
  }
  .chart-stat:nth-child(2) { border-right: 1px solid var(--line); }
  .chart-stat strong { font-size: 17px; }
  .chart-axis,
  .chart-date { font-size: 10px; }

  .popover {
    position: fixed;
    left: 12px; right: 12px;
    top: auto;
    bottom: calc(12px + env(safe-area-inset-bottom));
    max-width: none;
    max-height: min(70vh, 430px);
    max-height: min(70svh, 430px);
    display: flex;
    flex-direction: column;
  }
  .popover[hidden] { display: none; }
  .popover .pop-list {
    flex: 1 1 auto;
    min-height: 0;
  }
}

@media (max-width: 360px) {
  .topbar { padding: 10px 12px; }
  .topnav a { padding: 4px 6px; }
  .product {
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 4px 10px;
    padding: 8px;
  }
  .product .img-wrap { width: 96px; }
}
