:root {
  --bg: #f4f6f3; --card: #ffffff; --ink: #16211b; --mute: #5f6c64; --line: #e2e7e2;
  --brand: #1f6f4a; --brand-ink: #ffffff; --brand-soft: #e3f1e9; --accent: #d98c1a; --accent-soft: #fdf1dc;
  --ok: #2e8b57; --ok-soft: #e6f4ec; --danger: #b23b3b; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
  --r: 14px; --tabs-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1a14; --card: #172420; --ink: #e8efe9; --mute: #9aa89f; --line: #243229;
    --brand: #4fb582; --brand-ink: #0b1a12; --brand-soft: #1b3327; --accent: #f0b04b; --accent-soft: #3a2c12;
    --ok: #5ccf8f; --ok-soft: #173424; --danger: #ff8080; --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
body { padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--brand); color: var(--brand-ink); }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 32px; height: 32px; }
.top h1 { font-size: 20px; }
.top p { margin: 0; font-size: 12px; opacity: .85; }
.pill { padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.18); font-weight: 600; font-size: 14px; }
.pill:active { background: rgba(255,255,255,.3); }

.view { padding: 12px 16px 24px; max-width: 760px; margin: 0 auto; }

.weeknav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 12px; }
.weeknav button.arrow { width: 42px; height: 42px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow); font-size: 20px; }
.weeknav .title { text-align: center; }
.weeknav .title b { display: block; font-size: 18px; }
.weeknav .title small { color: var(--mute); }

.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--card); border-radius: var(--r); padding: 10px 12px; box-shadow: var(--shadow); }
.stat small { display: block; color: var(--mute); font-size: 12px; }
.stat b { font-size: 18px; }
.stat.accent { background: var(--brand-soft); }

.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 12px; }
.card h3 { padding: 10px 14px; font-size: 13px; color: var(--mute); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; }
.row { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .name { font-weight: 600; }
.row .meta { color: var(--mute); font-size: 13px; }
.row .amt { text-align: right; }
.row .amt b { display: block; }
.row .amt small { color: var(--mute); font-size: 12px; }
.row.done .name, .row.done .amt { text-decoration: line-through; opacity: .55; }
.check { width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--line); display: grid; place-items: center; color: var(--brand-ink); background: var(--card); }
.row.done .check { background: var(--ok); border-color: var(--ok); }
.row.plain { grid-template-columns: 1fr auto; }
.qty { display: inline-block; min-width: 30px; padding: 2px 8px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 700; text-align: center; margin-right: 6px; }
.step { display: inline-flex; align-items: center; gap: 2px; }
.step .qty { margin: 0; min-width: 34px; padding: 4px 6px; }
.step button { width: 34px; height: 34px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); font-size: 20px; font-weight: 700; line-height: 1; }
.step button:active { background: var(--brand); color: var(--brand-ink); }
.row .amt small { display: block; margin-top: 2px; }
.row.zero .name, .row.zero .meta { opacity: .45; }
.tag.warn { background: var(--accent-soft); color: var(--accent); }

.actions { display: flex; gap: 8px; margin: 12px 0 4px; }
.btn { flex: 1; padding: 12px; border-radius: 12px; background: var(--brand); color: var(--brand-ink); font-weight: 700; text-align: center; }
.btn.ghost { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.btn:active { opacity: .85; }

.month { margin-bottom: 10px; }
.month > button { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; text-align: left; }
.month > button b { font-size: 16px; }
.month > button small { color: var(--mute); display: block; }
.month .body { display: none; border-top: 1px solid var(--line); }
.month.open .body { display: block; }
.month .week { display: flex; justify-content: space-between; padding: 8px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.month .week.past { color: var(--mute); }
.chev { transition: transform .2s; color: var(--mute); }
.month.open .chev { transform: rotate(180deg); }

.search { position: sticky; top: calc(52px + env(safe-area-inset-top)); z-index: 4; background: var(--bg); padding: 6px 0 8px; }
.search input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 16px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { white-space: nowrap; padding: 6px 12px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); font-size: 13px; font-weight: 600; }
.chip.on { background: var(--brand); color: var(--brand-ink); }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--ok-soft); color: var(--ok); font-weight: 700; margin-left: 6px; }

.bars { display: flex; gap: 2px; align-items: flex-end; height: 26px; }
.bars i { flex: 1; background: var(--brand); opacity: .35; border-radius: 2px 2px 0 0; min-height: 2px; }
.bars i.hi { opacity: 1; }
.rank { color: var(--mute); font-weight: 700; font-size: 13px; width: 28px; }

.empty { text-align: center; color: var(--mute); padding: 32px 12px; }
.note { color: var(--mute); font-size: 13px; margin: 8px 2px; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr); background: var(--card); border-top: 1px solid var(--line); z-index: 5; }
.tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; color: var(--mute); font-weight: 600; }
.tabs button .ico { font-size: 20px; }
.tabs button.on { color: var(--brand); }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; transition: .25s; pointer-events: none; z-index: 9; white-space: nowrap; }
.toast.show { opacity: 1; transform: translateX(-50%); }
