* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #f6f8fa; color: #1f2328; min-height: 100vh; display: flex; justify-content: center; padding: 28px 16px 60px; }
.container { max-width: 820px; width: 100%; }

/* Header */
.header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.header-left { display: flex; align-items: center; gap: 10px; }
.logo { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, #1a7f37, #4ac26b); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.header h1 { font-size: 19px; font-weight: 700; }
.header .sub { font-size: 12px; color: #656d76; }
.save-hint { font-size: 12px; color: #8b949e; }

/* Buttons */
.btn { background: #f6f8fa; border: 1px solid #d0d7de; border-radius: 8px; color: #656d76; cursor: pointer; font-size: 12px; font-weight: 500; padding: 6px 14px; transition: all 0.15s; text-decoration: none; display: inline-flex; align-items: center; gap: 5px; font-family: inherit; }
.btn:hover { border-color: #0969da; color: #0969da; }
.btn.primary { border-color: #0969da; color: #0969da; }
.btn.primary:hover { background: rgba(9,105,218,0.06); }
.btn.green { background: #1a7f37; border-color: #1a7f37; color: #fff; }
.btn.green:hover { background: #2ea043; }

/* Cards + inputs */
.card { background: #fff; border: 1px solid #d0d7de; border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.card h2 { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.input { flex: 1; min-width: 100px; background: #f6f8fa; border: 1px solid #d0d7de; border-radius: 8px; padding: 9px 12px; font-size: 14px; outline: none; font-family: inherit; color: #1f2328; }
.input:focus { border-color: #0969da; }
select.input { cursor: pointer; }
.label { font-size: 11px; font-weight: 600; color: #656d76; display: block; margin: 10px 0 4px; }

/* Tags / chips / badges */
.tag { font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; flex-shrink: 0; }
.tag.cat { background: rgba(9,105,218,0.08); color: #0969da; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 99px; white-space: nowrap; }
.badge.ok { background: rgba(26,127,55,0.12); color: #1a7f37; }
.badge.warn { background: rgba(191,112,0,0.12); color: #bf7000; }
.badge.bad { background: rgba(207,34,46,0.10); color: #cf222e; }
.badge.na { background: rgba(101,109,118,0.12); color: #656d76; }
.filter-bar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.chip { font-size: 12px; padding: 5px 12px; border-radius: 99px; border: 1px solid #d0d7de; background: #fff; color: #656d76; cursor: pointer; font-family: inherit; }
.chip.active { background: rgba(26,127,55,0.10); border-color: #1a7f37; color: #1a7f37; }

/* Ingredient list */
.ing-list { display: flex; flex-direction: column; gap: 6px; }
.ing-item { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid #d0d7de; border-radius: 10px; padding: 8px 12px; }
.ing-item .name { font-weight: 600; font-size: 14px; }
.ing-item .qty { color: #656d76; font-size: 13px; }
.ing-item .exp { font-size: 11px; color: #8b949e; margin-left: auto; white-space: nowrap; }
.ing-item .exp.soon { color: #bf7000; font-weight: 600; }
.ing-item .exp.over { color: #cf222e; font-weight: 600; }
.ing-item .del { background: none; border: none; color: #d0d7de; cursor: pointer; font-size: 15px; padding: 2px; }
.ing-item .del:hover { color: #cf222e; }

/* Recipe cards */
.rec-list { display: flex; flex-direction: column; gap: 8px; }
.rec-item { background: #fff; border: 1px solid #d0d7de; border-radius: 12px; padding: 12px 14px; cursor: pointer; transition: border-color 0.15s; }
.rec-item:hover { border-color: #8b949e; }
.rec-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rec-name { font-size: 15px; font-weight: 600; }
.rec-meta { display: flex; gap: 10px; font-size: 12px; color: #656d76; margin-top: 4px; flex-wrap: wrap; }
.rec-detail { display: none; margin-top: 10px; padding-top: 10px; border-top: 1px solid #d0d7de; }
.rec-item.open .rec-detail { display: block; }
.rec-detail h4 { font-size: 12px; color: #656d76; margin: 8px 0 4px; }
.rec-detail .missing { color: #cf222e; font-weight: 600; }
.rec-detail .steps { font-size: 13px; line-height: 1.7; color: #1f2328; white-space: pre-wrap; }
.rec-detail .ing-line { font-size: 13px; color: #656d76; padding: 1px 0; }
.rec-detail .ing-line.have { color: #1a7f37; }
.rec-actions { display: flex; gap: 4px; justify-content: flex-end; margin-top: 8px; }
.item-btn { background: none; border: none; color: #d0d7de; cursor: pointer; font-size: 14px; padding: 2px 5px; }
.item-btn:hover { color: #cf222e; }
.item-btn.edit:hover { color: #0969da; }
.fav-btn { background: none; border: none; cursor: pointer; font-size: 17px; padding: 2px 5px; line-height: 1; color: #8b949e; transition: transform 0.1s; }
.fav-btn:hover { transform: scale(1.2); }

/* Meal plan grid */
.week-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.week-nav .range { font-size: 14px; font-weight: 600; }
.plan-grid { display: grid; grid-template-columns: 44px repeat(7, 1fr); gap: 5px; overflow-x: auto; }
.plan-head { font-size: 11px; text-align: center; color: #656d76; padding: 4px 0; font-weight: 600; }
.plan-head.today { color: #1a7f37; }
.plan-label { font-size: 11px; color: #656d76; display: flex; align-items: center; justify-content: center; font-weight: 600; writing-mode: vertical-lr; }
.plan-cell { min-height: 52px; background: #fff; border: 1px solid #d0d7de; border-radius: 8px; padding: 4px; cursor: pointer; transition: border-color 0.15s; display: flex; flex-direction: column; gap: 3px; }
.plan-cell:hover { border-color: #0969da; }
.plan-cell.today { background: rgba(26,127,55,0.04); border-color: rgba(26,127,55,0.4); }
.meal-chip { font-size: 11px; background: rgba(9,105,218,0.08); color: #0969da; border-radius: 6px; padding: 3px 6px; cursor: pointer; word-break: break-all; display: flex; align-items: center; gap: 4px; }
.meal-chip.custom { background: rgba(130,80,223,0.08); color: #8250df; }
.meal-chip.done .meal-name { text-decoration: line-through; opacity: 0.6; }
.meal-chip .x { margin-left: auto; color: #d0d7de; font-weight: 700; }
.meal-chip .x:hover { color: #cf222e; }
.add-hint { font-size: 10px; color: #afb8c1; text-align: center; }

/* Stats + misc */
.empty { text-align: center; padding: 50px 0; color: #8b949e; font-size: 14px; }
.stat-banner { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.stat { flex: 1; min-width: 120px; background: #fff; border: 1px solid #d0d7de; border-radius: 12px; padding: 12px 14px; }
.stat .num { font-size: 22px; font-weight: 700; color: #1a7f37; }
.stat .lbl { font-size: 12px; color: #656d76; }
.footer { text-align: center; margin-top: 24px; font-size: 11px; color: #afb8c1; }

/* Modal */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 100; justify-content: center; align-items: center; padding: 20px; }
.modal-overlay.active { display: flex; }
.modal { background: #fff; border: 1px solid #d0d7de; border-radius: 16px; box-shadow: 0 8px 32px rgba(0,0,0,0.15); padding: 24px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; }
.modal h2 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.modal input, .modal textarea, .modal select { width: 100%; background: #f6f8fa; border: 1px solid #d0d7de; border-radius: 8px; padding: 9px 12px; font-size: 14px; font-family: inherit; outline: none; color: #1f2328; }
.modal input:focus, .modal textarea:focus, .modal select:focus { border-color: #0969da; }
.modal textarea { resize: vertical; min-height: 70px; line-height: 1.6; }
.modal .btn-row { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end; }
.ing-row { display: flex; gap: 6px; margin-bottom: 6px; }
.ing-row input { flex: 1; min-width: 0; }
.ing-row .qty-in { width: 70px; flex: 0 0 70px; }
.ing-row .unit-in { width: 60px; flex: 0 0 60px; }
.ing-row .rm { flex: 0 0 30px; border: none; background: none; color: #d0d7de; cursor: pointer; font-size: 16px; }
.ing-row .rm:hover { color: #cf222e; }

@media (max-width: 560px) { .row { flex-direction: column; } .ing-item .exp { margin-left: 0; } }
