:root {
  --bg: #fff8f0;
  --surface: #ffffff;
  --surface2: #fef3e8;
  --border: #f0e0d0;
  --text: #3d2b1f;
  --text-dim: #9a8574;
  --orange: #e8734a;
  --orange-light: #fde8df;
  --green: #6b9b6f;
  --red: #d9534f;
  --yellow: #e8a94a;
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app { max-width: 480px; margin: 0 auto; min-height: 100vh; padding-bottom: 90px; }
.screen { padding: 20px 16px; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ===== PAGE HEADER ===== */
.page-header {
  background: linear-gradient(135deg, #e8734a 0%, #d45e35 100%);
  padding: 24px 16px 20px;
  margin-bottom: 0;
  color: white;
}
.page-header h1 { font-size: 24px; font-weight: 700; margin-bottom: 2px; }
.page-header .subtitle { font-size: 13px; opacity: 0.85; }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; color: var(--text); }
p.subtitle { color: var(--text-dim); font-size: 14px; margin: 0 0 16px; }
.section-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin: 16px 0 8px; }

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(61,43,31,0.06);
}
.card-flat {
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

/* ===== FORMS ===== */
label { display: block; font-size: 12px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; letter-spacing: 0.03em; text-transform: uppercase; }
input, select, textarea {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  padding: 13px 14px;
  font-size: 16px;
  margin-bottom: 14px;
  font-family: inherit;
  transition: border-color 0.15s;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--orange); }

button {
  border: none; border-radius: 12px; padding: 14px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: all 0.15s; font-family: inherit;
}
button:active { transform: scale(0.97); opacity: 0.85; }
.btn-primary { background: var(--orange); color: #fff; width: 100%; }
.btn-primary:hover { background: #d45e35; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1.5px solid var(--border); width: 100%; }
.btn-danger { background: transparent; color: var(--red); border: 1.5px solid var(--red); width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; width: auto; }

/* ===== STAT CARDS ===== */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 8px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(61,43,31,0.05);
}
.stat-box .num { font-size: 26px; font-weight: 700; color: var(--orange); line-height: 1; }
.stat-box .label { font-size: 11px; color: var(--text-dim); margin-top: 4px; font-weight: 500; }

/* ===== BADGES ===== */
.badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-healthy { background: rgba(107,155,111,0.15); color: #3d7a42; }
.badge-low { background: rgba(232,169,74,0.2); color: #8a5e0a; }
.badge-critical { background: rgba(217,83,79,0.15); color: var(--red); }
.badge-ready { background: rgba(107,155,111,0.15); color: #3d7a42; }
.badge-almost { background: rgba(232,169,74,0.2); color: #8a5e0a; }
.badge-not { background: rgba(154,133,116,0.12); color: var(--text-dim); }

/* ===== INGREDIENT ROWS ===== */
.ingredient-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.ingredient-row:last-child { border-bottom: none; }
.ingredient-row:active { opacity: 0.7; }
.ingredient-row .name { font-weight: 600; font-size: 14px; }
.ingredient-row .meta { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.ingredient-row .stock { text-align: right; font-size: 14px; font-weight: 600; }

/* ===== RECIPE CARDS ===== */
.recipe-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: box-shadow 0.15s;
  box-shadow: 0 1px 3px rgba(61,43,31,0.05);
}
.recipe-card:active { box-shadow: none; transform: scale(0.99); }
.recipe-card .top-row { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 4px; }
.recipe-card .recipe-name { font-weight: 700; font-size: 15px; }
.recipe-card .recipe-meta { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.recipe-card .recipe-missing { font-size: 12px; color: var(--yellow); margin-top: 4px; }

/* ===== ALERT BANNER ===== */
.alert-banner {
  border-radius: 12px; padding: 12px 14px; margin-bottom: 10px;
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 13px;
}
.alert-warn { background: rgba(232,169,74,0.15); border: 1px solid rgba(232,169,74,0.3); color: #7a5200; }
.alert-danger { background: rgba(217,83,79,0.12); border: 1px solid rgba(217,83,79,0.25); color: #8a1f1f; }

/* ===== FAB ===== */
.fab {
  position: fixed; bottom: 84px; right: 20px;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--orange); color: #fff; font-size: 26px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(232,115,74,0.45); z-index: 10;
  cursor: pointer; transition: transform 0.15s;
  border: none;
}
.fab:active { transform: scale(0.93); }

/* ===== PORTION ADJUSTER ===== */
.portion-display {
  text-align: center; font-size: 52px; font-weight: 800;
  color: var(--orange); margin: 8px 0 4px;
  line-height: 1;
}
.portion-unit { text-align: center; font-size: 14px; color: var(--text-dim); margin-bottom: 16px; }
.portion-controls { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 16px; }
.portion-controls button {
  width: 50px; height: 50px; border-radius: 50%; font-size: 22px; font-weight: 700;
  background: var(--surface2); color: var(--text);
  border: 1.5px solid var(--border); padding: 0;
  display: flex; align-items: center; justify-content: center;
}

/* ===== INGREDIENT CHECKLIST ===== */
.ing-check-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px;
}
.ing-check-item:last-child { border-bottom: none; }
.check { color: var(--green); font-weight: 600; }
.cross { color: var(--red); font-weight: 600; }

/* ===== TRANSACTION ===== */
.tx-item { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.tx-item:last-child { border-bottom: none; }
.tx-name { font-weight: 600; font-size: 14px; }
.tx-meta { color: var(--text-dim); font-size: 11px; margin-top: 2px; }
.tx-amount-neg { color: var(--red); font-weight: 700; font-size: 14px; }
.tx-amount-pos { color: var(--green); font-weight: 700; font-size: 14px; }

/* ===== CHOICE BUTTONS ===== */
.choice-grid { display: grid; gap: 8px; margin-bottom: 16px; }
.choice-btn {
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px;
  padding: 14px 16px; color: var(--text); text-align: left; font-size: 15px;
  cursor: pointer; transition: all 0.15s; font-family: inherit;
}
.choice-btn:active { border-color: var(--orange); background: var(--orange-light); }
.choice-btn.selected { border-color: var(--orange); background: var(--orange-light); }

/* ===== EMPTY STATES ===== */
.empty-state {
  text-align: center; padding: 32px 20px;
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state .empty-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.empty-state .empty-sub { font-size: 13px; color: var(--text-dim); line-height: 1.5; }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; max-width: 480px; margin: 0 auto;
  background: var(--surface); border-top: 1px solid var(--border);
  display: flex; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(61,43,31,0.06);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; color: var(--text-dim); font-size: 10px; padding: 6px 0; font-weight: 500;
  cursor: pointer; font-family: inherit; transition: color 0.15s;
}
.nav-item.active { color: var(--orange); }
.nav-item .icon { font-size: 22px; line-height: 1; }

/* ===== MISC ===== */
.loading { text-align: center; color: var(--text-dim); padding: 60px 0; font-size: 14px; }
.loading::before { content: "👩‍🍳"; font-size: 32px; display: block; margin-bottom: 12px; }
.error-msg { color: var(--red); font-size: 13px; margin-bottom: 12px; background: rgba(217,83,79,0.08); padding: 10px 14px; border-radius: 10px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
