:root {
  --bg: #000000;
  --card: #141417;
  --card-2: #232329;
  --text: #ffffff;
  --muted: #8e8e93;
  --lime: #c9f73a;
  --red: #ff5f56;
  --radius: 20px;
  --font-display: "Unbounded", "Inter", sans-serif;
  --font-body: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  padding: 20px 16px calc(90px + env(safe-area-inset-bottom, 0px));
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.lime { color: var(--lime); }
.red { color: var(--red); }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---------- Хиро ---------- */
.hero { text-align: center; padding: 22px 0 22px; }
.hero-badge {
  display: inline-block;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--card-2);
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 20px;
}
.hero h1 {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 900;
  line-height: 1.08;
  letter-spacing: -0.5px;
}
.hero h1 .accent { color: var(--lime); }
.hero-sub { color: var(--muted); font-size: 15px; margin-top: 16px; line-height: 1.45; }

/* ---------- Карточки ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
}
.warn-card {
  border: 1px solid rgba(255, 95, 86, 0.4);
  background: rgba(255, 95, 86, 0.08);
  color: #ffb3ae;
  font-size: 14px;
  line-height: 1.4;
}

/* ---------- Форма ---------- */
.field { margin-bottom: 20px; }
.field-label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}
.budget-input {
  display: flex;
  align-items: baseline;
  gap: 8px;
  border-bottom: 1px solid var(--card-2);
  padding-bottom: 8px;
}
.budget-input input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 42px;
  font-weight: 800;
  font-family: var(--font-body);
}
.budget-input .rub { font-size: 26px; color: var(--muted); }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.stepper { display: flex; align-items: center; gap: 20px; }
.stepper span { font-size: 24px; font-weight: 700; min-width: 24px; text-align: center; }
.step-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--card-2);
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
  transition: transform 0.1s;
}
.step-btn:active { transform: scale(0.9); }

/* Сегментированный селектор цели */
.segmented {
  display: flex;
  background: var(--card-2);
  border-radius: 999px;
  padding: 4px;
}
.segmented button {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  padding: 10px 0;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
}
.segmented button.active {
  background: var(--lime);
  color: #000;
}
#goal-hint { margin-top: 8px; text-align: center; }

.cta {
  width: 100%;
  background: var(--lime);
  color: #000;
  border: none;
  border-radius: 999px;
  padding: 17px;
  font-size: 17px;
  font-weight: 800;
  font-family: var(--font-body);
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
}
.cta:active { transform: scale(0.97); }
.cta:disabled { opacity: 0.5; }

/* ---------- Сводка ---------- */
.spent { display: flex; align-items: baseline; gap: 8px; margin-bottom: 14px; }
.spent-value { font-size: 32px; font-weight: 800; }
.progress {
  height: 10px;
  background: var(--card-2);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--lime);
  border-radius: 999px;
  transition: width 0.6s ease;
}
.progress-fill.over { background: var(--red); }
.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  margin-top: 10px;
}
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.stat {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
}
.stat-value { font-size: 20px; font-weight: 800; }
.stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* ---------- Меню ---------- */
.section-title { font-size: 22px; font-weight: 800; margin: 6px 0 16px; }
.day-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 4px;
}
.meal {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.meal-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--card-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}
.meal-body { flex: 1; min-width: 0; }
.meal-name { font-size: 15px; font-weight: 600; }
.meal-cost { color: var(--lime); font-weight: 700; font-size: 15px; }
.meal-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}
.swap-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, transform 0.15s;
}
.swap-btn:hover { color: var(--text); }
.swap-btn:active { transform: scale(0.85); color: var(--lime); }
.swap-btn.spinning { animation: spin 0.6s linear infinite; color: var(--lime); }

/* Рецепт раскрывается по тапу на блюдо */
.meal[data-recipe] { cursor: pointer; }
.meal-recipe {
  display: none;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--card-2);
  border-radius: 12px;
  border-left: 3px solid var(--lime);
}
.meal.open .meal-recipe { display: block; }
.meal.open .meal-name { color: var(--lime); }
.meal-ing {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 3px 0;
}
.meal-ing span:first-child { color: var(--text); }
.meal-ing span:last-child { color: var(--lime); font-weight: 600; }
.meal-recipe-text {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ---------- Покупки ---------- */
.shop-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.shop-row:first-child { border-top: none; }
.shop-name { font-size: 15px; font-weight: 500; }
.shop-price { color: var(--lime); font-weight: 700; }
.shop-total {
  display: flex;
  justify-content: space-between;
  font-size: 18px;
  font-weight: 800;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  padding-top: 14px;
  margin-top: 6px;
}
.shop-total span:last-child { color: var(--lime); }

/* ---------- Пустые состояния ---------- */
.empty { text-align: center; padding: 60px 0; color: var(--muted); }
.empty-icon { font-size: 44px; margin-bottom: 14px; }
.empty p { font-size: 15px; line-height: 1.5; }

/* ---------- Нижняя навигация ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: rgba(16, 16, 18, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 10;
}
.nav-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11px;
  font-family: var(--font-body);
  padding: 10px 0 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.nav-icon { font-size: 20px; filter: grayscale(1) opacity(0.55); transition: filter 0.2s; }
.nav-btn.active { color: var(--lime); }
.nav-btn.active .nav-icon { filter: none; }

/* ---------- Табы ---------- */
.tab { display: none; }
.tab.active { display: block; }

/* ---------- Тост и загрузка ---------- */
.toast {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  max-width: 448px;
  margin: 0 auto;
  background: #1f1f24;
  border: 1px solid rgba(255, 95, 86, 0.5);
  color: #ffb3ae;
  padding: 14px 18px;
  border-radius: 14px;
  text-align: center;
  font-size: 14px;
  z-index: 30;
}
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--muted);
  z-index: 20;
}
.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--card-2);
  border-top-color: var(--lime);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Экран исключений ---------- */
#prefs-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 15;
  padding: 32px 16px calc(24px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  max-width: 480px;
  margin: 0 auto;
}
.prefs-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.5px;
}
.prefs-sub { font-size: 14px; line-height: 1.5; margin-top: 12px; }
.prefs-search {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--card-2);
  border-radius: 999px;
  color: var(--text);
  padding: 13px 18px;
  font-size: 15px;
  font-family: var(--font-body);
  outline: none;
  margin-top: 16px;
}
.prefs-search:focus { border-color: var(--lime); }
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 24px 0;
}
.chip {
  background: var(--card);
  border: 1px solid var(--card-2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s;
}
.chip.excluded {
  background: rgba(255, 95, 86, 0.12);
  border-color: var(--red);
  color: #ffb3ae;
  text-decoration: line-through;
}
.ghost {
  width: 100%;
  background: none;
  border: none;
  color: var(--muted);
  padding: 14px;
  font-size: 15px;
  font-family: var(--font-body);
  margin-top: 10px;
  cursor: pointer;
}

.settings-btn {
  position: fixed;
  top: 14px;
  right: 14px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--card-2);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  z-index: 5;
}
