:root {
  color-scheme: light dark;
  --bg: #faf8f5;
  --surface: #ffffff;
  --text: #1d1b18;
  --muted: #6b655c;
  --line: #e5dfd6;
  --accent: #8a5a12;
  --accent-soft: #f6ead6;
  --good: #1f7a45;
  --good-soft: #e3f3e8;
  --bad: #a3361f;
  --focus: #2b6cb0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151412;
    --surface: #1e1c19;
    --text: #ece7df;
    --muted: #a39b8f;
    --line: #35312b;
    --accent: #e0a64a;
    --accent-soft: #3a2d18;
    --good: #6fcf97;
    --good-soft: #1c3326;
    --bad: #f08a6c;
    --focus: #7fb3ff;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
.top, main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; }
h1 { margin: 0; font-size: 1.4rem; }
h2 { margin: 28px 0 10px; font-size: 1.05rem; }
h3 { margin: 0; font-size: 1rem; }
.muted { color: var(--muted); font-size: 0.9em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.tabs { display: flex; gap: 4px; margin-left: auto; }
.tabs button { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.tabs button[aria-pressed="true"] { background: var(--text); color: var(--bg); }

.add { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px; }
.field { position: relative; display: flex; flex-direction: column; gap: 4px; }
.field.grow { flex: 1 1 260px; }
label { color: var(--muted); font-size: 0.85rem; }
input[type="search"], select { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; }

/* The list takes its own space, so it never covers the tick boxes of the matching listings. */
#suggestions { margin: 4px 0 0; padding: 4px; list-style: none; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
#suggestions li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: 6px; cursor: pointer; overflow-wrap: anywhere; }
#suggestions li:hover, #suggestions li[aria-selected="true"] { background: var(--accent-soft); }

.matches { margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.matches-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; }
.matches-head p { flex: 1 1 auto; margin: 0; }
#match-list { max-height: 320px; margin: 8px 0; padding: 0; overflow-y: auto; list-style: none; }
#match-list label { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; padding: 6px 4px; color: var(--text); font-size: 1rem; cursor: pointer; }
#match-list .match-name { overflow-wrap: anywhere; }
#match-list .muted { grid-column: 2; }
#match-list .match-price { grid-column: 3; grid-row: 1 / span 2; align-self: center; text-align: right; }
#match-list .note { padding: 6px 4px; color: var(--muted); }

button.link { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; }
button.primary { padding: 10px 16px; border: 0; border-radius: 10px; background: var(--accent); color: var(--surface); font: inherit; cursor: pointer; }
button.primary:disabled { opacity: 0.5; cursor: default; }
.live { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 12px; }
.live p { margin: 0; }
/* A display rule must not show an element that has the hidden attribute. */
[hidden] { display: none !important; }

.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table { width: 100%; min-width: max-content; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
thead th { color: var(--muted); font-size: 0.85rem; font-weight: 600; white-space: nowrap; }
tbody th { position: sticky; left: 0; min-width: 160px; max-width: 220px; background: var(--surface); font-weight: 500; overflow-wrap: anywhere; }
td.offer { white-space: nowrap; }
td.best { background: var(--good-soft); }
td.best .price { color: var(--good); font-weight: 700; }
td.unticked .price { opacity: 0.45; text-decoration: line-through; }
td.out, td.none { color: var(--muted); }
td.good { color: var(--good); }
td.bad { color: var(--bad); }
.price { padding: 0 0 0 6px; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.per-ml { display: block; padding-left: 26px; color: var(--muted); font-size: 0.8rem; }
.fallback { color: var(--muted); font-size: 0.85em; }
.badge { margin-left: 6px; padding: 1px 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 0.75rem; }

.detail { margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow-wrap: anywhere; }
.detail p { margin: 6px 0; }
.detail a { margin-right: 16px; color: var(--accent); }

.summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.seller-card { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.seller-card header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; margin: 8px 0; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; text-align: right; }
.checks { margin: 8px 0 0; padding: 0; list-style: none; }
.checks .met { color: var(--good); }
.checks .unmet { color: var(--bad); }
.notes { margin: 8px 0 0; color: var(--muted); font-size: 0.85rem; }
.empty { color: var(--muted); }
.error { padding: 12px; border-radius: 10px; background: var(--accent-soft); color: var(--bad); }

@media (max-width: 600px) {
  .tabs { margin-left: 0; }
  tbody th { min-width: 130px; }
}

.howto { margin-bottom: 16px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--accent-soft); }
.howto-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.howto h2 { margin: 0; }
.howto p, .howto ol { margin: 8px 0 0; }
.howto ol { padding-left: 20px; }
#match-hint { margin: 8px 0 0; }

.seller-filter { margin-bottom: 12px; }
.seller-filter-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; overflow-wrap: anywhere; }
.seller-filter-panel { margin-top: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.seller-filter-actions { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; }
.seller-filter-actions p { flex: 1 1 260px; margin: 0; }
#seller-filter-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 16px; margin: 10px 0; padding: 0; list-style: none; }
#seller-filter-list label { display: flex; align-items: baseline; gap: 8px; padding: 6px 4px; color: var(--text); font-size: 1rem; cursor: pointer; }
#seller-filter-list .muted { margin-left: auto; white-space: nowrap; }
td.none .link { margin-left: 8px; }
