:root {
  --bg: #f6f5f0;
  --card: #ffffff;
  --ink: #1c1917;
  --muted: #6b6560;
  --line: #e5e2da;
  --accent: #166534;
  --accent-ink: #ffffff;
  --best: #15803d;
  --best-bg: #ecfdf3;
  --danger: #b91c1c;
  --chip: #f1efe9;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141311;
    --card: #1e1c19;
    --ink: #efece6;
    --muted: #a39c93;
    --line: #2e2b27;
    --accent: #22c55e;
    --accent-ink: #06240f;
    --best: #4ade80;
    --best-bg: #102a1a;
    --chip: #26231f;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: inherit; text-decoration: none; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .2px; }
.topbar nav { display: flex; gap: 12px; font-size: 15px; }
.topbar nav a { color: var(--muted); }
.topbar nav a:hover { color: var(--ink); }
.container { max-width: 680px; margin: 0 auto; padding: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 10px 0; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 8px; }
.meta { color: var(--muted); font-size: 14px; }
.notes { margin: 8px 0 0; }
.flashes { margin: 8px 0; }
.flash { background: var(--best-bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 6px 0; font-size: 14px; }
.error { color: var(--danger); margin: 0; }
.login { max-width: 320px; margin: 12vh auto; display: flex; flex-direction: column; gap: 10px; }
.login h1 { text-align: center; }
input, select, textarea, button { font: inherit; }
input, select, textarea {
  width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink); min-height: 42px;
}
button {
  cursor: pointer; border: 0; border-radius: 8px; background: var(--accent);
  color: var(--accent-ink); padding: 10px 14px; font-weight: 600; min-height: 42px;
}
button.subtle { background: var(--chip); color: var(--ink); font-weight: 500; }
button.danger.subtle { background: var(--chip); color: var(--danger); }
button.x { background: none; color: var(--muted); font-size: 18px; padding: 0 6px; min-height: 32px; }
.addbar, .searchbar { display: flex; gap: 8px; margin: 10px 0; align-items: stretch; }
.addbar input[type=number] { width: 64px; flex: 0 0 auto; }
.grid2 { display: grid; gap: 8px; }
.grid2 button { justify-self: start; }
.rowline { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.summary .mixline { display: flex; flex-wrap: wrap; gap: 10px; font-size: 15px; }
.summary .save { color: var(--best); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { background: var(--chip); border-radius: 999px; padding: 3px 10px; font-size: 13px; color: var(--muted); }
.chip.warn { color: var(--danger); }
.items { list-style: none; margin: 10px 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px;
}
.item .info { flex: 1; min-width: 0; }
.item .name { display: block; font-weight: 600; }
.item .meta { font-size: 13px; color: var(--muted); }
.item .right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; white-space: nowrap; }
.best { color: var(--best); font-weight: 600; font-size: 14px; }
.best.big { font-size: 18px; }
.best em { font-style: normal; font-weight: 400; color: var(--muted); font-size: 13px; }
.best.dim { color: var(--muted); font-weight: 400; }
.noprice { color: var(--muted); font-size: 13px; }
.sub { font-size: 12px; color: var(--muted); }
.check {
  width: 26px; height: 26px; min-height: 26px; flex: 0 0 auto; border-radius: 50%;
  border: 2px solid var(--line); background: var(--card); padding: 0;
}
.item.done .check { background: var(--best); border-color: var(--best); }
.item.done .name { text-decoration: line-through; color: var(--muted); }
.qty { display: flex; align-items: center; gap: 6px; }
.qty button { width: 28px; height: 28px; min-height: 28px; padding: 0; border-radius: 50%; background: var(--chip); color: var(--ink); font-weight: 700; }
.qty span { min-width: 18px; text-align: center; }
.del { background: none; color: var(--muted); font-size: 20px; padding: 0 4px; min-height: 28px; }
.empty { color: var(--muted); text-align: center; padding: 18px 0; }
.checkedbox summary { cursor: pointer; color: var(--muted); }
details.card summary { cursor: pointer; font-weight: 600; }
.prices { width: 100%; border-collapse: collapse; margin: 6px 0; }
.prices th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line); padding: 4px 6px; }
.prices td { padding: 6px; border-bottom: 1px solid var(--line); font-size: 14px; }
.prices tr.cheapest td { background: var(--best-bg); }
.prices .num { text-align: right; font-variant-numeric: tabular-nums; }
.prices .ta-right { text-align: right; }
.prices form { display: inline; }
.dim { color: var(--muted); }
.dealnote { display: block; font-size: 12px; color: var(--best); }
.meta.deal { color: var(--best); }
.meta.alt { color: var(--best); }
.sub.deal { color: var(--best); }
.prodlist { list-style: none; margin: 10px 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.prod {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px;
}
.prod .name { font-weight: 600; display: block; }
.prod .meta { font-size: 13px; color: var(--muted); display: block; }
.prod .right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; white-space: nowrap; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 18px 0 calc(18px + env(safe-area-inset-bottom)); }
@media (min-width: 560px) {
  .grid2 { grid-template-columns: 1fr 1fr; }
  .grid2 textarea, .grid2 button { grid-column: 1 / -1; }
}
