/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f7fa;
  color: #1a1a2e;
  min-height: 100vh;
}

/* ── App shell ── */
#app {
  max-width: 640px;
  margin: 0 auto;
  padding-bottom: 100px;
}

/* ── Header ── */
.app-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px 20px 24px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 12px rgba(102,126,234,0.3);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.date-nav {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  font-size: 22px;
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
  line-height: 1;
}
.date-nav:hover { background: rgba(255,255,255,0.35); }

.date-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.15s;
}
.date-btn:hover { background: rgba(255,255,255,0.35); }

.daily-totals {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.total-pill {
  background: rgba(255,255,255,0.18);
  border-radius: 12px;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 72px;
}
.total-pill .val {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}
.total-pill .lbl {
  font-size: 11px;
  color: rgba(255,255,255,0.75);
  margin-top: 2px;
  white-space: nowrap;
}
.total-pill.cal .val { color: #ffd700; }

/* ── Meal list ── */
.meal-list {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #888;
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* ── Meal card ── */
.meal-card {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: box-shadow 0.15s;
}
.meal-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); }

.meal-card-header {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  gap: 10px;
}

.meal-card-name {
  font-weight: 600;
  font-size: 15px;
  flex: 1;
}

.meal-card-cal {
  font-size: 15px;
  font-weight: 700;
  color: #667eea;
  white-space: nowrap;
}

.meal-card-macros {
  display: flex;
  gap: 6px;
  font-size: 12px;
  color: #888;
}
.macro-badge {
  background: #f0f2ff;
  border-radius: 6px;
  padding: 2px 7px;
  color: #667eea;
  font-weight: 500;
}
.macro-badge.pro { background: #e8f5e9; color: #2e7d32; }
.macro-badge.carb { background: #fff3e0; color: #e65100; }
.macro-badge.fat { background: #fce4ec; color: #c62828; }

.meal-toggle {
  color: #bbb;
  font-size: 12px;
  transition: transform 0.2s;
}
.meal-card.open .meal-toggle { transform: rotate(180deg); }

.meal-card-body {
  display: none;
  border-top: 1px solid #f0f0f0;
  padding: 0 16px 12px;
}
.meal-card.open .meal-card-body { display: block; }

.ingredient-row {
  display: flex;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f8f8f8;
  gap: 8px;
  font-size: 13px;
}
.ingredient-row:last-child { border-bottom: none; }
.ingredient-name { flex: 1; color: #444; }
.ingredient-amount { color: #888; white-space: nowrap; }
.ingredient-cal { font-weight: 600; color: #667eea; white-space: nowrap; min-width: 60px; text-align: right; }

.meal-card-actions {
  display: flex;
  gap: 8px;
  padding: 8px 0 0;
  justify-content: flex-end;
}

/* ── FAB ── */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 58px; height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  font-size: 28px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(102,126,234,0.5);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
  z-index: 50;
  line-height: 1;
}
.fab:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(102,126,234,0.6); }
.fab:active { transform: scale(0.96); }

/* ── Modals ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open {
  opacity: 1; pointer-events: all;
}

.modal {
  background: #fff;
  width: 100%;
  max-width: 640px;
  border-radius: 20px 20px 0 0;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  transform: translateY(40px);
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
}
.modal-overlay.open .modal {
  transform: translateY(0);
}
.modal-sm { max-height: 280px; }

.modal-header {
  display: flex;
  align-items: center;
  padding: 20px 20px 16px;
  border-bottom: 1px solid #f0f0f0;
}
.modal-header h2 { flex: 1; font-size: 18px; font-weight: 700; }
.close-btn {
  background: none; border: none;
  font-size: 24px; color: #999;
  cursor: pointer; padding: 0 4px;
  line-height: 1;
}
.close-btn:hover { color: #333; }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.modal-footer {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid #f0f0f0;
}

/* ── Form elements ── */
.field-group {
  margin-bottom: 14px;
}
.field-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  margin-bottom: 6px;
}

input[type="text"], input[type="number"] {
  width: 100%;
  border: 1.5px solid #e0e0e0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
  background: #fafafa;
}
input[type="text"]:focus, input[type="number"]:focus {
  border-color: #667eea;
  background: #fff;
}

/* ── Autocomplete ── */
.autocomplete-wrap { position: relative; }
.dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #fff;
  border: 1.5px solid #e0e0e0;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 200;
  max-height: 240px;
  overflow-y: auto;
  list-style: none;
  display: none;
}
.dropdown.open { display: block; }
.dropdown li {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 1px solid #f5f5f5;
  display: flex;
  align-items: center;
  gap: 8px;
}
.dropdown li:last-child { border-bottom: none; }
.dropdown li:hover, .dropdown li.active { background: #f0f2ff; }
.dropdown-name { flex: 1; font-weight: 500; }
.dropdown-macros { font-size: 12px; color: #888; white-space: nowrap; }
.dropdown-source { font-size: 11px; color: #bbb; }
.dropdown-section {
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #aaa;
  background: #fafafa;
  border-bottom: 1px solid #f0f0f0;
}
.dropdown li.recipe-item { color: #764ba2; }
.dropdown li.recipe-item .dropdown-name::before { content: '📋 '; }
.spinner {
  padding: 10px 14px;
  font-size: 13px;
  color: #aaa;
  text-align: center;
}

/* ── Ingredient rows ── */
.ingredients-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
}

.ingredient-input-row {
  display: grid;
  grid-template-columns: 1fr 90px 32px;
  gap: 8px;
  align-items: start;
  margin-bottom: 8px;
}

.amount-field { position: relative; }
.amount-field input { padding-right: 36px; text-align: right; }
.amount-unit {
  position: absolute;
  right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 12px; color: #aaa; pointer-events: none;
}

.remove-row {
  background: none;
  border: none;
  color: #ccc;
  font-size: 18px;
  cursor: pointer;
  padding: 10px 0;
  line-height: 1;
  transition: color 0.15s;
}
.remove-row:hover { color: #e53935; }

.macro-preview-row {
  display: flex;
  gap: 6px;
  margin: -4px 0 8px;
  flex-wrap: wrap;
}
.mp-badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 5px;
  background: #f0f2ff;
  color: #667eea;
}
.mp-badge.pro { background: #e8f5e9; color: #2e7d32; }
.mp-badge.carb { background: #fff3e0; color: #e65100; }
.mp-badge.fat { background: #fce4ec; color: #c62828; }

.btn-add-row {
  background: none;
  border: 1.5px dashed #d0d0d0;
  border-radius: 10px;
  width: 100%;
  padding: 10px;
  font-size: 14px;
  color: #999;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  margin-top: 4px;
}
.btn-add-row:hover { border-color: #667eea; color: #667eea; }

/* ── Meal totals preview ── */
.meal-totals-preview {
  margin-top: 12px;
  background: #f8f0ff;
  border-radius: 12px;
  padding: 12px 16px;
}
.preview-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  flex-wrap: wrap;
}
.preview-row span:first-child { font-weight: 600; color: #764ba2; flex: 1; }
#previewCal { font-weight: 700; color: #764ba2; }
#previewPro { color: #2e7d32; }
#previewCarb { color: #e65100; }
#previewFat { color: #c62828; }

/* ── Buttons ── */
.btn-primary {
  flex: 1;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 13px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  background: #f0f2ff;
  color: #667eea;
  border: none;
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-secondary:hover { background: #e0e4ff; }

.btn-text {
  background: none;
  border: none;
  color: #667eea;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}
.btn-text:hover { text-decoration: underline; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  color: #bbb;
  font-size: 14px;
  transition: color 0.15s, background 0.15s;
}
.btn-icon:hover { color: #e53935; background: #fce4ec; }
.btn-icon.edit:hover { color: #667eea; background: #f0f2ff; }

/* ── Loading & Toast ── */
.loading { text-align: center; padding: 40px; color: #aaa; }

#toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #323232;
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 300;
  pointer-events: none;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Barcode placeholder ── */
.barcode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f5f5f5;
  border: 1.5px dashed #ddd;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  color: #bbb;
  cursor: not-allowed;
  margin-bottom: 14px;
  width: 100%;
  justify-content: center;
}
.barcode-btn span { font-size: 16px; }

@media (max-width: 400px) {
  .daily-totals { gap: 6px; }
  .total-pill { min-width: 60px; padding: 6px 10px; }
  .total-pill .val { font-size: 17px; }
}

/* ══════════════════════════════════════════════════════════
   AUTH & PROFILE ADDITIONS
══════════════════════════════════════════════════════════ */

/* ── Profile button in header ── */
.header-top {
  position: relative;
}
.profile-btn {
  position: absolute;
  right: 0;
  background: rgba(255,255,255,0.2);
  border: none;
  border-radius: 50%;
  width: 36px; height: 36px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
  padding: 0;
}
.profile-btn:hover { background: rgba(255,255,255,0.35); }
.profile-initial {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

/* ── Goal bar ── */
.goal-bar-wrap {
  margin-top: 12px;
  padding: 0 2px;
}
.goal-track {
  height: 6px;
  background: rgba(255,255,255,0.25);
  border-radius: 3px;
  overflow: hidden;
}
.goal-fill {
  height: 100%;
  background: #ffd700;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.goal-fill.goal-over { background: #ff6b6b; }
.goal-label {
  font-size: 11px;
  color: rgba(255,255,255,0.75);
  margin-top: 4px;
  text-align: center;
}

/* ── Profile modal ── */
.modal-profile {
  max-height: 94vh;
}

/* ── Profile sections ── */
.profile-section {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #f0f0f0;
}
.profile-section:last-of-type { border-bottom: none; margin-bottom: 0; }
.profile-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #667eea;
  margin-bottom: 12px;
}

/* ── Field hint ── */
.field-hint {
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #aaa;
  margin-left: 6px;
}

/* ── Segmented control (gender) ── */
.seg-control {
  display: flex;
  border: 1.5px solid #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
}
.seg-btn {
  flex: 1;
  border: none;
  background: none;
  padding: 9px 6px;
  font-size: 14px;
  cursor: pointer;
  color: #888;
  transition: background 0.15s, color 0.15s;
  border-right: 1px solid #e0e0e0;
}
.seg-btn:last-child { border-right: none; }
.seg-btn.active {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  font-weight: 600;
}

/* ── Unit toggle ── */
.unit-toggle-btn {
  background: none;
  border: none;
  color: #667eea;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  margin-left: 8px;
  text-decoration: underline;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}
.unit-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.unit-input-row input {
  flex: 1;
}
.unit-suffix {
  font-size: 13px;
  color: #aaa;
  white-space: nowrap;
}

/* ── Option button groups (activity / goal) ── */
.opt-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.opt-btn {
  background: #fafafa;
  border: 1.5px solid #e8e8e8;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: border-color 0.15s, background 0.15s;
}
.opt-btn:hover { border-color: #667eea; background: #f8f0ff; }
.opt-btn.active {
  border-color: #667eea;
  background: #f0f2ff;
}
.opt-title {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a2e;
  flex: 1;
}
.opt-btn.active .opt-title { color: #667eea; }
.opt-desc {
  font-size: 12px;
  color: #aaa;
  white-space: nowrap;
}

/* ── TDEE card ── */
.tdee-card {
  background: linear-gradient(135deg, #f8f0ff, #f0f2ff);
  border-radius: 14px;
  padding: 16px;
  margin-top: 16px;
}
.tdee-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #555;
  padding: 4px 0;
}
.tdee-row strong { color: #1a1a2e; }
.tdee-divider {
  height: 1px;
  background: rgba(102,126,234,0.2);
  margin: 8px 0;
}
.tdee-goal-row { padding-top: 6px; }
.tdee-goal-row span { font-weight: 600; color: #764ba2; font-size: 14px; }
.tdee-goal-row strong { font-size: 18px; color: #667eea; }

/* ── Date input ── */
.date-input {
  width: 100%;
}

/* ── Danger button (logout) ── */
.btn-danger {
  background: #fce4ec;
  color: #c62828;
  border: none;
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-danger:hover { background: #ffcdd2; }

/* ══════════════════════════════════════════════════════════
   TAB SYSTEM & DASHBOARD
══════════════════════════════════════════════════════════ */

/* ── Body / App adjustments for tab bar ── */
#app { padding-bottom: 68px; }
#toast { bottom: 150px; }
.fab  { bottom: 78px; }

/* ── Simple header (non-log tabs) ── */
.simple-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 0 2px;
  position: relative;
}
.simple-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}
.simple-header .profile-btn { position: absolute; right: 0; }

/* ── Tab views ── */
.tab-view { display: none; }
.tab-view.active { display: block; }

/* ── Tab bar ── */
.tab-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 62px;
  background: #fff;
  border-top: 1px solid #ececec;
  display: flex;
  z-index: 40;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
  max-width: 640px;
  margin: 0 auto;
}
.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  color: #bbb;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 8px 4px;
  transition: color 0.15s;
}
.tab-btn svg {
  width: 22px; height: 22px;
  stroke: currentColor;
  transition: stroke 0.15s;
}
.tab-btn.active { color: #667eea; }
.tab-btn:hover:not(.active) { color: #888; }

/* ── Dashboard scroll container ── */
.tab-content {
  padding: 14px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Dashboard cards ── */
.dash-card {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.dash-card-hd {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
}
.dash-card-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #667eea;
  margin-bottom: 12px;
}
.dash-card-hd .dash-card-title { margin-bottom: 0; }
.dash-sub {
  font-size: 12px;
  color: #bbb;
}

/* ── Weekly chart ── */
.chart-wrap {
  position: relative;
  height: 160px;
  margin-bottom: 12px;
}
.chart-wrap canvas { position: absolute; inset: 0; }

.week-stats {
  display: flex;
  justify-content: space-around;
  border-top: 1px solid #f5f5f5;
  padding-top: 12px;
  margin-top: 4px;
}
.week-stat { text-align: center; }
.week-stat-mid {
  border-left: 1px solid #f0f0f0;
  border-right: 1px solid #f0f0f0;
  padding: 0 16px;
}
.sval {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: #1a1a2e;
  line-height: 1.1;
}
.streak-val { color: #ff9800; }
.slbl {
  font-size: 11px;
  color: #aaa;
  margin-top: 2px;
  display: block;
}

/* ── Today ring + macro bars row ── */
.dash-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.today-ring-card { padding: 14px 12px 12px; }
.ring-wrap {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto;
}
.ring-wrap canvas { position: absolute; inset: 0; }
.ring-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.ring-val {
  font-size: 18px;
  font-weight: 700;
  color: #1a1a2e;
  line-height: 1;
}
.ring-lbl {
  font-size: 10px;
  color: #aaa;
  margin-top: 2px;
  text-align: center;
}

/* ── Macro bars ── */
.macro-bars-card { padding: 14px 12px 12px; display: flex; flex-direction: column; }
.mbar-list { flex: 1; display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.mbar-row {
  display: flex;
  align-items: center;
  gap: 7px;
}
.mbar-icon {
  font-size: 11px;
  font-weight: 700;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}
.mbar-icon.pro  { color: #667eea; }
.mbar-icon.carb { color: #ff9800; }
.mbar-icon.fat  { color: #f06292; }
.mbar-track {
  flex: 1;
  height: 8px;
  background: #f0f0f0;
  border-radius: 4px;
  overflow: hidden;
}
.mbar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}
.mbar-fill.pro  { background: linear-gradient(90deg, #667eea, #9c6fe8); }
.mbar-fill.carb { background: linear-gradient(90deg, #ff9800, #ffb74d); }
.mbar-fill.fat  { background: linear-gradient(90deg, #f06292, #f48fb1); }
.mbar-val {
  font-size: 10px;
  color: #999;
  white-space: nowrap;
  min-width: 28px;
  text-align: right;
}
.mbar-hint {
  font-size: 11px;
  color: #bbb;
  margin-top: 8px;
  text-align: center;
}
.mbar-hint a { color: #667eea; text-decoration: none; }
.mbar-hint a:hover { text-decoration: underline; }

/* ── Macro donut ── */
.donut-row {
  display: flex;
  align-items: center;
  gap: 16px;
}
.donut-wrap {
  width: 120px;
  height: 120px;
  flex-shrink: 0;
  position: relative;
}
.donut-legend { flex: 1; }
.leg-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #555;
  margin-bottom: 6px;
}
.leg-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.leg-dot.pro  { background: #667eea; }
.leg-dot.carb { background: #ff9800; }
.leg-dot.fat  { background: #f06292; }
.leg-total {
  font-size: 11px;
  color: #aaa;
  margin-top: 8px;
}

/* ══════════════════════════════════════════════════════════
   GOALS TAB
══════════════════════════════════════════════════════════ */

/* ── Calorie goal mode options ── */
.cal-mode-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.mode-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1.5px solid #e8e8e8;
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.mode-opt:has(input:checked), .mode-opt.active {
  border-color: #667eea;
  background: #f0f2ff;
}
.mode-opt input[type="radio"] { display: none; }
.mode-content { flex: 1; }
.mode-title { display: block; font-size: 14px; font-weight: 600; color: #1a1a2e; }
.mode-sub   { display: block; font-size: 12px; color: #aaa; margin-top: 1px; }
.mode-check {
  font-size: 14px;
  color: #667eea;
  opacity: 0;
  transition: opacity 0.15s;
}
.mode-opt.active .mode-check { opacity: 1; }

/* ── Stepper (calorie input) ── */
.stepper-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.step-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1.5px solid #e0e0e0;
  background: #fafafa;
  font-size: 20px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #555;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.step-btn:hover { background: #f0f2ff; border-color: #667eea; color: #667eea; }
.stepper-val-wrap { flex: 1; display: flex; align-items: center; gap: 8px; }
.stepper-val-wrap input {
  flex: 1;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: #1a1a2e;
  border: none;
  border-bottom: 2px solid #e0e0e0;
  border-radius: 0;
  background: none;
  padding: 4px 0;
}
.stepper-val-wrap input:focus { border-bottom-color: #667eea; outline: none; }
.stepper-unit { font-size: 13px; color: #aaa; white-space: nowrap; }

/* ── Quick adjust buttons ── */
.quick-row {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 4px;
}
.quick-btn {
  background: #f5f5f5;
  border: 1px solid #e8e8e8;
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.quick-btn:hover { background: #f0f2ff; border-color: #667eea; color: #667eea; }

/* ── Goals hint ── */
.goals-hint {
  font-size: 13px;
  color: #aaa;
  margin-bottom: 14px;
}

/* ── Macro target rows ── */
.mtgt-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f8f8f8;
}
.mtgt-row:last-of-type { border-bottom: none; }
.mtgt-lbl {
  font-size: 13px;
  font-weight: 700;
  width: 50px;
  flex-shrink: 0;
}
.mtgt-lbl.pro  { color: #667eea; }
.mtgt-lbl.carb { color: #ff9800; }
.mtgt-lbl.fat  { color: #f06292; }
.mtgt-input {
  width: 90px;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
}
.mtgt-kcal {
  font-size: 12px;
  color: #aaa;
  margin-left: auto;
  white-space: nowrap;
  min-width: 54px;
  text-align: right;
}

/* ── Macro split preview bar ── */
.split-preview {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #f0f0f0;
}
.split-track {
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  background: #f0f0f0;
  margin-bottom: 6px;
}
.split-seg {
  height: 100%;
  transition: width 0.3s ease;
}
.split-seg.pro  { background: #667eea; }
.split-seg.carb { background: #ff9800; }
.split-seg.fat  { background: #f06292; }
.split-legend {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.split-item {
  font-size: 12px;
  font-weight: 600;
}
.split-item.pro  { color: #667eea; }
.split-item.carb { color: #ff9800; }
.split-item.fat  { color: #f06292; }

/* ── Goals save button ── */
.goals-save-btn {
  width: 100%;
  border-radius: 14px;
  padding: 15px;
  font-size: 16px;
  margin-top: 4px;
}
