:root {
  --cream: #fbf5ef; --cream-2: #f3e7db; --white: #fffdfb; --brown: #9a5f36; --brown-d: #5c3a22;
  --ink: #3b2a1f; --muted: #7a6656; --pink: #f6cdd3; --green: #e5f4e4; --green-d: #2f6b2c;
  --yellow: #fff4c2; --red: #b3261e; --radius: 14px;
  --font: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--cream); color: var(--ink); font: 16px/1.5 var(--font); -webkit-text-size-adjust: 100%; }
h1, h2, h3 { color: var(--brown-d); line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .75em; }
a { color: var(--brown); }
.muted { color: var(--muted); font-size: .92rem; }
.err { color: var(--red); min-height: 1.2em; }
[hidden] { display: none !important; }

.top { position: sticky; top: 0; z-index: 4; background: var(--white); border-bottom: 1px solid var(--cream-2);
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); }
.brand { font-weight: 700; color: var(--brown-d); } .brand b { color: var(--brown); }
.view { max-width: 820px; margin: 0 auto; padding: 16px 16px 110px; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--white); border-top: 1px solid var(--cream-2); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { text-align: center; text-decoration: none; color: var(--muted); font-size: .75rem; font-weight: 700; padding: 8px 0 10px; }
.tabs a span { display: block; font-size: 1.3rem; line-height: 1.3; }
.tabs a.on { color: var(--brown); }

.card { background: var(--white); border: 1px solid var(--cream-2); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 999px;
  background: var(--brown); color: #fff; font: 700 1rem var(--font); padding: 12px 20px; cursor: pointer; text-decoration: none; min-height: 44px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--brown); border: 2px solid var(--brown); }
.btn.small { padding: 6px 14px; font-size: .9rem; min-height: 36px; }
.btn.full { width: 100%; }
.btn.danger { background: transparent; color: var(--red); border: 0; padding: 6px 8px; min-height: 36px; }
.linkbtn { background: none; border: 0; color: var(--brown); font: inherit; text-decoration: underline; cursor: pointer; padding: 0; }

input, select, textarea { font: inherit; color: inherit; border: 1px solid #d9c6b4; border-radius: 10px; padding: 9px 11px; background: #fff; width: 100%; min-height: 42px; }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; accent-color: var(--brown); }
label { display: block; font-weight: 700; font-size: .9rem; }
label input, label select { margin-top: 4px; font-weight: 400; }
.num { width: 92px; text-align: right; }

.qty { display: flex; align-items: center; gap: 6px; }
.qty button { width: 38px; height: 38px; flex-shrink: 0; border-radius: 50%; border: 2px solid var(--brown); background: #fff; color: var(--brown); font-size: 1.2rem; font-weight: 700; cursor: pointer; }
.qty input { width: 56px; text-align: center; padding: 8px 4px; }
.prod { flex-wrap: nowrap !important; }
.prod .grow { font-size: .95rem; }
.prod { padding: 12px 0; border-bottom: 1px solid var(--cream-2); }
.prod:last-child { border-bottom: 0; }
.chip { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--cream-2); color: var(--brown-d); }
.chip.warn { background: var(--yellow); color: #7a5b00; }
.chip.ok { background: var(--green); color: var(--green-d); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat { background: var(--cream); border-radius: 12px; padding: 12px; }
.stat b { display: block; font-size: 1.35rem; color: var(--brown-d); }

.item { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--cream-2); align-items: start; }
.item:last-child { border-bottom: 0; }
.item.done .what { text-decoration: line-through; opacity: .55; }
.item .price { font-weight: 800; color: var(--brown-d); white-space: nowrap; }
.tip { background: var(--yellow); border-radius: 10px; padding: 6px 10px; font-size: .85rem; margin-top: 6px; }
.aisle { margin: 18px 0 4px; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 800; }

table.lines { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.lines td, table.lines th { padding: 8px 6px; border-bottom: 1px solid var(--cream-2); text-align: left; vertical-align: middle; }
table.lines th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.part { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
details.ing { border-bottom: 1px solid var(--cream-2); padding: 10px 0; }
details.ing summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
details.ing summary::-webkit-details-marker { display: none; }
.pkg { display: grid; grid-template-columns: 1fr 90px 90px auto; gap: 8px; align-items: center; padding: 6px 0; }
.result { display: grid; grid-template-columns: 54px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--cream-2); }
.result img { width: 54px; height: 54px; object-fit: contain; background: #fff; border-radius: 8px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; text-align: center; }
.login-card img { margin: 0 auto 8px; border-radius: 16px; }
.login-card label { text-align: left; margin: 14px 0; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--brown-d); color: #fff;
  padding: 10px 18px; border-radius: 999px; z-index: 9; font-weight: 700; max-width: calc(100% - 32px); text-align: center; }
.back { display: inline-block; margin-bottom: 10px; }
@media (max-width: 560px) {
  .pkg { grid-template-columns: 1fr 80px 80px; }
  .pkg .act { grid-column: 1 / -1; }
  table.lines .hide-sm { display: none; }
}
@media print {
  .tabs, .top, .noprint { display: none !important; }
  .view { padding: 0; }
  .card { border: 0; }
}

table.lines td:nth-child(2) { white-space: nowrap; }
table.lines .num { width: 76px; }
