* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0a0a0a;
  --bg1: #111;
  --bg2: #1a1a1a;
  --border: #1e1e1e;
  --border2: #2a2a2a;
  --text: #d4d4d4;
  --text-dim: #666;
  --text-faint: #444;
  --accent: #ff6b2b;
  --green: #4ade80;
  --red: #f87171;
  --blue: #003087;
  --nav-h: 72px;
  --header-h: 70px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body { height: 100%; background: var(--bg); }

body {
  font-family: -apple-system, 'SF Pro Text', 'Helvetica Neue', sans-serif;
  color: var(--text);
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

/* ─── HEADER ─── */
.top-header {
  flex-shrink: 0;
  padding: calc(var(--safe-top) + 14px) 20px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.header-label {
  font-size: 10px; font-weight: 700; letter-spacing: 3px;
  color: var(--accent); text-transform: uppercase; margin-bottom: 2px;
}
.header-title {
  font-size: 22px; font-weight: 700; color: #f0f0f0; letter-spacing: -0.5px;
}

/* ─── CONTENT ─── */
.content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 16px calc(var(--safe-bottom) + 12px);
}

/* ─── BOTTOM NAV ─── */
.bottom-nav {
  flex-shrink: 0;
  display: flex;
  background: var(--bg1);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px;
  background: none; border: none; cursor: pointer;
  padding: 10px 4px 12px; color: var(--text-faint);
  transition: color 0.15s; min-height: 56px;
}
.nav-btn.active { color: var(--accent); }
.nav-icon { font-size: 20px; line-height: 1; }
.nav-label { font-size: 10px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; }

/* ─── TAB CONTENT ─── */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── MEALS ─── */
.meal-card {
  background: var(--bg1); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: 12px;
  padding: 16px; margin-bottom: 12px;
}
.meal-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.meal-day { font-size: 11px; font-weight: 700; color: var(--accent); letter-spacing: 2px; text-transform: uppercase; }
.meal-time { font-size: 12px; color: var(--text-faint); }
.meal-name { font-size: 17px; font-weight: 700; color: #f0f0f0; margin-bottom: 6px; letter-spacing: -0.3px; }
.meal-desc { font-size: 13px; color: var(--text-dim); line-height: 1.5; margin-bottom: 14px; }
.btn-cooked {
  background: var(--bg2); color: var(--text-faint); border: 1px solid var(--border2);
  border-radius: 8px; padding: 9px 16px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.15s; width: 100%; letter-spacing: 0.3px;
}
.btn-cooked:active { background: #0d1a0d; color: var(--green); border-color: var(--green); }
.btn-cooked:disabled { opacity: 0.5; }

/* ─── SHOP ─── */
#shop-generate-bar {
  background: var(--bg1); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; margin-bottom: 20px;
}
.generate-note { font-size: 13px; color: var(--text-dim); margin-bottom: 12px; line-height: 1.5; }
.btn-generate {
  width: 100%; background: var(--accent); color: #fff; border: none;
  border-radius: 10px; padding: 14px; font-size: 15px; font-weight: 700;
  cursor: pointer; letter-spacing: 0.3px;
}

.category-label {
  font-size: 11px; font-weight: 700; color: var(--text-faint); letter-spacing: 2px;
  text-transform: uppercase; padding: 16px 0 8px;
  border-bottom: 1px solid var(--border);
}
.grocery-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border);
  min-height: 48px;
}
.grocery-row.grocery-skipped { opacity: 0.35; }
.grocery-left { flex: 1; }
.grocery-name { font-size: 15px; color: var(--text); display: block; }
.grocery-qty-label { font-size: 12px; color: var(--text-faint); margin-top: 2px; display: block; }
.pantry-badge {
  display: inline-block; font-size: 10px; color: var(--green);
  background: #0d1a0d; border: 1px solid #1a3a1a;
  border-radius: 4px; padding: 1px 6px; margin-top: 3px; letter-spacing: 0.5px;
}
.grocery-price {
  font-size: 14px; font-weight: 600; color: var(--text-faint);
  min-width: 70px; text-align: right; font-variant-numeric: tabular-nums;
}
.grocery-price.loaded { color: var(--green); }
.grocery-price.loading { color: var(--border2); }

#shop-action-bar {
  background: var(--bg1); border: 1px solid var(--border); border-top: 2px solid var(--accent);
  border-radius: 12px; padding: 14px 16px; margin-top: 16px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.price-fetch-status { font-size: 11px; color: var(--text-faint); margin-bottom: 4px; letter-spacing: 0.3px; }
.total-amount { font-size: 26px; font-weight: 700; color: var(--accent); letter-spacing: -0.5px; }
.shop-btns { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.btn-fetch {
  background: var(--bg2); color: var(--text); border: 1px solid var(--border2);
  border-radius: 8px; padding: 10px 16px; font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.btn-cart {
  background: var(--green); color: #0a0a0a; border: none;
  border-radius: 8px; padding: 10px 16px; font-size: 13px; font-weight: 700;
  cursor: pointer; white-space: nowrap;
}
.btn-cart:disabled { opacity: 0.5; }
#frys-login-bar {
  background: var(--bg1); border: 1px solid var(--border); border-left: 3px solid var(--blue);
  border-radius: 12px; padding: 14px; margin-top: 14px;
}
.frys-login-note { font-size: 13px; color: var(--text-dim); margin-bottom: 10px; line-height: 1.5; }
.btn-frys {
  width: 100%; background: var(--blue); color: #fff; border: none; border-radius: 10px;
  padding: 13px; font-size: 14px; font-weight: 700; cursor: pointer;
}
#cart-status { margin-top: 12px; border-radius: 10px; padding: 12px 14px; font-size: 13px; line-height: 1.5; }

/* ─── PANTRY ─── */
.pantry-search-bar { margin-bottom: 20px; }
.pantry-search-bar input {
  width: 100%; background: var(--bg1); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 16px; color: var(--text); font-size: 15px; outline: none;
  font-family: inherit;
}
.pantry-search-bar input:focus { border-color: var(--accent); }

.pantry-block { margin-bottom: 28px; }
.pantry-block-title { font-size: 17px; font-weight: 700; color: #f0f0f0; margin-bottom: 4px; }
.pantry-block-sub { font-size: 13px; color: var(--text-dim); margin-bottom: 14px; line-height: 1.5; }

.pantry-staple-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border); min-height: 48px;
}
.pantry-item-name { font-size: 15px; color: var(--text); }

/* Toggle */
.toggle { position: relative; display: inline-block; width: 48px; height: 28px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg2); border-radius: 28px; transition: 0.2s; border: 1px solid var(--border2);
}
.toggle-slider:before {
  position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px;
  background: #555; border-radius: 50%; transition: 0.2s;
}
.toggle input:checked + .toggle-slider { background: #0d1a0d; border-color: #1a3a1a; }
.toggle input:checked + .toggle-slider:before { background: var(--green); transform: translateX(20px); }

.pantry-tracked-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border); min-height: 48px;
}
.pantry-qty-group { display: flex; align-items: center; gap: 8px; }
.pantry-qty-input {
  background: var(--bg2); border: 1px solid var(--border2); border-radius: 8px;
  color: var(--text); font-family: inherit; font-size: 15px;
  padding: 6px 10px; width: 70px; text-align: center; outline: none;
}
.pantry-unit-label { font-size: 13px; color: var(--text-faint); min-width: 36px; }
.btn-remove {
  background: none; border: none; color: var(--text-faint); font-size: 18px;
  cursor: pointer; padding: 4px 8px; line-height: 1;
}

.pantry-add-row {
  display: grid;
  grid-template-columns: 1fr 70px 80px 44px;
  gap: 8px; margin-top: 14px;
}
.pantry-add-row input, .pantry-add-row select {
  background: var(--bg1); border: 1px solid var(--border); border-radius: 8px;
  padding: 11px 10px; color: var(--text); font-size: 14px; font-family: inherit; outline: none;
}
.btn-add {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  font-size: 22px; font-weight: 700; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
}

/* ─── HISTORY ─── */
.history-entry {
  background: var(--bg1); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 12px;
}
.history-week {
  font-size: 11px; font-weight: 700; color: var(--accent);
  letter-spacing: 2px; text-transform: uppercase; margin-bottom: 10px;
}
.history-meal {
  display: flex; gap: 12px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--border); min-height: 40px;
}
.history-meal:last-child { border-bottom: none; }
.history-day { font-size: 11px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; min-width: 74px; }
.history-name { font-size: 14px; color: var(--text); }

/* ─── SETTINGS ─── */
.settings-block {
  background: var(--bg1); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; margin-bottom: 16px;
}
.settings-block-title { font-size: 15px; font-weight: 700; color: #f0f0f0; margin-bottom: 4px; }
.settings-block-sub { font-size: 13px; color: var(--text-dim); margin-bottom: 14px; line-height: 1.5; }
.settings-block textarea {
  width: 100%; height: 160px; background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 8px; padding: 12px; color: var(--text); font-size: 13px;
  font-family: inherit; resize: vertical; outline: none; margin-bottom: 12px;
}
.field { margin-bottom: 12px; }
.field label {
  display: block; font-size: 11px; font-weight: 700; color: var(--text-faint);
  letter-spacing: 1.5px; text-transform: uppercase; margin-bottom: 6px;
}
.field input {
  width: 100%; background: var(--bg2); border: 1px solid var(--border2); border-radius: 8px;
  padding: 12px 14px; color: var(--text); font-size: 15px; font-family: inherit; outline: none;
}
.field input:focus { border-color: var(--accent); }

/* ─── BUTTONS ─── */
.btn-primary {
  width: 100%; background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: 14px; font-size: 15px; font-weight: 700; cursor: pointer; letter-spacing: 0.3px;
}
.btn-secondary {
  width: 100%; background: var(--bg2); color: var(--text); border: 1px solid var(--border2);
  border-radius: 10px; padding: 13px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-danger {
  width: 100%; background: none; color: var(--red); border: 1px solid #3a1a1a;
  border-radius: 10px; padding: 13px; font-size: 14px; font-weight: 600; cursor: pointer;
}

/* ─── MESSAGES ─── */
.msg-success {
  background: #0d1a0d; border: 1px solid #1a3a1a; border-left: 3px solid var(--green);
  border-radius: 8px; padding: 12px 14px; font-size: 13px; color: var(--green); line-height: 1.5;
}
.msg-error {
  background: #1a0d0d; border: 1px solid #3a1a1a; border-left: 3px solid var(--red);
  border-radius: 8px; padding: 12px 14px; font-size: 13px; color: var(--red);
  line-height: 1.5; margin-top: 10px; word-break: break-all;
}

/* ─── EMPTY STATE ─── */
.empty-state {
  text-align: center; color: var(--text-faint); font-size: 14px;
  padding: 40px 20px; line-height: 1.6;
}
