:root {
  --green: #16a34a;
  --green-dark: #15803d;
  --ink: #0f172a;
  --muted: #64748b;
  --bg: #f8fafc;
  --card: #ffffff;
  --line: #e2e8f0;
  --walmart: #0071ce;
  --aldi: #e8720c;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 19px;
  line-height: 1.35;
}
#app { max-width: 560px; margin: 0 auto; padding: 12px 14px 90px; }
.hidden { display: none !important; }

.topbar { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 2px; }
.topbar h1 { font-size: 26px; margin: 0; }
.top-actions { display: flex; align-items: center; gap: 8px; }

.counts { color: var(--muted); font-size: 17px; margin: 2px 0 10px; }
.counts strong { color: var(--ink); }

.filters { display: flex; gap: 8px; margin-bottom: 12px; }
.fchip {
  flex: 1; padding: 12px 0; font-size: 18px; font-weight: 700;
  border: 2px solid var(--line); border-radius: 999px; background: var(--card);
  color: var(--muted); cursor: pointer;
}
.fchip.on-all { border-color: var(--green); color: var(--green-dark); background: #f0fdf4; }
.fchip.on-walmart { border-color: var(--walmart); color: var(--walmart); background: #eff6ff; }
.fchip.on-aldi { border-color: var(--aldi); color: var(--aldi); background: #fff7ed; }

.addrow { display: flex; gap: 8px; margin-bottom: 10px; }
.addrow input {
  flex: 1; font-size: 20px; padding: 14px; border: 2px solid var(--line);
  border-radius: 14px; background: var(--card); color: var(--ink);
}
.addrow input:focus { outline: none; border-color: var(--green); }

.btn {
  font-size: 19px; font-weight: 700; border: none; border-radius: 14px;
  padding: 14px 20px; cursor: pointer; background: var(--line); color: var(--ink);
  min-height: 52px;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:active { background: var(--green-dark); }
.btn-small { padding: 9px 14px; font-size: 16px; min-height: 44px; background: #e8f5ec; color: var(--green-dark); }
.btn-scan {
  width: 100%; background: var(--ink); color: #fff; margin-bottom: 14px;
  font-size: 20px;
}
.btn-ghost {
  width: 100%; background: transparent; color: var(--muted); margin-top: 14px;
  border: 2px dashed var(--line);
}
.btn-big { width: 100%; margin-top: 10px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 10px; background: var(--card);
  border: 1px solid var(--line); border-radius: 14px; padding: 8px 10px;
  min-height: 62px;
}
.row.done { opacity: 0.55; }
.row.done .txt { text-decoration: line-through; color: var(--muted); }
.check {
  width: 46px; height: 46px; flex: 0 0 46px; border-radius: 12px;
  border: 3px solid var(--green); background: #fff; font-size: 26px; font-weight: 900;
  color: var(--green); cursor: pointer; line-height: 1;
}
.row.done .check { background: var(--green); color: #fff; }
.txt { flex: 1; font-size: 20px; overflow-wrap: anywhere; }
.txt-edit { flex: 1; font-size: 20px; padding: 8px; border: 2px solid var(--green); border-radius: 10px; }

.store {
  flex: 0 0 auto; font-size: 14px; font-weight: 800; padding: 10px 12px;
  border-radius: 999px; border: 2px solid var(--line); background: #f8fafc;
  color: var(--muted); cursor: pointer; min-height: 44px; min-width: 76px;
}
.store-walmart { border-color: var(--walmart); color: var(--walmart); background: #eff6ff; }
.store-aldi { border-color: var(--aldi); color: var(--aldi); background: #fff7ed; }
.store-both {
  border-color: var(--walmart); color: #fff;
  background: linear-gradient(135deg, var(--walmart) 50%, var(--aldi) 50%);
}
.del {
  flex: 0 0 44px; width: 44px; height: 44px; border: none; border-radius: 12px;
  background: transparent; color: var(--muted); font-size: 28px; cursor: pointer;
}

.empty { text-align: center; color: var(--muted); padding: 34px 10px; font-size: 19px; }

.sheet {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-card {
  background: #fff; width: 100%; max-width: 560px; border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(24px + env(safe-area-inset-bottom)); max-height: 86vh; overflow-y: auto;
}
.sheet-card h2 { margin: 0 0 8px; font-size: 22px; }
.sheet-card p { color: var(--muted); font-size: 17px; }
.codebox {
  font-size: 30px; font-weight: 900; letter-spacing: 2px; text-align: center;
  background: #f0fdf4; border: 2px dashed var(--green); border-radius: 14px;
  padding: 14px; margin: 12px 0; color: var(--green-dark);
}
.review-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.review-row input[type="text"] { flex: 1; font-size: 19px; padding: 10px; border: 2px solid var(--line); border-radius: 10px; }
.rcheck { width: 40px; height: 40px; flex: 0 0 40px; accent-color: var(--green); }
.scan-note { font-size: 15px; color: var(--muted); background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.progress { text-align: center; padding: 26px 10px; font-size: 20px; color: var(--muted); }
.spinner { font-size: 34px; animation: spin 1.2s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.sync-pill { font-size: 14px; font-weight: 700; padding: 6px 12px; border-radius: 999px; background: #f0fdf4; color: var(--green-dark); }
.sync-pill.warn { background: #fef2f2; color: #b91c1c; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(26px + env(safe-area-inset-bottom)); z-index: 99;
  background: var(--ink); color: #fff; font-size: 17px; font-weight: 600;
  padding: 14px 20px; border-radius: 14px; max-width: 92vw; text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
