/* ХакЕда — дизайн-система в стиле референса */
:root {
  --teal: #007B8C;
  --teal-dark: #005E6C;
  --teal-deep: #00434D;
  --teal-light: #E8F5F6;
  --teal-soft: #F2FAFB;
  --bg: #FAF8F5;
  --card: #FFFFFF;
  --ink: #1C2B2E;
  --ink-soft: #5B6B6E;
  --line: #E8E8E8;
  --red: #FF3B30;
  --green: #0E8A3E;
  --amber: #FF8B1A;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow: 0 2px 12px rgba(28, 43, 46, .07);
  --shadow-lg: 0 10px 36px rgba(28, 43, 46, .14);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  min-height: 100vh;
}
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--teal); text-decoration: none; }
h1, h2, h3 { line-height: 1.2; }

.app { max-width: 720px; margin: 0 auto; padding: 0 16px 64px; }
.app.wide { max-width: 1080px; }

/* Шапка */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0 6px; gap: 10px;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 19px; letter-spacing: .02em; color: var(--teal-deep);
}
.brand .logo {
  width: 34px; height: 34px; border-radius: 12px; background: var(--teal);
  display: grid; place-items: center; font-size: 18px; color: #fff;
}
.topbar .spacer { flex: 1; }
.iconbtn {
  width: 40px; height: 40px; border-radius: 12px; background: #fff;
  border: 1px solid var(--line); display: grid; place-items: center; font-size: 18px;
}
.iconbtn:hover { border-color: var(--teal); }
.backbtn {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--teal); font-weight: 600; font-size: 15px; padding: 8px 12px;
  border-radius: 12px; background: #fff; border: 1px solid var(--line);
}

/* Прогресс шагов */
.stepbadge {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--teal); font-weight: 700; font-size: 13px; text-transform: uppercase;
  letter-spacing: .08em; margin-top: 10px;
}
.progress { height: 6px; background: var(--teal-light); border-radius: 99px; margin: 10px 0 18px; overflow: hidden; }
.progress .bar { height: 100%; background: var(--teal); border-radius: 99px; transition: width .3s; }

/* Типографика экрана */
.screen h1 { font-size: clamp(24px, 5.4vw, 34px); font-weight: 800; color: var(--teal-deep); }
.screen .sub { color: var(--ink-soft); margin-top: 8px; font-size: 16px; }
.screen { padding-bottom: 120px; }

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--teal); color: #fff; font-weight: 700; font-size: 16px;
  padding: 14px 24px; border-radius: 14px; transition: .15s;
  box-shadow: 0 4px 14px rgba(0, 123, 140, .25);
}
.btn:hover { background: var(--teal-dark); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn.secondary { background: #fff; color: var(--teal); border: 1.5px solid var(--teal); box-shadow: none; }
.btn.secondary:hover { background: var(--teal-light); }
.btn.danger { background: var(--red); box-shadow: 0 4px 14px rgba(255, 59, 48, .25); }
.btn.small { padding: 8px 14px; font-size: 14px; border-radius: 10px; }
.btn.big { width: 100%; }
.btn .price { opacity: .85; font-weight: 600; font-size: 14px; }

/* Кнопка «Далее» внизу */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: linear-gradient(to top, var(--bg) 70%, rgba(250, 248, 245, 0));
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  max-width: 720px; margin: 0 auto;
}
.bottombar .btn { width: 100%; }

/* Чипы выбора (магазины, аллергии, кухня) */
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 20px; }
.chip {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1.5px solid var(--line); border-radius: 14px;
  padding: 13px 14px; font-weight: 600; text-align: left; transition: .15s;
}
.chip .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.chip:hover { border-color: var(--teal); }
.chip.on { border-color: var(--teal); background: var(--teal-light); box-shadow: 0 0 0 1px var(--teal) inset; }
.chip .check { margin-left: auto; color: var(--teal); font-weight: 800; opacity: 0; }
.chip.on .check { opacity: 1; }
.chip .note { display: block; font-weight: 400; font-size: 12px; color: var(--ink-soft); }

.hint { margin-top: 14px; color: var(--red); font-size: 14px; font-weight: 600; min-height: 20px; }
.hint.ok { color: var(--green); }

/* Счётчики */
.counter {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; border: 1.5px solid var(--line); border-radius: 14px;
  padding: 14px 16px; margin-top: 14px;
}
.counter .label { font-weight: 700; }
.counter .sub { font-size: 13px; color: var(--ink-soft); font-weight: 400; display: block; }
.counter .ctrl { display: flex; align-items: center; gap: 14px; }
.counter .ctrl button {
  width: 38px; height: 38px; border-radius: 12px; background: var(--teal-light);
  color: var(--teal); font-size: 20px; font-weight: 800;
}
.counter .ctrl button:disabled { opacity: .4; }
.counter .val { min-width: 28px; text-align: center; font-weight: 800; font-size: 18px; }

/* Переключатели приёмов пищи */
.mealgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.mealbtn {
  background: #fff; border: 1.5px solid var(--line); border-radius: 14px;
  padding: 14px; text-align: center; font-weight: 600;
}
.mealbtn .em { font-size: 24px; display: block; margin-bottom: 6px; }
.mealbtn.on { border-color: var(--teal); background: var(--teal-light); box-shadow: 0 0 0 1px var(--teal) inset; }

/* Карточки-инфо */
.infocard {
  margin-top: 16px; background: var(--teal-light); border-radius: var(--radius);
  padding: 14px 16px; font-size: 14.5px; color: var(--teal-deep);
}
.infocard b { font-weight: 800; }

/* Бюджет */
.budgetbox {
  background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-top: 16px;
}
.budgetbox .amount { font-size: 40px; font-weight: 800; color: var(--teal-deep); }
.budgetbox input {
  width: 100%; margin-top: 10px; font-size: 22px; font-weight: 700;
  padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; outline: none;
}
.budgetbox input:focus { border-color: var(--teal); }
.slider { width: 100%; margin-top: 14px; accent-color: var(--teal); }
.slider-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-soft); }

/* Дашборд */
.weekgrid { display: grid; gap: 14px; margin-top: 16px; }
.daycard { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; border: 1px solid transparent; }
.daycard.today { border-color: var(--teal); box-shadow: 0 0 0 2px var(--teal-light), var(--shadow); }
.daycard .dayhead {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; background: var(--teal-soft);
}
.daycard.today .dayhead { background: var(--teal-light); }
.daycard .dayhead .name { font-weight: 800; color: var(--teal-deep); }
.daycard .dayhead .todaytag { background: var(--teal); color: #fff; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; }
.daycard .dayhead .kcal { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.mealrow { display: flex; gap: 12px; padding: 12px 16px; align-items: flex-start; border-top: 1px solid var(--line); cursor: pointer; }
.mealrow:hover { background: var(--teal-soft); }
.mealrow .em { font-size: 26px; }
.mealrow .mname { font-weight: 700; flex: 1; }
.mealrow .mtype { font-size: 12px; color: var(--ink-soft); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.mealrow .mprice { font-weight: 800; color: var(--teal); white-space: nowrap; }

.summarybar {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px;
}
.sumcard { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.sumcard .v { font-size: 24px; font-weight: 800; color: var(--teal-deep); }
.sumcard .v.red { color: var(--red); }
.sumcard .v.green { color: var(--green); }
.sumcard .l { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.sumcard.full { grid-column: 1 / -1; }
.budgetbar { height: 8px; background: var(--teal-light); border-radius: 99px; margin-top: 10px; overflow: hidden; }
.budgetbar .fill { height: 100%; background: var(--teal); border-radius: 99px; }
.budgetbar .fill.over { background: var(--red); }

.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-top: 16px; }
.actionbtn {
  background: #fff; border: 1.5px solid var(--line); border-radius: 14px;
  padding: 14px; font-weight: 700; text-align: center;
}
.actionbtn .em { font-size: 22px; display: block; margin-bottom: 4px; }
.actionbtn:hover { border-color: var(--teal); background: var(--teal-light); }

/* Список покупок */
.store-compare { margin-top: 16px; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.store-compare h3 { color: var(--teal-deep); margin-bottom: 10px; }
.store-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.store-row .dot { width: 10px; height: 10px; border-radius: 50%; }
.store-row .best { margin-left: auto; background: var(--green); color: #fff; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.store-row .price { font-weight: 800; }
.store-row .miss { font-size: 12px; color: var(--red); }

.shopgroup { margin-top: 18px; }
.shopgroup h3 { color: var(--teal-deep); font-size: 17px; margin-bottom: 8px; }
.shopitem { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; box-shadow: var(--shadow); }
.shopitem .em { font-size: 20px; }
.shopitem .nm { flex: 1; font-weight: 600; font-size: 14.5px; }
.shopitem .nm .qt { color: var(--ink-soft); font-weight: 400; font-size: 13px; }
.shopitem .pr { text-align: right; }
.shopitem .pr .t { font-weight: 800; color: var(--teal-deep); }
.shopitem .pr .s { font-size: 12px; color: var(--ink-soft); display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.shopitem .pr .s .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.checkbox { width: 22px; height: 22px; border: 2px solid var(--line); border-radius: 7px; flex: none; display: grid; place-items: center; font-size: 13px; color: #fff; }
.shopitem.done { opacity: .5; }
.shopitem.done .checkbox { background: var(--green); border-color: var(--green); }

/* Рецепты */
.reclist { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-top: 16px; }
.reccard { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; cursor: pointer; }
.reccard:hover { box-shadow: var(--shadow-lg); }
.reccard .em { font-size: 30px; }
.reccard .nm { font-weight: 700; margin-top: 6px; }
.reccard .meta { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }

.recipe-view .meta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; color: var(--ink-soft); font-weight: 600; font-size: 14px; }
.recipe-view .meta span { background: var(--teal-light); padding: 4px 12px; border-radius: 99px; color: var(--teal-deep); }
.recipe-view h2 { color: var(--teal-deep); font-size: 26px; margin-top: 4px; }
.steps { margin-top: 16px; }
.step-item { display: flex; gap: 12px; margin-bottom: 14px; }
.step-item .n { width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--teal); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.ing-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.ing-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.ing-table .pr { text-align: right; font-weight: 700; color: var(--teal); white-space: nowrap; }

/* Квиз-вкусы: карты */
.tastewrap { margin-top: 16px; position: relative; height: 300px; }
.tastecard {
  position: absolute; inset: 0; background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; text-align: center;
  padding: 24px; transition: transform .25s, opacity .25s;
}
.tastecard .em { font-size: 44px; }
.tastecard .nm { font-size: 19px; font-weight: 700; }
.tastecard .kc { color: var(--ink-soft); font-size: 14px; }
.tastecard.gone { pointer-events: none; }
.swipebtns { display: flex; gap: 14px; justify-content: center; margin-top: 18px; }
.swipebtns button { width: 64px; height: 64px; border-radius: 50%; font-size: 26px; box-shadow: var(--shadow); }
.swipebtns .no { background: #fff; border: 1.5px solid var(--line); }
.swipebtns .yes { background: var(--teal); color: #fff; }
.swipebtns button:hover { transform: scale(1.06); }

/* Формы */
.formwrap { max-width: 420px; margin: 24px auto 0; }
.formcard { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 24px; }
.formcard h1 { font-size: 26px; color: var(--teal-deep); }
.field { margin-top: 14px; }
.field label { display: block; font-weight: 700; font-size: 14px; color: var(--teal-deep); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 13px 14px; border: 1.5px solid var(--line);
  border-radius: 12px; outline: none; background: var(--teal-soft);
}
.field input:focus, .field select:focus { border-color: var(--teal); background: #fff; }
.formfoot { margin-top: 16px; text-align: center; font-size: 14px; color: var(--ink-soft); }

/* Модалка */
.modal-back {
  position: fixed; inset: 0; background: rgba(28, 43, 46, .45);
  display: grid; place-items: center; z-index: 50; padding: 16px;
}
.modal {
  background: var(--bg); border-radius: var(--radius-lg); max-width: 640px;
  width: 100%; max-height: 86vh; overflow-y: auto; padding: 22px; position: relative;
  box-shadow: var(--shadow-lg);
}
.modal .close {
  position: sticky; top: 0; float: right; width: 36px; height: 36px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow); z-index: 2;
}

/* Тост */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--teal-deep); color: #fff; padding: 12px 22px;
  border-radius: 14px; font-weight: 600; z-index: 60; box-shadow: var(--shadow-lg);
  max-width: 90vw;
}
.toast.err { background: var(--red); }

/* Таблицы (админка) */
.tblwrap { overflow-x: auto; margin-top: 14px; border-radius: var(--radius); box-shadow: var(--shadow); background: #fff; }
table.tbl { width: 100%; border-collapse: collapse; min-width: 640px; }
table.tbl th { text-align: left; font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); padding: 12px 14px; border-bottom: 2px solid var(--line); white-space: nowrap; }
table.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 14.5px; vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl input, table.tbl select {
  padding: 7px 10px; border: 1.5px solid var(--line); border-radius: 9px; width: 100%;
  min-width: 70px; background: var(--teal-soft);
}
table.tbl input:focus { border-color: var(--teal); background: #fff; outline: none; }
.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: var(--teal-light); color: var(--teal-deep); }
.tag.red { background: #FEECEB; color: var(--red); }
.tag.green { background: #E5F3E8; color: var(--green); }
.tag.gray { background: #EFEFEF; color: var(--ink-soft); }

/* Админка */
.admin-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.admin-nav .tab {
  padding: 10px 16px; border-radius: 12px; background: #fff;
  border: 1.5px solid var(--line); font-weight: 700; font-size: 14px;
}
.admin-nav .tab.on { background: var(--teal); color: #fff; border-color: var(--teal); }
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 16px; }
.statgrid .stat { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.statgrid .stat .v { font-size: 28px; font-weight: 800; color: var(--teal-deep); }
.statgrid .stat .l { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.searchbar { display: flex; gap: 10px; margin-top: 16px; }
.searchbar input { flex: 1; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; outline: none; }
.searchbar input:focus { border-color: var(--teal); }

.empty {
  text-align: center; padding: 48px 16px; color: var(--ink-soft);
}
.empty .em { font-size: 44px; display: block; margin-bottom: 10px; }

.loading { text-align: center; padding: 60px 0; color: var(--ink-soft); }
.spinner {
  width: 36px; height: 36px; margin: 0 auto 12px; border-radius: 50%;
  border: 4px solid var(--teal-light); border-top-color: var(--teal);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Лендинг */
.hero { text-align: center; padding: 40px 0 10px; }
.hero .em { font-size: 64px; }
.hero h1 { font-size: clamp(30px, 7vw, 44px); color: var(--teal-deep); margin-top: 10px; }
.hero p { color: var(--ink-soft); font-size: 17px; margin-top: 12px; max-width: 480px; margin-left: auto; margin-right: auto; }
.hero .btn { margin-top: 24px; }
.featuregrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 34px; }
.feature { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.feature .em { font-size: 28px; }
.feature b { display: block; margin-top: 8px; color: var(--teal-deep); }
.feature span { font-size: 14px; color: var(--ink-soft); }

@media (max-width: 560px) {
  .chips { grid-template-columns: repeat(2, 1fr); }
  .mealgrid { grid-template-columns: repeat(2, 1fr); }
  .summarybar { grid-template-columns: 1fr; }
  .mealrow .mprice { font-size: 13px; }
}
