:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #1d2320;
  --muted: #66706a;
  --line: #e3e0d8;
  --accent: #1f7a4d;
  --accent-ink: #ffffff;
  --accent-soft: #e2f1e8;
  --warn: #8a5a00;
  --warn-soft: #fbf0d6;
  --bad: #b3261e;
  --radius: 14px;
  --tap: 46px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121513;
    --card: #1b201d;
    --ink: #eceee9;
    --muted: #9aa49e;
    --line: #2c332f;
    --accent: #4fc08a;
    --accent-ink: #0b1a12;
    --accent-soft: #1d3326;
    --warn: #f0c566;
    --warn-soft: #3a3016;
    --bad: #ff8a80;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(70px + env(safe-area-inset-bottom));
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.05rem; }
.muted { color: var(--muted); font-size: .88rem; }
.error { color: var(--bad); min-height: 1.2em; margin: 0; }
button, input { font: inherit; color: inherit; }
button {
  min-height: var(--tap); padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); cursor: pointer;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.ghost { background: transparent; }
input {
  width: 100%; min-height: var(--tap); padding: 0 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card);
}
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

#top {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid var(--line);
}
.trip { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.big { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; }
.menu { display: grid; gap: 8px; padding-top: 10px; }

main { padding: 12px 16px; max-width: 720px; margin: 0 auto; }
.view > * + * { margin-top: 12px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.store-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 12px 14px; width: 100%; border: 0; border-radius: 0; text-align: left;
  background: transparent; min-height: 56px;
}
.store-head .name { font-weight: 700; }
.store-head .sub { color: var(--muted); font-size: .85rem; }
.store-head .sum { font-weight: 700; white-space: nowrap; }
.note {
  margin: 0; padding: 10px 14px; background: var(--accent-soft);
  font-size: .92rem; border-top: 1px solid var(--line);
}
.note.warn { background: var(--warn-soft); color: var(--warn); }
.items { list-style: none; margin: 0; padding: 0; }
.item {
  display: grid; grid-template-columns: 34px 1fr auto; gap: 8px; align-items: start;
  padding: 10px 14px; border-top: 1px solid var(--line);
}
.item.done .nm { text-decoration: line-through; color: var(--muted); }
.tick {
  width: 30px; height: 30px; min-height: 30px; padding: 0; border-radius: 9px;
  border: 2px solid var(--line); background: var(--card); font-size: 1.05rem; line-height: 1;
}
.tick[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.nm { font-weight: 600; overflow-wrap: anywhere; }
.grow { cursor: pointer; min-height: 30px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tag {
  font-size: .76rem; padding: 2px 8px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.plain { background: transparent; border: 1px solid var(--line); color: var(--muted); font-weight: 500; }
.price { text-align: right; font-weight: 700; white-space: nowrap; }
.price small { display: block; color: var(--muted); font-weight: 400; font-size: .78rem; }
.row-actions { grid-column: 2 / 4; display: flex; gap: 8px; align-items: center; }
.row-actions button { min-height: 36px; padding: 0 12px; font-size: .88rem; }
.qty { display: inline-flex; align-items: center; gap: 6px; }
.qty button { min-width: 36px; padding: 0; }

.searchbar { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.result {
  display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
  padding: 12px 14px; border-top: 1px solid var(--line);
}
.result:first-child { border-top: 0; }
.result .nm { font-weight: 600; }
.section-title { padding: 10px 14px 0; font-weight: 700; }

.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.sheet {
  position: fixed; inset: 0; z-index: 20; background: var(--bg);
  display: grid; place-items: center; padding: 16px;
}
.login { padding: 20px; width: min(420px, 100%); display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-weight: 600; }
label .muted { font-weight: 400; }

nav#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid;
  grid-template-columns: repeat(3, 1fr); background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
nav#tabs button { border: 0; border-radius: 0; min-height: 56px; background: transparent; color: var(--muted); font-weight: 600; }
nav#tabs button.on { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 30;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px;
  max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.stat { display: flex; justify-content: space-between; padding: 10px 14px; border-top: 1px solid var(--line); }
.stat:first-child { border-top: 0; }
.stat b { white-space: nowrap; }
.coupon { padding: 10px 14px; border-top: 1px solid var(--line); }
.coupon:first-child { border-top: 0; }
.spin { padding: 20px; text-align: center; color: var(--muted); }
@media (min-width: 720px) { main { padding-top: 20px; } }

a.btn {
  display: flex; align-items: center; justify-content: center; min-height: var(--tap);
  border-radius: 12px; border: 1px solid var(--line); text-decoration: none;
  background: var(--card); color: var(--ink); font-weight: 600;
}
a.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ---- reports ---------------------------------------------------------- */
/* The report picker scrolls sideways rather than wrapping: seven titles
   stacked two-deep pushed the report itself off a phone screen. */
.report-picker {
  display: flex; gap: 8px; overflow-x: auto; padding: 10px 14px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.report-picker::-webkit-scrollbar { display: none; }
.report-picker button {
  flex: 0 0 auto; min-height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-weight: 600; font-size: 14px; white-space: nowrap;
}
.report-picker button.on {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}
.report-picker button.pending { opacity: 0.55; }

.report { padding: 0 14px 28px; line-height: 1.5; }
.report h1 { font-size: 20px; margin: 14px 0 6px; }
.report h2 { font-size: 17px; margin: 22px 0 6px; }
.report h3 { font-size: 15px; margin: 18px 0 4px; color: var(--muted); }
.report p { margin: 8px 0; }
.report ul, .report ol { margin: 8px 0; padding-left: 22px; }
.report li { margin: 3px 0; }
.report hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.report code {
  background: var(--card); border: 1px solid var(--line); border-radius: 5px;
  padding: 1px 5px; font-size: 13px;
}
.report blockquote {
  margin: 12px 0; padding: 10px 12px; background: var(--card);
  border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0;
}
/* Report tables run to eight columns, so they scroll on their own rather
   than making the whole page scroll sideways. */
.report .tablewrap { overflow-x: auto; margin: 10px 0; }
.report table { border-collapse: collapse; width: 100%; font-size: 13px; }
.report th, .report td {
  border-bottom: 1px solid var(--line); padding: 7px 10px;
  text-align: left; vertical-align: top; white-space: nowrap;
}
.report th { color: var(--muted); font-weight: 600; }
.report td:first-child, .report th:first-child { white-space: normal; min-width: 150px; }
