:root {
  --bg: #f7f5f2; --card: #fff; --text: #22201c; --muted: #77716a; --line: #e6e1da;
  --accent: #c2410c; --accent-soft: #fde8dc; --good: #15803d; --warn: #b45309; --bad: #b91c1c;
  --radius: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #171513; --card: #211f1c; --text: #ece8e2; --muted: #9b948b; --line: #35312c;
          --accent: #fb923c; --accent-soft: #3b2417; --good: #4ade80; --warn: #fbbf24; --bad: #f87171; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: .2em 0 .5em; }
h2 { font-size: 1.1rem; margin: .2em 0 .6em; }
h3 { font-size: 1rem; margin: 0 0 .4em; }
main { max-width: 1200px; margin: 0 auto; padding: 1rem; }
main.narrow { max-width: 380px; margin-top: 10vh; }

.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem; padding: .6rem 1rem;
          background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; color: var(--text); }
.topbar nav { display: flex; flex-wrap: wrap; gap: .2rem; }
.topbar nav a { padding: .3rem .6rem; border-radius: 6px; color: var(--muted); }
.topbar nav a.active, .topbar nav a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
details.card > summary { cursor: pointer; font-weight: 600; }
details.card[open] > summary { margin-bottom: .6rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 0 1rem; align-items: start; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem;
        display: flex; flex-direction: column; gap: .15rem; color: var(--text); }
a.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile .label, .stat .label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.tile .big { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: .85rem; color: var(--muted); }
.stat { padding: .4rem .8rem; border: 1px solid var(--line); border-radius: 8px; }
progress { width: 100%; height: 6px; accent-color: var(--accent); }

.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.row.nowrap { flex-wrap: nowrap; }
.row.between { justify-content: space-between; }
.row.wrap { gap: .6rem; }
.spacer { flex: 1; }
.grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: .6rem; }
.filters { margin-bottom: 1rem; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .7rem 1rem; }
.fields .wide { grid-column: 1 / -1; }
.fields h2 { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: .2rem; font-size: .9rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: .4rem; color: var(--text); }
.row > label { flex-direction: row; align-items: center; gap: .4rem; }
.row > label.grow { flex-direction: column; align-items: stretch; }
input, select, textarea, button, .button { font: inherit; }
input, select, textarea { padding: .4rem .55rem; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); color: var(--text); min-width: 0; }
textarea { width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button, .button { display: inline-block; padding: .45rem .9rem; border-radius: 7px; border: 1px solid var(--accent);
                  background: var(--accent); color: #fff; cursor: pointer; font-weight: 600; white-space: nowrap; }
button.secondary, .button.secondary { background: transparent; color: var(--accent); }
button.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
button.small, .button.small { padding: .2rem .55rem; font-size: .85rem; }
button.link { background: none; border: none; color: var(--muted); padding: 0 .2rem; font-weight: 400; }
button.link:hover { color: var(--bad); }
.button:hover { text-decoration: none; }
form.inline { display: inline; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
th, td { padding: .4rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.compact td, table.compact th { padding: .25rem .4rem; }
table.rows td { padding: .2rem .25rem; border: none; }
table.rows input:not([type=checkbox]) { width: 100%; }
tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.active td { background: var(--accent-soft); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.good { color: var(--good); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }
.pill { display: inline-block; font-size: .72rem; padding: .05rem .45rem; border-radius: 99px; background: var(--accent-soft); color: var(--accent); vertical-align: middle; }
.pill.new { background: #dbeafe; color: #1d4ed8; }
.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.flash.ok { background: #dcfce7; color: #14532d; }
.flash.err { background: #fee2e2; color: #7f1d1d; }
.flash ul { margin: .3rem 0 0; }
ul.plain { list-style: none; padding: 0; margin: 0 0 .8rem; }
ul.plain li { padding: .2rem 0; }
details > summary { cursor: pointer; color: var(--muted); }
details form { margin-top: .4rem; }
.bar { display: inline-block; height: .7rem; width: var(--w); background: var(--accent); border-radius: 3px; vertical-align: middle; min-width: 2px; max-width: 100%; }
td .bar { max-width: 60px; }
td.barcell { width: 40%; }
td.barcell .bar { max-width: 100%; }

.week { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.day.today { border-color: var(--accent); }
.planned { display: flex; flex-wrap: wrap; gap: .3rem; align-items: baseline; padding: .3rem 0; border-bottom: 1px dashed var(--line); }

ul.shopping { list-style: none; padding: 0; margin: 0; }
ul.shopping li { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .45rem 0; border-bottom: 1px solid var(--line); }
ul.shopping li:last-child { border-bottom: none; }
ul.shopping li.done .grow { text-decoration: line-through; color: var(--muted); }
.check-btn { background: none; border: none; color: var(--text); font-size: 1.3rem; padding: 0 .2rem; }
details.bought > summary { list-style: none; color: #fff; }
details.bought[open] { flex-basis: 100%; order: 5; }
details.bought[open] > summary { display: none; }
.instructions p { margin: .4rem 0; }

@media (max-width: 640px) {
  .grid2 { grid-template-columns: 1fr; }
  main { padding: .6rem; }
  table.list thead { display: none; }
  .tile .big { font-size: 1.25rem; }
}
