/* =========================================================
   ДИЗАЙН-ТОКЕНЫ
   Палитра выбрана пастельной и "съедобной": тёплый молочный
   фон, приглушённый шалфейный для основных действий,
   абрикосовый для денег/бюджета, терракотовый для аллергий.
   ========================================================= */
:root {
  /* Цвета */
  --color-bg: #FBF8F3;
  --color-surface: #FFFFFF;
  --color-surface-sunken: #F3EFE6;

  --color-primary: #5B8C6E;
  --color-primary-dark: #3F6E51;
  --color-primary-light: #E3EDE3;

  --color-money: #E8A35C;
  --color-money-dark: #C9803E;
  --color-money-light: #FBE9D3;

  --color-warning: #D97C6B;
  --color-warning-light: #F8E2DE;

  --color-text: #3A3530;
  --color-text-secondary: #8A8378;
  --color-text-on-primary: #FFFFFF;

  --color-border: #EAE3D6;

  /* Типографика */
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, sans-serif;

  /* Радиусы и тени */
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  --shadow-card: 0 2px 12px rgba(58, 53, 48, 0.06), 0 1px 2px rgba(58, 53, 48, 0.04);
  --shadow-float: 0 8px 24px rgba(58, 53, 48, 0.12);

  --space-xs: 6px;
  --space-sm: 12px;
  --space-md: 18px;
  --space-lg: 28px;
  --space-xl: 40px;
}

/* =========================================================
   СБРОС И БАЗА
   ========================================================= */
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  margin: 0;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

h1 { font-size: 28px; line-height: 1.15; }
h2 { font-size: 20px; line-height: 1.25; }
h3 { font-size: 16px; }

p { margin: 0; }

button {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  background: none;
}

input {
  font-family: var(--font-body);
}

/* Видимый фокус для клавиатурной навигации (доступность) */
button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* =========================================================
   ОБЩИЙ КАРКАС ЭКРАНОВ (mobile-first)
   ========================================================= */
.screen {
  min-height: 100vh;
  width: 100%;
}

.screen.hidden {
  display: none;
}

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--space-md) var(--space-md) calc(var(--space-xl) + 64px);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* На широких экранах (планшет/десктоп) превращаем приложение
   в "телефон в центре", чтобы дизайн оставался mobile-first */
@media (min-width: 600px) {
  body {
    background: var(--color-surface-sunken);
  }
  .app-shell {
    position: relative;
    margin: var(--space-lg) auto;
    background: var(--color-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-float);
    min-height: calc(100vh - 2 * var(--space-lg));
  }
  .sticky-cta {
    position: absolute;
    left: 50%;
    bottom: var(--space-md);
    transform: translateX(-50%);
    width: calc(100% - 2 * var(--space-md));
  }
}

.eyebrow {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 4px;
}

/* =========================================================
   КНОПКИ
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: var(--radius-pill);
  font-size: 15px;
  font-weight: 700;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-block {
  width: 100%;
}

.btn-large {
  padding: 18px 24px;
  font-size: 16px;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-on-primary);
  box-shadow: 0 4px 14px rgba(91, 140, 110, 0.35);
}

.btn-secondary {
  background: var(--color-money);
  color: var(--color-text-on-primary);
  box-shadow: 0 4px 14px rgba(232, 163, 92, 0.35);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border: 2px solid var(--color-border);
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  font-size: 18px;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sticky-cta {
  position: fixed;
  left: 50%;
  bottom: var(--space-md);
  transform: translateX(-50%);
  width: calc(100% - 2 * var(--space-md));
  max-width: 480px;
  z-index: 50;
}

.back-btn {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-secondary);
  padding: 8px 0;
}

/* =========================================================
   ЭКРАН: ОНБОРДИНГ
   ========================================================= */
.onboarding-header {
  text-align: center;
  padding: var(--space-lg) 0 var(--space-sm);
}

.brand-badge {
  font-size: 48px;
  margin-bottom: var(--space-sm);
}

.onboarding-header .subtitle {
  color: var(--color-text-secondary);
  font-size: 15px;
  margin-top: var(--space-xs);
  max-width: 320px;
  margin-inline: auto;
}

.family-form-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.member-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  position: relative;
}

.member-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.member-card-remove {
  color: var(--color-warning);
  font-size: 13px;
  font-weight: 600;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

.text-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--color-border);
  background: var(--color-bg);
  font-size: 15px;
  color: var(--color-text);
}

.text-input:focus {
  border-color: var(--color-primary);
  outline: none;
}

.goal-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  background: var(--color-surface-sunken);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.goal-toggle-option {
  padding: 10px 4px;
  text-align: center;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.goal-toggle-option.active {
  background: var(--color-primary);
  color: var(--color-text-on-primary);
}

.allergy-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.allergy-chip {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--color-border);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  background: var(--color-surface);
}

.allergy-chip.active {
  background: var(--color-warning-light);
  border-color: var(--color-warning);
  color: var(--color-warning);
}

/* =========================================================
   ЭКРАН: ГЛАВНЫЙ (DASHBOARD)
   ========================================================= */
.dashboard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding-top: var(--space-sm);
}

.family-chips {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  padding-bottom: 4px;
}

.family-chip {
  flex-shrink: 0;
  background: var(--color-surface);
  border-radius: var(--radius-pill);
  padding: 8px 16px 8px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-card);
  white-space: nowrap;
}

.family-chip-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.hero-card {
  background: linear-gradient(155deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  border-radius: var(--radius-lg);
  padding: var(--space-lg) var(--space-md);
  color: var(--color-text-on-primary);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  box-shadow: var(--shadow-float);
}

.hero-kicker {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.85;
}

.hero-card h2 {
  color: var(--color-text-on-primary);
  margin-top: 4px;
}

.hero-desc {
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  margin-top: 8px;
}

.hero-card .btn-primary {
  background: var(--color-surface);
  color: var(--color-primary-dark);
}

.loading-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-lg) 0;
  color: var(--color-text-secondary);
  font-size: 14px;
}

.loading-indicator.hidden { display: none; }

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-primary-light);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.quick-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
}

.quick-stats.hidden { display: none; }

.stat-pill {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 110px;
}

.stat-pill-warning .stat-value {
  color: var(--color-warning);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--color-primary);
}

.stat-label {
  font-size: 12px;
  color: var(--color-text-secondary);
}

/* =========================================================
   ЭКРАН: МЕНЮ НА НЕДЕЛЮ
   ========================================================= */
.page-header {
  padding-top: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-days-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.menu-day-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.menu-day-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-secondary);
  padding-left: 4px;
}

.meal-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-sm);
}

.meal-card-photo {
  width: 72px;
  height: 72px;
  min-width: 72px;
  min-height: 72px;
  border-radius: var(--radius-md);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--color-surface-sunken);
  display: block;
}

.meal-card-body {
  flex: 1;
  min-width: 0;
}

.meal-card-slot {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.meal-card-name {
  font-size: 15px;
  font-weight: 600;
  margin-top: 2px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meal-card-calorie-tag {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.meal-card-warning {
  margin-top: 8px;
  background: var(--color-warning-light);
  color: var(--color-warning);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  line-height: 1.4;
}

/* =========================================================
   ЭКРАН: СПИСОК ПОКУПОК + БЮДЖЕТ
   ========================================================= */
.budget-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.budget-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.budget-input-row {
  display: flex;
  align-items: center;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  gap: 8px;
}

.budget-input {
  border: none;
  background: transparent;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--color-money-dark);
  width: 100%;
  outline: none;
}

.budget-currency {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-money-dark);
}

.budget-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.budget-progress-track {
  height: 14px;
  background: var(--color-surface-sunken);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.budget-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--color-primary);
  border-radius: var(--radius-pill);
  transition: width 0.5s ease, background 0.3s ease;
}

.budget-progress-bar.over-budget {
  background: var(--color-warning);
}

.budget-progress-bar.near-budget {
  background: var(--color-money);
}

.budget-progress-numbers {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--color-text-secondary);
}

.budget-status-label {
  font-weight: 700;
}

.savings-panel {
  background: var(--color-money-light);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.savings-panel.hidden { display: none; }

.savings-sub {
  font-size: 13px;
  color: var(--color-money-dark);
  opacity: 0.85;
}

.savings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.savings-item {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.savings-item-text {
  font-size: 13px;
  line-height: 1.4;
}

.savings-item-text strong {
  color: var(--color-money-dark);
}

.savings-apply-btn {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-primary);
  background: var(--color-primary-light);
  padding: 8px 12px;
  border-radius: var(--radius-pill);
}

.shopping-categories {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.shopping-category {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-card);
}

.shopping-category-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: var(--space-sm);
  display: flex;
  justify-content: space-between;
}

.shopping-item-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px 0;
  border-top: 1px solid var(--color-border);
}

.shopping-item-row:first-of-type {
  border-top: none;
}

.shopping-item-checkbox {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  border: 2px solid var(--color-border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: transparent;
}

.shopping-item-checkbox.checked {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-text-on-primary);
}

.shopping-item-info {
  flex: 1;
  min-width: 0;
}

.shopping-item-name {
  font-size: 14px;
  font-weight: 600;
}

.shopping-item-row.is-checked .shopping-item-name {
  text-decoration: line-through;
  color: var(--color-text-secondary);
}

.shopping-item-qty {
  font-size: 12px;
  color: var(--color-text-secondary);
}

.shopping-item-price {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-money-dark);
  flex-shrink: 0;
}

/* =========================================================
   ЭКРАН: ГОТОВО К ПОКУПКЕ (DELIVERY)
   ========================================================= */
.delivery-summary-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-xl) var(--space-md);
  text-align: center;
  box-shadow: var(--shadow-card);
}

.delivery-summary-label {
  font-size: 13px;
  color: var(--color-text-secondary);
  font-weight: 600;
}

.delivery-summary-amount {
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 700;
  color: var(--color-money-dark);
  margin-top: 4px;
}

.delivery-summary-sub {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-top: 4px;
}

/* =========================================================
   МОДАЛЬНОЕ ОКНО: ВЫБОР ДОСТАВКИ
   ========================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(58, 53, 48, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.hidden { display: none; }

.modal-sheet {
  background: var(--color-bg);
  width: 100%;
  max-width: 480px;
  border-radius: 28px 28px 0 0;
  padding: var(--space-sm) var(--space-md) var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  animation: slide-up 0.25s ease;
}

@keyframes slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--color-border);
  border-radius: var(--radius-pill);
  margin: 4px auto 8px;
}

.modal-sub {
  color: var(--color-text-secondary);
  font-size: 13px;
  margin-top: -8px;
}

.delivery-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin: var(--space-sm) 0;
}

.delivery-option-card {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-card);
  text-align: left;
  width: 100%;
}

.delivery-option-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.delivery-option-name {
  font-size: 15px;
  font-weight: 700;
}

.delivery-option-desc {
  font-size: 12px;
  color: var(--color-text-secondary);
}

/* =========================================================
   ТОСТ-УВЕДОМЛЕНИЕ
   ========================================================= */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--color-text);
  color: var(--color-bg);
  padding: 14px 22px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-float);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.hidden {
  display: none;
}
