:root {
  --bg: #f4f7f6; --card: #ffffff; --ink: #16222b; --muted: #5d6b73; --line: #d3ddda;
  --brand: #0f766e; --brand-ink: #ffffff; --danger: #b42318;
  --pork: #d9466f; --chicken: #d99a00; --fish: #2b7bd0; --vegetable: #3d9a45; --dessert: #8a54c9; --other: #6b7780;
  font-family: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11181c; --card: #1a2429; --ink: #e8efee; --muted: #9aa9b0; --line: #2c3a41; --brand: #2fb5a8; --brand-ink: #06201d; --danger: #ff8a7a; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.5; }
a { color: inherit; }
header.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 5; }
header.top h1 { font-size: 1.2rem; margin: 0; }
main { max-width: 960px; margin: 0 auto; padding: 16px; }
h2 { font-size: 1.1rem; margin: 28px 0 10px; }
.btn, button { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 9px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-block; }
.btn.primary, button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
.btn.danger, button.danger { color: var(--danger); border-color: var(--danger); }
button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; width: 100%; }
label { display: block; font-weight: 600; margin: 14px 0 4px; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--c, var(--other)); border-radius: 8px; padding: 10px 12px; text-align: left; cursor: pointer; }
.stat b { display: block; font-size: 2rem; line-height: 1.1; }
.stat span { color: var(--muted); text-transform: capitalize; }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.tabs button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.filters { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 600px) { .filters { grid-template-columns: 2fr 1fr; } }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; text-align: left; padding: 0; display: block; width: 100%; }
.card .ph { aspect-ratio: 4/3; width: 100%; object-fit: cover; background: var(--line); display: grid; place-items: center; font-size: 2rem; color: var(--muted); }
.card .body { padding: 10px 12px; }
.card h3 { margin: 0 0 4px; font-size: 1rem; }
.tag { display: inline-block; font-size: .8rem; padding: 1px 8px; border-radius: 99px; color: #fff; background: var(--c, var(--other)); text-transform: capitalize; }
.empty { color: var(--muted); padding: 20px 0; }

dialog { width: min(680px, 96vw); max-height: 92vh; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); padding: 0; }
dialog::backdrop { background: rgba(0,0,0,.5); }
.dlg { padding: 16px; }
.dlg .hero { width: 100%; max-height: 280px; object-fit: cover; border-radius: 8px; }
.tools { display: flex; gap: 12px; flex-wrap: wrap; }
.tools figure { margin: 0; text-align: center; width: 84px; font-size: .85rem; }
.tools img, .th { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
table { border-collapse: collapse; width: 100%; }
td { border-bottom: 1px solid var(--line); padding: 6px 4px; }
td:last-child { text-align: right; color: var(--muted); }

.row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; align-items: center; }
.row input[type=text] { flex: 1 1 140px; width: auto; }
.row input[type=file] { flex: 1 1 140px; width: auto; }
.row .th { width: 44px; height: 44px; }
.checks { display: flex; gap: 16px; flex-wrap: wrap; }
.checks label { font-weight: 400; margin: 0; display: flex; align-items: center; gap: 6px; }
.checks input { width: auto; }
#preview { max-width: 100%; max-height: 220px; border-radius: 8px; margin-top: 8px; }
.bar { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; display: flex; gap: 8px; flex-wrap: wrap; }
@media (prefers-reduced-motion: no-preference) { .card, .stat { transition: border-color .15s; } .card:hover, .stat:hover { border-color: var(--brand); } }

/* v2 additions */
header.top { flex-wrap: wrap; }
nav { display: flex; gap: 6px; flex-wrap: wrap; }
nav .btn { padding: 6px 10px; font-size: .9rem; }
h2 a { font-size: .85rem; font-weight: 400; color: var(--brand); }
label a { font-weight: 400; color: var(--brand); }
.th { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--line); display: inline-block; flex: none; }
.sw { width: 44px; height: 44px; border-radius: 8px; flex: none; border: 1px solid var(--line); }
ul.list { list-style: none; margin: 0; padding: 0; }
.item { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; }
.item > div { flex: 1; min-width: 0; }
.item .empty { padding: 0; font-size: .85rem; }
.row select { flex: 1 1 160px; width: auto; }
.chip { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px 4px 4px; background: var(--card); font-weight: 400; margin: 0; cursor: pointer; }
.chip input { width: auto; }
.chip .th { width: 32px; height: 32px; border-radius: 99px; }
td .th { width: 36px; height: 36px; }
td:last-child { white-space: nowrap; }
input[type=color] { width: 64px; height: 40px; padding: 2px; }

/* v3: prices + checklist */
.card { text-decoration: none; color: inherit; }
.item { flex-wrap: wrap; }
.panel { flex: 1 0 100%; border-top: 1px solid var(--line); padding-top: 10px; }
.pf { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.pf input { width: auto; flex: 1 1 110px; }
.pf .pr { flex: 0 1 100px; }
.hist td { vertical-align: middle; }
.hist td:nth-child(3) { color: var(--muted); }
.hist td:last-child { text-align: right; }
.hist button { padding: 4px 10px; font-size: .85rem; }
.up { color: var(--danger); } .dn { color: var(--vegetable); }
.hero { width: 100%; max-height: 300px; object-fit: cover; border-radius: 10px; }
.prog { font-weight: 600; margin: 12px 0 0; }
.chk { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 0 0 8px; font-weight: 400; cursor: pointer; }
.chk input { width: 24px; height: 24px; flex: none; accent-color: var(--brand); }
.chk .nm { flex: 1; font-weight: 600; }
.chk .ms { color: var(--muted); text-align: right; }
.chk.done { opacity: .55; }
.chk.done .nm { text-decoration: line-through; }

/* v4: units + cost */
.row input.qt { flex: 0 1 90px; width: auto; }
.row select.un { flex: 0 1 110px; width: auto; }
.pf .per { align-self: center; color: var(--muted); }
.pf .qt { flex: 0 1 90px; }
.pf select { width: auto; flex: 1 1 100px; }
.cost td:last-child { color: var(--ink); }
.cost tfoot td { font-weight: 700; font-size: 1.1rem; border-bottom: 0; padding-top: 10px; }

/* preparation steps editor */
.step { display: grid; grid-template-columns: 1fr; gap: 6px; margin-bottom: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.step .n { font-weight: 700; color: var(--muted); }
.step textarea { min-height: 64px; resize: vertical; }
.step .ctl { display: flex; gap: 6px; flex-wrap: wrap; }
.step .ctl button { padding: 6px 12px; }
.step .ctl button:disabled { opacity: .4; cursor: default; }
.step .rm { margin-left: auto; color: var(--danger); border-color: var(--danger); }

[hidden] { display: none !important; }
