:root {
  --bg: #faf6f0;
  --surface: #ffffff;
  --surface-2: #f3ece2;
  --text: #2a1d10;
  --muted: #76675a;
  --line: #e6dccd;
  --accent: #b5651d;
  --accent-ink: #ffffff;
  --good: #2f7d4f;
  --good-bg: #e3f2e8;
  --warn: #9a5b00;
  --bad: #b3261e;
  --shadow: 0 1px 2px rgb(42 29 16 / 0.06), 0 4px 16px rgb(42 29 16 / 0.05);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15110d;
    --surface: #1f1914;
    --surface-2: #2a221b;
    --text: #f3e9dc;
    --muted: #a8998a;
    --line: #3a3027;
    --accent: #e0953f;
    --accent-ink: #1a1007;
    --good: #6fcf97;
    --good-bg: #1d3326;
    --warn: #f0b45a;
    --bad: #ff8a80;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: inherit; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.top h1 { margin: 0; padding-top: 14px; font-size: 1.5rem; letter-spacing: -0.01em; }
.mark { color: var(--accent); }
.sub { margin: 2px 0 8px; color: var(--muted); font-size: 0.92rem; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs button {
  border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600; white-space: nowrap;
  padding: 8px 12px 10px; border-bottom: 3px solid transparent; cursor: pointer;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.count { font-weight: 500; color: var(--muted); font-size: 0.85em; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; align-items: center; }
.filters input, .filters select {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; min-width: 0;
}
.filters input { flex: 1 1 220px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.chip {
  font: inherit; font-size: 0.85rem; padding: 4px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
}
.chips-label { font-size: 0.8rem; font-weight: 600; color: var(--muted); align-self: center; margin-right: 2px; }
.chip-n { opacity: 0.7; font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.card {
  display: grid; grid-template-columns: 76px 1fr; gap: 12px; padding: 14px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); text-decoration: none;
  transition: border-color 0.15s;
}
.card:hover { border-color: var(--accent); }
.card .img { width: 76px; height: 110px; border-radius: 8px; background: #fff; display: grid; place-items: center; overflow: hidden; }
.card .img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.card .img.none::after { content: "◆"; color: #c8811f; font-size: 1.6rem; }
.card .body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.card .name { font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .shop { color: var(--muted); font-size: 0.85rem; }
.price { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.price .now { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.price .was { color: var(--muted); text-decoration: line-through; font-size: 0.9rem; }
.price .off { color: var(--good); background: var(--good-bg); font-weight: 700; font-size: 0.8rem; padding: 1px 7px; border-radius: 6px; }
.meta { color: var(--muted); font-size: 0.8rem; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.badge { font-size: 0.75rem; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); color: var(--text); }
.badge.low { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.badge.out { color: var(--bad); }
.elsewhere { font-size: 0.8rem; color: var(--warn); }
.spark { width: 100%; height: 26px; display: block; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.spark circle { fill: var(--accent); }

.tips { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.tips li a {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; padding: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none;
}
.tips img, .tips .noimg { width: 56px; height: 56px; object-fit: contain; border-radius: 8px; background: #fff; }
.tips .t { font-weight: 600; line-height: 1.3; }
.tips .m { color: var(--muted); font-size: 0.85rem; }
.tips .p { font-weight: 700; font-size: 1.15rem; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.hit { color: var(--good); font-weight: 700; }
.ok { color: var(--good); }
.fail { color: var(--bad); }

.note { color: var(--muted); font-size: 0.92rem; margin: 0 0 14px; max-width: 70ch; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }
.more { text-align: center; color: var(--muted); }
.foot { color: var(--muted); font-size: 0.85rem; padding-top: 24px; padding-bottom: 40px; max-width: 80ch; }

@media (max-width: 520px) {
  .grid { grid-template-columns: 1fr; }
  /* One swipeable line per chip row, so the filters don't push the deals off the first screen. */
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .chips::-webkit-scrollbar { display: none; }
  .chip, .chips-label { flex: none; }
  .tips li a { grid-template-columns: 44px 1fr auto; }
  .tips img, .tips .noimg { width: 44px; height: 44px; }
}
