/* Каркас страницы калькулятора заказов (ZK-58): левое меню, шапка раздела, строка условий,
   панель над таблицей, подвал таблицы. Размеры — из макета Claude Design, экран 1440×900. */

.app { display: flex; height: 100vh; min-width: 0; }

/* ── Левое меню 216px ───────────────────────────────────────────── */

.rail {
  width: var(--rail-w); flex: none; display: flex; flex-direction: column;
  padding: 18px 12px 14px; background: var(--bg-rail); border-right: 1px solid var(--line-block);
  overflow-y: auto;
}
.rail-brand { display: flex; align-items: baseline; gap: 6px; padding: 0 10px 16px; }
.rail-brand b { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.rail-brand span { font-size: 13px; color: var(--ink-2); }
.point-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  padding: 9px 12px; border: 1px solid var(--line-btn); border-radius: 10px; background: var(--surface); text-align: left;
}
.point-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.point-label { font-size: 11.5px; color: var(--ink-soft); }
.point-text b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.point-btn .caret { color: var(--ink-soft); }
.point-menu { left: 0; right: 0; top: calc(100% + 6px); padding: 6px; border-radius: 12px; box-shadow: var(--shadow-menu); }
.point-menu button, .point-menu a {
  display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; text-align: left;
}
.point-menu a { color: inherit; text-decoration: none; }
.point-menu button:hover, .point-menu a:hover { background: var(--hover-menu); }
.point-menu button.is-active { font-weight: 600; }

.rail-nav { display: flex; flex-direction: column; gap: 2px; margin-top: 18px; }
.nav-item {
  display: flex; flex-direction: column; gap: 2px; padding: 9px 12px; border-radius: 10px;
  text-decoration: none; color: inherit;
}
.nav-item:hover { background: oklch(0.93 0.01 80); color: inherit; }
.nav-title { font-weight: 500; }
.nav-status { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); min-height: 17px; }
.nav-status .dot { width: 7px; height: 7px; }
.nav-status .dot.is-ok { background: oklch(0.6 0.13 150); }
.nav-status .dot.is-warn { background: oklch(0.74 0.14 75); }
.nav-status .dot.is-empty { background: transparent; border: 1.5px solid oklch(0.7 0.01 80); }
.nav-status .dot.is-bad { background: var(--bad); }
.nav-item.is-active {
  background: var(--surface); box-shadow: 0 1px 2px oklch(0.4 0.02 60 / .10), 0 0 0 1px oklch(0.9 0.01 80);
}
.nav-item.is-active .nav-title { font-weight: 600; }
.rail-sep { height: 1px; background: var(--line); margin: 14px 12px; flex: none; }
.rail-link { padding: 6px 12px; font-size: 13.5px; color: var(--ink-2); text-decoration: none; }
.rail-link:hover { color: var(--ink); }
.rail-foot {
  margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 0 12px;
  font-size: 12.5px; color: var(--ink-soft);
}
.rail-foot .who { overflow: hidden; text-overflow: ellipsis; }
.rail-foot .link { align-self: flex-start; color: var(--ink-2); font-size: 12.5px; }
.rail-backdrop, .burger { display: none; }

/* Компьютер: меню закрыто, ☰ слева от заголовка открывает его, повторный щелчок закрывает
   (Кирилл 29.09: «по кнопке открывается и висит, пока снова на неё не нажмёшь»). Открытое меню стоит
   слева колонкой 216px, как в макете, а не поверх: иначе закрыло бы саму ☰. Телефон и планшет — свои правила. */
body:not(.is-touch):not(.rail-open) .rail { display: none; }
body:not(.is-touch) .burger {
  display: flex; flex: none; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  width: 36px; height: 36px; margin: 0 2px 0 -8px; border: 0; border-radius: 9px; background: transparent; cursor: pointer;
}
body:not(.is-touch) .burger:hover { background: var(--hover); }
body:not(.is-touch) .burger i { width: 18px; height: 2px; border-radius: 1px; background: var(--ink); }

/* ── Страница ───────────────────────────────────────────────────── */

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
body.is-stock .content { display: block; overflow: auto; }

.page-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding: 14px var(--page-x) 12px; white-space: nowrap;
}
/* Узкий ноутбук (1024–1366): что не влезло в строку, переносится ниже, а не вылезает за экран. */
.head-title { display: flex; flex-direction: column; gap: 3px; min-width: 240px; flex: 1 1 0; }
.section-title { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.1; }
.section-note { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; }
.section-note.is-warn { color: var(--warn-ink); font-weight: 500; }
.section-note:empty { display: none; }

.product-novelty-notice {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px;
  margin: 0 var(--page-x) 8px; padding: 9px 13px; border: 1px solid var(--line-block);
  border-left: 4px solid var(--ride); border-radius: 9px; background: var(--focus-row); color: var(--ink);
}
.product-novelty-notice[hidden] { display: none; }
.product-novelty-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.product-novelty-label { color: var(--ink-2); font-size: 11.5px; }
.product-novelty-title { font-size: 14px; font-weight: 600; }
.product-novelty-text { color: var(--ink-2); font-size: 12.5px; line-height: 1.35; }
.product-novelty-link { flex: none; }

.deadline {
  flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 10px;
  background: var(--warn-bg); color: var(--warn-text);
}
.deadline .dot { background: oklch(0.72 0.15 70); }
.deadline-text { display: flex; flex-direction: column; line-height: 1.25; }
.deadline-text b { font-weight: 600; }
.deadline-text span { font-size: 12.5px; }
.deadline.is-late { background: oklch(0.955 0.03 28); color: var(--bad-ink); }
.deadline.is-late .dot { background: var(--bad-dot); }

.head-right { flex: 0 1 auto; max-width: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.order-fresh { order: 4; flex-basis: 100%; margin-left: auto; text-align: right; color: var(--ink-strong); font-size: 12px; font-weight: 500; line-height: 1.3; }
.order-fresh.is-stale { color: var(--warn-text); }
/* Узкое окно компьютера (640–900): сумма, «Проверки» и шаги переносятся строкой ниже, а не вылезают. */
.head-sum { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; padding-right: 6px; }
.head-sum-label { font-size: 12.5px; color: var(--ink-2); }
.head-sum-value { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
body.set-simple .head-right { gap: 12px; }

.checks-btn {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface); color: inherit;
}
.checks-btn > span:not(.caret) { font-weight: 500; }
.checks-btn .dot { background: var(--bad-dot); }
.checks-btn.is-done .dot { background: var(--ok-dot); }

.steps { display: flex; align-items: center; padding: 3px; border-radius: 12px; background: oklch(0.93 0.008 80); }
.step {
  display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; border: 0; border-radius: 9px;
  background: transparent; color: var(--ink-2); font-weight: 600;
}
.step-num { font: 500 12px var(--mono); opacity: .7; }
.step.is-active { background: var(--dark); color: var(--on-dark); }
.step.is-done { color: oklch(0.36 0.09 150); }
.step:disabled { cursor: default; }
.step-arrow { padding: 0 4px; color: var(--ink-mute); }

.btn-copy { height: 44px; padding: 0 18px; border-radius: 11px; }
.btn-copy .caret { font-weight: 400; opacity: .6; color: inherit; }

/* ── Строка условий ─────────────────────────────────────────────── */

.conditions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 0 var(--page-x); padding: 9px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line-block); white-space: nowrap;
}
.cond-dates { flex: none; display: flex; align-items: center; gap: 6px; }
.date-card {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 4px 11px; border-radius: 8px; border: 1px solid var(--line-btn); cursor: pointer;
}
.date-card:hover { border-color: oklch(0.7 0.012 60); }
.date-label { font-size: 11.5px; color: var(--ink-soft); }
.date-value { font-weight: 600; min-width: 64px; }
.date-card input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; border: 0; padding: 0; cursor: pointer; }
.date-card input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: auto; height: auto; opacity: 0; cursor: pointer; }
.date-arrow { color: oklch(0.62 0.01 60); }
.days-split { padding-left: 4px; font-size: 12.5px; color: var(--ink-2); }
.days-split:empty { display: none; }
.cond-sep { flex: none; width: 1px; height: 32px; background: oklch(0.91 0.008 80); }
.reserve { flex: none; display: flex; align-items: center; gap: 8px; }
.reserve-label { font-size: 13px; color: var(--ink-2); }
.stepper { display: flex; align-items: center; border: 1px solid var(--line-btn); border-radius: 8px; overflow: hidden; }
.step-btn { width: 28px; height: 32px; border: 0; background: transparent; color: var(--ink-2); }
.step-btn:hover { background: var(--hover-menu); }
.stepper-value { min-width: 42px; display: flex; align-items: center; justify-content: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.stepper-value input {
  width: 2.2ch; padding: 0; border: 0; background: transparent; text-align: right; font-weight: 600; outline: none;
  font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield;
}
.stepper-value input::-webkit-inner-spin-button, .stepper-value input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper-value input:focus { box-shadow: 0 1px 0 var(--focus); }
.switch { flex: none; display: flex; align-items: center; gap: 9px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { width: 34px; height: 20px; border-radius: 10px; padding: 2px; display: flex; justify-content: flex-start; background: oklch(0.82 0.01 80); }
.switch-track i { width: 16px; height: 16px; border-radius: 50%; background: oklch(0.995 0 0); box-shadow: 0 1px 2px oklch(0.2 0 0 / .25); }
.switch input:checked + .switch-track { justify-content: flex-end; background: var(--ok-check); }
.switch input:focus-visible + .switch-track { box-shadow: var(--focus-ring); }
.switch-text { font-size: 13px; }
.day-cal-anchor { flex: none; display: flex; align-items: center; gap: 8px; }
.day-cal-anchor .btn-dashed:not(.is-set) { height: 34px; border-style: solid; border-color: var(--line-strong); background: var(--surface-sunk); color: var(--ink-strong); font-weight: 500; }
.btn-dashed.is-set { border-style: solid; border-color: oklch(0.7 0.1 150); background: oklch(0.965 0.025 150); color: oklch(0.3 0.08 150); }
.day-cal-reset { font-size: 12.5px; }
#importExcelMain { flex: none; height: 34px; padding: 0 11px; font-size: 12.5px; }
#calcBar:has(~ #deliveriesBar[hidden]) #importExcelMain { display: none; }
.cond-right {
  /* Расписание сжимается многоточием в той же строке (макет ovoshchi/01), на следующую уходит
     только когда места меньше 220 точек (узкий ноутбук). */
  flex: 1 1 220px; min-width: 0; display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  font-size: 12.5px; color: var(--ink-2);
}
.days-note { color: var(--warn-ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.days-note:empty { display: none; }
.schedule-note { display: none !important; }
.calendar-alert { margin: 0 var(--page-x) 4px; padding: 8px 12px; border-radius: 8px;
  background: oklch(0.97 0.035 80); color: var(--warn-ink); font-size: 13px; line-height: 1.35; }
.calendar-alert[hidden] { display: none; }
.sched-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sched-line .sched-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sched-line .dot { width: 7px; height: 7px; background: transparent; border: 1.5px solid oklch(0.65 0.01 60); }
.sched-line a { flex: none; }

/* ── Панель над таблицей ────────────────────────────────────────── */

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px var(--page-x) 10px; white-space: nowrap; }
.search {
  flex: none; display: flex; align-items: center; width: 220px; height: 36px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: var(--surface); cursor: text;
}
body.set-simple .search { width: 240px; }
.search-wide { width: 280px; }
/* Поиск в фокусе рамку не меняет — как в макете. */
.search-icon { padding: 0 6px 0 11px; color: var(--ink-mute); font-size: 15px; }
.search input {
  flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; outline: none; color: inherit;
}
.search input::-webkit-search-cancel-button { display: none; }
.search-count { padding: 0 10px; font-size: 12px; color: var(--ink-2); }
.search-count:empty { display: none; }
.search-nav { display: flex; flex: none; gap: 2px; padding-right: 5px; }
.search-nav[hidden] { display: none; }
.search-nav button { width: 25px; height: 26px; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--ink-2); cursor: pointer; }
.search-nav button:hover:not(:disabled) { background: var(--surface-sunk); }
.search-nav button:disabled { opacity: 0.4; cursor: default; }
/* «Показать:» и метки «Остатков» переносятся вместе, подпись не отрывается от меток (ноутбук 1024). */
.toolbar-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-width: 0; }
.toolbar-label { flex: none; font-size: 12.5px; color: var(--ink-soft); padding: 0 2px 0 8px; }
.chips { display: flex; align-items: center; gap: 8px; }
.chip {
  flex: none; display: flex; align-items: center; gap: 7px; height: 32px; padding: 0 11px; border-radius: 16px;
  border: 1px solid var(--line-btn); background: transparent; color: var(--ink-strong); font-size: 13px;
}
.chip:hover { border-color: oklch(0.7 0.012 60); }
.chip-dot { width: 8px; height: 8px; border-radius: 2px; background: var(--ink-3); }
.chip-count { font-weight: 600; font-variant-numeric: tabular-nums; }
.chip-pos { color: var(--ink-soft); font-size: 12px; }
.chip-pos:empty { display: none; }
.chip.is-active { background: var(--pop); border-color: oklch(0.6 0.012 60); }
body.set-simple .chip.is-active, .stock-toolbar .chip.is-active { border-color: oklch(0.45 0.015 60); }
.toolbar-right { margin-left: auto; flex: none; display: flex; align-items: center; gap: 4px; }
.toolbar-note { margin-left: auto; font-size: 12.5px; color: var(--ink-soft); }
.hide-btn {
  display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: transparent; color: var(--ink-strong); font-size: 13px;
}
.hide-btn:hover { border-color: oklch(0.6 0.012 60); }
.hide-btn.is-on { background: oklch(0.95 0.008 80); border-color: oklch(0.6 0.012 60); }
.hide-pop { right: 0; top: 40px; width: 340px; }
.hide-manual { display: flex; align-items: center; gap: 10px; padding: 6px 10px 2px; }
.hide-manual > span { flex: 1; font-size: 12.5px; color: var(--ink-2); }
.hide-manual b { color: var(--ink); }
.hide-manual .link { font-size: 12.5px; }

/* ── Подвал таблицы ─────────────────────────────────────────────── */

.table-foot {
  display: flex; align-items: center; gap: 18px; min-height: 34px; margin: 0 var(--page-x) 14px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 0 0 12px 12px; background: var(--footer);
  font-size: 12.5px; color: var(--ink-2); white-space: nowrap;
}
.foot-cursor { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 500; color: var(--ink-strong); }
.save-state { margin-left: auto; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; }
.save-state:empty { display: none; }
.save-state.is-error { color: var(--bad-ink); font-weight: 500; }
.save-state:empty + .foot-refresh { margin-left: auto; }
.foot-refresh { color: var(--ink-soft); font-size: 12.5px; }
.foot-keys:first-of-type { margin-left: 0; }

/* Рабочий бланк должен начинаться выше середины экрана ноутбука. На компьютере
   оставляем все действия на виду, но убираем лишние переносы над таблицей. */
body:not(.is-touch):not(.is-stock) .page-head { gap: 8px 10px; padding-top: 8px; padding-bottom: 8px; }
body:not(.is-touch):not(.is-stock) .head-title { flex: 0 1 290px; min-width: 210px; }
body:not(.is-touch):not(.is-stock) .head-right { gap: 6px; }
body:not(.is-touch):not(.is-stock) .deadline { padding: 6px 10px; }
body:not(.is-touch):not(.is-stock) .checks-btn { height: 36px; padding: 0 10px; }
body:not(.is-touch):not(.is-stock) .steps { padding: 2px; }
body:not(.is-touch):not(.is-stock) .step { height: 34px; padding: 0 10px; font-size: 13px; }
body:not(.is-touch):not(.is-stock) .conditions { padding-top: 6px; padding-bottom: 6px; }
body:not(.is-touch):not(.is-stock) .toolbar { gap: 6px; padding-top: 6px; padding-bottom: 6px; }
body:not(.is-touch):not(.is-stock) #toolbar > .search { width: 160px; }
body:not(.is-touch):not(.is-stock):not(.set-simple) #toolbar > .search:has(#searchInput:not(:placeholder-shown)) { width: 250px; }
body:not(.is-touch):not(.is-stock) .toolbar .chips { gap: 6px; }
body:not(.is-touch):not(.is-stock) .toolbar .chip { padding: 0 9px; }
body:not(.is-touch):not(.is-stock) #clearColumnDown:disabled { display: none; }

@media (min-width: 1240px) {
  body:not(.is-touch):not(.is-stock):not(.rail-open) .page-head { flex-wrap: wrap; }
  body:not(.is-touch):not(.is-stock):not(.rail-open) .head-right { order: 2; flex-wrap: nowrap; }
  body:not(.is-touch):not(.is-stock):not(.rail-open) .deadline { order: 3; margin-left: auto; }
}
@media (min-width: 1240px) and (max-width: 1319px) {
  body:not(.is-touch):not(.is-stock) .head-title { flex-basis: 220px; }
  body:not(.is-touch):not(.is-stock) .step { padding-right: 8px; padding-left: 8px; }
}

/* ── «Проверки N из 4» и «Скопировать заказ» ────────────────────── */

.checks-pop { left: 0; top: 48px; width: min(420px, calc(100vw - 16px)); max-height: calc(100vh - 76px); overflow: auto; padding: 16px; }
.checks-pop .pop-title { margin-bottom: 4px; }
.checks-pop .pop-sub { margin-bottom: 12px; }
.checks-list { display: flex; flex-direction: column; gap: 4px; }
.check-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px; border-radius: 10px; cursor: pointer; }
.check-item:hover { background: var(--hover-soft); }
.check-item input { position: absolute; opacity: 0; width: 0; height: 0; }
.check-item .check-box { margin-top: 1px; }
.check-item input:focus-visible + .check-box { box-shadow: var(--focus-ring); }
.check-text { display: flex; flex-direction: column; gap: 2px; line-height: 1.35; }
.check-text b { font-weight: 500; }
.check-sub, .checklist-fact { font-size: 12.5px; color: var(--ink-2); }
.checklist-fact.is-missing { color: var(--bad-num); }
.check-open { font-size: 12.5px; }

.copy-pop { right: 0; top: 52px; width: 460px; padding: 16px; }
body.set-noTare .copy-pop { width: 440px; }
.copy-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.copy-head span { font-size: 12.5px; color: var(--ink-soft); }
.copy-list, .copy-text {
  display: flex; flex-direction: column; max-height: 300px; overflow: auto; border-radius: 10px;
  border: 1px solid oklch(0.91 0.008 80); background: var(--surface-sunk); font-variant-numeric: tabular-nums;
}
.copy-list { padding: 4px 0; }
.copy-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 6px 12px; }
.copy-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-line > span:last-child { white-space: nowrap; }
.copy-line b { font-weight: 700; }
.copy-pcs { color: var(--ink-soft); }
.copy-text { padding: 10px 12px; line-height: 1.6; }
.copy-first { color: var(--ink-2); }
.copy-note { margin-top: 8px; font-size: 12.5px; color: var(--ink-2); }
.copy-empty { padding: 18px 12px; border-radius: 10px; border: 1px dashed var(--line-strong); text-align: center; color: var(--ink-2); }
.copy-acts { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.copy-hint { font-size: 12.5px; color: var(--ink-2); }
.copy-done { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line-group); }
.copy-done > span { flex: 1; font-size: 12.5px; color: var(--ink-2); }
.copy-done .btn-line { height: 32px; padding: 0 12px; border-radius: 8px; font-size: 13px; }
.chip-small { height: 28px; padding: 0 10px; border-radius: 7px; border: 1px solid oklch(0.8 0.03 150); background: var(--pop); font-size: 12.5px; }

/* Узкое окно компьютера (640–900, без сенсорного экрана): метки, даты условий, подвал и свежесть
   «Остатков» переносятся строкой ниже, а не раздвигают страницу вбок (ревью ZK-58, 29.09). */
body:not(.is-touch) .chips { flex-wrap: wrap; row-gap: 6px; }
.cond-dates { flex-wrap: wrap; row-gap: 6px; }
.table-foot { flex-wrap: wrap; row-gap: 4px; }
.freshness { min-width: 0; }
.fresh-text { min-width: 0; white-space: normal; }
.calculation-state { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; }
.calculation-state.is-loading { background: var(--hover-soft); color: var(--ink-2); }
.calculation-state .link { flex-shrink: 0; }
