/* ============================================================
   FoodCost — оформлення
   Палітра й компоненти за макетом. Дві теми: світла (типово)
   і темна — перемикається атрибутом data-theme на <html>.
   ============================================================ */

/* ═════════════════ Токени ═════════════════ */

:root {
  --bg: #f4f1ec; --side: #edeae3; --side-hov: #e4e0d7;
  --panel: #fffdfa; --panel-2: #faf8f4; --row-hov: #faf8f3; --seg-bg: #f7f5f1;
  --line: #e4dfd6; --line-2: #e0dbd2; --line-soft: #ece8e0; --line-faint: #f2efe9;
  --dash: #cfc9bd; --edge: #d9d4ca; --edge-2: #b9b3a8;
  --fg: #1b1a17; --fg-2: #55524b; --fg-3: #6d685f;
  --muted: #8b867c; --muted-2: #9a958b; --dim: #b8b2a7;
  --accent: #2e6a4f; --accent-2: #24543f; --accent-soft: #eef3ef; --on-accent: #fbfaf7;
  --danger: #a3402f; --danger-soft: #f9edea; --on-danger: #fdf7f5;
  --field: #ffffff;
  --ink: #1e1d1a; --ink-fg: #f3f0ea;
  --desk: #e6e2db; --thumb: #e9e3d6;
  --thumb-ink: rgba(27,26,23,.2); --thumb-ink-2: rgba(27,26,23,.3);
  --thumb-stripe: rgba(27,26,23,.035); --thumb-btn: rgba(255,253,250,.62);
  --focus: rgba(46,106,79,.14); --overlay: rgba(27,26,23,.42);
  --card-shadow: rgba(27,26,23,.28); --modal-shadow: rgba(27,26,23,.5); --nav-shadow: rgba(27,26,23,.04);
  --nav-active: #f6f3ed;

  --ui: 'Golos Text', system-ui, -apple-system, sans-serif;
  --num: 'IBM Plex Mono', ui-monospace, monospace;
  --r-s: 8px; --r-m: 10px; --r-l: 14px; --r-xl: 16px;
}

html[data-theme="dark"] {
  --bg: #16150f; --side: #1c1b17; --side-hov: #26241f;
  --panel: #201f1b; --panel-2: #1b1a16; --row-hov: #262420; --seg-bg: #191814;
  --line: #302d28; --line-2: #322f29; --line-soft: #2b2924; --line-faint: #272521;
  --dash: #3f3c35; --edge: #3f3c35; --edge-2: #575349;
  --fg: #f0ede6; --fg-2: #c0bbb1; --fg-3: #a5a097;
  --muted: #8d887f; --muted-2: #7e7970; --dim: #6b665e;
  --accent: #5f9d7c; --accent-2: #7ebb99; --accent-soft: #1e2b24; --on-accent: #10201a;
  --danger: #cc7c6c; --danger-soft: #33211d; --on-danger: #1b1310;
  --field: #26241f;
  --ink: #0e0d0b; --ink-fg: #f0ede6;
  --desk: #100f0d; --thumb: #2a2823;
  --thumb-ink: rgba(240,237,230,.22); --thumb-ink-2: rgba(240,237,230,.32);
  --thumb-stripe: rgba(240,237,230,.04); --thumb-btn: rgba(32,31,27,.7);
  --focus: rgba(95,157,124,.22); --overlay: rgba(8,7,6,.62);
  --card-shadow: rgba(0,0,0,.5); --modal-shadow: rgba(0,0,0,.6); --nav-shadow: rgba(0,0,0,.25);
  --nav-active: #262420;
}

/* ═════════════════ База ═════════════════ */

* { box-sizing: border-box; }
/* Явний display у компонентах інакше перебиває атрибут hidden */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  display: flex; min-height: 100vh; background: var(--bg); color: var(--fg);
  font-family: var(--ui); font-size: 15px; -webkit-font-smoothing: antialiased;
}
input, select, button, textarea { font: inherit; color: inherit; }
input::placeholder { color: var(--dim); }
button { white-space: nowrap; transition: background-color .13s ease, border-color .13s ease, color .13s ease, box-shadow .13s ease, transform .13s ease; }
button:active { transform: translateY(1px); }
input, select { transition: background-color .13s ease, border-color .13s ease, box-shadow .13s ease; }
aside, main, section, h1, h2, p { transition: background-color .22s ease, border-color .22s ease, color .22s ease; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; }

@keyframes fc-toast { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes fc-fade  { from { opacity: 0; } to { opacity: 1; } }
@keyframes fc-pop   { from { opacity: 0; transform: scale(.975) translateY(6px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes fc-rise  { from { opacity: 0; transform: scale(.94) translateY(24px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes fc-sheet { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fc-item  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ═════════════════ Сайдбар ═════════════════ */

.sidebar {
  width: 244px; flex: 0 0 244px; position: sticky; top: 0; align-self: flex-start;
  height: 100vh; overflow-y: auto; background: var(--side);
  border-right: 1px solid var(--line-2); display: flex; flex-direction: column;
  padding: 22px 14px 18px;
}
.brand { display: flex; align-items: center; padding: 0 10px 24px; }
.brand-name { font-size: 24px; font-weight: 700; letter-spacing: -.025em; }

.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  margin-top: 26px; padding: 0 11px 8px; font-family: var(--num); font-size: 10.5px;
  letter-spacing: .12em; text-transform: uppercase; color: var(--muted-2);
}
.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  padding: 9px 11px; border: 0; border-radius: 9px; background: transparent;
  color: var(--fg-2); font-size: 14px; font-weight: 500; text-align: left; cursor: pointer;
}
.nav-item:hover { background: var(--side-hov); color: var(--fg); }
.nav-item[aria-current="true"] {
  background: var(--nav-active); color: var(--fg); font-weight: 600;
  box-shadow: 0 1px 1px var(--nav-shadow);
}
.nav-item svg { flex: 0 0 auto; width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-count { font-family: var(--num); font-size: 12px; color: var(--muted); }
.nav-item.is-cta {
  margin-top: 8px; padding: 10px 11px; background: var(--accent);
  color: var(--on-accent); font-weight: 600; justify-content: flex-start;
}
.nav-item.is-cta:hover { background: var(--accent-2); color: var(--on-accent); }
.nav-item.is-sub { font-weight: 500; }
.nav-item.is-add { font-size: 13.5px; color: var(--fg-3); padding: 8px 11px; justify-content: flex-start; }
.nav-hint { margin: 2px 11px 6px; font-size: 12.5px; line-height: 1.5; color: var(--muted); }

.nav-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; padding-top: 18px; }

/* ═════════════════ Шапка телефона ═════════════════
   На великому екрані її просто немає: сайдбар там видно завжди.
   Нижче 900px сайдбар стає шухлядою, а керує нею цей бургер. */

.topbar { display: none; }
.burger {
  display: grid; place-items: center; width: 44px; height: 44px; border: 0;
  border-radius: var(--r-m); background: transparent; color: var(--fg); cursor: pointer;
}
.burger:hover { background: var(--side-hov); }
.burger svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }
.burger .i-close { display: none; }
.nav-scrim { display: none; }

/* ═════════════════ Каркас екранів ═════════════════ */

.work { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.screen { display: none; width: 100%; max-width: 1080px; margin: 0 auto; padding: 56px 48px 72px; }
.screen.is-active { display: block; }
#s-home.is-active { padding-top: 84px; }
#s-calc.is-active { padding-top: 40px; }
#s-settings { max-width: 760px; }

.h1 { margin: 0 0 8px; font-size: 38px; font-weight: 700; letter-spacing: -.025em; }
.h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.lede { margin: 0; font-size: 15px; line-height: 1.55; color: var(--fg-2); }

.screen-head { margin-bottom: 26px; }
/* Обгортка пошуку: на телефоні саме вона липне до шапки */
.tools-bar { margin-bottom: 16px; }
.screen-head.with-action { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.head-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }

/* ═════════════════ Кнопки ═════════════════ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 16px; border: 1px solid var(--line-2); border-radius: var(--r-m);
  background: var(--panel); color: var(--fg); font-size: 14.5px; cursor: pointer;
}
.btn:hover { border-color: var(--edge-2); }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { border: 0; background: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent-2); }
.btn-danger { border: 0; background: var(--danger); color: var(--on-danger); font-weight: 600; }
.btn-ghost { border: 0; background: transparent; color: var(--fg-3); }
.btn-ghost:hover { background: var(--side-hov); color: var(--fg); }
/* «Видалити» в калькуляції й напівфабрикаті: без цього кольору кнопка
   незворотної дії виглядала так само сіро, як «Скасувати» */
.btn-ghost.is-danger { color: var(--danger); }
.btn-ghost.is-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-soft { border: 0; background: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn-soft:hover { background: var(--accent-2); }
.btn-dash {
  height: 34px; padding: 0 12px; border: 1px dashed var(--dash); border-radius: 9px;
  background: transparent; color: var(--fg-2); font-size: 13.5px; cursor: pointer;
}
.btn-dash:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-2); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn-mini {
  height: 26px; padding: 0 9px; border: 1px solid var(--line-2); border-radius: 7px;
  background: var(--panel); font-size: 12px; color: var(--fg-2); cursor: pointer;
}
.btn-mini:hover { border-color: var(--edge-2); color: var(--fg); }
.btn-mini.is-danger:hover { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }

.icon-btn {
  display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: var(--r-s);
  background: transparent; color: var(--dim); cursor: pointer;
}
.icon-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.is-danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ═════════════════ Поля ═════════════════ */

.inp {
  width: 100%; padding: 10px 8px; border: 1px solid transparent; border-radius: var(--r-s);
  outline: none; background: transparent; font-size: 14.5px; color: var(--fg);
}
.inp:hover { border-color: var(--line-2); }
.inp:focus { border-color: var(--accent); background: var(--field); box-shadow: 0 0 0 3px var(--focus); }
.inp.is-num { text-align: right; font-family: var(--num); font-size: 14px; font-variant-numeric: tabular-nums; }

.search-wrap {
  display: flex; align-items: center; gap: 8px; width: 260px; padding: 0 12px; height: 38px;
  border: 1px solid var(--line-2); border-radius: var(--r-m); background: var(--panel);
}
.search-wrap svg { flex: 0 0 auto; width: 15px; height: 15px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
.search-wrap .inp { padding: 0; border: 0; font-size: 14px; }
.search-wrap .inp:hover, .search-wrap .inp:focus { border-color: transparent; background: transparent; box-shadow: none; }

.unit-sel {
  padding: 5px 3px; border: 0; border-radius: 6px; outline: none; background: transparent;
  -webkit-appearance: none; appearance: none; font-family: var(--num); font-size: 12.5px;
  color: var(--muted); cursor: pointer;
}
.unit-sel:hover { background: var(--side-hov); color: var(--fg); }
.cell-pair { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.cell-pair .inp.is-num { width: 62px; }
.qty-wrap { position: relative; display: block; }
.qty-wrap .inp { padding-right: 30px; }
.unit-tag {
  position: absolute; top: 50%; right: 10px; transform: translateY(-50%);
  font-family: var(--num); font-size: 12px; color: var(--dim); pointer-events: none;
}

/* ═════════════════ Панелі й таблиці ═════════════════ */

.panel { border: 1px solid var(--line); border-radius: var(--r-l); background: var(--panel); overflow: hidden; }
.panel-scroll { overflow-x: auto; }
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 16px 20px 14px; border-bottom: 1px solid var(--line-soft);
}
.panel-sum { display: flex; align-items: baseline; gap: 10px; font-size: 13px; color: var(--muted); }
.panel-sum b { font-family: var(--num); font-size: 16px; font-weight: 600; color: var(--fg); font-variant-numeric: tabular-nums; }
.panel-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px; background: var(--panel-2);
}
.panel-tip { font-size: 12.5px; color: var(--muted); }

.tbl { width: 100%; border-collapse: collapse; table-layout: fixed; }
.tbl th {
  padding: 9px 6px; border-bottom: 1px solid var(--line-faint); background: var(--panel-2);
  font-family: var(--num); font-size: 10.5px; font-weight: 400; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted-2); text-align: left; white-space: nowrap;
}
.tbl thead th:first-child { padding-left: 20px; }
.tbl thead th:last-child { padding-right: 20px; }
.tbl th.h-num { text-align: right; }
.tbl th.h-mid { text-align: center; }
.tbl td { padding: 0 6px; border-bottom: 1px solid var(--line-faint); vertical-align: middle; }
.tbl tbody tr:hover { background: var(--row-hov); }
.tbl tbody td:first-child { padding-left: 20px; }
.tbl tbody td:last-child { padding-right: 20px; }
.t-act { width: 44px; text-align: center; }
.t-mid { text-align: center; }
.t-cost {
  text-align: right; font-family: var(--num); font-size: 14px; font-weight: 600;
  font-variant-numeric: tabular-nums; padding: 10px 8px;
}
.t-cost.t-empty { color: var(--dim); font-weight: 400; }
.tbl-empty { padding: 44px 20px; text-align: center; color: var(--fg-3); font-size: 14px; }

/* Згорнута картка рядка — тільки телефон, розгортається в адаптиві наприкінці файла */
.row-peek, .row-fold, .m-sum { display: none; }

/* ширини колонок */
.w-price { width: 122px; }   /* вміщає заголовок «Ціна упаковки» без переносу */
.w-pack  { width: 118px; }
.w-qty   { width: 108px; }
.w-cost  { width: 102px; }
.w-unit  { width: 76px; }
.w-mode  { width: 68px; }

/* ═════════════════ Групи (напівфабрикат у калькуляції) ═════════════════
   Шапка групи та її складники — звичайні рядки таблиці з міткою. Межу групи
   тримає вертикальна рейка зліва, а не рамка: у щільній таблиці рамка на
   кожну групу перетворює екран на сітку. */

.ing-group > td { background: var(--side); border-bottom-color: var(--edge); }
.ing-group:hover > td { background: var(--side-hov); }

/* Шеврон живе у власному жолобі ліворуч, а не в потоці назви — інакше
   назва групи опиняється правіше за свої ж складники, і ієрархія читається
   навиворіт. Тому в цієї клітинки свій відступ замість табличних 20px. */
.tbl tbody tr.ing-group > td:first-child { padding-left: 8px; }
.grp-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.grp-chev {
  flex: 0 0 auto; display: grid; place-items: center; width: 20px; height: 20px;
  border: 0; border-radius: 5px; background: transparent; color: var(--muted); cursor: pointer;
}
.grp-chev:hover { background: var(--edge); color: var(--fg); }
.grp-chev svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .16s ease; }
.ing-group.is-closed .grp-chev svg { transform: rotate(-90deg); }
.grp-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grp-of { flex: 0 0 auto; font-family: var(--num); font-size: 11.5px; color: var(--muted); }

/* Рідкісна дія — тримаємо місце, але показуємо лише під курсором,
   щоб шапка групи не перетворювалась на смугу з трьох написів. */
.grp-unlink { flex: 0 0 auto; opacity: 0; pointer-events: none; transition: opacity .13s ease; }
.ing-group:hover .grp-unlink, .grp-unlink:focus-visible { opacity: 1; pointer-events: auto; }
/* На тачскріні наведення не буває — там кнопка має бути видима завжди */
@media (hover: none) { .grp-unlink { opacity: 1; pointer-events: auto; } }
.ing-group .t-cost { color: var(--accent); }

/* Рейка вздовж складників групи. Псевдоелемент на першій клітинці, бо
   border-left на самому tr у складених таблицях не малюється.
   Селектор довший за потрібне навмисне: .tbl tbody td:first-child задає
   padding-left і без цієї ваги перебиває відступ. */
.tbl tbody tr.ing-child > td:first-child { position: relative; padding-left: 48px; }
.tbl tbody tr.ing-child > td:first-child::before {
  content: ''; position: absolute; left: 26px; top: 0; bottom: 0;
  width: 2px; background: var(--edge);
}
.tbl tbody tr.ing-child.is-last > td:first-child::before { bottom: 50%; }

.foot-acts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ═════════════════ Смуга «ціни змінились» ═════════════════
   Зʼявляється лише коли є що оновлювати, тому не мозолить око. */

.stale-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 18px; padding: 12px 14px 12px 16px;
  border: 1px solid var(--accent); border-radius: var(--r-m); background: var(--accent-soft);
}
.stale-txt { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--fg); min-width: 0; }
.stale-txt svg {
  flex: 0 0 auto; width: 17px; height: 17px; fill: none; stroke: var(--accent);
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.stale-bar .btn { flex: 0 0 auto; height: 36px; }

/* ═════════════════ Напівфабрикат ═════════════════ */

.prep-name-btn {
  padding: 11px 0; border: 0; background: transparent; font-size: 14.5px; font-weight: 600;
  color: var(--fg); text-align: left; cursor: pointer; width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.prep-name-btn:hover { color: var(--accent-2); text-decoration: underline; }
.t-mono { text-align: right; font-family: var(--num); font-size: 13.5px; font-variant-numeric: tabular-nums; color: var(--fg-2); }
.t-mono.t-empty { color: var(--dim); }

/* Такі самі 20px, як між панелями калькуляції */
.panel-yield { margin: 20px 0; }
.yield-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 18px 20px; }
.yield-ctl { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; }
.yield-ctl .cell-pair { border: 1px solid var(--edge); border-radius: var(--r-s); background: var(--field); padding: 0 8px 0 2px; }
.yield-ctl .cell-pair .inp.is-num { width: 84px; height: 38px; }
.yield-ctl .cell-pair .inp.is-num:focus { box-shadow: none; border-color: transparent; }

/* Модалка вставки */
.modal > select.inp { cursor: pointer; }
.prep-pick-meta { margin-top: 8px; font-family: var(--num); font-size: 12.5px; color: var(--muted); }
.prep-take-lbl { display: block; margin-top: 18px; margin-bottom: 6px; font-size: 13.5px; color: var(--fg-2); }
.prep-take-row { display: flex; align-items: center; gap: 12px; }
.prep-take-row .qty-wrap {
  flex: 0 0 132px; border: 1px solid var(--edge); border-radius: var(--r-s); background: var(--field);
}
.prep-take-row .inp { height: 40px; padding: 0 30px 0 12px; }
.prep-take-hint { font-family: var(--num); font-size: 12.5px; color: var(--muted); }

/* ═════════════════ Головна ═════════════════ */

.home .h1 { max-width: 620px; margin-bottom: 20px; font-size: 52px; line-height: 1.08; text-wrap: balance; }
.home .lede { max-width: 470px; margin-bottom: 48px; font-size: 16.5px; }
.home-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; max-width: 780px; }
.home-card {
  display: flex; flex-direction: column; padding: 26px 26px 24px;
  border: 1px solid var(--line); border-radius: var(--r-l); background: var(--panel);
}
.home-card-step { font-family: var(--num); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted-2); }
.home-card-title { margin: 14px 0 10px; font-size: 21px; font-weight: 600; letter-spacing: -.015em; }
.home-card-desc { margin-bottom: 26px; font-size: 14.5px; line-height: 1.55; color: var(--fg-2); }
.home-card .btn { align-self: flex-start; margin-top: auto; }

/* ═════════════════ Папка ═════════════════ */

.folder-meta { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.folder-meta .num { font-size: 13px; color: var(--muted); }
.folder-meta .sep { width: 1px; height: 13px; background: var(--edge); }
.link-btn { padding: 3px 4px; border: 0; border-radius: 6px; background: transparent; font-size: 13px; color: var(--fg-3); cursor: pointer; }
.link-btn:hover { color: var(--accent-2); text-decoration: underline; }
.link-btn.is-danger:hover { color: var(--danger); }
/* Іконки дій папки — тільки телефон, там вони замінюють текст */
.link-btn .i-ico { display: none; }

.folder-tools { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }

.seg { display: flex; gap: 4px; padding: 3px; border: 1px solid var(--line-2); border-radius: var(--r-m); background: var(--seg-bg); }
.seg button {
  padding: 6px 12px; border: 0; border-radius: var(--r-s); background: transparent;
  color: var(--fg-2); font-family: var(--num); font-size: 13px; cursor: pointer;
}
.seg button:hover { color: var(--fg); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.folder-order { display: flex; gap: 8px; }
.seg-view { display: none; }
.seg-view svg { display: block; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(216px, 1fr)); gap: 18px; }
.rcard {
  position: relative; display: flex; flex-direction: column; padding: 0; text-align: left;
  border: 1px solid var(--line); border-radius: var(--r-l); background: var(--panel);
  overflow: hidden; cursor: pointer; color: inherit; font: inherit;
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}
.rcard:hover { border-color: var(--edge); transform: translateY(-3px); box-shadow: 0 12px 26px -14px var(--card-shadow); }
.rcard:active { transform: translateY(-1px); }
.rcard-thumb {
  position: relative; display: grid; place-items: center; aspect-ratio: 4 / 3;
  background: var(--thumb) repeating-linear-gradient(135deg, var(--thumb-stripe) 0 1px, transparent 1px 7px);
  font-size: 30px; font-weight: 500; color: var(--thumb-ink);
}
.rcard-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rcard-thumb::after {
  content: 'фото'; position: absolute; bottom: 9px; left: 12px; font-family: var(--num);
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--thumb-ink-2);
}
.rcard-thumb.has-img::after { display: none; }
.rcard-body { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px 16px; }
.rcard-title { font-size: 15.5px; font-weight: 600; letter-spacing: -.01em; }
.rcard-line { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--muted); }
.rcard-line .num { font-size: 12.5px; color: var(--muted); }
.rcard-line.is-price { padding-top: 8px; border-top: 1px solid var(--line-faint); color: var(--fg-2); }
.rcard-line.is-price .num { font-size: 16px; font-weight: 600; color: var(--accent); }

.empty {
  display: flex; flex-direction: column; align-items: flex-start; gap: 14px;
  padding: 44px 40px 46px; border: 1px dashed var(--dash); border-radius: var(--r-l); background: var(--panel-2);
}
.empty::before { content: ''; width: 34px; height: 34px; border: 1px dashed var(--dash); border-radius: var(--r-m); }
.empty b { font-size: 18px; font-weight: 600; }
.empty span { max-width: 360px; font-size: 14.5px; line-height: 1.55; color: var(--fg-3); }
.empty .btn { margin-top: 6px; }

/* ═════════════════ Калькуляція ═════════════════ */

.calc-top { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.back-btn {
  display: flex; align-items: center; gap: 8px; margin-left: -8px; padding: 6px 10px 6px 8px;
  border: 0; border-radius: var(--r-s); background: transparent; font-family: var(--num);
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); cursor: pointer;
}
.back-btn:hover { background: var(--side-hov); color: var(--fg); }

.save-state { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.save-state::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.save-state:empty { display: none; }
.save-state.is-saved { color: var(--accent); }
.save-state.is-dirty { color: var(--muted); }
.save-state.is-warn { color: var(--danger); font-weight: 600; }

.calc-titlebar { display: flex; align-items: flex-start; gap: 18px; margin-bottom: 34px; }
.title-inp {
  flex: 1; min-width: 0; margin-left: -10px; padding: 6px 10px; border: 1px solid transparent;
  border-radius: var(--r-m); font-size: 34px; font-weight: 700; letter-spacing: -.028em;
}
.title-inp:hover { border-color: var(--edge); background: var(--panel); }
.title-inp:focus { border-color: var(--accent); background: var(--field); box-shadow: 0 0 0 3px var(--focus); }

.photo-btn {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px; margin-top: 6px; padding: 0 16px;
  height: 42px; border: 1px dashed var(--dash); border-radius: var(--r-m); background: transparent;
  font-size: 14px; color: var(--fg-2); cursor: pointer;
}
.photo-btn:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-2); }
.photo-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.photo-box { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.photo-box img { width: 72px; height: 54px; object-fit: cover; border-radius: var(--r-s); border: 1px solid var(--line-2); display: block; }
.photo-acts { display: flex; flex-direction: column; gap: 4px; }

.calc-mid { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; margin: 20px 0; }
/* 480, не 360: рядок витрати тепер має ще й тип+вартість поруч з назвою.
   Колонки фіксовані (mode/value/cost/дії), тож таблиці потрібен поверх —
   інакше «Назва» стискається до нечитабельного мінімуму. */
.calc-mid .panel:first-child { flex: 1 1 480px; min-width: 0; }
.calc-mid .panel:first-child .tbl { min-width: 460px; }
.panel-margin { flex: 1 1 260px; max-width: 320px; padding: 16px 20px 20px; }
.panel-margin .h2 { margin-bottom: 14px; }
.margin-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.margin-field { position: relative; display: block; width: 96px; }
.margin-field .inp {
  padding: 9px 26px 9px 10px; border-color: var(--edge); background: var(--field);
  font-size: 16px; font-weight: 600;
}
.margin-field .suffix {
  position: absolute; top: 50%; right: 10px; transform: translateY(-50%);
  font-family: var(--num); font-size: 13px; color: var(--muted); pointer-events: none;
}
#margin-sum { font-family: var(--num); font-size: 15px; color: var(--accent); font-variant-numeric: tabular-nums; }
.margin-quick { display: flex; gap: 6px; }
.margin-quick button {
  flex: 1; padding: 8px 0; border: 1px solid var(--line); border-radius: 9px; background: var(--panel);
  color: var(--fg-2); font-family: var(--num); font-size: 13px; cursor: pointer;
}
.margin-quick button:hover { border-color: var(--edge-2); color: var(--fg); }
.margin-quick button[aria-pressed="true"] {
  border-color: var(--accent); background: var(--accent-soft); color: var(--accent-2); font-weight: 600;
}

/* Підсумок */
.panel-total .panel-head { position: relative; }
.panel-total .panel-head::after {
  content: ''; position: absolute; bottom: -1px; left: 0; width: 100%; height: 1px;
  background: var(--accent); opacity: .5;
}
.receipt { display: flex; flex-direction: column; gap: 12px; max-width: 520px; padding: 18px 20px 20px; font-size: 14px; }
.receipt-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.receipt-row .lbl { color: var(--fg-2); }
.receipt-row .val { font-family: var(--num); font-variant-numeric: tabular-nums; }
.receipt-row.is-sub { padding-top: 12px; border-top: 1px solid var(--line-faint); }
.receipt-row.is-sub .val { font-weight: 600; }
.receipt-row.is-margin .val { color: var(--accent); }

.total-bar {
  display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 20px;
  padding: 18px 20px 20px; border-top: 1px solid var(--line-soft); background: var(--panel-2);
}
.total-box { display: flex; flex-direction: column; gap: 6px; }
.total-lbl { font-family: var(--num); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted-2); }
.total-val { font-family: var(--num); font-size: 40px; line-height: 1; font-weight: 600; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.total-note { font-size: 13px; color: var(--fg-3); }
.total-acts { display: flex; align-items: center; gap: 10px; }
.total-acts .btn { height: 40px; }

/* ═════════════════ Харчова цінність ═════════════════ */

/* Вимкнено в налаштуваннях — ховаємо все одним правилом, дані лишаються */
html:not(.nut-on) .nut-only { display: none !important; }

.w-nut { width: 80px; }
.nut-btn {
  height: 28px; padding: 0 9px; border: 1px dashed var(--dash); border-radius: 7px; background: transparent;
  font-family: var(--num); font-size: 11.5px; letter-spacing: .04em; color: var(--muted); cursor: pointer;
}
.nut-btn:hover { border-color: var(--edge-2); color: var(--fg); }
.nut-btn.is-part { border-style: solid; border-color: var(--edge); color: var(--fg-2); }
.nut-btn.is-full { border-style: solid; border-color: var(--accent); background: var(--accent-soft); color: var(--accent-2); }
.nut-btn[aria-expanded="true"] { box-shadow: 0 0 0 3px var(--focus); }

.tbl tbody tr.is-open > td { border-bottom-color: transparent; }
.tbl tbody tr.nut-row, .tbl tbody tr.nut-row:hover { background: var(--panel-2); }
.tbl tbody tr.nut-row > td { padding: 6px 20px 16px; }

.nut-edit { display: flex; flex-direction: column; gap: 12px; }
.nut-fields { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.nut-cap {
  flex: 0 0 auto; min-width: 76px; font-family: var(--num); font-size: 10.5px;
  letter-spacing: .1em; text-transform: uppercase; color: var(--muted-2);
}
.nut-f { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--fg-3); }
.nut-f .inp { width: 72px; height: 32px; padding: 0 8px; border-color: var(--edge); background: var(--field); }
.nut-f .qty-wrap .inp { width: 86px; padding-right: 24px; }
.nut-f .unit-tag { right: 9px; }
.nut-al { display: flex; align-items: flex-start; gap: 16px; }
.nut-al .nut-cap { padding-top: 7px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 28px; padding: 0 11px; border: 1px solid var(--line-2); border-radius: 999px;
  background: var(--panel); font-size: 12.5px; color: var(--fg-2); cursor: pointer;
}
.chip:hover { border-color: var(--edge-2); color: var(--fg); }
/* Позначений алерген — нейтральний темний, а не зелений: зелене читалося б як «добре» */
.chip[aria-pressed="true"] { border-color: var(--fg); background: var(--fg); color: var(--panel); }
.chip.is-none[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-2); }
.chip.is-static { display: inline-flex; align-items: center; border-color: var(--edge-2); color: var(--fg); cursor: default; }
.al-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
/* Поле свого алергену — пунктирною «пігулкою» в тон чипам: видно, що це додавання, а не ще один чип */
.inp.al-add {
  width: 220px; max-width: 100%; height: 30px; padding: 0 12px;
  border: 1px dashed var(--dash); border-radius: 999px; background: transparent; font-size: 13px;
}
.inp.al-add:focus { border-style: solid; }
.nut-hints { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.nut-hint { font-size: 12.5px; color: var(--muted); }
.nut-hint.is-warn { color: var(--danger); }

.panel-nut { margin-bottom: 20px; }
.panel-nut .panel-head { align-items: center; min-height: 54px; padding-top: 8px; padding-bottom: 8px; }
.nut-out-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.nut-out { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--fg-3); }
/* Сума інгредієнтів, підставлена сама, — сірим: видно, що число не вписане руками */
.nut-out .inp.is-auto { color: var(--muted); }
.nut-out-reset { font-size: 12.5px; }
.nut-out .qty-wrap { width: 116px; border: 1px solid var(--edge); border-radius: var(--r-s); background: var(--field); }
.nut-out .inp { height: 34px; padding: 0 28px 0 10px; }
.nut-out .inp:focus { border-color: transparent; box-shadow: none; }
.nut-body {
  display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); gap: 18px 40px;
  align-items: start; padding: 14px 20px 18px;
}
.nut-tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.nut-tbl th {
  padding: 0 0 8px; font-family: var(--num); font-size: 10.5px; font-weight: 400; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted-2); text-align: left; white-space: nowrap;
}
.nut-tbl th.r, .nut-tbl td.r { text-align: right; }
.nut-tbl td { padding: 8px 0; border-top: 1px solid var(--line-faint); color: var(--fg-2); }
.nut-tbl td.r { padding-left: 18px; font-family: var(--num); font-variant-numeric: tabular-nums; color: var(--fg); white-space: nowrap; }
.nut-tbl tr.is-kcal td { font-weight: 600; color: var(--fg); }
.nut-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; font-size: 13.5px; line-height: 1.55; }
.nut-al-view { display: flex; align-items: flex-start; gap: 12px; }
.nut-al-view .nut-cap { min-width: 0; padding-top: 7px; }
.nut-none { padding-top: 3px; color: var(--fg-2); }
.nut-warn { color: var(--danger); }
.nut-miss { color: var(--fg-3); }
.nut-fix {
  padding: 0 1px; font-size: inherit; color: inherit; white-space: normal; text-align: left;
  text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px;
}
.nut-orphan { color: var(--fg-3); }
.nut-note { font-size: 12.5px; color: var(--muted); }
.nut-empty { padding: 18px 20px 20px; font-size: 14px; color: var(--fg-3); }
/* Подвійний клас навмисно: .modal нижче у файлі й інакше перебиває ширину — 14 чипів у 420px стають стовпчиком */
.modal.modal-nut { max-width: 620px; }
.modal-nut .nut-edit { margin-top: 18px; }

/* ═════════════════ Налаштування ═════════════════ */

.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 18px 22px; border-bottom: 1px solid var(--line-faint);
}
.set-row:last-child { border-bottom: 0; }
.set-row-txt { max-width: 420px; }
.set-row-txt .h2 { font-size: 15px; }
.set-row-desc { display: block; margin-top: 4px; font-size: 13.5px; line-height: 1.5; color: var(--fg-3); }
#btn-reset, #btn-wipe { height: 38px; }

/* ═════════════════ Інструкція ═════════════════ */

#s-help { max-width: 760px; }
.help { display: flex; flex-direction: column; gap: 14px; }
.help-sec { padding: 20px 22px 18px; }
.help-step, .help-group {
  display: block; font-family: var(--num); font-size: 11px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted-2);
}
.help-step { margin-bottom: 8px; }
.help-group { margin: 18px 0 0; }
.help-sec .h2 { margin-bottom: 10px; font-size: 17px; }
.help-sec p, .help-sec li { font-size: 14.5px; line-height: 1.6; color: var(--fg-2); }
.help-sec p { margin: 0 0 8px; }
.help-sec ul { margin: 0 0 8px; padding-left: 20px; }
.help-sec li + li { margin-top: 4px; }
.help-sec b { font-weight: 600; color: var(--fg); }
.help-sec > :last-child { margin-bottom: 0; }
/* Відʼємний відступ — текст посилання на одній лінії з абзацами над ним */
.help-go { margin: 4px 0 0 -4px; font-size: 14px; font-weight: 500; color: var(--accent); }
#btn-reset:hover, #btn-wipe:hover { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }

/* ═════════════════ Оверлеї ═════════════════ */

/* Вище за шапку телефона (60), інакше логотип із бургером світиться поверх модалки */
.overlay {
  position: fixed; inset: 0; z-index: 70; display: none; place-items: center; padding: 24px;
  background: var(--overlay);
}
.overlay.is-on { display: grid; animation: fc-fade .14s ease; }
.modal {
  width: 100%; max-width: 420px; padding: 24px 24px 20px; border-radius: var(--r-xl);
  background: var(--panel); box-shadow: 0 30px 60px -24px var(--modal-shadow);
  animation: fc-pop .18s cubic-bezier(.2,.7,.3,1) both;
}
.modal-title { margin-bottom: 6px; font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.modal-sub { font-size: 14px; line-height: 1.5; color: var(--fg-3); }
.modal > .inp {
  margin-top: 16px; padding: 0 12px; height: 40px; border-color: var(--edge); background: var(--field);
}
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-foot .btn { height: 40px; }

/* Запрошення: головна дія зверху на всю ширину, відмова — тихо під нею.
   Анімація помітніша, ніж у робочих модалок: вікно зʼявляється само, а не
   у відповідь на дію, тож затримка дає сторінці спершу намалюватись, і
   поява читається як запрошення, а не як збій. */
#invite-overlay.is-on { animation: fc-fade .35s ease .25s both; }
.modal.modal-invite { max-width: 440px; animation: fc-rise .5s cubic-bezier(.2,.8,.25,1) .3s both; }
.modal-invite .invite-list li, .modal-invite .invite-acts { animation: fc-item .4s ease both; }
.modal-invite .invite-list li:nth-child(1) { animation-delay: .5s; }
.modal-invite .invite-list li:nth-child(2) { animation-delay: .58s; }
.modal-invite .invite-list li:nth-child(3) { animation-delay: .66s; }
.modal-invite .invite-acts { animation-delay: .76s; }
.invite-list { display: flex; flex-direction: column; gap: 10px; margin: 16px 0 0; padding: 0; list-style: none; }
.invite-list li { position: relative; padding-left: 26px; font-size: 14.5px; line-height: 1.5; color: var(--fg-2); }
.invite-list li::before {
  content: ''; position: absolute; left: 7px; top: .28em; width: 5px; height: 10px;
  border: solid var(--accent); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.invite-list b { font-weight: 600; color: var(--fg); }
.invite-acts { display: flex; flex-direction: column; gap: 6px; margin-top: 22px; }
.invite-acts .btn {
  width: 100%; height: 44px; text-decoration: none;
  transition: filter .18s ease, box-shadow .18s ease, transform .18s ease, background-color .18s ease, color .18s ease;
}
/* Яскравіше через filter, а не темніший --accent-2: так кнопка світлішає в обох темах */
.invite-acts .btn-primary:hover, .invite-acts .btn-primary:focus-visible {
  background: var(--accent); filter: brightness(1.15) saturate(1.1);
  box-shadow: 0 10px 24px -10px var(--accent); transform: translateY(-1px);
}
.invite-acts .btn-primary:active { filter: brightness(1.05); box-shadow: none; transform: none; }
.invite-acts .btn-ghost:hover, .invite-acts .btn-ghost:focus-visible { background: var(--danger-soft); color: var(--danger); }

.folder-list { display: flex; flex-direction: column; gap: 8px; margin: 18px 0 0; }
.folder-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--r-m);
  background: var(--panel); color: var(--fg); font-size: 14.5px; text-align: left; cursor: pointer;
}
.folder-opt:hover { border-color: var(--edge-2); }
.folder-opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.folder-opt .tick { width: 14px; height: 14px; fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.folder-opt[aria-pressed="true"] .tick { opacity: 1; }
/* Назва забирає вільне місце — лічильник притискається до галочки, а не висить посередині */
.folder-opt > span:first-child { flex: 1; min-width: 0; }
.folder-opt.is-new { border-style: dashed; color: var(--fg-2); justify-content: flex-start; }
.folder-opt.is-new:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-2); }

.toast {
  position: fixed; bottom: 28px; left: 50%; z-index: 80; transform: translateX(-50%);
  display: none; padding: 12px 18px; border-radius: 11px; background: var(--ink); color: var(--ink-fg);
  font-size: 14px; box-shadow: 0 18px 34px -18px var(--modal-shadow);
}
.toast.is-on { display: block; animation: fc-toast .18s ease; }

/* ═════════════════ Прев'ю експорту ═════════════════ */

.pdf-modal {
  display: flex; flex-direction: column; width: 100%; max-width: 840px; max-height: 88vh;
  border-radius: var(--r-xl); background: var(--panel); overflow: hidden;
  box-shadow: 0 30px 60px -24px var(--modal-shadow);
  animation: fc-pop .18s cubic-bezier(.2,.7,.3,1) both;
}
.pdf-modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 22px; border-bottom: 1px solid var(--line-soft);
}
.pdf-modal-head .modal-title { font-size: 16px; font-weight: 600; margin: 0; }
.pdf-modal-head .modal-sub { margin-top: 3px; font-family: var(--num); font-size: 11.5px; color: var(--muted); }
.pdf-modal-head .btn { height: 38px; }
.btn-row { display: flex; align-items: center; gap: 10px; }
.pdf-modal-body { flex: 1; min-height: 0; overflow-y: auto; padding: 26px; background: var(--desk); }
/* 772 = 700px документа + бічні поля аркуша, box-sizing: border-box */
.pdf-stage { width: 772px; margin: 0 auto; background: #fff; box-shadow: 0 8px 20px -12px rgba(0,0,0,.45); padding: 34px 36px 40px; }
/* під час експорту знімаємо обмеження, щоб html2canvas побачив документ цілком */
.pdf-modal.is-exporting { max-height: none; }
.pdf-modal.is-exporting .pdf-modal-body { overflow: visible; max-height: none; }

/* ═════════════════ Документ PDF ═════════════════
   Друкований аркуш — завжди світлий, незалежно від теми,
   тому кольори тут літеральні. Розміри в em від .pdf-doc:
   так документ стискається під одну сторінку зміною одного числа. */

.pdf-doc { width: 700px; background: #fff; color: #1b1a17; font-family: var(--ui); font-size: 12px; padding: 2px 6px; }
.pdf-head { padding-bottom: .66em; border-bottom: 2px solid #1b1a17; }
.pdf-brand { font-size: 1.17em; font-weight: 700; letter-spacing: -.01em; }
.pdf-title { font-size: 1.92em; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; margin: 1.66em 0 1.5em; }

/* Рамка блока навмисно важча за внутрішні лінії рядків —
   інакше блоки зливаються з таблицею в суцільну сітку. */
.pdf-block { border: 1.5px solid #9d968a; margin-bottom: 1.16em; }
.pdf-sec {
  margin: 0; padding: .66em 1em; background: #f4f1ec;
  border-bottom: 1.5px solid #9d968a; font-size: 1.04em; font-weight: 700;
}

.pdf-tbl { width: 100%; border-collapse: collapse; }
.pdf-tbl th {
  font-family: var(--num); font-size: .75em; text-transform: uppercase; letter-spacing: .08em;
  color: #6d685f; text-align: left; padding: .5em .8em; border-bottom: 1px solid #e4dfd6;
  font-weight: 500; white-space: nowrap;
}
.pdf-tbl th.r { text-align: right; }
.pdf-tbl td { font-size: .96em; padding: .5em .8em; border-bottom: 1px solid #f2efe9; }
.pdf-tbl td.r { text-align: right; font-family: var(--num); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pdf-tbl td.b { font-weight: 600; }

/* Напівфабрикат у друкованій калькуляції: шапка групи й відступ у складників.
   Кольори тут задані вручну — документ завжди друкується світлим. */
.pdf-grp td { background: #f2efe9; font-weight: 700; border-bottom: 1px solid #e4dfd6; }
.pdf-grp td.r { font-weight: 700; }
.pdf-sub td:first-child { padding-left: 2em; position: relative; }
.pdf-sub td:first-child::before {
  content: ''; position: absolute; left: 1.1em; top: 0; bottom: 0; width: 1px; background: #d9d4ca;
}

.pdf-subtotal { display: flex; justify-content: space-between; gap: 1em; padding: .66em 1em; font-size: 1em; font-weight: 700; }
.pdf-subtotal b { font-family: var(--num); font-weight: 700; }
.pdf-line { display: flex; justify-content: space-between; gap: 1em; padding: .5em 1em; font-size: .96em; }
.pdf-line .v { font-family: var(--num); font-variant-numeric: tabular-nums; }
.pdf-rule { height: 3px; margin: .5em 1em; border-top: 1px solid #1b1a17; border-bottom: 1px solid #1b1a17; }
.pdf-price { display: flex; justify-content: space-between; align-items: baseline; gap: 1em; padding: .33em 1em .83em; }
.pdf-price .l { font-size: 1.04em; font-weight: 700; letter-spacing: .02em; }
.pdf-price .v { font-family: var(--num); font-size: 2.16em; font-weight: 600; font-variant-numeric: tabular-nums; }
.pdf-note { padding: 0 1em .83em; font-size: .92em; color: #55524b; }
.pdf-line .t { font-weight: 600; text-align: right; }

/* ═════════════════ Адаптив ═════════════════ */

@media (max-width: 1080px) {
  .screen { padding: 48px 32px 64px; }
}

/* ── Планшет і телефон: навігація їде в шухляду ──────────────────
   Панель зліва з'їдала перший екран телефона, тому нижче 900px
   лишається лише смужка з логотипом і бургером, а сама панель
   виїжджає поверх контенту. Розмітка та сама — інакше довелось би
   тримати два меню й синхронізувати їх. */

@media (max-width: 900px) {
  html { -webkit-text-size-adjust: 100%; }
  body { flex-direction: column; padding-top: 56px; }

  .topbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 60;
    display: flex; align-items: center; justify-content: space-between;
    /* Логотип і видима іконка бургера — рівно по краях контенту (20px).
       Праворуч менше, бо сама іконка сидить у 44-піксельній кнопці з полями. */
    height: 56px; padding: 0 6px 0 20px;
    background: var(--side); border-bottom: 1px solid var(--line-2);
  }
  .topbar .brand-name { font-size: 20px; }
  .burger[aria-expanded="true"] .i-open { display: none; }
  .burger[aria-expanded="true"] .i-close { display: block; }

  .sidebar {
    position: fixed; top: 56px; right: 0; bottom: 0; z-index: 50;
    /* align-self лишається від флекс-розкладки й підрізає шухляду по вмісту */
    width: min(320px, 84vw); flex: none; height: auto; align-self: stretch;
    border-right: 0; border-left: 1px solid var(--line-2);
    padding: 16px 14px 28px;
    transform: translateX(100%); transition: transform .22s ease;
  }
  .sidebar.is-open { transform: none; box-shadow: -26px 0 50px -28px var(--modal-shadow); }
  /* Логотип уже є в шапці — другий у шухляді лише забирав би висоту */
  .sidebar .brand { display: none; }
  .nav-scrim { display: block; position: fixed; top: 56px; left: 0; right: 0; bottom: 0; z-index: 45; background: var(--overlay); }
  html.nav-open, html.nav-open body { overflow: hidden; }

  /* Пошук лишається під рукою на будь-якій глибині списку */
  .tools-bar, .folder-tools {
    position: sticky; top: 56px; z-index: 12;
    margin: 0 -20px 14px; padding: 10px 20px;
    background: var(--bg); border-bottom: 1px solid var(--line-soft);
  }

  .screen { padding: 24px 20px 56px; }
  #s-home.is-active { padding-top: 40px; }
  .home .h1 { font-size: 36px; }
  .home-cards { grid-template-columns: 1fr; }
  .h1 { font-size: 30px; }
  .screen-head.with-action { flex-direction: column; align-items: stretch; }
  .head-actions { flex-wrap: wrap; }
  .search-wrap { width: 100%; }
  .calc-titlebar { flex-direction: column; }
  .title-inp { font-size: 27px; }
  .panel-scroll .tbl { min-width: 660px; }
  .panel-margin { max-width: none; }
  /* Опис виходу довший за підпис у налаштуваннях — у вузьку колонку не влазить */
  .yield-row { flex-direction: column; align-items: stretch; gap: 14px; }
  .yield-ctl { justify-content: space-between; }
  /* Поруч із кнопкою тексту лишається смужка на три рядки — краще в стовпчик */
  .stale-bar { flex-direction: column; align-items: stretch; gap: 12px; }
  .stale-bar .btn { width: 100%; }
  .nut-body { grid-template-columns: 1fr; }
  .panel-nut .panel-head { flex-wrap: wrap; }
  .nut-al { flex-direction: column; gap: 8px; }
  .nut-al .nut-cap { padding-top: 0; }
  .panel-foot { flex-wrap: wrap; }
  .total-bar { flex-direction: column; align-items: stretch; }
  .total-acts { flex-wrap: wrap; }
  .total-acts .btn { flex: 1; }
  /* Аркуш лишається А4-ширини навмисно: html2pdf знімає той самий вузол,
     що й на екрані, тож «підігнати» його під телефон означало б віддати
     користувачу PDF, зверстаний під 320px. Прев'ю натомість зменшує
     аркуш цілком — масштаб рахує fitPdfPreview() і знімає перед експортом. */
  .pdf-modal-body { padding: 18px; }
  .pdf-stage { margin: 0; padding: 24px 26px 30px; transform-origin: top left; }
}

/* ── Телефон: таблиця стає списком карток ───────────────────────
   Рядок на шість колонок у 390px не живе: або текст завбільшки з
   крихту, або скрол убік. Тому нижче 760px кожен рядок — картка:
   зверху назва й видалення, під ними поля з дрібними підписами.
   Підписи беруться з data-lbl, який проставляє app.js — на компʼютері
   їх не видно, там за це відповідає шапка таблиці. */

@media (max-width: 760px) {
  .screen { padding: 20px 16px 48px; }
  .topbar { padding: 0 2px 0 16px; }   /* та сама лінія, що й у контенту — 16px */
  #s-home.is-active { padding-top: 28px; }
  .tools-bar, .folder-tools { margin: 0 -16px 14px; padding: 10px 16px; }

  .h1 { font-size: 26px; }
  .home .h1 { font-size: 31px; }
  .home .lede { margin-bottom: 30px; }
  /* Менші за 16px поля iOS зустрічає зумом сторінки на кожному тапі */
  .inp, .inp.is-num, .unit-sel, .search-wrap .inp { font-size: 16px; }

  /* ── Таблиці ──
     Рядок стає карткою на сітці. Підпис стоїть НАД полем, а не збоку:
     збоку він забирав половину колонки, і в полі лишалось місце на «10(»
     замість «1000». Висота всіх полів однакова — лінії сітки не пливуть. */
  /* Блоки на фоні — з тінню. Панель і фон на телефоні майже одного тону,
     і одна тонка рамка вже не відділяла «Інгредієнти» від сторінки.
     Кольори тіні з токенів теми — у темній вона сама стає глибшою. */
  .panel, .home-card, .rcard {
    box-shadow: 0 1px 2px var(--nav-shadow), 0 8px 22px -14px var(--card-shadow);
  }
  .panel-scroll { overflow-x: visible; }
  .panel-scroll .tbl, .calc-mid .panel:first-child .tbl, .tbl { min-width: 0; display: block; }
  .tbl thead { display: none; }
  .tbl tbody { display: block; }
  .tbl tbody tr {
    position: relative; display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px 12px; padding: 12px 14px;
    border-bottom: 1px solid var(--line);
  }
  .tbl tbody td, .tbl tbody td:first-child, .tbl tbody td:last-child {
    display: block; padding: 0; border: 0; min-width: 0;
  }
  /* Назва — на всю ширину. Хрестик переїхав у нижній правий кут, на лінію
     вартості: у шапці він обрізав назву («Борошно вищий ґатуно»). */
  .tbl tbody td:first-child { grid-column: 1 / -1; padding-right: 0; }
  .tbl tbody td.t-act { position: absolute; top: auto; bottom: 14px; right: 8px; width: auto; }
  .tbl tbody td[data-lbl] { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; row-gap: 5px; }
  .tbl tbody td[data-lbl]::before {
    content: attr(data-lbl); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-family: var(--num); font-size: 10px; letter-spacing: .08em;
    text-transform: uppercase; color: var(--muted-2);
  }
  /* Вартість — не поле, але стоїть на тій самій лінії, що й поле поруч */
  .tbl tbody td.t-cost { grid-template-rows: auto 40px; align-items: center; text-align: left; font-size: 15px; }
  .tbl tbody td.t-mid { text-align: left; }

  /* Наведення на дотику немає — поле має саме показувати, що воно поле */
  .tbl tbody .inp { height: 40px; padding: 0 10px; border-color: var(--line-2); background: var(--field); }
  .tbl tbody .inp.is-num { width: 100%; min-width: 0; padding: 0 10px; }
  .tbl tbody .cell-pair { gap: 6px; justify-content: stretch; }
  .tbl tbody .cell-pair .inp.is-num { flex: 1 1 auto; width: auto; }
  .tbl tbody .qty-wrap .inp { padding-right: 24px; }
  .tbl tbody .unit-tag { right: 9px; font-size: 12px; }
  .tbl tbody td[data-lbl] > .unit-sel { width: 100%; }
  /* Свій шеврон: без нього рамка на дотику читається як заблоковане поле.
     Колір лінії однаковий у світлій і темній темі, тому задано літерально. */
  .tbl tbody .unit-sel {
    flex: 0 0 auto; height: 40px;
    border: 1px solid var(--line-2); padding: 0 22px 0 10px; color: var(--fg);
    background-color: var(--panel-2);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238c877e' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 5px center; background-size: 11px;
  }

  /* ── Згорнута картка бази ──
     Список пробігають очима по назвах; поля відкриваються тапом. */
  /* Назва окремим рядком, підсумок під нею: в один рядок довга назва
     обрізається саме там, де продукти й відрізняються один від одного */
  /* white-space: normal — у всіх кнопок nowrap, і довга назва не переносилась,
     а залазила під поле кількості («Борошно вищий ґатун» на 320px) */
  .row-peek {
    display: grid; grid-template-columns: minmax(0, 1fr) 16px; align-items: center;
    gap: 3px 10px; width: 100%; padding: 3px 0; white-space: normal;
    border: 0; background: transparent; text-align: left; cursor: pointer;
  }
  .peek-name {
    grid-column: 1; min-width: 0; overflow-wrap: anywhere;
    font-size: 15.5px; font-weight: 500; color: var(--fg);
  }
  .peek-name.is-empty { color: var(--dim); font-weight: 400; }
  .peek-sum { grid-column: 1; font-family: var(--num); font-size: 12.5px; color: var(--muted); }
  .peek-caret { grid-column: 2; grid-row: 1; display: grid; place-items: center; width: 16px; height: 16px; }
  .peek-caret svg { width: 15px; height: 15px; fill: none; stroke: var(--dim); stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
  .row-fold {
    flex: 0 0 40px; place-items: center; height: 40px;
    border: 0; border-radius: var(--r-s); background: transparent; color: var(--muted); cursor: pointer;
  }
  .row-fold svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; transform: rotate(180deg); }

  #base-body tr:not(.is-edit) > td:not(:first-child),
  #expbase-body tr:not(.is-edit) > td:not(:first-child) { display: none; }
  #base-body tr:not(.is-edit) [data-f="name"],
  #expbase-body tr:not(.is-edit) [data-f="name"] { display: none; }
  #base-body tr:not(.is-edit) > td:first-child,
  #expbase-body tr:not(.is-edit) > td:first-child { padding-right: 0; }

  /* Відкрита картка бази. Хрестик із шапки прибрано: поруч зі шевроном
     «згорнути» він читався як другий хрестик. Видалення — текстом унизу. */
  #base-body tr.is-edit { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 76px; }
  #expbase-body tr.is-edit { grid-template-columns: 76px minmax(0, 1fr); }
  #base-body tr.is-edit > td.nut-only { grid-column: 1; justify-self: start; align-self: center; }
  #base-body tr.is-edit > td.t-act { position: static; grid-column: 2 / -1; justify-self: end; }
  #expbase-body tr.is-edit > td.t-act { position: static; grid-column: 1 / -1; justify-self: end; }
  #base-body .t-act .icon-btn, #expbase-body .t-act .icon-btn {
    display: inline-flex; align-items: center; gap: 6px; width: auto; height: 36px; padding: 0 10px;
    color: var(--danger); font-size: 14px;
  }
  #base-body .t-act .icon-btn svg, #expbase-body .t-act .icon-btn svg { width: 12px; height: 12px; }
  #base-body .t-act .icon-btn::after, #expbase-body .t-act .icon-btn::after { content: 'Видалити'; }
  #base-body tr.is-edit > td:first-child,
  #expbase-body tr.is-edit > td:first-child { display: flex; align-items: center; gap: 6px; padding-right: 0; }
  /* Шеврон лишається праворуч, як і в згорнутому стані — інакше він стрибає */
  #base-body tr.is-edit [data-f="name"],
  #expbase-body tr.is-edit [data-f="name"] { order: 1; }
  #base-body tr.is-edit .row-fold,
  #expbase-body tr.is-edit .row-fold { order: 2; }
  #base-body tr.is-edit .row-peek,
  #expbase-body tr.is-edit .row-peek { display: none; }
  #base-body tr.is-edit .row-fold,
  #expbase-body tr.is-edit .row-fold { display: grid; }
  /* Розгорнута картка трохи світліша — видно, що працюєш саме з нею */
  #base-body tr.is-edit, #expbase-body tr.is-edit { background: var(--panel-2); }

  /* Напівфабрикати відкриваються власним екраном — тут потрібен лише підсумок */
  #prep-body td[data-lbl] { display: none; }
  #prep-body .m-sum {
    display: block; margin-top: 2px;
    font-family: var(--num); font-size: 12.5px; line-height: 1.6; color: var(--muted);
  }
  .prep-name-btn { padding: 3px 0; }
  /* Тут під назвою йде підсумок на всю ширину — хрестик лишається збоку по центру */
  #prep-body td:first-child { padding-right: 42px; }
  #prep-body td.t-act { top: 50%; bottom: auto; transform: translateY(-50%); }

  /* ── Інгредієнт калькуляції: згорнутий рядок ──
     Згорнутий рядок лише читають: зверху назва й вартість, під ними звідки
     ціна і скільки взято («45,00 ₴ за 1000 г / 400 г»). Полів тут немає,
     тож тап будь-де по рядку відкриває його (rowTapTarget в app.js). */
  #ing-body tr:not(.ing-group):not(.is-edit),
  #prep-ing-body tr:not(.is-edit), #exp-body tr:not(.is-edit) { grid-template-columns: minmax(0, 1fr); cursor: pointer; }
  #ing-body tr:not(.ing-group):not(.is-edit) [data-f="name"],
  #prep-ing-body tr:not(.is-edit) [data-f="name"], #exp-body tr:not(.is-edit) [data-f="name"],
  #ing-body tr:not(.ing-group):not(.is-edit) > td:not(:first-child):not(.t-cost),
  #prep-ing-body tr:not(.is-edit) > td:not(:first-child):not(.t-cost), #exp-body tr:not(.is-edit) > td:not(:first-child):not(.t-cost) { display: none; }
  /* Вартість — просто числом праворуч на рівні назви, без рамки: рамка
     робила її схожою на поле, а редагувати тут нічого. Назва лишає місце. */
  #ing-body tr:not(.ing-group):not(.is-edit) .peek-name,
  #prep-ing-body tr:not(.is-edit) .peek-name, #exp-body tr:not(.is-edit) .peek-name { padding-right: 84px; }
  #ing-body tr:not(.ing-group):not(.is-edit) > td.t-cost,
  #prep-ing-body tr:not(.is-edit) > td.t-cost, #exp-body tr:not(.is-edit) > td.t-cost {
    position: absolute; top: 15px; right: 14px; display: block;
    text-align: right; font-size: 15px;
  }
  #ing-body tr:not(.ing-group):not(.is-edit) > td.t-cost::before,
  #prep-ing-body tr:not(.is-edit) > td.t-cost::before, #exp-body tr:not(.is-edit) > td.t-cost::before { display: none; }
  /* Два поверхи: назва з вартістю, під ними — з повітрям — опис (ціна,
     упаковка, скільки взято), а шеврон у правому куті на лінії опису,
     рівно під вартістю. Опис на найвужчих екранах обрізається трикрапкою,
     а не зсуває шеврон униз. */
  #ing-body .row-peek, #prep-ing-body .row-peek, #exp-body .row-peek { display: flex; flex-wrap: wrap; align-items: center; column-gap: 8px; }
  #ing-body .peek-name, #prep-ing-body .peek-name, #exp-body .peek-name { order: 1; flex: 1 1 100%; min-width: 0; }
  #ing-body .peek-sum, #prep-ing-body .peek-sum, #exp-body .peek-sum {
    order: 2; margin-top: 8px; max-width: calc(100% - 24px);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  /* margin-right від'ємний: сама стрілка всередині іконки має поля, без
     зсуву її видимий край стояв на 3,6px лівіше за край вартості над нею */
  #ing-body .peek-caret, #prep-ing-body .peek-caret, #exp-body .peek-caret { order: 3; margin-top: 8px; margin-left: auto; margin-right: -3.6px; }
  /* Фіксована витрата без опису — один рядок «Коробка 15,00»; шеврону
     без рядка опису нема де стояти, а тап по рядку й так відкриває його */
  #exp-body .peek-sum:empty, #exp-body .peek-sum:empty + .peek-caret { display: none; }
  /* Відкритий інгредієнт — та сама картка, що й раніше, плюс «згорнути» біля назви */
  #ing-body tr.is-edit .row-peek, #prep-ing-body tr.is-edit .row-peek, #exp-body tr.is-edit .row-peek { display: none; }
  #ing-body tr.is-edit > td:first-child,
  #prep-ing-body tr.is-edit > td:first-child, #exp-body tr.is-edit > td:first-child { display: flex; align-items: center; gap: 6px; }
  #ing-body tr.is-edit [data-f="name"], #prep-ing-body tr.is-edit [data-f="name"], #exp-body tr.is-edit [data-f="name"] { order: 1; }
  #ing-body tr.is-edit .row-fold, #prep-ing-body tr.is-edit .row-fold, #exp-body tr.is-edit .row-fold { order: 2; display: grid; }
  #ing-body tr.is-edit, #prep-ing-body tr.is-edit, #exp-body tr.is-edit { background: var(--panel-2); }

  /* Службові рядки — на всю ширину картки */
  .tbl tbody td.tbl-empty { grid-column: 1 / -1; padding: 30px 4px; }
  .tbl tbody tr.nut-row { padding-top: 0; }
  .tbl tbody tr.nut-row > td { grid-column: 1 / -1; padding: 0 0 12px; }

  /* Група напівфабрикату: рейку складників замінює рамка зліва на картці */
  .tbl tbody tr.ing-group { background: var(--side); border-bottom-color: var(--edge); }
  .tbl tbody tr.ing-group > td { background: transparent; }
  .tbl tbody tr.ing-group > td:first-child { padding: 0; }
  .grp-head { flex-wrap: wrap; gap: 6px 8px; }
  .grp-name { white-space: normal; }
  .tbl tbody tr.ing-child { padding-left: 24px; border-left: 2px solid var(--edge); }
  .tbl tbody tr.ing-child > td:first-child { position: static; padding: 0; }
  .tbl tbody tr.ing-child > td:first-child::before { display: none; }

  /* ── Шапка калькуляції й напівфабрикату ──
     Було: 40px зверху (компʼютерний відступ перебивав мобільний), назва
     окремо, «Додати фото» ще одним рядком і 34px до панелі — пів екрана
     повітря до першого інгредієнта. Тепер назва й фото в одному рядку. */
  #s-calc.is-active, #s-prep-edit.is-active { padding-top: 12px; }
  .calc-top { margin-bottom: 2px; }
  .calc-titlebar { flex-direction: row; align-items: center; gap: 10px; margin-bottom: 14px; }
  /* .inp.title-inp, а не .title-inp: правило «поля 16px» вище в цьому ж
     блоці має ту саму вагу й робило назву страви дрібнішою за підписи */
  .inp.title-inp { font-size: 24px; padding: 4px 10px; }
  .photo-btn { width: 42px; height: 42px; margin-top: 0; padding: 0; justify-content: center; gap: 0; font-size: 0; }
  .photo-btn svg { width: 20px; height: 20px; }
  .photo-box { margin-top: 0; gap: 8px; }
  .photo-box img { width: 48px; height: 42px; }

  /* ── Підсумок ──
     Головна кнопка першою. flex: 1 з блоку вище в стовпчику ставав
     висотою 0 — кнопки сплющувало до смужки, тож висота тут явна. */
  .total-acts { flex-direction: column-reverse; align-items: stretch; }
  .total-acts .btn { flex: 0 0 auto; width: 100%; height: 44px; }
  /* Шапка панелі в один рядок: підпис «Собівартість» зайвий — число поруч
     з «Інгредієнтами» і так читається як їхня сума */
  /* Шапка панелі — заголовок розділу, а не ще один рядок списку: тонована
     смуга й більший жирний шрифт. «Інгредієнти» 16px/600 поруч із назвами
     продуктів 15.5px/500 читались як черговий інгредієнт. */
  .panel-head { padding: 14px 14px 12px; background: var(--seg-bg); border-bottom-color: var(--line); }
  .panel-head .h2, .panel-margin > .h2, .panel-yield .h2 { font-size: 18px; font-weight: 700; letter-spacing: -.015em; }
  .panel-sum { font-size: 0; gap: 0; }
  .panel-sum b { font-size: 16px; }
  .nut-out-wrap { align-items: flex-start; }
  .panel-foot { padding: 12px 14px; }

  /* ── Папка ── */
  .folder-tools { flex-direction: column; align-items: stretch; }
  /* Лічильник окремим рядком: інакше «Видалити» зривається вниз із роздільником */
  /* Шапка папки: дії — іконками в рядку з назвою, під нею лише лічильник.
     Текстом «Перейменувати | Видалити» того ж кольору, що й лічильник, вони
     читались як три однакові пункти й займали два рядки. */
  #s-folder .screen-head > div:first-child {
    display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; column-gap: 2px;
  }
  #s-folder .folder-meta { display: contents; }
  #folder-title { grid-column: 1; grid-row: 1; margin: 0; overflow-wrap: anywhere; }
  #s-folder .folder-meta .num { grid-column: 1 / -1; grid-row: 2; margin-top: 2px; font-family: var(--ui); font-size: 14px; color: var(--muted); }
  #s-folder .folder-meta .sep, .folder-meta .link-btn > span { display: none; }
  #folder-rename { grid-column: 2; grid-row: 1; }
  #folder-delete { grid-column: 3; grid-row: 1; }
  .folder-meta .link-btn { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; color: var(--fg-3); }
  .folder-meta .link-btn .i-ico { display: block; width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .head-actions .btn { flex: 1 1 100%; }
  .empty { padding: 32px 22px 34px; }

  /* Сортування й перемикач колонок в одному рядку. Кнопки сортування — за
     шириною тексту: порівну «За ціною» на 320px не вміщалось */
  .seg-view { display: flex; flex: 0 0 auto; }
  .folder-order #seg-sort { flex: 1; min-width: 0; }
  .folder-order #seg-sort button { flex: 1 1 auto; padding-left: 6px; padding-right: 6px; }
  .seg.seg-view button { flex: 0 0 auto; display: grid; place-items: center; padding: 0 10px; }
  /* Дві колонки на телефоні — не фіксовані 2, а мінімум 130px: у портреті
     це рівно дві, а в ландшафті картки не розтягуються на пів екрана */
  .grid-cards.is-2col { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
  .is-2col .rcard-thumb { font-size: 24px; }
  .is-2col .rcard-thumb::after { bottom: 6px; left: 9px; font-size: 9px; }
  .is-2col .rcard-body { gap: 6px; padding: 10px 11px 12px; }
  .is-2col .rcard-title { font-size: 14px; overflow-wrap: anywhere; }
  /* Підпис над числом: поруч «Собівартість» і сума в 115px не вміщаються */
  .is-2col .rcard-line { flex-direction: column; align-items: flex-start; gap: 1px; font-size: 11.5px; }
  .is-2col .rcard-line .num { font-size: 12.5px; }
  .is-2col .rcard-line.is-price { padding-top: 6px; }
  .is-2col .rcard-line.is-price .num { font-size: 15px; }

  /* ── Інструкція ── */
  .help-sec { padding: 16px 18px 14px; }
  .help-go { margin-left: -6px; }

  /* ── Налаштування ── */
  .set-row { flex-direction: column; align-items: stretch; gap: 14px; padding: 16px 18px; }
  .set-row-txt { max-width: none; }
  .set-row .btn-row { flex-wrap: wrap; }
  .set-row .btn-row .btn { flex: 1 1 150px; }
  #btn-reset, #btn-wipe { width: 100%; }
  /* Перемикачі на всю ширину: чотири валюти інакше тиснуться в кут */
  .seg { justify-content: stretch; }
  .seg button { flex: 1; padding: 9px 10px; }

  /* ── Модалка стає шторкою знизу: так до кнопок дістає палець ── */
  .overlay { place-items: end center; padding: 0; }
  .modal, .modal.modal-nut {
    max-width: none; max-height: 92vh; overflow-y: auto;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    padding: 22px 18px calc(18px + env(safe-area-inset-bottom));
  }
  .modal-foot .btn { flex: 1; }
  /* На телефоні вікно — шторка, тож і виїжджає знизу, а не збільшується */
  .modal.modal-invite { animation: fc-sheet .5s cubic-bezier(.2,.8,.25,1) .3s both; }
  .pdf-modal { max-height: 94vh; border-radius: var(--r-xl) var(--r-xl) 0 0; }
  .pdf-modal-head { flex-wrap: wrap; gap: 12px; padding: 14px 16px; }
  .pdf-modal-head .btn-row { width: 100%; }
  .pdf-modal-head .btn-row .btn { flex: 1; }
  .pdf-modal-body { padding: 12px; }
  .prep-take-row { flex-wrap: wrap; }

  /* ── Розміри під палець ── */
  .icon-btn { width: 36px; height: 36px; }
  .link-btn { padding: 6px; }
  .chip { height: 32px; }
  .btn-dash { height: 38px; }
  /* Ті самі дві колонки, що й у решті картки — вільний перенос на 320px
     виштовхував останнє поле за край екрана */
  .nut-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 10px; align-items: center; }
  .nut-fields .nut-cap { grid-column: 1 / -1; }
  .nut-f { min-width: 0; }
  .nut-f > span:first-child { flex: 0 0 auto; }
  .nut-f .inp, .nut-f .qty-wrap { flex: 1 1 auto; width: auto; min-width: 0; }
  .nut-f .inp { height: 38px; }
  /* «Вуглеводи» з полем у 137px уже не вміщаються — на найвужчих екранах в один стовпчик */
  @media (max-width: 360px) { .nut-fields { grid-template-columns: 1fr; } }
  /* Панель «Харчова цінність»: три колонки таблиці не влазили —
     «6 674 ккал» і «Весь виріб» обрізались, «Молоко» падало за край */
  .nut-body { padding: 12px 14px 16px; }
  .nut-tbl { font-size: 13px; }
  .nut-tbl th { white-space: normal; }
  .nut-tbl td.r { padding-left: 10px; }
  .nut-al-view { flex-direction: column; gap: 8px; }
  .nut-al-view .nut-cap { padding-top: 0; }
  .nut-al-view .chips { min-width: 0; }
  /* 16px — інакше iOS зумить сторінку на тапі; .inp.al-add важить більше за загальне «.inp 16px» */
  .inp.al-add { width: 100%; max-width: 280px; height: 36px; font-size: 16px; }
  .panel-tip { flex: 1 1 100%; }
}
