/* ── TOKENS ─────────────────────────────────────────── */
:root {
  --sage:        #4a6741;
  --sage-light:  #6b8f61;
  --sage-pale:   #e8efe6;
  --cream:       #f7f4ef;
  --cream-dark:  #ede9e1;
  --warm-white:  #fdfcfa;
  --ink:         #2c2c2a;
  --ink-mid:     #5a5955;
  --ink-light:   #9a9791;
  --border:      #ddd9d0;
  --green-ok:    #3a7d44;
  --green-bg:    #eaf4ec;
  --red-over:    #c0392b;
  --red-bg:      #fdecea;
  --shadow-sm:   0 1px 3px rgba(44,44,42,0.08);
  --shadow-md:   0 4px 16px rgba(44,44,42,0.10);
  --radius:      12px;
  --radius-sm:   8px;
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body:    'Inter', system-ui, sans-serif;
  --transition:  0.2s ease;
}

/* ── RESET ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--ink);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
input, button, select { font-family: inherit; }
button { cursor: pointer; border: none; background: none; }

/* ── HEADER ─────────────────────────────────────────── */
.app-header {
  background: var(--warm-white);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.header-brand { display: flex; flex-direction: column; gap: 1px; }
.header-logo-space {
  height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.app-logo-icon {
  height: 32px;
  width: 32px;
  flex-shrink: 0;
}
.app-name {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--sage);
  letter-spacing: 0.01em;
  line-height: 1;
}
.app-subtitle {
  font-size: 0.68rem;
  color: var(--ink-light);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 400;
}
.lang-switcher {
  display: flex;
  gap: 4px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px;
}
.lang-btn {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 16px;
  color: var(--ink-mid);
  transition: all var(--transition);
}
.lang-btn.active {
  background: var(--sage);
  color: #fff;
}

/* ── NAV ────────────────────────────────────────────── */
.app-nav {
  background: var(--warm-white);
  border-bottom: 1px solid var(--border);
  display: flex;
}
.nav-btn {
  flex: 1;
  padding: 10px 4px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-light);
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.nav-btn svg { width: 18px; height: 18px; }
.nav-btn.active {
  color: var(--sage);
  border-bottom-color: var(--sage);
}

/* ── MAIN CONTENT ───────────────────────────────────── */
.app-main {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 100px;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}

/* ── SCREEN ─────────────────────────────────────────── */
.screen { display: none; }
.screen.active { display: block; }

/* ── SCREEN HEADER ──────────────────────────────────── */
.screen-header { margin-bottom: 20px; }
.screen-title {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
  margin-bottom: 4px;
}
.screen-subtitle {
  font-size: 0.82rem;
  color: var(--ink-mid);
  line-height: 1.5;
}

/* ── CARD ───────────────────────────────────────────── */
.card {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.card-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--sage);
  letter-spacing: 0.01em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--cream-dark);
}

/* ── GOALS SCREEN ───────────────────────────────────── */
.nutrient-row {
  display: grid;
  grid-template-columns: 32px 1fr 90px;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--cream-dark);
}
.nutrient-row:last-child { border-bottom: none; }

.toggle-wrap { display: flex; align-items: center; justify-content: center; }
.toggle {
  width: 28px; height: 28px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--cream);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  cursor: pointer;
  flex-shrink: 0;
}
.toggle.checked {
  background: var(--sage);
  border-color: var(--sage);
}
.toggle svg { width: 14px; height: 14px; stroke: #fff; stroke-width: 2.5; fill: none; opacity: 0; transition: opacity var(--transition); }
.toggle.checked svg { opacity: 1; }

.nutrient-info { display: flex; flex-direction: column; gap: 1px; }
.nutrient-name { font-weight: 500; font-size: 0.88rem; color: var(--ink); }
.nutrient-type-badge {
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--ink-light);
}

.goal-input-wrap { position: relative; }
.goal-input {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--cream);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink);
  text-align: right;
  transition: border-color var(--transition);
  -moz-appearance: textfield;
}
.goal-input::-webkit-outer-spin-button,
.goal-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.goal-input:focus { outline: none; border-color: var(--sage); background: var(--warm-white); }
.goal-input:disabled { opacity: 0.35; }
.goal-unit {
  font-size: 0.62rem;
  color: var(--ink-light);
  text-align: right;
  margin-top: 2px;
}

.save-btn {
  width: 100%;
  padding: 14px;
  background: var(--sage);
  color: #fff;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: background var(--transition), transform var(--transition);
  margin-top: 8px;
}
.save-btn:hover { background: var(--sage-light); }
.save-btn:active { transform: scale(0.98); }
.save-btn.saved { background: var(--green-ok); }

/* ── DAILY SCREEN ───────────────────────────────────── */
.meal-card { margin-bottom: 14px; }

.meal-input-row {
  display: grid;
  grid-template-columns: 1fr 90px;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--cream-dark);
}
.meal-input-row:last-child { border-bottom: none; }
.meal-nutrient-name { font-size: 0.86rem; font-weight: 400; color: var(--ink-mid); }

.meal-input {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--cream);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink);
  text-align: right;
  transition: border-color var(--transition);
  -moz-appearance: textfield;
}
.meal-input::-webkit-outer-spin-button,
.meal-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.meal-input:focus { outline: none; border-color: var(--sage); background: var(--warm-white); }

.daily-totals-bar {
  background: var(--sage-pale);
  border: 1px solid #c5d9c0;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.daily-totals-title {
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--sage);
  margin-bottom: 10px;
}
.totals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
}
.total-chip {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  text-align: center;
}
.total-chip-label { font-size: 0.62rem; color: var(--ink-light); text-transform: uppercase; letter-spacing: 0.04em; }
.total-chip-value { font-size: 1rem; font-weight: 600; color: var(--ink); font-family: var(--font-display); }
.total-chip-unit { font-size: 0.6rem; color: var(--ink-light); }

.reset-btn {
  width: 100%;
  padding: 11px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-mid);
  background: var(--warm-white);
  transition: all var(--transition);
}
.reset-btn:hover { border-color: var(--red-over); color: var(--red-over); }

/* ── SUMMARY SCREEN ─────────────────────────────────── */
.summary-row {
  display: grid;
  grid-template-columns: 1fr 56px 64px 100px;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--cream-dark);
}
.summary-row:last-child { border-bottom: none; }
.summary-header-row {
  display: grid;
  grid-template-columns: 1fr 56px 64px 100px;
  gap: 8px;
  padding: 0 0 8px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 4px;
}
.summary-col-label {
  font-size: 0.62rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-light);
}
.summary-col-label.right { text-align: right; }

.sum-nutrient { font-size: 0.86rem; font-weight: 500; color: var(--ink); }
.sum-value { font-size: 0.88rem; font-weight: 600; color: var(--ink); text-align: right; }
.sum-goal { font-size: 0.82rem; color: var(--ink-mid); text-align: right; }
.sum-diff { font-size: 0.82rem; font-weight: 600; text-align: right; }
.sum-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-green { color: var(--green-ok); }
.status-green .status-dot { background: var(--green-ok); }
.status-red { color: var(--red-over); }
.status-red .status-dot { background: var(--red-over); }

.summary-card-bg-green { background: var(--green-bg); }
.summary-card-bg-red { background: var(--red-bg); }

/* ── EMPTY STATES ───────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-light);
}
.empty-state p { font-size: 0.88rem; margin-bottom: 16px; line-height: 1.5; }
.empty-cta {
  display: inline-block;
  padding: 10px 20px;
  background: var(--sage);
  color: #fff;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.empty-cta:hover { background: var(--sage-light); }

/* ── TOAST ──────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--sage);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  z-index: 200;
  max-width: calc(100vw - 40px);
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── FOOTER ─────────────────────────────────────────── */
.app-footer {
  padding: 10px 16px;
  text-align: center;
  border-top: 1px solid var(--border);
  background: var(--warm-white);
}
.app-footer p {
  font-size: 0.68rem;
  color: var(--ink-light);
  letter-spacing: 0.01em;
}

/* ── DIVIDER ────────────────────────────────────────── */
.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ── RESPONSIVE ─────────────────────────────────────── */
@media (max-width: 400px) {
  .summary-row,
  .summary-header-row {
    grid-template-columns: 1fr 48px 56px 90px;
    gap: 5px;
  }
  .sum-value, .sum-goal, .sum-diff { font-size: 0.78rem; }
  .sum-nutrient { font-size: 0.78rem; }
  .sum-status { font-size: 0.66rem; gap: 4px; }
  .status-dot { width: 6px; height: 6px; }
}
