:root {
  --bg: #f3f5f7;
  --card: #ffffff;
  --ink: #20262e;
  --muted: #6b7683;
  --line: #e6eaf0;
  --brand: #2f9e57;
  --brand-dark: #237d44;
  --brand-soft: #e6f4ea;
  --warn: #e8851a;
  --warn-soft: #fdf0dc;
  --danger: #d64545;
  --danger-soft: #fbe7e7;
  --miss: #b23b3b;
  --have: #2f9e57;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(30, 40, 50, .08);
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: "Nunito", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 20px; }

.topbar {
  background: linear-gradient(135deg, #2f9e57, #1f7a42);
  color: #fff;
  padding: 18px 0 64px;
}
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-ico { font-size: 40px; width: 56px; height: 56px; display: grid; place-items: center; background: rgba(255,255,255,.15); border-radius: 14px; }
.brand h1 { margin: 0; font-family: "Lora", serif; font-size: 26px; font-weight: 700; }
.brand p { margin: 2px 0 0; font-size: 13px; opacity: .85; }

.top-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.summary { display: flex; gap: 8px; font-size: 12.5px; font-weight: 700; }
.summary span { background: rgba(255,255,255,.14); padding: 6px 12px; border-radius: 20px; display: inline-flex; gap: 5px; align-items: center; }
.summary b { font-size: 14px; }
.summary .sum-warn { background: #fff; color: var(--warn); }
.summary .sum-danger { background: var(--danger); }

.btn {
  font-family: inherit; font-weight: 700; border: none; cursor: pointer;
  border-radius: 12px; padding: 11px 18px; font-size: 14px; transition: transform .05s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2, #27844a); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: #111; }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }

/* Alerts pill thing */
.alerts {
  display: flex; gap: 10px; flex-wrap: wrap; margin: -34px 0 18px;
  position: relative; z-index: 2;
}
.alert {
  background: var(--card); border-radius: 14px; padding: 12px 16px;
  box-shadow: var(--shadow); font-size: 13.5px; font-weight: 600;
  display: flex; align-items: center; gap: 10px; flex: 1 1 260px;
}
.alert .ic { font-size: 20px; }
.alert.danger { border-left: 4px solid var(--danger); }
.alert.warn { border-left: 4px solid var(--warn); }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 22px 0; }
.stat { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .num { font-size: 30px; font-weight: 800; line-height: 1; }
.stat .lab { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-top: 6px; }
.stat .num.ok { color: var(--brand); }
.stat .num.soon { color: var(--warn); }
.stat .num.danger { color: var(--danger); }

/* Panels */
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 24px; }
.panel-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.panel-head h2 { margin: 0; font-family: "Lora", serif; font-size: 21px; }
.panel-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }

/* Recipes */
.recipe-legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 12px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.dot.have { background: var(--have); }
.dot.miss { background: var(--miss, #e0e0e0); }

.recipes { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.recipe { border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; }
.recipe .r-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.recipe h3 { margin: 0; font-size: 15px; font-family: "Lora", serif; }
.recipe .r-meta { font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.recipe .match { font-size: 11.5px; font-weight: 800; color: var(--brand); background: var(--brand-soft); padding: 3px 8px; border-radius: 8px; white-space: nowrap; }
.recipe ul { list-style: none; margin: 12px 0 0; padding: 0; font-size: 13px; display: grid; gap: 5px; }
.recipe li { display: flex; justify-content: space-between; gap: 8px; }
.recipe li .have { color: var(--have); font-weight: 700; }
.recipe li .miss { color: var(--miss, #a94444); font-weight: 600; text-decoration: line-through; text-decoration-color: rgba(169,68,68,.4); }

/* Inventory */
.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.filters input, .filters select {
  font-family: inherit; font-size: 13.5px; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--ink);
  outline: none;
}
.filters input:focus, .filters select:focus { border-color: var(--brand); }
.filters input { flex: 1 1 180px; }

.inventory { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.icat { margin-bottom: 20px; }
.icat h3 { margin: 4px 0 10px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }

.item {
  border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
  display: flex; align-items: center; gap: 12px; transition: box-shadow .15s;
}
.item:hover { box-shadow: var(--shadow); }
.item.li-perime { background: #fff8f8; }
.item.li-soon { background: #fffbf3; }
.it-ico { font-size: 22px; width: 38px; height: 38px; display: grid; place-items: center; background: #f2f4f7; border-radius: 10px; flex-shrink: 0; }
.it-body { flex: 1; min-width: 0; }
.it-body[data-edit] { cursor: pointer; }
.it-body[data-edit]:hover .it-name { color: var(--brand-dark); }
.it-body .it-name { font-weight: 700; font-size: 14.5px; }
.it-body .it-meta { font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 1px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .02em; padding: 2px 7px; border-radius: 6px; }
.badge.perime { background: var(--danger-soft); color: var(--danger); }
.badge.soon { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: var(--brand-soft); color: var(--brand); }
.badge.nodate { background: #eef0f3; color: var(--muted); }
.nodate-e { color: var(--muted); }
.it-x { background: none; border: none; cursor: pointer; font-size: 18px; color: #c0c6cf; padding: 4px; border-radius: 8px; }
.it-x:hover { color: var(--danger); background: var(--danger-soft); }

.empty { text-align: center; color: var(--muted); font-size: 15px; padding: 30px 0; margin: 0; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(20,28,38,.5); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal-card { background: #fff; border-radius: 18px; padding: 24px; width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-card h2 { margin: 0 0 18px; font-family: "Lora", serif; font-size: 21px; }
.modal-card label { display: block; margin-bottom: 14px; font-weight: 600; font-size: 13.5px; }
.modal-card label span { display: block; margin-bottom: 6px; }
.modal-card input[type=text], .modal-card input[type=number], .modal-card input[type=date], .modal-card select {
  width: 100%; font-family: inherit; font-size: 14.5px; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 10px; outline: none; background: #fff; color: var(--ink);
}
.modal-card input:focus, .modal-card select:focus { border-color: var(--brand); }
.modal-card small { color: var(--muted); font-weight: 500; }
.modal-card .row2 { display: grid; grid-template-columns: 1fr 1.4fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

[hidden] { display: none !important; }

@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .brand h1 { font-size: 22px; }
  .topbar-in { align-items: flex-start; }
}